News for hackers. Stuff that matters.
Re:SICP Goodness – Why you don't need looping constructs by chriswarbo on Friday June 29, 2018 @07:25AM (#17423815)
All else being equal, it's better to implement things in libraries rather than bake them into a language.

If we want to do something that requires a change to the language, e.g. the "async/await" stuff that seems to be popular these days, then we must convince the language designers that it's a good idea, wait for it to be implemented, wait for a new release of the language, and maybe (if we want our code to be portable) wait a few years for it to become widespread (e.g. new versions of RedHat, Debian, etc. to include it by default). Alternatively we could maintain a fork or patchset, which might be a lot of work and receive little support. We may also have to do this for multiple implementations, e.g. GCC + Clang + MSVC + .... We might also have to go through some form of standardisation effort (e.g. C++14, Haskell2010, etc.).

Our change may impact every user (e.g. if we add exceptions to a language, everyone must now worry about catching them, e.g. from callbacks). This impact may last for decades, even if that feature falls out of favour, since it must remain for backwards compatibility. Any subsequent language features must take our feature into account (e.g. if we added exceptions, and someone wants async/await, that person must consider how async/await deals with exceptions and vice versa).

On the other hand, if something can be implemented as a library then we don't have to wait for anyone: we can just write it. It will work with multiple implementations of the language. Those who don't want or care about our feature can just avoid the library. If the feature falls out of favour, we can just avoid importing that library in our new projects.

Re:SICP Goodness – Why you don't need looping constructs by Const-me on Friday June 29, 2018 @09:07AM (#17424210)
> it's better to implement things in libraries rather than bake them into a language.

That’s debatable and there’re also strong arguments why not. I don’t work on programming languages but I use them a lot. I generally prefer built-in features over libraries, here’s why.

Language designers are usually conservative, in a good way. If they implemented a feature into the language or into a standard library, it’s likely to stay. As a user, this gives me a good chance my code will compile by a version of compiler 10 years in the future.

Libraries are easier to fork, modify and evolve. This is good for development of language and libraries but not necessarily good for developers using them, first I need to pick one, then I need to ensure all developers on the project agree on the set of libraries and their version. Both take time. For languages with batteries included, I don’t need to worry about that.

Libraries baked into a language are of better quality, on average. They receive higher users count, the bugs are more likely to be found and fixed.

Not everything can be implemented in libraries. C++ designers made a mistake with multithreading, only fixed recently. Async-await feature is the same, note how in .NET and golang it spawns across the whole stack: libraries, compiler & language, runtime, OS kernel interface.

Re:SICP Goodness – Why you don't need looping constructs by willtim on Friday June 29, 2018 @09:18AM (#17424294)
> Not everything can be implemented in libraries. C++ designers made a mistake with multithreading, only fixed recently. Async-await feature is the same.

Minor correction: In Haskell and F#, Async/Await can and is implemented as a library.

Re:SICP Goodness – Why you don't need looping constructs by chriswarbo on Friday June 29, 2018 @11:42AM (#17425134)
I said "all else being equal" for a reason. All your points stem from the fact you ommitted that from the quotation ;)

For example, built-in features are usually better quality than libraries due to survivorship bias, caused by the difficulties I listed. Libraries can also undergo scrutiny, need for buy-in, etc. and I claim that if those are equally rigorous for both a language feature and a library, then the library would be preferable.

Likewise, rather than relying on the language designers to pick a consistent set of features, we could instead rely on some other external entity to pick a consistent set of features in the form of libraries. I claim that if those two groups are equally competent, recognised, etc. then the set of libraries would be preferable.

And so on.

As an aside, regarding your preference to have exceptions baked into a language: I personally think that exceptions are dangerous and confusing-inducing (compared to Maybe, continuations, etc.). If they were a library, I could ignore them; baking them into a language makes me less inclined to use that language ;)

Re:SICP Goodness – Why you don't need looping constructs by Const-me on Saturday June 30, 2018 @05:51AM (#17430198)
> built-in features are usually better quality than libraries due to survivorship bias

Yes, they’re better. No, that’s not survivorship bias, the reason is more careful selection (for third-party built-in libraries like C++ standard library) or better design (for first party libraries like .NET framework or JRE).

> and I claim that if those are equally rigorous for both a language feature and a library

I claim that’s impossible in practice, especially for powerful languages with multiple ways of doing same things. Look at C++ for an example.

> we could instead rely on some other external entity

Again, this is theory. In practice there’s no such external entities. Picking consistent features = doing design. Collective bodies, like committees or markets, are terrible at designing things.

> regarding your preference to have exceptions baked into a language

You’re probably replying to someone else’s comment?

> baking them into a language makes me less inclined to use that language

Most mainstream languages include them. You can stop programming such languages but you can’t stop using software written in them, exceptions are baked in e.g. C++ and JavaScript languages.

Re:SICP Goodness – Why you don't need looping constructs by chriswarbo on Sunday July 01, 2018 @03:11AM (#17434502)
> No, that’s not survivorship bias, the reason is more careful selection (for third-party built-in libraries like C++ standard library) or better design (for first party libraries like .NET framework or JRE).

"More careful selection" is exactly what I meant by survivorship bias, i.e. the only language features we encounter (outside one-person pet languages) are those which managed to survive this selection process. Rejected proposals aren't as visible, and we'll never know about all those ideas which were never even proposed due to their low chance of being selected.

Libraries don't have this selection pressure, so we can see many more of bad ideas, poor implementations, throw-away experiments and learning exercises.

As for better design, this is another survivorship effect: after a feature is selected (e.g. "we're going to add exceptions"), those features go through critique and consensus-building processes ("should they work like this? how should this edge-case be handled? etc.") which weed out low-quality suggestions and (hopefully) spit out generally better designs.

Libraries don't undergo as much scrutiny and collective-ownership, unless they become popular.

> I claim that’s impossible in practice

I never claimed it wasn't. Still, I'd point to projects like Boost for C++, Rails for Ruby, Numpy/Scipy/Pandas/etc. for Python, etc. as examples of third-party libraries which offer features comparable in quality, stability, etc. to that of language built-ins (but not necessarily their own language's features; e.g. C++ is way more stringent than Boost, but Boost's API may be more stable than e.g. Nim's).

> Collective bodies, like committees or markets, are terrible at designing things.

Like programming language features? ;)

> You’re probably replying to someone else’s comment?

Oops, you're right about that part; apologies!

Re:SICP Goodness – Why you don't need looping constructs by Const-me on Tuesday July 03, 2018 @11:34AM (#17451017)
> I'd point to projects like Boost for C++… as examples of third-party libraries which offer features comparable in quality, stability, etc.

On Windows I tend to avoid Boost when I can. At least when I worked on Boost-based C++ projects a few years ago, boost’s quality varied a lot between different parts of the library. Also it’s huge, affects complexity of build process, may affect compilation times, by default it links to some very large dynamic libraries i.e. complicates and inflates installer. Also they have a lot of code for compatibility with older versions of the language, they support C++0x. I usually have much newer versions, always C++14 usually 17. In short, with boost I feel like I’m paying for a lot of things I don’t need.

> Like programming language features? ;)

Some languages have core design teams, who aren’t a collective body, have clear shared vision, and are therefore able to do better design. When I’m looking at what’s happening with Rust, or Golang, or C#, I see rate of improvements faster than that of C++ or Python or JavaScript.

Re:SICP Goodness – Why you don't need looping constructs by cousin_it on Friday June 29, 2018 @09:40AM (#17424438)
> All else being equal, it's better to implement things in libraries rather than bake them into a language.

I was in the extensible languages camp for so long. Now I believe that widely used stuff should be part of the language. The reason is that people love to write libraries to scratch their own itch, but it takes a whip to make them write libraries that work together: use consistent naming, accept and return the same types, avoid overlaps in functionality, etc. It's just nobody's job. Except if you call your collection of libraries a "language" and try your best to harmonize them. That's what a language should be. Being minimal is no virtue.

My favorite example is Unicode: the best languages are those that bake it in and force everyone to use it. Or exception handling: you could give people the tools to build their own error handling mechanism, or you could build one good mechanism (with deep language integration, stacktraces etc) and force everyone to use it. When everything uses the same kind of strings and the same kind of errors, programmers can focus on what matters.

Re:SICP Goodness – Why you don't need looping constructs by kiriakasis on Saturday June 30, 2018 @12:40PM (#17431468)
You can sort of get the best of both world by having a set of "blessed" libraries that are publicized as supported by the language. This allow for users to experiment and for the maintainer to select well built solutions