21st Century Smalltalk

February 21, 2007

Lisp Primitives

Filed under: Lisp — pfisk @ 3:59 pm

In the example Lisp code that I have posted, functions are defined in terms of either other defined functions or “built-in” functions which are written in the underlying implementation language – ActionScript for Flash and C# for WPF.

Built-in functions are quite easy to implement. For example, in the recent “Accordion” demo, there is a function “prim-accordion-new” which generates an instance of the Flash “Accordion” container. Here is how it is defined in ActionScript:

private static function z_initializeBuiltinPrimAccordionNew_z():void {
  z_makeGlobalBuiltin_z("prim-accordion-new",
  function(args:VOop, context:Context, process:Process):VOop {
  return z_asVOop_z(new Accordion());
  });
}

For each "primitive" Lisp function, there is a corresponding ActionScript function - the technique is similar for the .Net platform, with "function" being replaced by "delegate" and, of course, the appropriate syntax adjustments.

There is no fixed rule as to what constitutes a “primitive” function. Basically, primitives run faster than interpreted code but have less flexibility at runtime. It is a matter of judgement.

In March, there will be an SDK for the Flash implementation to allow developers to add custom primitives to the language.

More Observations on Flash versus WPF

Filed under: Adobe, Xaml — pfisk @ 3:29 pm

Ryan Stewart had an interesting post this morning comparing about WPF:

This blog post got me thinking about how Windows Presentation Foundation really is the next level, and while it’s not cross platform, it provides the ability to create experiences that simply cannot exist in the browser. Apollo applications are enhanced browser apps, but WPF applications are an entirely different way to think about user interface and design. Because of that, WPF is in a position to turn heads and bring people around to realizing how much life is left in the desktop and why the browser is so limiting.

He is saying that there is a difference in the experience of desktop applications compared to web applications, although there is overlap between the two. Browser applications are, almost by definition, cross-platform and so can’t take advantage of all of the features of any single OS. Conversely, desktop applications are usually tied to a single OS and can leverage all of its capabilities.

The question of whether to develop in Flash or WPF depends upon the application. If you are developing for the widest deployment, then Flash is the better platform at this point. However, if your users mainly have Windows or Macintosh and you want the best graphics (or text rendering, 3D, etc) then WPF or WPF/e is currently the best choice.

What I am trying to build into Vista Smalltalk is commonality between the two approaches – the same code running in both WPF and Flash. That way, you are ready for future changes in either the technology or the requirements of your users.

Blog at WordPress.com.