Live data from Hacker News

To learn a new language, read its standard library

patshaughnessy.net

31–40 of 243 posts

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

#31

Reading the Python stdlib was a brilliant move a peer encouraged me to do. I learned three themes of stuff: 1. A good look at long lasting, durable pure python. 2. A good look at long lasting, durable C implementations of python (dict is the core of Python. Read the source!) 3. A look at a bunch of libraries that basically never get used and a sense of how they compare to popular third party libraries. (Doing this is…

I'd love if you could elaborate on your thoughts for 3. Is it a problem of not being feature complete in unpopular parts of the stdlib?

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

#32
I'm not sure how many languages this works well for but it certainly doesn't work with C. You won't learn the important distinctions between implementation defined, unspecified and undefined behavior. And reading a C standard library implementation will not really teach you to write normal idiomatic C code. You will also not learn the strict discipline required to avoid doing things unless you absolutely know with certainty that they are either strictly conforming or defined for your particular set of target platforms (usually much harder to answer this second question which is why when writing C you should avoid having to).

That being said, for Erlang, I think this is a good idea. I learned a lot when reading the standard library.

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

#33
Emacs comes with a manual called "An Introduction to Programming in Emacs Lisp". It says:

> I hope that you will pick up the habit of browsing through source code. You can learn from it and mine it for ideas. Having GNU Emacs is like having a dragon’s cave of treasures.

- https://www.gnu.org/software/emacs/manual/html_node/eintr/On...

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

#35
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 actually what I do whenever I’m lacking humility as a coder. One F12 on std::iterator (which is now deprecated lol [0]) is enough for me to remember that I don’t know anything.

[0] https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated...

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

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

Yeah, the first thing that popped into my head was some poor n00b spending the next six years of their life deciphering glibc. There have got to be easier ways :)

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

#37
The goals of library authors are frequently different from those of application developers. Library authors usually have to consider how to make their code work on more environments, on older language versions, more configurable, handling more edge cases.

I think there’s definitely value to reading a language’s standard library, and I’ve also gotten lots of value from even reading the language’s implementation! But I hope people take this advice to start with reading the standard library with a grain of salt: it can be one extra resource for you, and likely to show you new things that weren’t written in docs somewhere, but if it doesn’t click or is proving difficult to understand, that’s fine!

In particular, for the “reading code to learn” bit, consider reading an application written in that language (command line tool, web application, etc.) and it might serve as a more reduced intro to the language.

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

#38
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 would have commented that if you didn't

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

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

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”?

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

#40

I find languages are pretty easy to pick up after the first few. What seems to be the barrier nowadays is frameworks. How do people go about learning a new framework? Obviously most of them have an intro project to follow on with, but they tend to be pretty simplistic, and once that's done, getting to the complicated bits that you actually want to implement seem to be the barrier.

IMHO, if a framework isn't well documented, I avoid it. It means they probably didn't think it through very well and it will soon be unmaintained.
Post reply on HN