I’m quite overdue for a status update, so here we go.

I spent most of July with a busted ankle. Crutches are fun, I tells ya. That helps sum up the whole lotta nothin’ I did this month. It’s a really bad sprain I got late June, and it took many weeks and many doctors, and it’s still not fully healed yet, but at least I’m not on the crutches anymore.

Oh, you want to know more about Smile, right. Y’all come here to find out what I’ve been coding, not for personal stuff. So let’s talk about Smile.

The language grammar is now fully implemented in the interpreter, and a number of bugs in the methods on the core objects have been fixed. It has a REPL now, which makes experimenting and testing much easier.

I discovered somewhat to my chagrin that .NET does not handle stack sizes in a nice way. This shouldn’t surprise me that much, since Windows as a whole doesn’t handle the stack in a nice way, but it’s especially annoying in an interpreter. The current Smile implementation uses a recursive Eval() routine that would not be wholly unrecognizable to a Lisper, albeit with some alterations to support Smile’s notion of colored cons cells.

(Lisp only has cons cells, you see, whereas Smile’s cons cells come in two colors: Black cells, which make the lists that Lispers are used to, and red cells, which are structured just like the black cells, with the usual ‘a’ and ‘d’ pointers, but which are processed differently by Eval(). The coloring allows for sophisticated object-orientation to be implemented without really changing the way that Lisp “thinks,” and are how the language is able to also be a Smalltalk derivative. As this change — adding a color to the cons cells — is a fairly straightforward derivative of Lisp — and I’m sure somebody will eventually implement a Smile interpreter in Lisp to show it — I still consider Smile a Lisp, even if it supports forms a traditional Lisp cannot.)

Anyway, the problem with using a recursive Eval() is that you dig deeper every expression, so a relatively small recursive Smile function can blow out the .NET stack, and I discovered to my chagrin that a StackOverflowException cannot be caught, handled, or treated in any sane way.

Boo on you, Microsoft.

Seriously, how are you supposed to build a safe interpreter in .NET for a programming language if somebody can write a program in your language that can crash the interpreter just by recursing deeply enough? In Smile, you can crash the current interpreter with a handful of keystrokes: [f=||[f]]

(For those who don’t grok Smile well enough to read that, let me provide a version of that in a more traditional language, like JavaScript: function f() { f(); }; f();)

It works for now, as long as you don’t recurse too deeply, but this is something I’m going to have to fix before a public release. I’ve been thinking for a while now about writing an alternate interpreter that takes the cons cells for a function and unpacks them into a stack-based bytecode VM-like form. I’d been thinking about that mainly for the speed, since a bytecode-based Eval() would likely run an order of magnitude faster than the current Eval(), but now I might have to create that just to get it to run without being able to crash. ‘Tis a bummer, but it is what it is.

I’m also writing unit tests for a lot of the methods now to prove their correctness. List is about 80% covered, and Enumerable is about 20% covered. This is a good thing, believe me. A lot more coverage is needed so that you guys can trust it does what it says it does.

I also still need to fix a lot of the string-handling. The Unicode thing is still an issue, and I’m planning now on doing the strings as UTF-8, having read a lot of the arguments both for and against it. That’s still a lot of code I have to write yet.

So the big question is when is the public release? The answer is “when enough of the core objects are implemented and unit tested and documented.” I only just built Array, and we don’t have anything like hash-based Maps or BinaryTrees yet, and until the core data structures are ready, the language isn’t ready. But we have more people using it now, privately: Folks at my office are putting it through its paces and uncovering bugs, so at least when it does go public, it’ll be usable. I’d like to think the first public release is this year, maybe a Christmas present to y’all, but if it goes into next year, so be it.

Anyway, that’s the status. Got a crying baby I have to pay attention to now, so I’m out.

Comments Off on Continuation

Filed under Smile

Comments are closed.