That's not really what readability is to me. For example, I consider this idiomatic golang code (from the standard library, no less) to be entirely unreadable:
https://golang.org/src/crypto/tls/handshake_messages.go#L297
For me readability is more about suitable levels of abstraction. Languages can affect that by making abstraction longwinded, or expensive at runtime, or hard to compose.
Really? It's a binary parser that's parsing data from a byte array and stuffing the results into a struct, it seems pretty straightforward.
If you've used Brainfuck for more than 5 minutes, you already know the entire language. Is it the most readable language ever designed?
> I can usually just go to the source code if I'm trying to figure out how to use a library I just pulled in from clojars.
Will a cursory read of the source code either tell you how the library deals with corner cases, or convince you that such corner cases don't exist?
version = ((data[0] & 0x0F) << 8 | data[1]);
But why? Is this still correct with the current specification of the message format? Who knows! And this is a best case, where "version" is a meaningful variable name.Oh, come on... BF was specifically/pathologically designed to be unreadable.
> Will a cursory read of the source code either tell you how the library deals with corner cases, or convince you that such corner cases don't exist?
Um... no, not really (at least not a cursory glance), but readability certainly helps track down issues later when you do run into an unforeseen corner case. Language choice is all about trade-offs -- if things like this are what is most important to you, perhaps you would be happier with something like Haskell or Ada.
I was just exposing a flaw in your “readability” criterion. Another example: you can learn the rules that govern a given cellular automaton in 5 minutes, yet be completely unable to predict what said automaton will do when run.
> readability certainly helps track down issues later when you do run into an unforeseen corner case.
I'd rather not have issues, and always be sure that I've handled everything. Only applied formal logic can help.
> Language choice is all about trade-offs
Normally, understandability trumps all else. The only exception is when it's too badly in conflict with performance.
> if things like this are what is most important to you, perhaps you would be happier with something like Haskell or Ada.
Nah. GHC Haskell and Ada are both ginormous languages that I don't believe anyone could fit into their heads in their entirety. In particular, with GHC Haskell, I don't feel confident saying “this code does exactly what I want and nothing else”, because someone might enable an extension I haven't accounted for, and then hilarity ensues.
(And nobody uses the language specified in the Haskell Report.)
One thing I found while messing around with Haskell is that while learning and writing vanilla Haskell is one thing, deciphering Haskell written by others is quite another, given the propensity of library authors to use language extensions and stuff like TemplateHaskell.
If you have any examples of code that, when an extension is enabled, neither fails to compile nor fails to behave in the same way it would be really interested to see them!
If I were to try to conjure some up the first place I would start would be interactions between scoped type variables and typeclasses.
Enter Golang... a language smaller than even ANSI C. It's readable because if you've worked with Golang for more than a week, you basically know every language construct you'll encounter.
As an aside, I've found Clojure to be one of the most "readable" languages I've ever seen, in that I can usually just go to the source code if I'm trying to figure out how to use a library I just pulled in from clojars.