[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 378
Thread images: 19

File: a language you can't believe in.png (211KB, 638x592px) Image search: [Google]
a language you can't believe in.png
211KB, 638x592px
Previous thread: >>56202150

What are you working on, /g/?
>>
Disassembler in Rust: https://panopticon.re/
>>
>>56208637
What do you guys use for GUI's in Clojure? Googling gives me Seesaw, but the Github looks abandoned.
>>
>>56208697
We don't use Clojure
>>
>>56208697
We don't use GUIs
>>
Rust is a bust
>>
>>56208637
I occasionally hear people here calling Rust an sjw language. I don't follow community drama, what is sjw-ish about its community?
>>
File: received_10209286858583863.jpg (33KB, 858x390px) Image search: [Google]
received_10209286858583863.jpg
33KB, 858x390px
Anyone have any hints as to how I can do this?
>>
>>56208768
It doesn't have HKTs because they are bigoted against less privileged programmers who do not understand them.
>>
>>56208812
Ah, so it doesn't support things like type inferred functors, so fmap has to be named?

I guess can see how that could be considerd sjw-ish. After all, irl sjw's support namespace creep and reject type-inferred pronouns.
>>
>>56208637
>What are you working on, /g/?
Trying to determine if I should be inventing a wheel that suits my needs better than the existing wheels.
>>
>>56208880
It means typeclasses are crippled just like in F#. It's a toy language.

Oh wait, that's ableist, I guess they'll have to cancel the language now :^)
>>
>>56208796
I don't know your language but I wrote it in Lua so maybe that'll be of help as an example.

local add = function(a, b) return a + b end
local sub = function(a, b) return a - b end

local function transformer(query)
return function(params)
local res = 0
for i = 1, #query do
res = query[i](res, params[i])
end
return res
end
end

local tq = transformer({sub, add})
print(tq({1, 2}))
print(tq({3, 1}))


I had to define sub and add functions myself though because I'm not aware of s-neg and s-sub global operators in Lua.
>>
>>56208768
>>56208880
The whole concept of the language is SJW-like. You have to designate what parts of your code are safe spaces. Also it's made by Mozilla and sold as a way for unskilled web developers to do systems programming.
>>
>>56208932
I think there's a need for a systems programming language that's less easy to shoot yourself in the for with than C or C++, but nobody has made anything satisfactory yet.
>>
>>56208930
Actually disregard that, I completely missed the recursion part.
>>
Reminder that non-singleton types are constrained generics.

void f(int a)
is a generic function that can be used with any int, as opposed to
void f(5 a)
which can only be used with the int value 5.
>>
>>56208930
Its in lisp for a functional programming course

I'll give yours a read but Ive been having a lot of difficulties returning functions up a recursive stack
>>
$families[$c][1][$z][1][$s][1][] = $p;

send help...
>>
>>56208950
this

safety is not bad they just screwed the pooch with making rust and now nobody will ever use it
>>
>>56208950
What about ADA?
>>
>>56208768
Code of Conduct bullshit and stuff...
>>
>>56209034
No HKTs
>>
>>56209034
ADA is the way to go. I am so interested in ADA now that safety is an acceptable idea in computer science. It is easy to get started with ADA. I have written hundreds of thousands of lines of ADA code. You should pay for an ADA compiler.
>>
>>56208796
If i understood this correctly

def generate(i):
for range(i):
print('Hello')
for i in range(100):
functionlist.append(lambda i=i: generate(i))
#thus when functionlist[65] is called it'll print 65 Hellos


this is really handy for when you need to call a function but can't supply a positional argument, like in tkinter's button feature (so you would just be able to call functionlist[65] rather than functionlist(65) on the press of a button)
>>
What do you guys do/listen to while you're waiting on certain things, like compiling, building, just general moments where you're waiting about 10-30 seconds at a time to wait on your computer to do something.

I'm looking for something productive I can be doing during this time, preferably small bits of reading on programming principles or listening to something that will make me better as a programmer.

Any suggestions?
>>
>>56209034

Programming in Ada may make you want to kill yourself. That said, I'd take Ada any day over something like COBOL. If I ever start learning COBOL, either I have been offered a job earning $200,000 or more per year in an area that isn't California, or I have completely failed to obtain a job as a programmer and am making a last ditch attempt to enter a niche market.
>>
>>56209089
Not sure if shill
>>
D seems interesting.

but nobody seems to ever talk about it. Is D worth learning?

I need a new language goddammit and Rust is not really sticking with me.
>>
>>56209097
oh whoops the for i in range 100 shouldn't be indented

so it's actually

def generate(i):
for range(i):
print('Hello')
for i in range(100):
functionlist.append(lambda i=i: generate(i))
functionlist[65]
>>
>>56209100
>Programming in Ada may make you want to kill yourself.

This is indeed true.
>>
>>56209034
Cuckservative language.
>>
>>56209124
I absolutely loved D but am completely crushed that it's not getting as much attention as Rust and Go, that the standard lib isn't stable (in the sense that there have been a lot of changes and a project I wrote a year ago does not compile anymore due to deprecation and stuff), and dub is mediocre at best (Cargo is probably the best example of how such a tool should be made).

With that being said, D is really nice if you don't mind GC and fun to write and it's being actively developed so I'm hoping that it'll get better once it matures.
>>
File: 7phuJaq6.jpg (42KB, 512x512px) Image search: [Google]
7phuJaq6.jpg
42KB, 512x512px
>>56209124
>but nobody seems to ever talk about it. Is D worth learning?

Do it for him.
>>
>>56209124
D was the meme language of the year every year for like 15 years.
>>
>>56209148
>>56209149
>>56209124
D is the memeiest meme

Hint: there's a reason it has never taken off
>>
File: 1471301997290.jpg (8KB, 250x250px) Image search: [Google]
1471301997290.jpg
8KB, 250x250px
>That one kid who goes on about ASSEMBLY but never produces any meaningful software
>>
where do you guys grab your textbooks online? i need to grab a couple of books for revision, but i dont want to shell out stupid prices for something im only going to use for my next exam
>>
>>56209186
How does a cat post here
>>
Hi, beginner here. I started learning Python.
Read the 'Ryan Heitz - Hello Raspberry Pi' book and finished projects inside.
It covered basic steps - from printing messages to rock-paper-scissors and random number guessing games.
What books should i get next for learning further steps?
>>
>>56209192
#bookz
>>
>>56209192
Piracy is wrong anon
>>
>>56209124
>>56209149

D is significantly better than C++ and I hope it replaces it, but it's not exactly Haskell
>>
>>56209203
Yes but copyright infringement is not piracy.
>>
>>56209195
learn general programming, learn design patterns, read other peoples code, look for code you can re-use to make your life easier and enable bigger projects

>>56209198
rizon?

>>56209203
im on 7k a year, i dont have fucking £40 to spend on each bloody textbook i need
>>
>>56209222
Why are you buying books covered in blood anon?
>>
>>56209222
If you weren't able to afford a car would you justify stealing one? If you weren't able to afford food would you justify robbing a grocery store?
>>
>>56209222
yes
>>
>>56209232
i cant afford the £60 ones
>>
>>56208637
So is rust worth the trouble? Whats example of project that rust best fits?
>>
>>56209233
>information works are the same as physical goods
no

>>56209235
thanks senpai, you sure theyll have programming textbooks? im after More Effective C++: 35 new ways to improve your programs and design
>>
>>56209239
A rust tutorial
>>
>>56208912
and Ocaml and any real work programming language

if you have HKT, you have a memelang
>>
>>56209239
>So is rust worth the trouble?
No. It's only worth it if trouble is all you want. Hope you like fighting the borrow checker for weeks at a time.

>Whats example of project that rust best fits?
Shilling.
>>
>>56209238
Why not use your uni library
>>
>>56209248
People put as much effort, time and money into producing "information" as they do into producing physical goods, so it's really the same thing.
>>
>>56209248
yes I'm sure they have literally everything I've ever looked for
>>
File: 3497046_300x300.jpg (19KB, 300x300px) Image search: [Google]
3497046_300x300.jpg
19KB, 300x300px
>>56208768
top contributor and core member is a SJW (pic related), mozilla are SJWs (they own Rust), actively look for trans, etc.,
https://blog.rust-lang.org/2016/06/30/State-of-Rust-Survey-2016.html

lots of other shit
>>
>>56209253
Scala has them but I guess you think that's a memelang too (it's not)
>>
>>56208768
Database triggers give them PTSD.
>>
>>56209271
Any language made after the year 2000 is a meme
>>
Why are .dll's such a pain in the ass?
>>
>>56209291
Use .so instead
>>
I've decided to dive into D. It just looks so inviting (as a Java / C programmer).

Rust is aggravating to learn and a little too functional for me right now. I really did give it an honest effort, but I'm gonna take it easy with D for now and come back in a few months and give Rust a second shot.
>>
>>56209262
you sure you gave me the right server and channel? because it looks empty to me

>>56209261
no, its not, information functions via duplication, and therefore is fundamentally different from physical goods. dont get me wrong, id like to reward their effort, but i flat out do not have the money to.

>>56209258
that means going in, when i could read it at home and sip tea
>>
>>56209291
Because you're stupid.
>>
File: 1451442675372.jpg (73KB, 604x453px) Image search: [Google]
1451442675372.jpg
73KB, 604x453px
>>56209193
fite me
>>
>>56209268
Holy fuck that survey.
>> More gays than women.
>> Same number of trans as women.

These are some seriously skewed demograpics.
>>
local variables
global variables
functions
properties
methods
objects
event handlers
assignment operators
values
semicolon
parentheses
curly braces
parameters
call
comments
>>
>>56208768
The core rust community is, but the community around rust tools isn't, with the usual exceptions (diesel is the only one I'm aware of, though). However, there are also C#-style profiteers, such as the developers behind the leaf ML libraries, who, it turns out, were doing what they were doing not because they wanted a good ML suite in a good language, but rather because they wanted to make money.
>>
>>56209253
Even C++ has HKT
>>
>>56208796
Induct on the argument to transformer.
-If the argument is a constant, return a function that always returns that constant value.
-If it is a variable, return a function that looks up the variable in the environment (use assoc for this) and returns its corresponding value, if there is one.
-If it is an operator application, return a function that applies the corresponding operator (you can define an alist for this and use assoc to access the operator) to the arguments of the operator transformed and evaluated within the given environment.
>>
>>56209271
scala has no default currying, shit type inference (if you can call it that, thanks JVM), no proper tail call optimization (thanks JVM), 10 years to compile

Since you can pass any dictionary anywhere to any implicit you can't rely on the canonicity of anything. If you make a Map or Set using an ordering, you can't be sure you'll get the same ordering back when you come to do a lookup later. This means you can't safely do hedge unions/merges in their containers. It also means that much of scalaz is lying to itself and hoping you'll pass back the same dictionary every time.
etc

it's a worse language where halfassed HKT can't help it
>>
>>56209418
muh templates mutha fucka
>>
>>56209425
Hi Edward.

I wish more languages had typeclasses instead of implicits too.
>>
>>56209362
I know, right? They aren't diverse enough, they are sorely lacking in strong independent black lesbian wymmynz.
>>
>>56209405
Oh, how terrible!
>>
>Rust is a statement based language
Sad!
>>
>>56208637
I'm gonna try to make a de-duper program in C++ for records, with a merge feature added in.
>>
>>56209124

D has actually a prety nice syntax, but honestly you would be better of with learning C#, since there are no D jobs..
>>
>>56209124
D is a really good language. Learn Go.
>>
>>56208950
Except rust. The only issues that rust still has are
1- playing with numbers is awful due to the lack of implicit conversions: you have to manually convert usize to isize, isize to f32, etc.; things like
let a: usize = 3;
let b: isize = 5;
let c = a + b;

isn't allowed due to the type difference. Meanwhile, I've really never seen type promotion-related errors ever appear in any software, so the lack of convenience in this case seems wasted.

2- overflow. You can explicitly specify the overflow behavior (panic by default, but it can be fall-through as in C, and it can be clamped within the range), but there's no type promotion.

More complicated typing construct (namely, dependent type support) would be nice to have, but they're not necessary: we want safety, but we don't want it to be too inconvenient to use, which is why languages like idris, agda or coq aren't taken seriously outside theorem-proving.

Otherwise, rust has C's smallness and speed (no runtime required as in C++, the rust compiler produces binaries that are smaller than gcc when both are in static mode, or 10% larger than gcc in dynamic mode, and speed tends to be roughly within 10% of C speed, being faster in real life examples like that one xml parser, and the leaf library v.s. caffe), with safety guarantees that ensure no memory-related bugs, making rust programs orders of magnitude safer than their C/C++ counterparts.
>>
>>56209566
You've got it backwards. A more powerful type system would make the language more convenient to use.
>>
>>56209262
if its undernet youre talking about, they dont have it
>>
>>56209458
let x = if 1 == 2 { "hello world" } else { "foo bar" };
let y = match 5 {
0 ... 3 => "baz",
4 ... => "bat"
};
let z = { something(); something_else(); let w = even_more_things(); w };

What else do you want?
>>
File: sussman shig.jpg (71KB, 500x375px) Image search: [Google]
sussman shig.jpg
71KB, 500x375px
>>56209584
For autofellatio, perhaps.
>>
>>56209615
I used higher-kinded types all the time in my work.
>>
File: 91i328.jpg (142KB, 740x740px) Image search: [Google]
91i328.jpg
142KB, 740x740px
>>56209612
>side effects
>>
>>56209584
No, because type inference becomes even less deterministic so you have to provide more and more type-hints. Not to mention the issues generated by bad type-matching (e.g. lack of implicit upcasts or trait conversions) and how ridiculously complex and impossible to understand type errors become. Again, just look at languages with more complex type systems like ATS or again, agda or idris.
>>
>>56209633
int i = 1;
int j = i++ + ++i / i-- - --i;

Triggered?
>>
>>56209612
What language doesn't have this functionality?

This is all trivial.
>>
>>56209650
>Triggered
No, disgusted.
If you went outside for more than 5 seconds, people would be disgusted, not triggered.
>>
>>56209647
I disagree that those are problematic. I want safety and performance without giving up flexibility.
>>
>>56209660
Virtually no non-functional languages can do that.
>>
>>56209566
A real systems language would have what C has:
- Pointer arithmetic so you can address any part of memory
- Pointer reinterpretation so you can work with any data as raw blobs of bytes
- Convenient bitwise operations for creating and manipulating arbitrary bitstrings
- Inline assembly with volatile variables and manual register assignment for talking to hardware
- No automatic memory management AT ALL
>>
>>56209663
>t. muh purity autist
>>
Since OP picked a Rust logo, I might as well ask here:

At my University I can learn Rust. Is it worth it? I'm currently pretty busy with learning other langauges and Rust seems overly complicated to me..
>>
traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
>>
>>56209671
The rest of the world disagrees and with good reason.
Also, nothing with a complex type-system is faster than rust, beside perhaps ATS, isn't it? That is to say, the correlation is at best sub-linear.
As for safety, it's a cost v.s. gain question. If none of the bugs you can have can possibly be critical (security risk, memory leak, resource starvation, etc.), adding significant complexity isn't much benefit just to shake a few bugs that would have been trivially obvious with manual examination anyway, for example. So for example, show an example of bug that can be found out by a more complex system that isn't easy to notice manually (let alone via unit tests) and cannot be found out purely by uniqueness types.
>>
>>56209688
Rust has all that and more, that's why it's so great.
>>
>>56209718
Don't do it. It's a fad at best. Don't buy into the shills here.
>>
Does one have to use windows, like windows to learn C#?
>>
>>56209734
Rust has:
- Safety

It is not even part of the conversation. Stop pretending it is.
>>
>>56209718
You shouldn't learn programming languages at university, period. You should drop all courses that are about programming languages right now and select courses that actually matter, be it cryptography, quantum computing or machine learning. Don't waste your time on bullshit.
>>
>>56209738
>m-m-m-muh everyone I d-d-disagree with are s-s-s-shills!!!!!!
>>/pol/
>>
>>56209720
What's your point?
>>
>>56209685
var x = 1 == 2 ? "hello world" : "foo bar";
var y =
5.IsInRange(0, 3) ? "baz"
: 5.IsInRange(4, int.MaxValue) ? "bat"
: "whatever default value";
var z = new Action(() => { Something(); SomethingElse(); var w = EvenMoreThings(); });
>>
>>56209725
It's not about bugs. It's about DRY. I like what I hear about the memory safety Rust gives you, but it currently comes at a cost of not being able to write generic code, meaning that I have to write specialized instances for every case I need.
>>
File: le progressive nsa man.png (217KB, 523x372px) Image search: [Google]
le progressive nsa man.png
217KB, 523x372px
>>56209756
Oh boy, we got a live one.
>>
>>56209781
>I like what I hear about the memory safety Rust gives you, but it currently comes at a cost of not being able to write generic code
Isn't this the same problem Go has?
>>
>>56209747
It literally has all that, though. At least learn what you're talking about before proving you're retarded.
https://doc.rust-lang.org/book/unsafe.html (https://doc.rust-lang.org/book/ffi.html)
https://doc.rust-lang.org/book/inline-assembly.html
https://doc.rust-lang.org/bitflags/bitflags/macro.bitflags!.html
And the whole point of uniqueness types is that there is no GC.
>>
>>56209763
are you retarded or just pretending?
>>
>>56209801
Go is useless. There are other languages that are better everything than it. Rust has a niche.
>>
>>56209818
Are you retarded or just pretending?
>>
>>56209725
It my code runs out of memory and crashes, whatever, I can restart it. If it calculates the wrong number, I'm fucked.
>>
>>56209760
It's a useful function.
>>
>>56209875
It's a shame we don't have named instances & explicit application, then you'd be able to do stuff like

traverse_ @bfs
traverse_ @dfs
traverse_ @rev
traverse_ @ascending
etc
>>
>>56209809
Okay, I'll explain it to you again, since you can't seem to understand.

Point #1: Systems programming requires you to do things that are not "safe."
Point #2: The whole point of Rust is to prevent you from doing things that are not "safe."
Conclusion: Rust prevents you from doing systems programming.

Now go bother someone else and consider coming back here after you're an adult.
>>
>>56209688
Forth does all of that better than C.
>>
>>56209911
Forth is a toy.
>>
>>56209781
That's false, generics are supported unlike in Go:
pub struct Test<T> {
something: T,
val: i32,
}

impl<T> Test<T> {
fn value(&'a self) -> &'a i32 {
&self.val
}

fn thing(&'a self) -> &'a T {
&self.something
}

fn exchange_thing<T2>(&self, new_thing: T2) -> Self {
Test { something: new_thing, val: self.val }
}
}

let x = Test { something: 3, val: 1 };
println!("x: {}, {}", x.thing(), x.value()};
let y = x.exchange_thing("hello, world");
println!("y: {}, {}", y.thing(), y.value());


However you can't have e.g. counts as in C++-style template metaprogramming, but it's only a minor issue due to opendylan- (thus, scheme-)style templates (which can recur), as well as compiler extensions (basically another kind of macro that works on the AST and where appropriate regions where they apply are annotated - this allows arbitrary code transformations).
>>
>>56209922
>generic code
>generics
>>
>>56209908
>The whole point of Rust is to prevent you from doing things that are not "safe" by default, but also allow you to do unsafe things if you want.

Fixed that for you, and your conclusion is invalidated.
>>
>>56209908
Who pays you to make such low-effort, low-quality posts? There's no way a real human would unironically do that on their own, you're too obvious.
>>
>>56209922
First-order generics are supported, but you can't write something like >>56209720, which is a function that I use time and time again in my work.
>>
>>56209922
>
    fn value(&'a self) -> &'a i32 {
&self.val
}

fn thing(&'a self) -> &'a T {
&self.something
}

fn exchange_thing<T2>(&self, new_thing: T2) -> Self {
Test { something: new_thing, val: self.val }
}

Jesus christ. Are you a Javadrone or some shit?
>>
>>56209650
I give up, what value does this program store in the variable j?
>>
>>56209953
Depends on the language.
In C, that is undefined behaviour and all output is completely meaningless.
>>
>>56209938
>post disagrees with me
>l-low q-quality!
>>
>>56209908
Systems programming requires you to do things that are unsafe, true. But not everything done in systems programming is unsafe.

Rust protects you from shooting yourself in the foot to the point that you can only do so when you absolutely have to risk doing so.
>>
>>56209973
>gets accused of low quality posting
>greentexts response

I couldn't bait this hard if I tried.
>>
>>56209930
Then what do you mean exactly? The whole point of generics is to write generic code, hence the name. Beyond that, all I can think of is the plain purpose of programming but that can't be what you're refering to since rust is turing-complete.

>>56209946
You can, actually. That's because traits are a thing.

pub trait A { };
pub trait B { };

pub trait Traverse {
fn traverse<T1, T2, T3, T4>(f: T3, a: T1) -> Box<T2> where T1: A, T2: B, T3: Fn(T4) -> Box<T2>;
};
>>
>>56210004
>Rust protects you from shooting yourself in the foot
or you could just stop shooting yourself in the foot on your own
>>
File: frametime spikes.png (4KB, 309x374px) Image search: [Google]
frametime spikes.png
4KB, 309x374px
Trying to figure out what the hell is causing these massive frametime spikes. They're large enough to cause visible, annoying pauses. The engine is locked to 60 FPS. It's not even rendering anything else except the graph :-(

All graph bars should be between the two horizontal cyan lines, the topmost is a 16-ms axis. Green bars are <= 16 ms, yellow (not visible) are between 17 and 32, and red is anything bigger than 32.

The spikes occur at every two seconds and I am lost. I don't know what causes them, but I think SFML might have something to do with them. It does its own internal timing stuff.
>>
>>56209949
It's a simple demonstration of generics. Calm your panties and don't get yourself in a bunch.
>>
>>56209973
I posted hard evidence that you were wrong in every single way and then you just meme and pretend people don't agree with you because you disagree with them. I don't even know why I bother explaining to you how to do your shilling job better, but hey, here's your free advice.
>>
>>56209685

>Virtually no non-functional languages can do that.

It's not like the Rust syntax is a bad rip-off of Ruby..

a = 1==2 ? "foo" : "Bar"

y = case 4
when 0..3
"baz"
when Numeric
"bat"
end
>>
>>56210026
implying youre good enough to not shoot yourself in the foot
>>
>>56210026
Why bother? My code is guaranteed to be foot shot free and I'm not paying any runtime overhead what so ever.
>>
>>56210028
SFML is a piece of shit. Use SDL instead.
>>
>>56210069
The rust programmer isn't paying any runtime overhead and doesn't need to limit himself to programming hello world over and over again.
>>
>>56210060
>implying Ruby is not functional

It's not like the Ruby syntax is a bad rip-off of Eiffel, Python and Smalltalk..
>>
>>56210060
Ruby is different because it pushes the idea of objects to the limit, so your y is really a "case object" and so on. In a sense, it can be considered to be functional programming.

Moreover, of that example, the 'a' case is invalid because it's not a full 'if' (which is the point that needs to be demonstrated).
>>
>>56209217
>D is significantly better than C++ and I hope it replaces it
That's like saying apples are significantly better than oranges.
>>
File: adablocks.gif (2KB, 235x98px) Image search: [Google]
adablocks.gif
2KB, 235x98px
Let's at least try to have a conversation even if the shills won't leave.

What would a real, good, satisfactory systems programming language look like?
>>
>>56209919
Forth is what you use when you need to land on a comet. Granted, that's not an everyday task, but it's great for that purpose.
>>
>>56210128
Forth is science fiction. Got it.
>>
>>56210122
Like Rust.
>>
>>56209749

>You shouldn't learn programming languages at university, period. You should drop all courses that are about programming languages right now and select courses that actually matter, be it cryptography, quantum computing or machine learning.

I've already done most of the courses I need, I'm just looking for something cool which is interesting and maybe good for my CV.

I could choose between Rust and "concurrent programming in C". I have some C knowledge, but I'm not sure about that concurrent stuff. It could be nice but could also be difficult and boing.
>>
>>56210115
No, it's like saying fresh apples are significantly better than rotten apples
>>
>>56210122
Rust.
It's like ada if ada wasn't fucking garbage.
>>
>>56209566
>languages like idris, agda or coq aren't taken seriously outside theorem-proving
Yeah, I wonder why somebody hasn't written a bug-free optimizing compiler for C99 in Coq yet. Oh, wait a minute...
>>
>>56210158
It's apalling that you have so few choices, but concurrent programming in C is a ridiculously better option than a programming language course. Knowing programming languages will never be a plus on any resume, nevermind the fact that it is the single easiest fakeable claim.
>>
>>56210188
Please stop pretending you're retarded for at least a second, thank you.
>>
>>56210215
Go shill somewhere else please.
>>
>>56210231
No, the Go shills were last week. This week is Rust again.
>>
What makes Rust better than C++ with static analysis?
>>
>>56210203

Why do you hate programming coursees? They force you to actually do something productive and give you guidance. Of course you can't claim to "know" a langauge after that, but it's not a bad introduction IMO.


>the fact that it is the single easiest fakeable claim

Well, if you make some interesting projects and put it on GitHub they have a "proof" that you actually know what you are talking about.

Of course you could also put some "stolen" code up there, but why would you do this? They would find out pretty fast and kick your ass.
>>
>>56210304
By this logic, what makes C++ better than ASM with static analysis?
>>
What kid of project is rust today best suited for? Examples plox. I dont give a damn about theoretical benefits.
>>
>>56210028
what engine do you use?
And please don't tell me you think SFML is a engine.
>>
>>56210321
>what makes C++ better than ASM with static analysis?
Portability
>>
>>56210024
That doesn't do the same thing.
>>
>>56210316
Because you already know programming and all programming languages are "the same thing". You gain precisely nothing from getting programming language courses since it should take at most a week to learn a new language and you can do that purely with internet information. On the other hand, specialized fields like qm, crypto or ML are not (properly) learnable without guidance from qualified professors - this is literally what you're paying for in the first place so why waste your time AND money just for a free muh A? Except if your GPA is currently 1.2 or something.
>>
File: fregg.jpg (77KB, 460x628px) Image search: [Google]
fregg.jpg
77KB, 460x628px
Just ran into a really hard practice problem.
Does it get easier lads?
Still trying to wrap the head around the answer.
>>
>>56210321
No arthritis.
>>
>>56210028
Doing any IO?
Garbage collection?

Run it through a profiler and see what takes most of the time.
>>
>>56210325
Systems programming and desktop programming.
>>
>>56208697
>>56208701
>>56208759
I loled.
>>
>>56210339
How so?
>>
There are more monad tutorials than atoms in the universe.
>>
>>56210357
Meaning exactly what? What can i do now without implementing bunch of stuff by hand? Can i make game engine gor e.g? Retarded crud app?
>>
File: 1464332006727.jpg (118KB, 467x349px) Image search: [Google]
1464332006727.jpg
118KB, 467x349px
Howdy, /dpt/, need your help.

I've got a huge number of parallel calculations to do in C# so I'm looking into utilizing the GPU (complete newbie at it).
I'm running an AMD card tho, and all the major libraries people recommend are either
>NVIDIA only (CUDA / CUDAfy)
>Deprecated / outdated / no longer supported (Brahma, GPU.Net, C$, MS Accelerator)
Everything else I can find is super low-level, which I'd prefer to avoid to preserve both sanity and time.

What are my options?
It's an entirely personal project so flexibility / scalability don't matter. Just has to work on my rig.
>>
>>56210142
Was thinking about the Philae lander. It was entirely programmed in Forth since its custom hardware had no C compiler or full-fledged OS.
>>
>>56210390
>AMD
I don't know if I can help you, I'll be busy laughing at you for the next 3 weeks
>>
fn main() {
for i in 0u32..101 {
match (i%3, i%5) {
(0, 0) => println!("FizzBuzz"),
(0, _) => println!("Fizz"),
(_, 0) => println!("Buzz"),
_ => println!("{}", i),
}
}
}


Rate my Rust
>>
File: Poland1.jpg (73KB, 709x533px) Image search: [Google]
Poland1.jpg
73KB, 709x533px
>>56210406
Can't afford anything better. Such is life in slavland.
>>
>>56210414
shill/10, very diverse, much oppression, wow
>>
>>56210390
>AMD

OpenCL most likely https://openclnet.codeplex.com/
>>
>>56209908
The whole point of Rust is to confine the unsafe stuff as much as possible. This narrows down significantly where you have to look to track down a bug. Also, the compiler can do lots of optimizations to safe code because of the guarantees.
>>
>>56210342

OK, interesting point.
>>
>>56210325
Anywhere you would use C++, Java, C#, etc.
>>
>>56210342
>all programming languages are "the same thing"
bullshit
>>
>>56209423
>-If it is an operator application, return a function that applies the corresponding operator (you can define an alist for this and use assoc to access the operator) to the arguments of the operator transformed and evaluated within the given environment.

is it possible to define all these functions within the transform function or will this need to be done outside of it?
>>
>>56210414

>one-hot encoding
>muh nig.. person of color
>>
>>56210480
>what is lambda
>>
>>56210494
as in a lambda function? thats what im thinking i just wanted to get some feedback because iv'e had problems before with passing back functions
>>
>>56210370
From what I can tell, you've written:

traverse :: (c -> b) -> a -> b
>>
>>56210500
As in a way to create a function. Functions aren't special, they're just values.
>>
>>56210024
Rust doesn't have HKTs. It sorely needs them. HKTs would allow you to abstract over Rc and Arc, for example.
>>
>>56210383
There are bindings to a fuckton of useful libraries, including sdl2 and the accompanying libraries, so you could make a 2D game engine easily.
There is a project or two about 3D engines purely in rust, and there are bindings for opengl/glew.
3D game engines include piston
(https://github.com/PistonDevelopers/piston/wiki/Games-Made-With-Piston)
and Kiss3d (https://github.com/sebcrozet/kiss3d).

You can also do web stuff with e.g. iron-framework and there's pretty good support for basic web interfaces (REST, CRUD, etc.) but it's not fully mature yet.
>>
>>56210512
Use the scrollbar, luke. The where clause does the time limitation via traits.
>>
>>56210543
So its actually useful language?
>>
>>56210533
You mean something like Arc<T>? That's already possible. Otherwise what do you mean?
>>
>>56210077
Been seriously considering that lately.

>>56210326
It's a homemade engine. SFML is just for window creation and mouse/keyboard and event handling. Which is why I've been looking at SDL and GLFW, as I don't need 99% of SFML's features.

>>56210355
No I/O in the main loop and C++ has no GC.

Profiling shows window.display() (SFML function) taking most of the time. I've stripped off everything from the main loop except event checking and then it's straight up rendering, all ending in window.display().
>>
>>56210466
But that's why learnxinyminutes works.
>>
>>56210562
I did, that's how I unified T3 with T4 -> T2. There's no other type information there.
>>
>>56210543
>You can also do web stuff with e.g. iron-framework and there's pretty good support for basic web interfaces (REST, CRUD, etc.) but it's not fully mature yet.
I'm curious:

Can you show me an example of retrieving data from one database, manipulating it, and writing it to another database?
>>
>>56210569
Of course. It's young but it can already properly be used for most tasks without having to write any preliminary framework or library.
>>
>>56209239
>>56209718
>So is rust worth the trouble?
If you already know some languages, especially C++11, you will really like it. The hardest part is the beginning because there is some quite unique rules in Rust that you need to follow and you need to think the way Rust is supposed to be.
>Whats example of project that rust best fits?
Similar to C/C++.
Project where security with high performance is required: drivers, renderers, physic engines/simulations and various other back-end. But it's not very good language if you want to make some simple GUI program, games, webservices. It all can be done, but there are better alternatives.

>>56209268
But the top contributor is https://github.com/brson
He looks nothing like your picture.
The guy you posted isn't even a programmer. He just spam commits by adding commas and brackets in documentation like other SJW tards.

>>56209566
As for 1- I think this is actually better this way. It makes you think if you really need conversions and about potential consequences. Without them you might easily cause bugs, for example: on 64 bit systems by saving usize to u32 and wondering why super large collections are not working.
>>
>>56210612
U wot m8?
Did you seriously not notice the T1: A, T2: B or are you just pretending?
>>
>>56210028
>but I think SFML might have something to do with them

Easy way to check would be to remove anything from your logic that takes time and see if they are still there.

Or use a profiler?
>>
>>56210522
alright thanks! however whenever i try returning the lambda function i create in my function call it stops the recursive function in its tracks and it just returns the first function it encounters instead of going all the way down the function call
>>
>>56210640
I saw those, they don't add any information.
>>
>>56210627
Lets say i write rust game engine. How hard is it to cross compipe when im using c libraries?
>>
>>56210543
But what can you do that can ONLY be done in Rust? Is there anything?
>>
what do you need to be turing complete?
>>
>>56210571
For instance, using them as functors.
>>
>>56210658
Are you paid to post this? You must be, nobody can be this retarded.
>>
>>56210726
Gain a lot of safety without losing performance.
>>
>>56210727
If you can implement lambda calculus in your language, it's Turing complete.
>>
>>56210726
Every meaningful language is turing complete. You can do anything you want in malboge or brainfuck. Nothing can "only" be done in any language.
>>
>>56210571

example<Arc>
>>
>>56210726
>>56210743
Well, the same can be said for e.g. ATS, but Rust is also still pretty convenient.
>>
>>56210726
You can't do anything in Rust that you can't do in HTML5 + CSS3.
>>
>>56210739
No, and I'm glad I'm not. I'm despairing at you, I'd hate to have to do this for a living.

Fine. Why don't you give me what you think the Haskell type signature for what you wrote is?
>>
>>56210753
Coq and Agda are meaningful.
>>
>>56210758
Box<Arc<T>> already works though
>>
>>56210753
well no you can't do anything you want in brainfuck

you are constrained to text I/O
>>
>>56210783
That's not the same thing
>>
>>56210783
That's not the same thing. You just constrained the type parameter to Arc.
>>
>>56210788
That is just a matter of library support, not the language itself
>>
>>56210783
>>56210792

It's like saying

f(g)
and
f( g(x) )

are identical
>>
>>56210788
False.
>>
>>56210795
So what do you mean by example<Arc> then?
>>
>>56210820
well for instance

example<x> = x<int>

example<arc>
>>
>>56210820
Something wonderful.
>>
>>56210640
A and B are empty traits. You can create instances of them for any type. They add no useful information.
>>
>>56210801
>>56210807
fairly sure you'd have to fork the language itself to allow libraries
can't think of any way to open a file, for instance, unless you implemented that in your translator's language (which changes the rules of the (i.e, brainfucks) language)
>>
>>56210836
OK, I get it.
There are still macros for that, but I get your point now.
>>
>>56210856
Add any non-empty trait, the reason why I defined A and B as empty is simply to demonstrate the process. Seriously, if you're going to purposely """argue""" in bad faith, fuck off.
>>
>Rust still can't handle polymorphic recursion
>>
>>56210024
>>56210562
>>56210640
Here's what you should have written:

pub trait Traverse {
fn traverse<T, F, A, B, C>(foo: C, bar: T<A>) -> F<()>
where T: Foldable, F: Applicative, C: Fn(A) -> T<B>;
}


Except you can't do this in Rust. There's no way to implement the corresponding traits:

pub trait Foldable<...> { ... };
pub trait Applicative<...> { ... };
>>
>>56210859
You don't need to allow libraries at the language-level, just write a program that preprocesses your source to copy-paste the content of the listed file into the source before compilation, for instance.
>>
>>56210866
>macros
It's part of the type system


void<F, a>(F<a>) -> F<()>
>>
>>56210880
I'm not arguing in bad faith. I pointed you at a type, you said "rust can do that too!!!!", and then gave a failed attempt at a proof, and I pointed out some errors in it.
>>
>>56210888
Thank you. I was bored of his dunderheadedness.
>>
File: 1471879902923.png (1MB, 1200x1800px) Image search: [Google]
1471879902923.png
1MB, 1200x1800px
>>
>>56210866
That's not an excuse for the lack of HKTs. By that logic, we don't need generics at all.
>>
>>56210921
this really needs updating
>>
>>56210028
Could be your timestep lock that every now and then locks up for a longer period of time? Is the frequency of the lockups consistent?
>>
>>56210928
It's funny when rust fanboys act like go fanboys when you know that they will deny that they are anything alike.
>>
>>56210890
that program wouldn't be written in brainfuck though
brainfuck has no way of doing anything during runtime, you can't execute anything

I'll concede that you can indeed write a library which can fill your arrays and even write brainfuck code from within the language but you still can't do anything but print for all the information that you collect. You can't ask any other programs to do anything for you either, all you have is the ability to print
>>
>>56210953
Rust and Go are literally the same language
>>
>>56210978
Same shit, different SJW.
>>
>>56210953
All language fanboys do the same thing. It's a well-documented phenomenon.
https://en.wikipedia.org/wiki/Linguistic_relativity#Programming_languages
>>
>>56210933
I feel the same way
>>
http://spectrum.ieee.org/computing/software/the-2016-top-programming-languages
>>
>>56211066
More people can use programming languages designed for morons than programming languages not designed for morons shocker
>>
>>56211066
>>56211082
It's like being surprised that more people have read Twilight than Finnegan's Wake
>>
>>56209124
It has got a ways to go, but it's got a great community behind it and I would say it's worth learning.
>>
>>56210414
defmodule FizzBuzz do
def fb(i) do
case {rem(i, 3), rem(i, 5)} do
{0, 0} -> IO.puts "FizzBuzz"
{0, _} -> IO.puts "Fizz"
{_, 0} -> IO.puts "Buzz"
{_, _} -> IO.puts i
end
end

def run(from, to) do
Enum.map(from..to, fn(i) -> fb(i) end)
end
end

FizzBuzz.run(1, 100)


Rate my Elixir
>>
File: GXdusMs.jpg (29KB, 500x500px) Image search: [Google]
GXdusMs.jpg
29KB, 500x500px
>>56209342
uh oh
>>
>>56210707
I never used c libraries nor cross compiled. But from what I see it shouldn't be any difficult at all. All you need to do is add new target and choose correct linker. #[link(...)] should work normally.
https://github.com/japaric/rust-cross
https://doc.rust-lang.org/book/ffi.html

>>56210727
If you can simulate turing machine in it.
>To show that something is Turing complete, it is enough to show that it can be used to simulate some Turing complete system. For example, an imperative language is Turing complete if it has conditional branching (e.g., "if" and "goto" statements, or a "branch if zero" instruction. See OISC) and the ability to change an arbitrary amount of memory (e.g., the ability to maintain an arbitrary number of variables). Since this is almost always the case, most (if not all) imperative languages are Turing complete if the limitations of finite memory are ignored.
Even Game of Life is turing complete.

>>56210978
Go doesn't have generics and has garbage collector. Just that makes them way different.
>>
>>56210888
>>56210905
>>56210920
Inbreds.
trait Foldable<T> { fn fold(&self); }
trait Applicative<T> { fn apply(&self); }
enum Nothing {
Nil,
}

trait Traverse<A, B> {
fn traverse<C> (foo: C, bar: Box<Foldable<A>>) -> Box<Applicative<Nothing>> where C: Fn(A) -> Box<Foldable<B>>;
}

struct A { }
struct B { }

struct Fo { }
struct Ap { }

impl<T> Foldable<T> for Fo { fn fold(&self) {} }
impl<T> Applicative<T> for Ap { fn apply(&self) {} }

struct S { }

impl Traverse<A, B> for S {
fn traverse<C> (foo: C, bar: Box<Foldable<A>>) -> Box<Applicative<Nothing>> where C: Fn(A) -> Box<Foldable<B>> {
Box::new(Ap { })
}
}

fn the_fn(a: A) -> Box<Foldable<B>> {
Box::new(Fo { })
}

fn main() {
S::traverse(the_fn, Box::new(Fo { }));
}
>>
>>56210960
You could write a wrapper program (in an another language) which would act like a runtime environment for the Brainfuck program.
Brainfuck program would ask the runtime to open a file / execute a program / etc, by writing to stdout and reading the results from stdin.

But that's just kicking the can down the road.
>>
>>56210928
I'm not saying it has full HKT support, but I am arguing that anything further than uniqueness types (i.e. lifetimes) and generics is too much trouble for too little gain. On the other hand, some forms of dependent types would be nice to have.
>>
Does anyone know how to get javascript to understand regex? Or maybe I am wrong.

I have string which may contain any number of matches, and I want to find them all.
I can find the first one, but if I add the global option, I don't get any correct results.

    
var str = 'example=\"value1\"\nexample=\"value2\"'
var ex = str.match(/example=\"([\s\S]*?)\"/g);


I don't want the search term, surely there must be an easy way to remove it or should I just process the result as well?
>>
>>56211166
>dependent types without HKTs

???
>>
>>56211128
Simplified a bit but I'm still not sure if that anonymous function is needed there at all, can I just pass fb as a second argument to Enum.map?

defmodule FizzBuzz do
def fb(i) do
case {rem(i, 3), rem(i, 5)} do
{0, 0} -> "FizzBuzz"
{0, _} -> "Fizz"
{_, 0} -> "Buzz"
{_, _} -> i
end
end

def run(from, to) do
Enum.map(from..to, fn(i) -> IO.puts "#{fb(i)}" end)
end

def run(to) do
Enum.map(1..to, fn(i) -> IO.puts "#{fb(i)}" end)
end
end

FizzBuzz.run 100
>>
>>56210888
>>56211147
What the fuck is the point of all this?

Is this just mental masturbation?

Why would you ever put this in production code?
>>
>>56211147
It's still not the same thing, falamity.

No HKTs means you can't do it.
>>
>>56211196
Because it's useful and concise.
>>
>>56211220
>concise
>>
>>56211220
I'm not seeing either of those qualities.

What's a real-world example of using this tomfoolery?
>>
>>56211234
Yes, concise. Such a generic function has high reusability, so you don't need to keep writing specialized instances of it.
>>
>>56211164
Hmm, so basically you can keep your instance of code in brainfuck but spawn children in other languages which hook into your console and preform functions for the code

Yeah, I could see it. Wouldn't be pure bf but other languages have dlls in even other languages so it's fair game I suppose
>>
>>56211252
Well you defined traverse wrong.

traverse_ gives back an f ()
traverse gives back an f (t b)
>>
>>56211190
Specifically limited dependent types that aren't proper, full-powered dependent types.
>>
>>56211264
The rust anon decided to do traverse instead of traverse_. I wrote none of the rust code.
>>
>>56211203
It's almost identical. To make it identical, change the impl line to
impl<T1, T2> Traverse<T1, T2> for S {

And proceed as usual.
>>
>>56211284
You mean dependent types but without the dependent or the type parts?

Seriously, it's like saying you want functions but without being able to call them
>>
>>56211196
Abstraction over different kinds of data structures.
>>
>>56211246
That's like asking what a real world application of foreach is.
>>
>>56211284
It's not a spectrum.
>>
>>56211301
For example, dependent types that only support integer dependency arguments. More importantly, the completely pointless bloat comes in when you start supporting garbage like relative value conditioning, but that's necessary to have proper dependent types as opposed to limited dependent types.
>>
>>56211300
Still not there. You can't do it until Rust has HKTs. It is not possible to get it right without them.
>>
>>56211330
You mean like in C++? That's not dependent types, that's type-level integers.
>>
>>56211330
>only integer arguments

Then they're not dependent types
>>
>>56211344
>it's identical therefore it's not identical
My sides!
>>
>>56211348
C++ does have compile time dependent types, completely unintentionally

template <T x> e
is pi x:T. e
>>
>>56211297
No. See >>56209720
>>
>>56211301
#include <cstdio>

template <typename F>
struct Fun {
F f;
Fun(F f): f{f} {}

void operator()() {
}
};

int main(int, const char **)
{
auto x = []() -> int {
fprintf(stdout, "say no more senpai\n");
};
Fun<decltype(x)> f{x};
f();
}


¯\_(ツ)_/¯
>>
File: LearningD_cover.jpg (145KB, 500x617px) Image search: [Google]
LearningD_cover.jpg
145KB, 500x617px
>>56209124
D was designed to be an improved C++ (hence the name D) so everything about the syntax sticks as close as possible to C++. That said it does have most of the advanced features that you get with Swift, Go, Rust. The reason that D never took off is because Walter Bright and Andrei Alexandrescu have always been afraid to say that D is a C++ replacement. There is really no reason to use D if youre not replacing C++ with it so the language was never taken seriously.
>>
>>56211348
Yes.
>>56211350
It is. So long as the type contains a dependency to a value, it is called a dependent type.
>>
>>56211368
Holy fuck you're retarded.
>>
>>56211379
That's the least of its problems. Split standard libraries and GC everywhere by default (and in the stdlibs) is a more important issue.
>>
>>56211384
No, you have integer -> type functions.
You may as well be saying you have a dependent type.

Besides, do Rust's generics actually exist at run time?
>>
>>56211394
Holy fuck you're a paid shill.
>>
>>56211405
oh boy, its the standard library memer, stick with Java if you like unified libraries Pajeet
>>
>>56211147
You turned static dispatch into dynamic dispatch. This all breaks down when you go to implement things like
for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)
because there's no way to use the same Traversable/Applicative instances across the different arguments.
>>
>>56211367
Type-level integers are not values.
>>
>>56209192
>3 hougs lateg
library genesis
>>
>>56211453
Types are terms
>>
>>56211437
There is, if you use T and where T : Traversable. The breakage point is that you can't use dependencies on generic types. Not that this causes any issue with that particular example either. At least learn what you're trying to shitpost about.
>>
Oops, >>56211453 is for >>56211384.

>>56211367
That's like saying System F has dependent types. Forall can be encoded with pi as well as a type of types, but it's not pi.
>>
>>56211478
>The breakage point is that you can't use dependencies on generic types.
FUCKING EXACTLY, THIS IS WHAT HKTS DO
>>
>>56211490
t. inbred
>>
>>56211479
What are you talking about?
It's exactly (compile time) dependent types

Ï€ x:T. e

template <T x> e

e.g.

Ï€ x:size_t. arrayOfSize(x)
template <size_t x> struct array;
>>
>>56211405
There is now one de facto standard library, and if you cannot get by with the @nogc code it provides in addition to your own then you're a retard that assumes memory can be managed via magic.
>>
>>56211302
That's not a real-world example.Why would you want to do that?

>>56211313
A real-world application of foreach would be something like (pseudocode):
foreach (file in folder) {
Delete(file);
}


What's the real-world application of whatever that other noise is?
>>
>>56211479
>>56211511
Pi:
template <T x> e

Forall:
template <typename T> e
>>
>>56211522
He's trying to mimic something from haskell

traverse_ is basically foreach
Haskell also has traverse
Which is like a foreach that also yields back into the exact same data structure

E.g. you could label a tree with increasing integers
>>
>>56211537
Again, you people keep telling me what it is.

What would you do with it? Why does it exist?
>>
>>56211522
The same thing, when t is [] and f is IO.

traverse_ putStrLn ["a", "b", "c"]


There are many other real world applications too.
>>
File: 200_.jpg (45KB, 381x499px) Image search: [Google]
200_.jpg
45KB, 381x499px
>>56209239
>So is rust worth the trouble? Whats example of project that rust best fits?
Its really not, and I say that as someone who loves to study advanced languages. But after reading pic related I finally found a language where I can say its not worth the effort to learn unless you need to get anal over explicitly level of control of lifetime of data which is something you dont even have to think about in gc languages
>>
>>56211515
Or via linear or uniqueness types, as many languages have done. Nevermind the fact that the stdlib isn't fullly gc-free yet.
>>
>>56211567
>
traverse_ putStrLn ["a", "b", "c"]

What does do? What is it trying to accomplish?
>>
>>56211548
(traverse_ delete) folder
-- does what your example did
folder `for_` delete
-- i prefer this syntax, for_ is flipped mapM_ which is mostly similar to traverse_


On the other hand, if "delete" returned some exit code, you could do this:

traverse delete folder

Now you get back the same data structure the folder was using, with all the files replaced with the appropriate exit codes.
>>
>>56211548
It's just a way to turn a usually runtime fact into a compile-time fact, which allows compile-time correctness verification. It's almost purely masturbatory though.
>>
>>56211592
Nobody knows.
>>
>>56211592
It does this:

do { putStrLn "a"; putStrLn "b"; putStrLn "c"; }
>>
Sup, /dpt/.
What is the current state of cross-platform programming? Is there any non-broken* way of creating apps for win/lin/mac/ios/android with minimal code duplication?

*I know several broken and severely broken ways, like NWjs and react-native. If you are familiar with JS, you know that it runs gui and logic within a single thread — we used to live with it in browser, but it cripples UX in comparison with native code.
>>
>>56211575
You don't have to think about it in rust either. The inference engine gets the right lifetime almost always without any hints. The exception is when you return references to struct-internals, for example, which lifetime needs to be bounded by the lifetime of the struct.
>>
>>56211615
>>56211597
So why would you write all that complicated masturbatory bullshit just to do something to each element in a collection?

There are far easier built-in ways to things like that in sane languages.
>>
>>56211625
Yes, just use rust.
>>
>>56211592
The same thing that would do this in C++:
for(const auto &val: std::vector<std::string>{"a", "b", "c"}) { 
std::cout << val << std::endl;
}
>>
>>56211592
It's a total mystery to me, too. I can't even begin to guess what the intent here is.
>>
>>56211625
You can write one C# codebase and use Xamarin and GTK# to deploy to all mobile and all desktop OSs, respectively.
>>
>>56211639
The real reason is >>56211604
and yes, it's only very marginally useful.
>>
>>56211646
I'm not familiar with Rust ecosystem. What library would you recommend?
>>
>>56211511
>>56211523
I get your point, but it's not useful to call it dependent types if you cannot depend on runtime values (i.e. free variables). We don't say System F has dependent types, and we don't say Haskell has dependent types, either.
>>
>>56211625
C++ w/ Qt.
>>
>>56211626

The difference is, Rust is hard, and,
>>
>>56211583
It does not need to be, not by a long shot. I'd really like to see peoples' ideas for realtime applications that are preemptively ruined by stdlib calls that use the garbage collector.
>>
>>56211677
What are the other "specializations" you're talking about?
>>
>>56211663
You may want to start here for inspiration:
https://github.com/kennytm/rust-ios-android
https://github.com/Geal/rust_on_mobile
Anything that uses pure rust is safe to use in that manner. For bindings, the usual constraints apply.
>>
>>56211625
Use D
>>
>>56211639
You're clearly not going to understand, but why do you care?
Anon was trying to fuck around in Rust to replicate what exists in Haskell.
In Haskell that is the "foreach loop".
Consider the example before:

>On the other hand, if "delete" returned some exit code, you could do this:
>traverse delete folder
>Now you get back the same data structure the folder was using, with all the files replaced with the appropriate exit codes.

You have a directory tree of file names. You call this function, and "yield" a pair of the file name and the exit code. Now you have exactly the same tree consisting of all the exit codes in the same data structure, with the same shape.

Another example - for loops that "yield"
That's also done with traverse

What about putting elements back into a set? An optional value? Etc etc.

>>56211668
Runtime/compile time is completely orthogonal to type theory
>>
>>56211707
You can use it with any t and f.
>>
>>56211654
Thank you for the idea, I've completely forgot about C#. Last time I've used GTK# it was a pain to make a proper layout, though.
>>56211669
Hell no! But thanks for the suggestion.
>>
>>56211699
>a language whose sole purpose is to replace another language does not need to be able to do what the other language can do by a longshot
Dtards everybody!
>>
>/source/blender/editors/interface/
>Is the widget drawing code (don't look here unless you're ready to spend hours going in circles)

Thanks for the warning I guess
>>
>>56211721
>Runtime/compile time is completely orthogonal to type theory
Type theorists don't say that System F has "partial dependent types". You either have full dependence over potentially runtime values or you don't have dependent types.
>>
>>56211729
So just like a foreach? Any STL container will work, furthermore any class implementing iterators will also work, and additionally you can use the std::for_each function if you prefer it. I'm not the anon that originally asked but what would be an example of a T and F combination that wouldn't work with traditional foreach?
>>
>>56211752
Type theorists don't talk about compile time or runtime because they've got nothing to do with type theory
>>
>>56211764
Exactly. It's not a dependent type if it can only be used at compile-time because dependent types transcend that.
>>
>>56211734
You can always use good 'ol WinForms.

Obviously the "modern" way of doing things is to just use a native GUI container and host HTML5 elements in something like a Chromium runtime. Think Slack and Discord.
>>
>>56211626
>You don't have to think about it in rust either. The inference engine gets the right lifetime almost always without any hints.
thats bull, you have to explicitly declare ownership in Rust to control scope, Rust doesnt work without hints in the type
>>
>>56211792
1/10, I replied.
>>
>>56211763
If F is something other than IO.
>>
>>56211721
Thanks for explaining for the 7th time what it actually does.

I still don't understand the purpose of writing your own esoteric implementation of foreach.
>>
>>56211707
Suppose you have a list of inputs and you want to check they're all valid. You write a function that checks whether a single input is valid and returns a success or a failure message. You can use traverse_ with this function to validate the list of inputs, returning all the failures if there were any, or Success ().
>>
>>56211807
Because effects are more than just *side* effects.
>>
>>56211807
It's more generic than foreach.
>>
>>56211809
You can use the generic functionality of foreach or lambdas that are built-in to modern languages to do this.
>>
>>56211764
except maybe to do with effects systems

>>56211781
That's nothing to do with it, "compile time" and "run time" do not exist innately in type theory. C++ has compile time dependent types. The "compile time" bit is only relevant to C++.

>>56211807
Jesus fucking christ try reading a reply rather than just posting some condescending remark
>Anon was trying to fuck around in Rust to replicate what exists in Haskell.
>In Haskell that is the "foreach loop".
And in decent languages you don't make everything a fucking language feature when it could be a library feature
>>
>>56211807
>writing your own
I mean, it's a library function. You wouldn't even have to write it yourself. You just use it.
>>
>>56211737
What the fuck are you talking about? Are you actually autistic to the point that the mere presence of GC code is enough to make you shriek and stamp your feet?
>>
>>56211832
Does System F have "type checking time" dependent types?
>>
>>56211827
Can you provide a specific example that illustrates this?
>>
>>56211832
So you're saying that Rust doesn't have foreach or set comprehension, and thus you have to write all of this dumb bullshit.
>>
>>56211849
See >>56211809 for another real world application.
>>
>>56211874
see >>56211830
>>
>>56211830
You need applicative functors to do it correctly, otherwise you have to write boilerplate or rely on the language having built-in support for whichever special case you're using.
>>
>>56211847
You honestly don't know what you're talking about

System F does not have a "type checking time"
There are valid programs and invalid programs.

Consider GHCi (emphasis on the i). There is no compile time. It's just runtime - there are still valid and invalid programs.

The compile time / runtime in C++ just means that you can't do dependent function application with values that come from runtime.


>>56211865
What the fuck are you on about?
Do you even know who you're replying to any more?
>>
>>56211809
So like this? Again, I'm not trying to argue usefulness of either, I'm genuinely curious.

typedef std::pair<bool, std::string> Ret;

template <typename T>
auto validate(T v) -> Ret {
//if (/* condition */) {

if (v % 5)
return {true, "Success!"};
else
return {false, "Failure message."};
}

std::vector<int> inputs{1, 3, 5, 6, 7, 9, 12};
std::vector<std::string> failureMessages{};

std::for_each(inputs.begin(), inputs.end(), [&validate, &failureMessages](const int &value) {
const Ret &ret = validate(value);
if (!ret.first)
failureMessages.push_back(ret.second);
});


>>56211900
Fucked up a bit here.
>>
>>56211849
data Result a = Success a | Errors [String] deriving Functor
instance Applicative Result where
pure = Success
Success f <*> Success a = Success (f a)
Errors es <*> Success _ = Errors es
Success _ <*> Errors es = Errors es
Errors es <*> Errors es' = Errors (es ++ es')

foo :: Int -> Result ()
foo x | x < 10 = Error (show x ++ " < 10!")
foo _ = Success ()

foos :: Result ()
foos = traverse foo [5, 11, 73, 0]
-- foos = ["5 < 10!", "0 < 10!"]
>>
>>56211952
Sorry,
-- foos = Error ["5 < 10!", "0 < 10!"]


You can do the same for any data structure that is Traversable. So an array, a tree with some traversal order, etc.
>>
>>56211928
>>56211939
Apols for the snark, I'm not used to genuine curiosity. Yes, I think it would be something like that. My C++ isn't very good so I can't be fully sure.
>>
>>56211841
typical dtard
>>
>>56211928
By using traverse, you don't have to explicitly construct the output vector. It happens implicitly as the result of the traversal.

Rust's iterators give you some of the functionality of traverse through iterator adapters, and some of it through .collect(), and for anything not covered by those use cases you can write a foreach loop (well, it's just spelled "for" in Rust). The point is, Haskell has one very general function that does all of that, and in Rust, it has to be like 20 different things.
>>
File: 1470789626656.gif (46KB, 100x155px) Image search: [Google]
1470789626656.gif
46KB, 100x155px
--NEW THREAD--

>>56211985
>>56211985
>>56211985

--NEW THREAD--
>>
>>56211916
So it has dependent types, but you can only use them when they're equivalent to weaker constructs that are not dependent types.
>>
>>56212025
I can't be bothered to continue with this
>>
>>56211998
What's more, you know that traverse_ isn't doing any funny shit because its extreme generality restricts what it can do.
>>
Hey /g/
How do I make it work without Box
fn main() {
struct FizzBuzz<'s> { f: &'s Fn(&FizzBuzz, i32, Box<Iterator<Item=i32>>) }
let fizzbuzz = FizzBuzz{
f: &|fizzbuzz, n, x| if n >= 250 {x.collect::<Vec<i32>>();}
else {(fizzbuzz.f)(fizzbuzz, n + 1, Box::new(
x.skip_while(|n| if n % 3 > 0 && n % 5 > 0 {println!("{}", n); true} else {false})
.skip_while(|n| if n % 3 ==0 && n % 5 ==0 {println!("fizzbuzz"); true} else {false})
.skip_while(|n| if n % 3 ==0 && n % 5 > 0 {println!("fizz"); true} else {false})
.skip_while(|n| if n % 3 > 0 && n % 5 ==0 {println!("buzz"); true} else {false})))}
};
(fizzbuzz.f)(&fizzbuzz, 0, Box::new(1..));
}
>>
Is it possible to program using kana? Or some other script?
>>
>>56212319
https://jsfiddle.net/94t0twrx/
>>
>>56212319
Rust experimentally supports Unicode for labels.
>>
>>56212319
Yes
>>
>>56210414
>>0u32..101
Wait what? Isn't 0..101 valid rust?
>>
>>56212484
It is, but he's ricing it.
>>
>>56209633
>Haskellfags triggered because computers are made of transistors instead of magical mathematics fairies
>>
>>56213459
Alan Turing was an academic


so was ritchie
>>
>>56209718
It's the only language that has even the potential to replace C and C++, and a replacement is needed seeing as writing correct complex software in those languages is empirically impossible for humans. It's made by SJWs but that doesn't matter because it's Free Software so you can fork whenever you want.
>>
>>56213554
A real Turing machine has infinite memory cells.
>>
>>56213621
Computers were invented by academics
The people you call engineers, the ones who've contributed significantly to the development of computers, are also academics, most of them have masters
Thread posts: 378
Thread images: 19


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.