

How Kal Compiles Itself - rzimmerman
http://blog.rzimmerman.me/how-kal-compiles-itself/

======
jashkenas
As CoffeeScript also went through this same process, bootstrapping itself away
from an original Ruby-based compiler (at this moment:
[https://github.com/jashkenas/coffee-
script/commit/6446e0004c...](https://github.com/jashkenas/coffee-
script/commit/6446e0004c6e53cf909b300ebb12a934ccb33eb6)), Kal is now in some
sense "two self-hosted steps" away from a "normal" language. That's pretty
neat.

GorillaScript (here:
[https://github.com/ckknight/gorillascript/tree/master/src](https://github.com/ckknight/gorillascript/tree/master/src)),
Coco (here:
[https://github.com/gkz/LiveScript/tree/master/src](https://github.com/gkz/LiveScript/tree/master/src))
et al, are also implemented in themselves. I hope that this trend of compile-
to-JS languages tending to self-host continues.

------
anaphor
Why isn't anyone doing languages that compile to a trampolined form of JS? It
would kill two birds with one stone: you get to write recursive code without
wasting memory, and you can easily implement a lightweight thread scheduler.
It seems like people are just picking the low hanging fruit, i.e. "JS syntax
is ugly, let's implement a desugarer". I haven't seen many people try to
change the semantics of JS much. maybe Whalesong or something, but nobody is
using that.

~~~
kevingadd
One reason is that performance would be miserable. Most current JS runtimes
aren't very good at optimizing that kind of code, and it actually uses quite a
bit of extra memory.

------
lmartel
This is definitely one of the coolest "Show HN"-style projects I've seen in a
while. Great work!

------
_random_
A word of warning: the name 'Kal' will be funny to russian-speaking devs. In
case you care.

~~~
teebrz
Sure, it would be a poor name for a new soda you plan to market in Russian-
speaking countries; but probably not really worth mentioning here. I'm sure
you realize, but lots of Russian words/phrases sound funny (or obscene) in
English too - this is true of every language and vice versa. Naming things is
hard enough already without trying to cover what it might sound like in every
major language.

~~~
solomatov
Kal means feces in Russian.

>Naming things is hard enough already without trying to cover what it might
sound like in every major language.

IMO, when you give a name to internationally used thing, this should be taken
care of. I.e. name shouldn't sound funny obscene in any of the major
languages.

~~~
teebrz
I think most Russian-speaking programmers are intelligent enough to understand
it's a foreign name, especially since it's written as "kal" and not "кал".

> I.e. name shouldn't sound funny obscene in any of the major languages.

My point is that this is probably more difficult than you realize.

It's also pointless; if you're the maker of a consumer product (like a soda)
and you expect to market it in Russian-speaking countries, then of course you
need to watch out for such things. Something like this which is only
incidentally used by a small portion of technically literate Russian speakers
- it's not really worth bothering with.

------
vorg
I'm wondering what Kal's license is? I'm especially wondering if source
written in the language itself qualifies as _open source_ under the terms of
any/some/most/all of the Free and Open Source licenses, or if the source of
_every_ version ever used to compile another version must be made available?

~~~
fleitz
All self-hosted GPL compilers have this 'problem'...

The output of the compiler under the GPL can be licensed however you like.

------
teleological
"wait for" and "for parallel" seem useful. Are they inspired by constructs in
other languages, or do they have analogs in other languages?

~~~
octo_t
Fortress and Scala have similar concepts

    
    
      (0 to 10).par.foreach(expensiveOp)

~~~
qu4z-2
C# has

    
    
      range.AsParallel().Select(expensiveOp);
    

Which is hilariously verbose, and map is called select. But it's nice to
have...

------
callesgg
So in essense it dosen't, not more than any other language atleast.

It originaly compiles from coffescript.

It's a point of view thing.

~~~
norswap
It does. Coffeescript is not involved at any point in the current compilation
process.

It did not originally however.

------
aa0
While it may be cool that Kal compiles itself, unless there is a source tree
for the Kal binaries themselves, there is a indubitably huge issue of trust
with distributing binaries.

Relevant: [http://cm.bell-labs.com/who/ken/trust.html](http://cm.bell-
labs.com/who/ken/trust.html)

~~~
spicyj
The article links to that very page:

> anarbi posted a great [link] about how compilers can contain a memory of
> things that are no longer in the code.

