John Lindal’s Blog
Erlang Message Passing
August 21, 2009 on 12:25 pm | In Deep Thoughts, Programming | No CommentsI’ve only just started learning Erlang, so I certainly don’t know all the tricks, but when I found a blog post claiming that message passing between actors made deadlock less likely, it got me thinking. A classic deadlock occurs when A and B both want to aquire locks X and Y, and A gets X while B gets Y. In Erlang, it seems that the equivalent can happen if A is waiting for a message from B while B is simultaneously waiting for a message from A. Message passing is neat, but concurrency is still just plain hard
On the subject of message passing, I’ve noticed several libraries for implementing message passing in Java, but they all seem overly complex. A simple base class which manages a message queue for each actor should be sufficient. The only public API is the function to send a message and functions for telling actors about one another. All derived class functions should be private, protected, or at worst package-public.
Of course, you also need some discipline. The messages must be send-and-forget. Once a message has been sent, the sender should discard all references to it and everything inside it. Otherwise, you are back to standard shared objects which require locking.
This produces a system where all state is stored in messages. State can only be modified by the single actor which has a reference to it. I doubt if everything can be implemented this way, but it is a good exercise to try!
I’ve posted the code on github
The Muppet Christmas Carol
August 10, 2009 on 12:47 pm | In Movies | No CommentsMy wife borrowed The Muppet Christmas Carol from the local library this weekend. I was a bit leery of it, since it was released after Jim Henson’s death, but it turned out to be very good — if you like a good story mixed with a healthy dose of Muppet MadnessTM. What can you expect when Gonzo narrates and Rizzo tags along for the ride?
There were a few minor adjustments, like adding a second Marley, but it all made sense, given how the roles were doled out to the muppets. Lest you think it was all muppeteering, Michael Caine did a wonderful job playing Scrooge.
JSLint
August 4, 2009 on 9:36 am | In Programming | No CommentsOn the advice of my esteemed colleague, Eric G., I tried JSLint recently, just for kicks.
I’ve never been a big fan of lint programs, since in any sane language, if it compiles, then the syntax is valid, and the important bugs require execution, not static code analysis.
While JSLint did find a couple of minor issues, I had to wade through a sea of “unnecessary semicolon” messages to find those issues. WTF? This is JavaScript, the language that finally managed to make programmers paranoid about semicolon placement. In any other language, if you miss a semicolon, the compiler will complain, but JavaScript is practically a random semicolon generator. If you miss one, anything could happen: it might work, it might crash, or it might launch a nuclear strike against Albania.
So I didn’t get my feelings hurt. Instead, I concluded that JSLint isn’t any more useful than any other lint program, despite JavaScript being insane.
Programming Languages
August 4, 2009 on 8:06 am | In Computers, Programming | No CommentsHex is like starting with Carbon, Hydrogen, Oxygen and Nitrogen to evolve sheep to get wool to make clothing.
Assembly is like starting with some basic, biological molecules, but you still don’t have RNA or DNA. You still have to evolve sheep to get wool to make clothing.
C is like raising sheep to get wool to make clothing.
Java is like using a loom to weave cloth to make clothing.
Your favorite framework is like using a pattern to make clothing.
But most people just go to Kmart, or Gap, or Macy’s and buy clothing because they don’t care about how it’s made. Even starting from a pattern requires knowing how to use a sewing machine.
So now you know why most people click the e
to get to Google and then type AOL
to read their mail!
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^