2017-05-25
Finished model 2017-III
Finished model 2017-II
In honour of the centenary of Finnish independence I decided on a colour scheme inspired by the Finnish national hockey team, even though they usually don’t carry heavy blasters and rocket packs. (Really, your knife will be sufficient for most eventualities.)
2017-05-08
Lua
I got to thinking about the design of programming languages. It may be a recency effect, but it seems to me there’s been a plethora of programming languages designed and supported by a single person in the last decade or so. Usually their existence is very clearly due to some pet peeve of the designer, which is reflected in the grammar and feature set of the language. Some, like Ruby, have syntactical features which, while I find them annoying, presumably save the designer some typing in their typical idioms.
I presume that older languages have gone through processes of standardisation that have worn off the most idiosyncratic bits, if they weren’t designed by a committee to begin with. (Which does not mean that there aren’t disgusting bits in those languages too.)
The latest of these vanity languages I’ve run in to is Lua, which, on the whole, is not too bad. I still haven’t decided if I like the concept of metatables, but I have to admit it allows some nifty and powerful tricks.
So, how does it do the usual Hailstone program?
function hailstone(n) while (n > 1) do n = (n % 2 == 0) and n // 2 or n * 3 + 1 print(n) end end
I was a bit disappointed that assignment isn’t an expression and thus couldn’t be fed into the print()
. Of note is also that Lua does not adhere to the C syntax patterns used by Java, JavaScript, awk, or even Perl, in particular the conditional assignment is done through short-circuiting logical expressions instead.