Live data from Hacker News

To learn a new language, read its standard library

patshaughnessy.net

231–240 of 243 posts

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

#232
post #158

Earlier quoted context omitted.

I think the Scheme quote is interesting, because it almost applies to C. Most people consider learning C hard (for example, compared to python), but it is an extremely small language with a "standard library so small it's pretty much useless".

I'd recommend then read musl though and not that atrocity that is glibc

I also recommend musl. The code is just much more readable. I couldn't even find what I was looking for in glibc source code.

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

#233
post #200

Earlier quoted context omitted.

Sorry mate, your argument doesn't make much sense. People can and do write OOP in C++, and just because it is multi-paradigm does not mean no one should write OOP. It's like saying, because an artist is using watercolors for this painting, they should therefore never do pencil drawings on other projects.

> People can and do write OOP in C++, if that's "textbook java oop" with runtime polymorphism then that should definitely be avoided and is pretty much considered an anti-pattern nowadays

I don’t disagree, but that’s an entirely different issue than your original argument, which was to suggest that C++ is not an object oriented language.

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

#234
post #228
post #189

Earlier quoted context omitted.

Very well put. (And if the standard library doesn't represent idiomatic use of the language, that's a red flag).

Take Scala collections. These are written using builders and if-else checks of emptiness which are definitely not idiomatic. Authors of the std-lib did them for you so you do not have to. That is not a red flag.

The other way around: non-idiomatic use of a language in its standard library points to weaknesses in the language.

If emptiness is something that is so important you add extra branchpoints inside collections to check for it, there ought to be some way of disallowing emptiness or {nil,null}ness in the language itself.

Sure, it is nice for people who use the standard library, but it points to things in the language that perhaps should have been given some more thought.

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

#235
post #188

Earlier quoted context omitted.

You seem to be implying that it is desirable to employ programmers who would get confused over bitshifting and lack the ability to figure it out.

It's the norm to work together with people with varying skill level. Weather people have the skill to figure it out also doesn't matter as they normally don't have time to figure it out. And even experienced programmers can get confused about bit hacks, sure temporary but that already a step price to pay which is seldomly worth it. It always comes with the risk of accidentally introduce a bug, even if your team only…

I agree that complex bit hacks makes code less readable and should be avoided. But that's not necessarily what we're talking about here. Most common uses I see of shift operators tend to do the opposite: they make what you are doing more explicit when you do bitwise operations.

If flipping the Nth bit inside an integer or a byte array is an "advanced" technique, unfit for "application programmers" then I'm not sure I want to work with "application programmers".

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

#236
post #67
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.

The same is true of clojure. Don’t read clojure.core as idiomatic.

One thing I have wondered about is the number of multi-arity functions that individually specify 1, 2, 3, 4, 5 argument cases in 3rd-party library code. Is it a result of people thinking that’s idiomatic, or is

  ([a b c d])
performant enough to matter in library code instead of using

  ([a b & more])
? I hope it’s the former.

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

#237
post #234
post #228

Earlier quoted context omitted.

Take Scala collections. These are written using builders and if-else checks of emptiness which are definitely not idiomatic. Authors of the std-lib did them for you so you do not have to. That is not a red flag.

The other way around: non-idiomatic use of a language in its standard library points to weaknesses in the language. If emptiness is something that is so important you add extra branchpoints inside collections to check for it, there ought to be some way of disallowing emptiness or {nil,null}ness in the language itself. Sure, it is nice for people who use the standard library, but it points to things in the language th…

I'm not sure I would call it a weakness. Performance vs expressiveness and maintainability will always be a trade off. It could be a weakness, but it's just as likely that it was a deliberate trade off.

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

#238

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…

Could I trouble you to compare Ada and Rust, especially in terms of safety? I'd like to be able to write low-level code without dealing with the insanity of C, and my top picks are Ada (traditional answer to "safe language"), Rust (the up and coming answer to "safe language"), and Pascal (friendlier than C and way better at least for memory safety), but I'm reluctant to learn all of them to sufficient depth to be abl…

Of those three, Ada and Pascal are as I understand it pretty closely related syntax-wise (in the same "family"), so learning one of those will help a lot with the other.

I'd recommend starting with Pascal, because of the comprehensive and high quality standard libraries (or "frameworks" -- see related recent HN discussion...) in Free Pascal and Delphi, and because Free Pascal can target a lot of different OSes. OTOH, a downside might be that you learn (to rely on) too much of the FCL/VCL in stead of just syntax, so you get confused at the lack of those libraries in Ada; that could speak for taking it the other way around.

TL;DR: IMO, in a way that's perhaps closer to two new languages to learn than three.

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

#239

Crystal core developer here. Happy to see Crystal's stdlib as an example for how you can grasp a language by looking into stdlib code. That's what I like a lot about Crystal. Even its stdlib easily readable. Arguably, this is somewhat deteriorating as algorithms get optimized. Readability and performance being in competition. I agree with some of concerns from many commenters. For many languages, especially those tha…

> Crystal

Sorry, stupid question: Is this derived from the old Crystal Reports, or something completely separate?

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

#240

Earlier quoted context omitted.

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.

Got it, thanks!
Post reply on HN