I very much enjoyed this one-hour talk by Brian Kernighan:
He’s absolutely right about small languages. Doing a big one is hard to get right.
Last time I began exploring Python decorators, which are a way of having one function “wrap” another function. Because the wrapper has access to both the input parameters and the return value, it can modify these values (unbeknownst to the inner function).
This time I pick up where I left off by exploring decorators modifying return values, decorators that take parameters, and decorators in classes.
This is another note for a friend: a followup to a discussion about how some programmers really hate Object-Oriented Programming (OOP) languages.
Most of those who hate OOP hold up Imperative Programming (IP) as the One True Way to write code. The key difference is the IP is function (or verb) oriented whereas OOP is object (or noun) oriented.
I’ve never really understood that active dislike. It’s just another way to organize the same code you’d write anyway.
When it comes to what makes a computer (or any other) language a programming language, there are three characteristics usually required:
This post is just a brief note (for a friend) about the third item and why it allows three distinct options.
Here’s the last of the oddball Little Programming Languages (for now). This one is a little like LPL-2 in using a three-part syntax (which turns out to be non-ideal). Unlike LPL-3, neither of these are particularly usable languages — more along the lines of being something a language designer amused himself with on a rainy afternoon.
A key goal in LPL-1 was to minimize the use of punctuation characters. No brackets or parenthesis to create syntax blocks. (Square brackets for array indexing and parentheses for expressions, but that’s it.)
The language I showed you last time, in LPL-3, was a fairly reasonable one. This time I’m showing you a preposterous one no one would actually use. Worse, it turns out to be something of a failure due to weird holes left by the design goal of orthogonal single-syntax construction.
But that oddness helps us focus on what a programming language actually is, so it’s worth a peek. And maybe it’ll give you a laugh.
I’ll pick up with the language I began describing last time in a future post. Right now I want to pick up the thread of Little Programming Languages (LPLs) and use several examples to illustrate what underlies a programming language. (And as it turns out, these are “little” only in a certain sense.)
This first example, LPL-3, is Lisp-like and, because of that, is fairly orthogonal. Even better, it’s probably actually usable, although — like Lisp — it doesn’t have the cleanest syntax (languages like Python have really spoiled me).
One characteristic of the hard-core coder is a love of computer languages, programming languages in particular. Programmers of that ilk — of my ilk — collect new languages like merit badges. (I get a kick out of saying that I’ve programmed “from Ada to the Z-80!”)
The especially far gone of us also enjoy creating new languages (or in some cases, new dialects of XML). Lately I’ve been playing with a language design that follows a favorite theme: the single-syntax construction language.
This is a brief explanation of which is which and why.