Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web.
|
2012-08-22 My view on the understandability of language idiomsIn my entry on the periodic strangeness of idiomatic Python I noted that I found the C version of the 'repeat N times' loop much more immediately understandable than the Python version. In response, a commentator wrote:
Looking at my entry again I see that I was unclear about what I meant by immediately understandable. My impression from the comment is that the commentator expects idiomatic code to be understandable even if you don't know the language it's written in. I don't believe in this for idiomatic code any more than I believe in this for ordinary code (which I don't). When I talked about the C code being more immediately understandable, I
meant to someone who knew C in general. If you know C, you know what
a (This is in a sense what 'idiomatic code' conventionally means; it is the natural way to solve the problem for someone who is familiar with the language.) When an idiom is not obvious or immediately understandable, it's using some less common or relatively obscure feature of the language, or an odd convention that you have to know about, or doing something tricky but clever. There are perfectly good, well regarded idioms that fall into this general category, for example the Schwartzian transform. What these idioms all have in common is that you either have to know them already or you need to carefully think them through before you can understand what they do; someone who merely knows the language without knowing the idioms cannot read code with them in it and immediately understand it. In a sense, such idioms are slang or jargon. To me this is what makes them strange and worthy of note. If you know the idiom the code's perfectly natural; if you don't know the idiom (but do know the language) it's a 'huh? what?' moment. (2 comments.)
programming/IdiomUnderstandability written at 01:18:05; Add Comment
|
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |