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.

2017-04-28

Veckans ord: pelargon

Det är klart att en stylit vill vara ensam för en stunds pelargon i solskenet.

2017-04-21

Viikon sana: hummustuhnu

Huononlaatuisen falafelannoksen seuraus: hummustuhnu.

2017-03-25

Finished model 2017-I

Something a bit unusual. A Relocatable Equipment Building in 1:76 scale from Scale Model Scenery’s kit. The material is cardboard and paper. I have to say the kit was of impressively high quality and the pieces making up a quite easy build. (I still managed in a moment of distraction to confuse the roof and floor, so had to tear them off and swap before the glue had set.)

I expect it will eventually find its place in some diorama context. In particular, it is my entry in the prestigious competition between me and Kipper, both of us known for never finishing our models, in who will get the most models finished during 2017.

Model donated by Big Mike.