Amiga, MUI and code nostalgia

The MUI toolkit for the Amiga

A session of link hopping caused me to hunt down a program I wrote for the Amiga in 1994. I didn’t really think I would be able to locate it, but once again, I underestimated the power of the Internet.

Not only did I find it but Aminet, the entire archive where I published it, is actually online!. The software is an accounting program called Banker which featured a fairly complex user interface. I was actually using a GUI toolkit called MUI (Magic User Interface) which was extremely impressive for its time. It featured complex widgets with support for a lot of listeners, on the fly reloading of resources and skins, localization, etc…

The only problem with MUI is that it was a bit ahead of its time processor-wise, so user interfaces written with it tended to be a bit sluggish. But it was totally worth it.

Back to Banker, I realized while browsing its entry on Aminet that the archive contained its source, so I suddenly became very eager to see the kind of code that I was writing sixteen years ago. The archive is a .lha, another format that was popular on the Amiga, and for which I was quickly able to find a decompressor running on Mac called DropUnLha.

I was bracing myself, expecting the worst, but… well, it’s actually not that bad. I uploaded the whole project to github.com for posterity, and here is one of the sources. Check out this cute comment ASCII art at the top of the file, neat, uh?

My only regret is that I wasn’t able to come up with any screen shot of Banker, even in this review of my program from a Dutch magazine, so I would need to run the the Amiga emulator to really see what it looked like.

How about you, dear readers: what’s the oldest piece of code you’ve been able to dig up?

The IDE, reloaded

Here is a very interesting take on the concept of Integrated Development Environment.

As opposed to traditional IDE’s, which work at the same level as the Java language itself (classes and packages), this IDE, called Code Bubbles, allows you to work at a much finer granularity: methods, fragments of code and whatever you need for the resolution of a specific task. All these tasks are linked to each other in a workspace, thus allowing you to stay focused only on what is relevant for your current task.

Of course, the concept is not new since it’s exactly what Mylyn is trying to achieve, but to be honest, every time I’ve tried to get into Mylyn (and I tried several times over the past years), I ended up giving up in frustration. This is not to say that Mylyn is a bad product, just that retrofitting such an idea on a traditional IDE, no matter how flexible, is probably impossible.

Still, I can’t shake this impression that it should be possible to mix both approaches, and considering the mindsharing that Eclipse has, being able to offer an intuitive and lightweight add-on that would enable the kind of unit of work granularity that Code Bubbles enables could be very interesting.

And this thought led me to git, but I’ll need to make a digression first.

One of the strengths of git is its branching model: branches are so cheap that you find yourself branching all the time and then switching, merging and committing very often.

Another interesting aspect of source control systems (not limited to git) is that the diffs that you are creating capture the unit of work that is relevant to you. And a git branch is actually very similar to a Code Bubbles Workspace.

So how about an Eclipse perspective that would be based on git branches?

The perspective wouldn’t just show the diffs, an information that is in itself not very interesting, but it would be a bit smarter than that and be able to infer that if you modified a couple of lines in the method init(), the that whole method should become a bubble in that perspective. Intelligent linking between bubbles could also be provided by looking at the chronological order in which the methods have been edited: git would only know that you added two lines in the method init() and that you then renamed a field in the class Foo, but the perspective would note that the two events are related since they followed each other, and it would reflect this by linking the bubbles.

Thoughts?

Gates, Jobs and the future of computing

This article describing the early days of Windows was a very interesting read, and even though I know this part of the computer history pretty well, I did learn a couple of things that I’d like to share.

The first is that after Windows 2.0 came out, Apple sued Microsoft for copying the look and feel of its MacIntosh:

In 1988, Apple decided to sue Microsoft over Windows 2.0’s “look and feel”, claiming it infringed on Apple’s visual copyrights. Having been a principal manager in charge during development of Windows 2.0, I was now caught up in the maelstrom and over the next year I got a thorough education on the US legal process as I briefed the Microsoft legal team, created exhibits for them, and was grilled by deposition by the other side. To me the allegation clearly had no merit as I had never intended to copy the Macintosh interface, was never given any directive to do that, and never directed my team to do that.

Interestingly, the suit ended up being dropped because:

Apple had previously granted a license to Microsoft to use any part the interface included in its applications for the Mac.

I’m guessing a few heads must have rolled in the Apple legal department when they realized that they filed a suit that they had already signed themselves out of.

But the more interesting part comes in the next paragraph:

However, I can recall that within my first year at Microsoft, Gates had acquired a Xerox Star, and encouraged employees to try it out because he thought it exemplified the future of where the PC would be headed and this was long before Microsoft even saw a Mac or even a Lisa from Apple. Gates believed in WYSIWYG (What You See Is What You Get–i.e. fidelity between the screen and document output) and the value of a graphical user interface as far back as I can remember. And prototypes of Windows existed long before the first appearance of the Macintosh.

Intrigued about the timing, I did some digging and I found out that Gates bought that Xerox Star in 1981:

Among the developers of the Gypsy editor, Larry Tesler left Xerox to join Apple in 1980 and Charles Simonyi left to join Microsoft in 1981 (whereupon Bill Gates spent $100,000 on a Xerox Star and laser printer)

This was just a few months after Steve Jobs himself got his epiphany about graphical user interfaces and the mouse during a visit to Xerox PARC:

In the early 1980s, Jobs was among the first to see the commercial potential of the mouse-driven graphical user interface

This story about Steve Jobs is well known but the fact that just a few months later, Bill Gates himself envisioned the same future of computing is news to me.

Lua and World of Warcraft

Ultimate Craft Queue add-on

A few people asked me what I was doing with Lua, so here it is: http://beust.com/ucq.

It’s a simple add-on called “Ultimate Craft Queue” that I wrote to help me craft glyphs. This will probably only mean something to WoW players, but in short, with some discipline, it’s possible to make a lot of money with this profession in WoW, but there are a lot of repeated operations involved in this process, so any automation you can come up with helps. This add-on is simply helping me streamline my process.

Back to Lua, I have to admit that the problems I described in my previous entry were pretty minor overall, and the hardest part of writing this add-on was the WoW Lua API itself, not the language. It is extremely powerful, if the number of add-ons in existence is any indication, but it takes quite a bit of effort to navigate through the scarce and sometimes nonexistent docs. The usage of extra libraries (such as AceGUI) is pretty much mandatory and there are quite a few holes (such as the tooltip API) that make a WoW add-on developer’s life absolutely miserable.

But once it works, it’s really rewarding…

Suffering in Lua

I have been writing a lot of Lua recently, and it hasn’t been a very pleasant experience.

The first thing that took a little while to get used to is the fact that table indices start at 1, not 0. Admittedly, it is possible to configure this, but the default is certainly confusing and I have been battling nil errors in tables that I knew couldn’t be empty.

But the worst was the following:

function f()
  print("f()")
end

f(2)

function f(n)
  print("f(n):" .. n)
end

This snippet will print "f()", indicating that when the interpreter read f(2) and couldn’t find a matching function (since it wasn’t defined yet), it decided to get rid of my parameter and call f() instead. And all this without any error or warning.

It doesn’t stop here:

function f(n)
  if n then print("f(n):" .. n)
  else print("f(nil)")
  end
end

f()

This will print… f(nil).

Here again, the interpreter couldn’t find a signature matching f() so it decided to pick f(n) and simply pass nil as parameter.

I am willing to suffer some discomfort when using a dynamically typed language, but this is really terrible and I dread the fact that it’s inevitably going to cause more bug hunting in the future….

A couple more things of interest:

  • Writing in Lua has confirmed me in my conviction that using end as a
    closing statement is really painful. Not only is it noise when I read a source but it just
    makes it impossible to match a closing end to its opening statement (you will also notice that
    there is not always such a thing: if requires a then but the declaration
    of functions doesn’t require anything). If you’re going to create a language, do me
    a favor and pick symmetric opening/closing tokens (or significant spacing, like Python).

  • Lua is doing something clever with its comment syntax, which I haven’t seen in any other
    languages: comment blocks are defined by --[[ and --]] but if you add
    a third hyphen on the opening part, then the commenting is disabled again:

      --[[
      This is commented out
      --]]
    
      ---[[
      ... but this is not
      --]]
      

    I like the practicality of this idea.

What I find disappointing is that Lua is a language that’s more recent than Python, so it’s hard to understand why it’s being so lackdaisical about signaling errors. Having said that, there is no question that Lua is alive and well and used increasingly more often as an embedded languages, especially in video games, so it’s most likely here to stay…

Oracle busy removing all traces of Sun from the Internet

Oracle is not kidding when they acquire a company, and Sun is no exception. They are actively replacing every single instance of “Sun” and Sun owned companies (such as MySQL) with “Oracle” everywhere.

Witness this post from Mark Matthews, which initially read (web archive link from 2006):

and which has now become:

Mark Matthews
Principal Software Developer – Enterprise Tools
Oracle

http://www.mysql.com/products/enterprise/monitor.html

In a few years, all traces of Sun will probably have been completely wiped off the Internet.

NoSQL explained correctly (finally)

Now here is a definition of “NoSQL” that I can agree with:

A very interesting write-up with one little oversight: you’re wrong.

I am part of a large program to write a NoSQL database for military applications. It’s not a backlash against paying Oracle (the DoD has a blanket license for Oracle installations) or a philosophical stance by the hippies in the defense arena; it’s the fact that RDBMSs are built in a different space in the CAP trades (see this article).

Google, Amazon, Facebook, and DARPA all recognized that when you scale systems large enough, you can never put enough iron in one place to get the job done (and you wouldn’t want to, to prevent a single point of failure). Once you accept that you have a distributed system, you need to give up consistency or availability, which the fundamental transactionality of traditional RDBMSs cannot abide. Based on the realization that something fundamentally different needed to be built, a lot of Very Smart People tackled the problem in a variety of different ways, making different trades along the way. Eventually, we all started getting together and trading ideas, and we realized that we needed some moniker to call all of these different databases that were not the traditional relational databases. The NoSQL name was coined more along the lines of “anything outside of the SQL part of the Venn diagram” rather than “opposed to SQL”.

The NoSQL databases are a pragmatic response to growing scale of databases and the falling prices of commodity hardware. It’s not a noble counterculture movement (although it does attract the sort that have a great deal of mental flexibility), it’s just a way to get business done cheaper.

This is a comment to this article.

The commenter is dead on. There is nothing (well, very little) wrong with SQL. It’s an old language, but it’s still the best language that we have today when we need to retrieve data stored in tables. Nothing comes even close. And as a matter of fact, NoSQL products have typically very crippled query functionalities compared to SQL.

This is not to say that NoSQL is useless, but as the commenter correctly points out, NoSQL is just an extension of the current model to meet certain specific needs.

I bet that in ten years from now, we will still have a majority of SQL based systems complemented by a small portion of NoSQL frameworks.

Battle of the fonts

I decided to revisit my choice of programming fonts recently, mostly inspired by this article.

After trying the various fonts in this article, I narrowed down my choices to Consolas and Inconsolata. Here is what they look like:

Consolas 12 Inconsolata 12
Inconsolata 13

They all look great in Eclipse. The Inconsolata font is freely available but Consolas is a bit more tricky to obtain on Mac since it’s a font created by Microsoft and usually shipped with Microsoft products.  Here are instructions how to install it on your Mac.

Any other suggestions for good programming fonts?

New blog

Those of you reading this on the web probably already noticed that I changed my blog. I upgraded from Movable Type 2 (yes, 2) to Wordpress.

My older blog is still available at the address http://beust.com/weblog2 and I made sure to update the RSS feeds and put in place all the mod_rewrite rules necessary to make this transition absolutely transparent to everyone, so hopefully, I didn’t lose anyone in the process.

More on multithreaded topological sorting

I received a few interesting comments on my previous entry regarding the new multithreaded topological sort I implemented in TestNG and there is one in particular from Rafael Naufal that I wanted to address:

The @Priority annotation couldn’t be adapted to say which free methods get scheduled first? BTW, the responsibility of knowing which nodes are free couldn’t be moved to the graph of test methods?

This is pushing my current algorithm even further in the sense that we not only want to schedule free nodes as they become available, we also want to schedule them in order of importance.

What makes a node more important than another? Its level of dependencies. The more a node is depended upon, the more beneficial it is to schedule it as soon as possible since this will end up freeing more nodes. Admittedly, you are still bounded by the size of your thread pool, but this is exactly what we want: increasing the pool size should lead to more parallelism and therefore better performance, but the current scheduling algorithm being fair (or random) means that we are not guaranteed to see this performance increase.

My first reaction was to modify my Executor but as it turns out, you can actually do this with the existing implementation. The constructor of all the Executors takes a
BlockingQueue in parameter, which is the queue that the Executor will use to process the workers. Unsurprisingly, there already is a priority queue called PriorityBlockingQueue.

All you need to do is to use that queue instead of the default one when you create your Executor and then make sure that the workers you pass it have a natural ordering. In this case, the weight of a worker is how many other workers depend on it, which is very easy to calculate.

On a related topic, I wanted to get a closer look at how the algorithm I described in my previous blog post actually works. I described the theory and I have tests that show that it seems to work as expected, but it occurred to me that I could actually “view it from the inside” with little effort.

First, I added a method called toDot which generates a Graphviz file representing the current graph. This turned out to be trivial:

/**
* @return a .dot file (GraphViz) version of this graph.
*/
public String toDot() {
  String FREE = "[style=filled color=yellow]";
  String RUNNING = "[style=filled color=green]";
  String FINISHED = "[style=filled color=grey]";
  StringBuilder result = new StringBuilder("digraph g {\n");
  Set<T> freeNodes = getFreeNodes();
  String color;
  for (T n : m_nodesReady) {
    color = freeNodes.contains(n) ? FREE : "";
    result.append("  " + getName(n) + color + "\n");
  }
  for (T n : m_nodesRunning) {
    color = freeNodes.contains(n) ? FREE : RUNNING;
    result.append("  " + getName(n) + color + "\n");
  }
  for (T n : m_nodesFinished) {
    result.append("  " + getName(n) + FINISHED+ "\n");
  }
  result.append("\n");
  for (T k : m_dependingOn.getKeys()) {
    List<T> nodes = m_dependingOn.get(k);
    for (T n : nodes) {
      String dotted = m_nodesFinished.contains(k) ? "style=dotted" : "";
      result.append("  " + getName(k) + " -> " + getName(n) + " [dir=back " + dotted + "]\n");
    }
  }
  result.append("}\n");
  return result.toString();
}

Then I modified the executor to dump the graph every time a worker terminates, and finally, I wrote a shell script to convert these dot files into images and to create an HTML file. I ran a simple test case, processed the files with the shell script and here is the final result.

A yellow node is “free”, green means that the node is “ready” (to be run in the thread pool), grey is “finished” and white nodes haven’t been processed yet. Dotted arrows represent dependencies that have been satisfied.
As you can see, the execution matches very closely what you would expect based on my description of the algorithm and I confirmed that changing the size of the thread pool creates different executions.