Spry update: Spry goes visual!

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Spry update: Spry goes visual!

Göran Krampe
Hi folks!

Just wanted to give a quick update on where I am (<hint>only me
still</hint>) on the Spry project. I am taking the liberty to post on
squeak-dev since I hope Squeakers find it interesting, especially the
small movie below :) I also have some ideas on Squeak<->Spry interop, if
anyone is interested - catch me on chat.

I am right now trying to nail down a few language level things, and
finish the manual. The manual is up on the site and is fairly complete
now (although needs a few rounds of polish):

http://www.sprylang.org/manual/index.html

...along with other things, like an article about "Smalltalk vs Spry"
which I have only just started:

http://www.sprylang.org/spry-vs-smalltalk/index.html

But... the most interesting part to tell about is probably the fact that
Spry is taking its first steps with a user interface! Unless you count
the command line REPL Spry has had for a long time. Or the "spry REPL in
a browser page" that you can also find on the website (that is actually
the real Spry VM compiled to js).

A short 2 min movie I made is here:

http://krampe.se/spry-ide.mp4

I hope you found that movie intriguing!

Because it shows a truly *live* experience, just like traditional
Smalltalks offer. The code we type in is parsed and evaluated live and
the IDE itself *is written in Spry* (not Nim). This makes it just as
malleable as a Smalltalk environment.

To make this I have selected the excellent C library called libui:

https://github.com/andlabs/libui

There is already a wrapper in Nim (auto generated) for libui which made
it easy for me to create a Spry VM module with primitives using it, the
primitives and node types so far are here:

https://github.com/gokr/spry/blob/master/src/modules/spryui.nim

The OO mechanism including polymorphism in Spry is still being worked on
- so naming for some of those things are needlessly messy (to make each
unique), but apart from that it's very straight forward.

NOTE: There is also a Nim wxWidgets wrapper, a gtk2 wrapper and a gtk3
wrapper. But... I wanted native on all 3 desktops and libui looks MUCH
easier and lightweight than wx.

With that VM module included, we can finally look at the code for the
IDE shown in the movie:

https://github.com/gokr/spry/blob/master/src/ide.sy

That's 57 lines of Spry code! ...and a big part is constructing the menu
which the movie doesn't even show.

Also note how I attach Spry code blocks as handlers for the click
events, menu items etc, for example:

https://github.com/gokr/spry/blob/master/src/ide.sy#L43

So what we have are Spry code blocks (they are closures) that gets run
as callbacks called from the C library. Those of you with a bit of
history knows this has been a truly sore part of Squeak through the years.

And yes, this means we run in libui's event loop which we enter at the end:

https://github.com/gokr/spry/blob/master/src/ide.sy#L91

And finally... this runs *natively* in Windows, OSX and Linux (Gtk3).
The movie was recorded on my Ubuntu so its gtk3 that you see. I have
tried it on OSX too, looks great!

regards, Göran

PS. I am on #squeak and #sprylang on freenode, but also on gitter which
I kinda prefer: http://gitter.im/gokr/spry