/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

github.com/jtsiomb/c11threads/blob/master/c11threads.h
nyaa.se/?page=download&tid=884762
pastebin.com/W395EBGT
wiki.haskell.org/GHC/Memory_Management
stackoverflow.com/questions/4858585/why-is-ghc-so-large-big
github.com/isagalaev/highlight.js
twitter.com/NSFWRedditImage

Why is it taking so long for glibc to implement threads.h?

musl has supported threads.h for a while now

Need to setup a website with back end storage for a local business.

What's an easy web interface to design and build?

Functional programming thread:

Functional programming thread:

Wondering if it's a better idea to compile something that looks like it was never actually compiled (on Linux) or fork the project and rewrite the entire damn thing.

FYI anything associated to v8 is falling to shit.

Put an ad out for "C#, jQuery and entity framework." Literally stuff they teach anywhere.

Nah I'm looking to try and build it myself.

Either they've got something else they're working on implementing, they're being lazy shits, or there's difficulty implementing it on some non-posix systems. Either way, have a drag and drop implementation using pthreads:

github.com/jtsiomb/c11threads/blob/master/c11threads.h

You need knowledge in those three things.

jQuery is what you'll use to call the back-end from the ui/front-end, specifically what's called Ajax calls.

C# is a good idea for a minimalist backend since there are plenty of backend libraries there and 90% of them are faster than ASP.

Entity framework is for SQL databases, not really my thing but there's plenty of database drivers in C# that load and store whatever data.

You can do that shit, get a service that can do at least 1000 serves a second, respond in under a millisecond and not cost you more than $5 a month. This is many multiples times faster PHP or ASP or the fast majority of interpreted languages.

Is /wdg/ up?

>try and build it myself
Sure thing, but if you have to ask...

It's for a local network only. I'm talking about 1 hit every few hours at most!

>have a drag and drop implementation using pthreads
I always try to use musl, but I was just wondering what was taking ganoo so long

Im have a legit version of win7 OEM, but wanna install it on a ssd, so am currently cucke dby the OEM..

Fuck, my RSS feed downloader doesn't work. I've had something similar before and it was because Cloudflare rejects requests without a User Agent. Ah well, at least I have something to do.

It takes quite a while for new shit to make it into glibc, and they have a very slow review process.
There were some patches implementing it that appeared in August 2015 or so, if I'm not mistaken, but the author didn't really follow through for that long to get the glibc developers to get off their ass and review it properly.

I'm trying to find some motivation to do programming for work, but I'm struggling... I'd rather be at home watching series or something.

>back end storage for a local business
Then do whatever, go research databases. Not programming. Be gone vague troll of vague questions.

Productivity must be sought for productivity sake.

>Productivity must be sought for productivity sake.
What does that even mean?

Same shit m8, same shit, this end of the year thing is totally killing my motivation.

My question was about front end web interface that would talk to a database. That's programming!

Basically anything that doesn't disable jQuery in anyway, it's the only thing you absolutely need if you want to keep web api calls pretty.

From the back-end, literally go "your favourite language here" "your preferred database here" driver in a google search and you've got everything you need there. There's so much choice you're so dumb if you choose something bad.

Learn to enjoy your work.

What does the :: mean in pub fn send(self) -> ::Result {

The root namespace of the crate:
const MESSAGE : &'static str = "ABC";

mod a {
pub mod b {
pub mod c {
pub fn print_it() {
// error[E0425]: unresolved name `MESSAGE`:
// println!("{}", MESSAGE);
println!("{}", ::MESSAGE);
}
}
}
}

fn main() {
a::b::c::print_it();
}

That's nifty, thanks.

It really would be nice if we had a way to specify language syntax highlighting in code blocks.
That way, we wouldn't get basically the entire program in green in languages that use " or ' in a non-balanced way.

Found the problem: 'nyaa.se/?page=download&tid=884762 stream did not contain valid UTF-8'.
I parsed binary data as UTF-8. I'm retarded.

1. Is SICP worth going through? I've just started chapter 3. Some of it is cool, some of it badly explains concepts that are more easily explained elsewhere.

2. What CS university courses are especially helpful in real world programming? Basic algorithms courses?

3. Are things like Haskell / scheme just hipster meme languages? If not, why aren't they used more in the real world? Why aren't financial institutions or other places with money hiring smart haskell / scheme programmers if they can afford to get the best?

picrelated is my face when seeing all the contradictory advice and potential things to learn. Every topic is a million miles deep.

>1
Dunno, never read it
>2
Look for stuff like linux/windows programing
>3
They are excelent tools for learning functional concepts, but are rarely used in real life

>Is SICP worth going through?
Yes, but only if you get something out of it. Reading it for the sake of reading it, without understanding what you're actually reading, isn't useful. In that case, you should consider revisiting SICP at a later point in time when your understanding of the topic has increased.

>What CS university courses are especially helpful in real world programming? Basic algorithms courses?
Yes, and:
Any programming course or course that requires you to do problem solving / programming tasks.

Discrete mathematics and logic stuff

Anything with real world application, such as a course on Operating System, Computer Architecture, Data Communication, Networking etc.

>Are things like Haskell / scheme just hipster meme languages?
Haskell I don't know about, it has a pretty small user base though, if that's an indication of anything. But there are some cool applications written in Haskell AFAIK, so it is indeed a programming language designed for real world use.

As for Scheme, any Lisp dialect is handy to know, because it will teach you the fundamentals of a functional programming mindset. It's not much used in real world, but of course there are some exceptions to this rule.

I bet someone will pounce on me for this claim, but IIRC Lisp itself was designed as a proof of concept that it was possible to do lambda calculus on a computer.

>Why aren't financial institutions or other places with money hiring smart haskell / scheme programmers if they can afford to get the best?
"Financial institutions" is a pretty broad term, which ranges from anything doing menial Java back-end stuff and JavaScript/HTML front-end to maintaining legacy COBOL code to doing statistical analysis using R or some other language suitable for doing that to math-heads designing the latest HFT algorithm using C or C++ or even Fortran.

Fixed it: pastebin.com/W395EBGT

1. No
2. use unit testing, version control, learn OOP, databases, understand how a computer works at the lowest level, understand the platform you're developing on
3. the functional stuff added to C#, Java is great, but Haskell is a meme. It was designed for academics, not real programming

>1. Is SICP worth going through?
No, it's an outdated text with some interesting things here and there, but overall it won't help you to become a better real-world programmer.
>Basic algorithms courses?
Yes, also Software Engineering, Operation Systems and Compilers.
> 3. Are things like Haskell / scheme just hipster meme languages?
Scheme - definitely yes, Haskell actually works well in some applications.
>If not, why aren't they used more in the real world?
Haskell (and related languages like F# and OCaml) is being used, by financial institutions among others, but the demand is relatively low.

>Haskell is a meme
No it isn't

Your mother is a meme, and not even the dank kind.

>wiki.haskell.org/GHC/Memory_Management
>it's not uncommon to produce 1gb of data per second

That's how fast it can allocate.
It doesn't actually keep all that at once.

>Haskell computations produce a lot of memory garbage - much more than conventional imperative languages. It's because data are immutable so the only way to store every next operation's result is to create new values. In particular, every iteration of a recursive computation creates a new value.

Oh wow, I thought this was only a joke we had on Sup Forums to bait Haskellfags, but it's actually true? Jeez Louise

>allocating 1 GB of data only to have the garbage collector reclaim it immediately

Why??? Isn't the compiler able to do some form of optimising to avoid this?

Optimisers aren't magicians.

Well, C and C++ compilers are able to implicitly do TCO... Why can't haskell compilers?

>TCO
That is something different.
It's to do with the fact that everything in Haskell is immutable.

Garbage collectors are generally a part of the runtime, not the compiler. Also, most people would rather 1 GB of memory not stay allocated any longer than it has to.

>immutable
Well, so are const references. You don't need to pass everything by copy, not even meme language #1 aka Python does this.

stackoverflow.com/questions/4858585/why-is-ghc-so-large-big
>2017 - 3 days
>not getting 4 copies of every library

But muh purity

>Sup Forums is bitching about how bloated Java is and how the JVM uses too much memory
>Sup Forums shills Haskell as the one language to rule them all despite it's perfectly acceptable for the Haskell runtime to allocate >1GB of data that's never used and hold it until it's GC'd

If this doesn't confirm that Sup Forums is full of retards, I don't know what is

Isn't the whole point of letting the runtime deal with things that the runtime is tainted but not the code?

Isn't that for example the mental gymnastics Haskellfags do when they defend the io monad thing? That the user's code is still pure even if the monad returns code that taints the runtime since io is a side-effect?

>it's perfectly acceptable for the Haskell runtime to allocate >1GB of data that's never used and hold it until it's GC'd
You can tell GHC what the maximum heap size should be

It's not mental gymnastics.
Main is an IO action.
It's like returning an AST rather than being able to literally perform actions.
The point is you can't (without non-standard unsafe extensions) write a function (forall a. IO a -> a)

>C
>Python
>Java

Do you even need any other programming languages?

>You can tell GHC what the maximum heap size should be
Doesn't this just cause Haskell programs to either crash (like in Java, when an OutOfMemoryException is thrown) or run slower (because it has to wait for the GC)?

>It's not mental gymnastics.
My point is this: What's stopping the runtime from passing a const reference and do COW like a sane system would do?

>Rust
>C#
>Python
ftfy

>xe still uses programming languages

>My point is this: What's stopping the runtime from passing a const reference and do COW like a sane system would do?
I don't know what COW is, but Haskell is pure and that's a good thing.

>crash or run slower
Well yeah.
If it bothers you, you can do manual memory in Haskell, but unfortunately you can't turn GC off (though you can set the heap to 0)

>github.com/isagalaev/highlight.js
Is what we need, and if I remember correctly, it's what Discord uses with its markup extensions.

Oh and Haskell is getting a LinearTypes extension that should alleviate some allocations

>I don't know what COW is,
Copy On Write. Meaning that only values that are written to are actually copied.

>but Haskell is pure and that's a good thing.
You just mentioned how impurity can be contained.....

>Well yeah.
Then that's not an optimisation or a fix...

>If it bothers you, you can do manual memory in Haskell,
Still not an optimisation or a fix

Copy on Write.

>>Well yeah.
>Then that's not an optimisation or a fix...
>>If it bothers you, you can do manual memory in Haskell,
>Still not an optimisation or a fix
What do you mean an "optimisation or fix"?
GHC can allocate a GB in a second, that's fast allocation.
What's the problem?

COW = Copy on Write

You don't copy data unless it is manipulated.

Haskell data is immutable, so there isn't any "write"

>GHC can allocate a GB in a second, that's fast allocation.
>What's the problem?
First of all, allocating a GB in a second is absolutely not fast. Any userspace application mmap the size of the entire RAM in a matter of nanoseconds.

Second of all, we're talking about unnecessary allocations, not how fast Haskell is. Allocating memory unnecessarily is bad. Having to wait until it is reclaimed is bad. A second is "forever" on modern computers. Anything above a couple of nanoseconds is an eternity for an operation.

Imagine the scenario where you have a Haskell program running and it's using almost the entire heap. Then you call some function that returns some list it generates recursively and tries to allocate 1 GB, even though you only need to modify the final list.

It fails to allocate enough space for that list because it's already using the entire heap. This causes the Haskell runtime to crash and your program crashes. How can any sane person claim this isn't a problem?

>>All
Stop using acronyms to pretend to be knowledgeable!

wiki.haskell.org/GHC/Memory_Management

Are you legally retarded or just pretending to be? Immutable does not mean you have to copy everything. Immutable simply means that you can't mutate it (aka modify it aka write to it), correct?

>GHC can allocate a GB in a second, that's fast allocation.

Ruby can allocate a string of size 1,000,000,000, with every character in it being the letter 'a', in only 0.41 seconds. That is a memory allocation, and a memset of size a billion.

Then there is no need to copy.

>Immutable does not mean you have to copy everything
I didn't say it does

That is the link I'm fucking responding to, you dolt. Follow the chain of posts.

Just because the Haskell authors tries to justify their insane design decisions, doesn't mean that they are actually justified, which is why we are currently discussing this.

>insane design decisions
Haskell has GC.
So do many other languages.
Haskell is pure.
This is not that common.

What are the insane design decisions?

>I didn't say it does
I asked why Haskell has to copy everything instead of doing COW and you literally just replied "immutable".

> What are the insane design decisions?
Not him, but lazyness was a mistake, and it has a direct impact on memory consumption.

>Haskell has GC.
>So do many other languages.
>Haskell is pure.
These are all good things, I'm not bitching about this.

>What are the insane design decisions?
Allocating gigabytes of memory that's never actually used only to have it collected at a later point.

Yes, it's immutable. So you can't write.

It doesn't allocate "gigabyte of memory that isn't used", and anyway this is an issue with GHC, not Haskell

Haskell doesn't need COW because there is no write, but Haskell does share all the data it can between data structures(basically COW without write part), that's one of the perks of immutability.

>Yes, it's immutable. So you can't write.
You are copying data so you don't modify the original data, this is the immutability.

SO WHY THE FUCK CAN'T YOU DO COPY ON WRITE INSTEAD???????

>It doesn't allocate "gigabyte of memory that isn't used",
It does, it fucking says so in the link you posted.

>Haskell computations produce a lot of memory garbage - much more than conventional imperative languages. It's because data are immutable so the only way to store every next operation's result is to create new values. In particular, every iteration of a recursive computation creates a new value. But GHC is able to efficiently manage garbage collection, so it's not uncommon to produce 1gb of data per second (most part of which will be garbage collected immediately).

>and anyway this is an issue with GHC, not Haskell
>le garbage collector is not part of haskell
>le runtime is tainted not haskell
>le io isn't impure because the runtime is tainted
MENTAL GYMNASTICS

>copy on write, but always copy
You're literally just saying it copies everything every time.

This is not "COW without the write part".

le mad xd

>You are copying data so you don't modify the original data, this is the immutability.
>SO WHY THE FUCK CAN'T YOU DO COPY ON WRITE INSTEAD???????
It doesn't copy.
You can't write.

>>It doesn't allocate "gigabyte of memory that isn't used",
>It does, it fucking says so in the link you posted.
The data is used you utter fucking moron.
The GC doesn't just fucking say "why not allocate some data right now?"

>MENTAL GYMNASTICS
Wow, then I guess that one obscure C++ implementation that is really fucking shit is indicative of every fucking C++ implementaiton.
Jesus you fucking moron, grow a brain.

I'm not the guy you're been arguing with, Haskell doesn't copy everything every time:
let a = [1, 2, 3, 4]
let b = 0 :: tail a
let c = b

Both a and b will share the [2, 3, 4] part, and both b and c will use the same memory. This is that COW does in other languages, but since there is no write in Haskell, there is no need for coping anything on write.

>It doesn't copy.
That's literally what you do. You copy everything so the original remains """pure""" and not mutated.

>You can't write.
You write to your own fucking copy, or are you actually saying that you can't append a value to a list or assign a value to a variable? Because if you are saying the latter, then I don't think you know any Haskell.

>The data is used you utter fucking moron.
No, it's not used. It's duplicated for no reason other than having the original unmodified.

>The GC doesn't just fucking say "why not allocate some data right now?"
No, the GC collects data that isn't referenced anymore. So when you make a bunch of unused copies, the GC has the job of cleaning that up.

The job of the GC is literally to clean up memory that isn't used anymore FFS. What the fuck do you think that statement means?

>Jesus you fucking moron, grow a brain.
GHC is literally the reference Haskell implementation you dick. Not only that, it's the only Haskell implementation that's currently used because all others are defunct and were never official.

Multiple users want to make simultaneous comments on something.

The shared excel spreadsheets doesn't seem to be cutting it. What's the next step up? I kind of feel databases is going to be overkill for this.

>shared excel spreadsheets
Just use a fuckin' database at this point.

>That's literally what you do. You copy everything so the original remains """pure""" and not mutated.
No. It keeps a reference.
Nothing is mutated so you can always keep a reference.
This is one of the advantages of purity, you always know that your old data will never be mutated.

>You write to your own fucking copy, or are you actually saying that you can't append a value to a list or assign a value to a variable? Because if you are saying the latter, then I don't think you know any Haskell.
No, you create new data.
You don't "assign to a variable", you declare a variable.
It has one value and only one value.
"append a value to a list" is returning a different list.
It isn't copying the list and then adding a value in front, it's saying that the new list IS the old list with the value at the front. It's pure, so you can just keep a reference to the old list. Hence
zeroes = 0 : zeroes
doesn't take up an infinite amount of space, it takes up very little space.

>clean up memory that isn't used anymore
This isn't what you originally said, which was that it allocates unused data.
This is what every GC does and every GC ends up with data that temporarily isn't freed.
You have no fucking argument, you're just trying to not be wrong at this point.

>GHC is the reference Haskell implementation
Wow, so I guess you're saying it's not a real Haskell implementation if it doesn't use GHC's implementation of the GC?
Weird demand for the language.

Do Haskell programmers even care about language implementation? They often seem rather distanced from what the actual generated code looks like.

gee, it's like I've stepped into the fpg containment thread

SQLite

They do when they try to push it into production and suddenly realize it's an order of magnitude slower than C++.

People that want to attack Haskell do
They don't like Haskell because it isn't what they're used to

Is ocaml the best lang ever made?

G I L

I'll second this for the general use case, except when there is a need for many, many simultaneous writers.

>People that want to attack Haskell do
Implementation performance is a pretty valid reason to attack a language. This still doesn't answer the question of why Haskell programmers don't seem to care.

>They don't like Haskell because it isn't what they're used to
Unfamiliarity is a pretty good reason to dislike a language as well. Could the ideas proposed in Haskell be more popular if they were designed in a syntactic form similar to other languages, such as C, Python, or even a Lisp? Probably. Haskell programmers would like to ask newcomers to not only learn a lot of type theory that they never learned in university, but also to learn a new syntax, and ignore performance problems.

you can just spawn another process.

Wait, ocaml has GIL? Why?

Haskell isn't that slow, but obviously it has a GC so it's not going to compete with C or C++.
It's very declarative so it's also going to lose speed on that front too.
It has a GC so it's obviously not a systems programming language either.

Very fast Haskell doesn't look much like Haskell

>Haskell isn't that slow, but obviously it has a GC so it's not going to compete with C or C++.

careful, you might trigger some Go users

No matter what the devs say Go's aim won't be to compete with C for as long as you can't manage memory manually.

>Very fast Haskell doesn't look much like Haskell
This is an important point. If one must sacrifice the benefits of writing Haskell in a way the language designers intended just to get some performance, why not simply use another language altogether?

Because Haskell is a brilliant and amazing language, and some times you would rather have 30% written in not-really-haskell haskell than 100% written in not-haskell.

Same shit with OCaml (my favourite language), writing low level stuff feels so dirty

I'd rather have 100% fast than 30% fast, to be honest. And hell, it's not as if there aren't languages other than C and C++ that do a decent job at performance. Consider Rust, for instance. Or Ada if you have a death wish.

So use soul-crushing languages when you really need performance, and languages you actually like when you don't.

I'm pretty sure someone has already realised this, somewhere...

There are plenty of occasions where you don't need to go that fast.