
Shem: A Haskell-Derived Compile-to-JavaScript Lisp - rwosync
https://github.com/xixixao/Shem
======
chenglou
Man AST editors are so hard to get right. I've tried many of them, this one
(Golem) included, but it's just very hard to kill the habit of wanting to move
around/delete single text characters. Because of that, many people give up and
don't move past the initial stage.

I think what we need is "Elm error messages" ([http://elm-
lang.org/blog/compiler-errors-for-humans](http://elm-lang.org/blog/compiler-
errors-for-humans)) for AST editors. Take paredit for example. If you're
trying to delete a closing parenthesis, instead of refusing to do so and
silently fail, display a tooltip that explains why such action is disallowed,
and a list of (heck, hard-coded even, like some Elm errors) likely actions the
user's trying to take. Deleting the list? Deleting just a token? Show the
keybindings. Or even automatically pick the most likely action after a second
invalid delete attempt.

I actually believe the constraints imposed by structural editing can be very
beneficial (again, see paredit which helps your program stay syntactically
valid). But constraints are good when they're visible. You can exhaustively
check what's there. Constraints are frustrating when they're invisible and you
repeatedly accidentally stumble against them.

(Ideally you'd also provide a free-form mode where you can edit things as
plain text. But from personal experience I'd just go back to this instead of
learning the AST editing keybindings.)

~~~
lomnakkus
This makes it near-useless for me as well.

The thing I'm wondering is _why_ people are so obsessed with this kind of AST
editing. I don't find that code _text entry_ speed is the limiting factor for
any of my coding. The limiting factor is usually a) understanding the problem
well enough, and b) understanding the existing code well enough. A good IDE
with symbol/type and usage lookup usually suffices for the latter.

EDIT: If the point here is to prevent invalid ASTs, then I don't really see
how much that helps. The number of invalid programs with valid ASTs is going
to be huge, so you need good error handling _anyway_.

~~~
kpmah
It lets you do some nice things.

You can always get instant feedback (types, errors) because your code is
always a valid AST. No ambiguous braces etc.

Also things like markdown comments and inline evaluation.

My attempt: [http://sediment.io](http://sediment.io)

~~~
baghead66
Awesome.

Naive question; is "defn" really necessary?, isn't "let" and "lambda" enough
to express a program?.

~~~
kpmah
You're right, it's not necessary, it's just a preference :)

Although it does 'flatten' the bindings. Defn a, Defn b… is the same as let a
= … in let b = … in …

------
xixixao
The irony of the project you've worked on for a year hitting HN while you're
sitting on an 11 hour flight... AMA if you wish

~~~
sooheon
No questions, just want to say as a clojure/emacs fan this is right up my
alley, and you really blew me away.

Actually, I do have a question: do you have a blog or thought dump I can read?

~~~
xixixao
A hundred pages of brain dump here (the thesis for the project):

[https://www.dropbox.com/s/02adjyvrsc4pdof/report.pdf?dl=0](https://www.dropbox.com/s/02adjyvrsc4pdof/report.pdf?dl=0)

------
bkase
Don't miss the presentation linked at the bottom of the readme[1], and the
browser-based IDE, Golem linked in the middle[2].

[1]
[https://www.youtube.com/watch?v=HnZipJOan54](https://www.youtube.com/watch?v=HnZipJOan54)
[2] [http://shem.io/](http://shem.io/)

------
ScottBurson
Not to be confused with Shen [0].

[0] [http://www.shenlanguage.org/](http://www.shenlanguage.org/)

------
provemewrong
This is one of the most Hacker News titles I've seen.

~~~
yenda
My brain is still buzzing, it's a magic hacker buzzword combo ! Impressive
work though

------
techdragon
So it came to pass that Haskell begat a Lisp, who in turn begat many children
unto the clan of JavaScript.

The title translates to "biblical speak" pretty well haha

------
mikkom
So this is not javascript version of shen? Very confusing name.

[http://www.shenlanguage.org/](http://www.shenlanguage.org/)

------
jamesfisher
> The semantics are based on Haskell

Are the semantics available anywhere? I've been waiting for someone to create
a Lisp with pure/monadic IO, but I don't know whether Shem is what I imagine.

------
daxfohl
Is it lazy evaluated? Tail-call optimized?

~~~
izym
Evaluates like PureScript, so no, it's eagerly evaluated. Not quite sure about
the TCO part though.

------
reycharles
How is this 'Haskell-derived'?

~~~
kornish
From the README:

"Shem is a new compiled-to-JS, statically typed, pure-by-default functional
programming language. The semantics are based on Haskell but the language
evaluates strictly in a similar way to PureScript."

The document, unfortunately, doesn't go deeper into what about the semantics
are derived from Haskell. A better HN title might be "Shem: a Statically Typed
Compile-to-Javascript LISP".

~~~
reycharles
This claim confuses me. It's eager, not lazy. And judging from the video
presentation, where an incorrect[1] binary search results in a stack overflow,
it doesn't have proper tail calls either. This doesn't suggest to me that it
_derives_ from Haskell at all.

[1]: The lower bound wasn't updated correctly which should made it loop
indefinitely.

~~~
reycharles
Just confirmed, calling (loop) will cause a stackoverflow. You'd expect TCO
for a Lisp and proper tail calls for a Haskell-derived langauge.

    
    
        loop (fn []
          (loop))

