Off topic: An experimental language...

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

Off topic: An experimental language...

Göran Krampe
Hi guys!

I recently discovered Rebol (!) and just for fun I started implementing
a little experimental language that takes ideas from Rebol and mixes it
with Smalltalk and Nim.

I call the language Ni - as in "smaller than Nim" and of course with a
reference to Monty Python. Its not a very good name, it could be called
Smallbol, Nimbol, Rebnitalk or whatever :)

Why this post?

Because... I want to bounce around the language and its ideas with
Smalltalkers that possibly even know Rebol. So I simply want feedback
and thoughts - but remember, this is a very early stage :) There is no
point in saying "but, I can't even open a file..." - I know you can't,
that's just library stuff - I want ideas about the language itself.

What is it?

The idea is implementing a live language as in the Smalltalk tradition
but based on some of the core ideas in Rebol (free form Forth-ish
syntax, homoiconic, blocks and series etc) mixed with an object model
that feels more realistic for a Smalltalker. And... well, I am not sure
where it will go :). So no, its not *a Smalltalk* - but it can probably
turn into a language that feels Smalltalkish.

But why?

Well, the Nim ecosystem is very strong in most areas. Its a nice
language to code in (compared to alternatives with similar properties)
and you can very easily reuse most everything from the C/C++ eco system.

BUT... its not live. Its still in an edit-compile-run-cycle and its
statically typed. Ni explores what would happen if we could easily have
a fully live dynamically typed homoiconic language embedded in Nim able
to mix relatively easily with Nim code.

Ni could become a live Smalltalk-like language that finally plays well
in the native arena so it can:

- Do real multicore native threads
- Use C/C++ libraries easily
- Run anywhere Nim runs, which is anywhere C compiles
- ...and much more.

This means its a very *practical* language. Very soon it should be able
to do all these things, and quite easily too. There is also a very
interesting field of further evolution since Nim offers very interesting
opportunities to actually *compile* Ni code into Nim code, and not just
interpret.

Status

I am implementing Ni very simply as a plain recursive descent parser
(niparser.nim) in about 350 lines of code, that produces an AST. The AST
nodes also double as the core objects of both code and data in Ni.

Then it runs in an Interpreter (ni.nim) which is a bit of a work in
progress, its about 700 lines of code right now. The interpreter
executes the AST directly.

The language is an experimental Rebol-ish language but the intention is
to push it towards Smalltalk-isms on the higher levels. It also tries to
play nice with Nim ideas.

Currently Ni is not very useful, its more of a "spike". I haven't added
objects yet either, its thus currently a prototype of a functional
language. However objects are brewing in my head and the model for them
will most likely be a prototype based model with some kind of mechanism
for delegation to mixins/traits (objects containing methods only).

For code samples there is:

https://github.com/gokr/ni/blob/master/hello.ni
https://github.com/gokr/ni/blob/master/sample.ni
https://github.com/gokr/ni/blob/master/factorial2.ni

..and some tests:

https://github.com/gokr/ni/blob/master/nitest.nim

Is it fast? Well, before I screwed it all up by trying to make the funcs
proper closures (not fully there yet, almost) it could run factorial
recursively almost the same speed as Rebol3 which is about 5x slower
than Squeak/Cog. That's pretty nippy for a plain AST interpreter.

Now its slower though, since I am fiddling with contexts :) but speed
isn't a big concern.

regards, Göran

PS. If you wish to chat with me about Ni, I hang around on IRC as gokr,
typocally in #pharo, #squeak and #nim.

Reply | Threaded
Open this post in threaded view
|

Re: Off topic: An experimental language...

Göran Krampe
...and its obviously at:

http://github.com/gokr/ni

To build and play you would first need to install the Nim compiler. Then
you would compile the ni interpreter using:

nim c -d:release ni.nim

...and well. The shell scripts show how to run tests etc.

regards, Göran