Live data from Hacker News

To learn a new language, read its standard library

patshaughnessy.net

41–50 of 243 posts

Re: To learn a new language, read its standard library

#41
IMHO, any language worth learning has a large enough user base in both corporate and academic settings and that there are books written on it. That's my criteria. If it doesn't have at least 5 books on Amazon, I'm suspicious of it (and from real publishers, and not publishing mills). There's too much wheel-reinventing happening for me to get excited about new languages.

In the last decade I've spent time learning five sufficiently novel languages: Scheme, Ada, Erlang, Rust, and Go. Three of those are from the late 70's. I'm really glad I learned Ada and Rust. I started using Ada for embedded programming, and I'm trying to find more opportunities to use Rust because it so robust. I only studied Erlang, Scheme, and Go because smart people I knew told me I should investigate, but I have not used them.

Re: To learn a new language, read its standard library

#42

Earlier quoted context omitted.

Uh yeah if you try and read the Haskell standard library, you're screwed. It's list fusion and fancy algorithms to hack asymptotics all the way down.

What does it mean to “hack asymptotics”?

Algorithm runtime analysis is usually measured with asymptotic estimates (Big O, Little O, Big Theta, etc). In something as commonly and generically used as the standard library of any performance focused language you're liable to find a focus on optimizing these algorithmic performance guarantees for corner cases over optimizing for simple and straightforward code.

Re: To learn a new language, read its standard library

#45
post #12

To anyone that considers this approach for learning C++, I would advise strongly against it. Standard library code has to deal with too many cases and tries to be optimal for as many of them as possible. Also the formatting is highly unusual, compared to other C++ code found in the wild.

That's probably true of quite a few languages actually. I mean if there is any library you want to be as fast as possible, it's the standard library. Take python for example, a big chunk of the standard library is actually written in c (although there is often an equivalent implementation in python). In rust the standard library uses quite a bit of unsafe code, and even nightly only features and standard-library-only features that you don't usually need in real code, because you will be calling something in core or std that does it for you, and has been rigorously checked to be safe. The java standard library has parts that are written in c++. Etc. Etc.

Re: To learn a new language, read its standard library

#46
post #12

To anyone that considers this approach for learning C++, I would advise strongly against it. Standard library code has to deal with too many cases and tries to be optimal for as many of them as possible. Also the formatting is highly unusual, compared to other C++ code found in the wild.

I was about to post the same but here you are. The only time I would study std:: namespace would be is I needed to write some generic library. Trying to learn C++ by reading std:: can make one's head explode.

Re: To learn a new language, read its standard library

#47
post #17

Ugh Crystal is so beautiful and sorry to make this typical complaint but I wish the compile time was 1/10th of what it is. The dev cycle loop is just not there for me but the language is incredible.

Does Crystal benefit from these new M1 beasts? My Rust compile times became much more pleasant.

LLVM implements fewer optimization passes for ARM, so it's doing less work than compiling for x86.

Re: To learn a new language, read its standard library

#49
post #22
post #15

I’m using Zig a lot right now, and I have been pleasantly surprised by the standard library. Maybe it’s due to Zig being a very straightforward language, but I find most everything I read in the standard library to make immediate sense. I don’t know about reading std alone to learn Zig though, I used other sources like ziglings and ziglearn which taught me syntax and patterns. Had I started with the standard library…

Is there any learning resource for Zig that doesn’t assume you already know C? I couldn’t find any.

I'll be honest there aren't really any complete learning resources even for those that do know C. For what there is the language is changing whatever you read in documentation might not be true between stable and master at the moment. The stdlib source is probably the best reference but even reading strictly from that it doesn't mean you'll learn to make code that works it means you'll learn to make code that's correct. There are plenty of known compiler and language issues on GitHub and the self hosted compiler is still being written.

At the moment since Zig isn't complete you aren't going to find documentation that is either. Particularly for newcomers.

Re: To learn a new language, read its standard library

#50

IMHO, any language worth learning has a large enough user base in both corporate and academic settings and that there are books written on it. That's my criteria. If it doesn't have at least 5 books on Amazon, I'm suspicious of it (and from real publishers, and not publishing mills). There's too much wheel-reinventing happening for me to get excited about new languages. In the last decade I've spent time learning fiv…

What is novel about Go? It just seems like C repacked with a garbage collector and basic concurrent programming support to me. Which both weren't novel even when Go was designed.
Post reply on HN