Hacker News new | ask | show | jobs
by hacker_9 3531 days ago
> You need to allow a user to run half a dozen functions, with a syntax.

You could do this with Javascript 'eval' too and I still wouldn't recommend it. Usually when this sort of requirement comes up the answer is actually visual programming, where the user just has to join blocks up and get's some sort of immediate real time feedback [1]. It's the only time VP is a good idea as the problem is in an extremely extremely constrained environment. Putting Lisp in it's place is really just an all round awful solution. Look at how the AutoCAD Lisp experience turned out [2].

[1] http://acegikmo.com/shaderforge/

[2] https://www.youtube.com/watch?v=LM1RMgIdgR8

1 comments

JS doesn't have first-class environments, so you can't have the same safety guarantees. Added with its weak typing... You could instruct JS to calculate anything.

Visual Programming might possibly be useful for end users, but in most areas, there are better approaches.

Serving limited environments to users is useful in at least these situations:

* nREPL * Database APIs (ala firebase) * Mathematical APIs (ala Mathematica)

Some of these I've needed in production, such as more precise calculations for statistics. (FloNum integrations into pre-existing applications).

My main point was, LISP is unconstrained, but still gives safety to the programmer.

A simple example of a first class environment:

    (eval (read (current-input-port)) 
    (let
      ((add (lambda args (apply + args))) 
        (null-environment))) 
The only function exposed is called add. There isn't a way to break that. It makes embedding Scheme into applications such as GIMP or games much easier.

(Just a side note, antimony [0] seems to be gaining popularity in its niche)

[0] https://github.com/mkeeter/antimony