Archive for the ‘Newspeak’ Category

Newspeak First Public Release

Saturday, February 28th, 2009

We’re very excited to announce the first public release of Newspeak. We have been working hard on making this initial release as easy to use as possible. Newspeak is still very much a prototype, and the language is far from complete. However, we already have a fully functional IDE, debugger, and unit test GUI.

Initially, we had hoped to release Newspeak earlier this year, and I’m certainly to blame for delaying it. However, we needed a debugger which could run in native mode to really show of the power of Newspeak. Fortunately, the fundamentals of the Squeak debugger aren’t tied as closely to the Morphic tool as we initially thought. After abstracting the Squeak classes Process and Thread in a mirror api, we had a pretty powerful base and just needed to get the UI just right. I think we did pretty well:

But a screenshot isn’t really a good way to get a feel for a new programming language. Download the release and give it a spin. Be sure to read the included tutorial (newspeak-101.pdf), it has great example which walks you through building you own GUI application in the Hopscotch framework.

Newspeak Constructors

Wednesday, January 2nd, 2008

Constructors in Newspeak are unlike constructors in the Java™ programming language. We use the terminology to refer to methods generated by the compiler to initialize a newly created instance of a class.

Unlike Smalltalk, but just as in the Java programming language, Newspeak has complete syntax for class declarations. However, there is no single part of the syntax which maps directly to the constructor. Instead, the constructor is compiled from various parts of the class header.

The overall syntax is:

ClassDeclaration ::= ClassHeader InstanceSide : ClassSide
ClassHeader ::= class ClassName ConstructorMessagePattern = Superclass SuperConstructorCall ( | SlotInitializers | InitializerExpression )

Some of these syntax productions are optional, but I will ignore that for now. Here is an example of an immutable point:

class Point x: xVal y: yVal = Object new (
  |
  x = xVal.
  y = yVal.
  |
) (
  printString = ( ^x printString, ‘@’, y printString )
)

Slot initializers can be arbitrary expressions, so we can define a version initialized from polar coordinates:

class Point r: r theta: theta = Object new (
  |
  x = r * theta cos.
  y = r * theta sin.
  |
) (
  printString = ( ^x printString, ‘@’, y printString )
)

As the constructor is defined implicitly in the class declaration, a Newspeak class has exactly one constructor. However, you can define additional class-side methods which are indistinguishable from constructors (except to subclasses which must refer to the one constructor in SuperConstructorCall). So we can define a point which can be initialized from cartesian and polar coordinates:

class Point x: xVal y: yVal = Object new (
  |
  x = xVal.
  y = yVal.
  |
) (
  printString = ( ^x printString, ‘@’, y printString )
) : (
  r: r theta: theta = ( ^x: r * theta cos y: r * theta sin )
)

This was written in response to Christian’s Newspeak Constructors.

Java Programming Language is a trademark of Sun Microsystems, Inc.

Modules and Dependency Injection

Monday, December 17th, 2007
Gilad has revealed more details on our project. Read his take on dependency injection.