Live data from Hacker News

To learn a new language, read its standard library

patshaughnessy.net

101–110 of 243 posts

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

#101
post #9

Definitely true for Golang, learned a ton reading its stdlib (and even found a bug this way)

I actually partially disagree with this. Sure, for the higher level OS independent packages (e.g. “archive/tar”) this is great. For stuff in the “os” package it’s a different matter. All of that code is a bit messy. Not because the authors did a bad job, but simply because it’s hard to implement the same API on half a dozen operating systems. Then there is the “runtime” package which relies on a lot of global state,…

I suspect that the part of the stdlib that deals with the OS and runtime will be fairly messy and un-idiomatic in any language. They are inherently hairy problems.

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

#103

laughs in C++

Indeed; In C/C++ land this is rather the norm.

I learnt more about C and C++ from studying Plauger's The Standard C Library and Plauger/Stepanov's The C++ Standard Template Library. I also remember learning Object-Oriented Framework design from MFC Internals.

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

#104
post #89

This is a classic academia-ish take. Consume a bunch of theory and regurgitate whatever you've read. Better way to learn is making stuff with the language, having actual skin in the game. Only then bounce back to theory on the more nuanced stuff.

I don't think this is a good read. A standard library is very concrete - it's the core of the language in action, and the shape that its code takes will likely be repeated regularly in 3rd party code written in that language. There's nothing academic or abstract about it.

EDIT: As others note, a good chunk of a stdlib may involve system interop that isn't representative, so that tempers my comment with regards to whether that code is idiomatic. But my case still stands regarding concrete vs. abstract.

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

#105

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.

[deleted]

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

#106
post #84
post #66

Earlier quoted context omitted.

> 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 I have found the Rust std lib to be a great resource. Much of the unsafe is necessary because there is literally no other way to build up abstractions like Box or certain data structures without it. Obviously once those are written though, you want…

Do you know of any examples of good quality application code in rust?

There are many like firecracker vm, polkadot, linkered proxy, tokio, hyper etc. And these are the one I know and I think there are too many good quality application code in Rust.

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

#107
post #47

Earlier quoted context omitted.

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

Does that hurt performance of the output?

There is high probability that it can hurt runtime perf. Because less passes means less optimization (in general)

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

#108
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.

This is also true for .NET, especially modern .NET where performance is critical nearly everywhere. It's representative of perf-sensitive code, but not general purpose C#.

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

#109

Whole heartedly agree. I was big into Go years ago, and some newer guys tried to make it a functional language. When they argued with me, I couldn't say 'its's just not right', but instead pointed them to std library code. Protip: That doesn't change their mind, it just makes them hate Go.

Why is that wrong? A language can be multi-paradigm while the “official” documents are written in a specific style. Like human languages, they evolve with their use (or fork into another language completely), while the high literature is the last one to change.

Together with that, I agree that one should read the high literature before inventing a new writing style.

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

#110

Whole heartedly agree. I was big into Go years ago, and some newer guys tried to make it a functional language. When they argued with me, I couldn't say 'its's just not right', but instead pointed them to std library code. Protip: That doesn't change their mind, it just makes them hate Go.

Why is that wrong? A language can be multi-paradigm while the “official” documents are written in a specific style. Like human languages, they evolve with their use (or fork into another language completely), while the high literature is the last one to change. Together with that, I agree that one should read the high literature before inventing a new writing style.

I'm a big believer in 'when in Rome', not just in languages but life.

If you don't like language X, don't take a job writing language X.

Post reply on HN