Sunday, April 29, 2007

Stongtalk

Strongtalk seems very interesting. It is a version of smalltalk that uses runtime type feedback for optimization and also has static typing.

A great interview is online here:

http://www.cincomsmalltalk.com/audio/2007/industry_misinterpretations-01-14-07.mp3

The conclusion is that static typing doesn't improve the performance very much. A problem with smalltalk systems is that they causes you

Interface based type systems are not good for performance, implementation based type systems are good for performance but not good for programming. The Self compiler would compile all code and this would take a lot of space, 64M on bootup which was a lot for the early 90's. A significant improvement in Strongtalk was that it only compiles code that is used a lot.

Smalltalk like languages have a much higher call frequency than Java. This is because the language provide mechanisms for constructing your own control structures. Type feedback keeps statistics at every call site and then does a jump and compare rather than dereferenced call which stalls the pipeline. In fact one doesn't even have to jump, one can just compare and go straight into the inlined code.

Stack allocation is much more efficient than heap allocation. Strongtalk manages to to do stack allocation by doing escape analysis. It can determine that a stack frame does not need to be allocated on the heap.

With inlining it becomes possible to do range check removal on the inlined code.

Megamorphic means that a callsite calls several different methods. If there is a small number of methods then each one can be inlined. However it turns out that very few calls have much impact on program performance. Most of the gain is in optimizing monomorphic sites.

Another optimization technique is "customization": methods are copied down into child classes then self calls to the method become monomorphic. Double dispatch is another technique: call a method and pass self, then the method calls you back. These dispatches can be removed using by inlining, because one inlining leads to another.

So far there are no smalltalks vm's which are multithreaded. One idea is to go multiprocess vs multithreaded. This probably works well in conjunction with green threads.

In a discussion about .NET, the criticism is that CLR doesn't permit inlining because it supports legacy languages such as C and C++. The CLR seems to have changed to using inline caching, which is a technique related to inlining. A VM which is highly tuned to Java or C# doesn't work well for languages like smalltalk; no tagged types, and different method of dispatching.

Saturday, November 18, 2006

Neverwinter Nights 2



The much anticipated sequal to Neverwinter Night 1. After 5 years of development and high expectations this game fails to live up to expectations. The game is fun to play, but feels very retro. In the time since Baldurs Gate was released the world of fantasy roll playing games has moved on. Games such as Dungeons and Dragons online provide an emmursive action filled world, Neverwinter Night 2 by comparison has the same mechanics as Baldurs Gate series with a party consisting of several characters all controlled by a single player. Action is very stillted; having four players to control means constantly pausing the game, stupid AI means that if you turn your back for just a second, your casters start fireballing the party with on hard core rules really hurts.

In keeping with its closeness to Baldurs Gate series Neverwinter nights 2 has an involved story with plenty of cut scenes. If one is prepare to overlook some bad acting in places and some rather cliqued plot line (you foil your nemesis at every turn until he has no more henchies left, then you take him down), it can be kind of fun. The cut scenes are certainly much better than trying to read some inscurably small dialog text.

The game works in a multiplayer mode tollerably well. With two players, each having control over their own character plus all the henchmen one can play the game without pausing. The social aspect makes the game more fun. It doesn't work playing with random people because they can for instance loot your NPC and then disconnect leaving you trying to hold off hoards of undead with nothing but a naked dwarf.

NWN 1 was famous for the community hosted servers. Some of these were really a lot fun. So far here is very little online action to be had with only a small assortment of power levelers and endless hack and slash fests to be had. This may well change.