What are lightweight lisp dialects that compile to readable js?
Asked Answered
E

6

12

What are lisp dialects that compile to short, readable and modifiable JS, using JS's own types?

Epstein answered 27/10, 2012 at 21:5 Comment(4)
have the Bad Idea Bears come to town? Modifying the compiled output is going to cause you serious pain when you need to maintain it. I'm sure it is possible (e.g. with ClojureScript) but don't do it if you value your sanity. You should only modify the original source, and look at the compiled output only if needed for debugging purposes.Treasonous
I never said I want to modify it, but compiling to readable JS means it has no/little overhead (ClojureScript has around 12k lines overhead) and you can hope engines are optimized for linguistic JS.Epstein
@Viclib I realise this is years late, but I wrote eslisp to address this exact problem. Having the mapping to generated JavaScript be obvious and easily editable is a major design priority. No overhead. It's just JavaScript with an S-expression syntax and a macro system. Should I add an answer?Crucifixion
@Crucifixion yes, go ahead. I could accept it.Epstein
N
9

Here's an extensive list of compilers for programming languages that compile to JavaScript, including several Lisp/Scheme dialects. Regarding the "short, readable and modifiable" part, that's a bit subjective ... you can test a couple of the compilers listed, and decide which one works best for you.

From the "Lisp, Scheme" section of the list [with minor formatting changes to the sub-section headers]:

Lisp, Scheme

Clojure-like

  • ClojureScript Clojure to JS, the official version. Supports the majority of Clojure including persistent datastructures.
  • ClojureJS Subset of Clojure to JS.
  • Chlorinejs A fork of ClojureJS with a port of clojure.core library.
  • wisp A homoiconic JavaScript dialect with Clojure syntax, S-expressions and macros. Aims to be rich subset of Clojure(Script) that seamlessly interops with both Clojure(Script) and JavaScript.
  • Scriptjure Library for generating JavaScript from Clojure forms.
  • ki Clojure-like syntax, mori's immutable data structures in a few sweet.js macros. Can be intermixed with JavaScript.

Scheme-like

  • BiwaScheme Scheme(R6RS) in JavaScript
  • Fargo Scheme in JavaScript
  • Moby Scheme A Scheme running in JS.
  • nconc Scheme interpreter in JavaScript with stack-friendly tail calls and full call/cc
  • scheme2js Scheme to JavaScript.
  • Spock A Scheme to JavaScript compiler that uses Henry Baker's Cheney-on-the-MTA compilation strategy
  • Whalesong Racket to JS compiler

Other

  • eslisp An S-expression syntax for ECMAScript/JavaScript, with Lisp-like hygienic macros that are just JS functions. Aims to be very close to JS, and highly experimental.
  • EdgeLisp A Lisp in the tradition of Common Lisp
  • Parenscript Subset of Common Lisp to JS.
  • Ralph Lisp-1 dialect that compiles to JavaScript, inspired by Dylan
  • Oppo A JavaScripter’s lisp. Inspired by JavaScript, Clojure and CoffeeScript. Compiler built using Jison.
  • LispyScript A JavaScript with Lispy syntax and Macros.
  • Outlet A simple Lisp that supports CPS and in-browser stepping debugging, and other things. In development.
  • Hot Cocoa Lisp A Lisp-like language that compiles to JavaScript.
  • Sibilant JavaScript with a lisp.
  • jisp A JS-native and axiomatic Lisp that focuses on the core ideas of code-as-data, S-expressions, and macros, introducing as few new concepts as possible.
Nonsuch answered 27/10, 2012 at 21:13 Comment(2)
It does not specify if it's compiled to readable js, though. One has to check one by one.Epstein
If it is readable it is probably well-optimized, because it's not interpreted and probably simpler for the VM.Epstein
I
5

Parenscript is pretty lightweight and readable. And you use a superior interactive environment for it with slime-proxy.

Intradermal answered 29/10, 2012 at 6:16 Comment(1)
ParenScript is a great answer.Epstein
B
4

I think one of the most advanced is ClojureScript. It a very complet implmentation of clojure that compiles to readable or minified JS.

https://github.com/clojure/clojurescript

Maybe check out this if you want to get started: http://clojurescriptone.com/

Bathypelagic answered 28/10, 2012 at 12:46 Comment(1)
It also has a huge overhead.Epstein
E
2

LispyScript, Sibilant do it nicely. Parenscript, as suggested by Vsevolod Dyomkin, too, but you need Common Lisp. Óscar López's answer provides a list of other possibilities.

Epstein answered 16/11, 2012 at 0:9 Comment(0)
O
1

The stated design goals of Wisp match OP's requirements exactly.

It is Clojure-like but has JS semantics and very little overhead. Great if ClojureScript's approach of preserving Clojure semantics even with the cost of 12k lines of overhead is a bad match for you.

Oakley answered 23/8, 2014 at 9:35 Comment(0)
F
0

This is a bit of an esoteric answer, but you can have a Haskell-like lisp compile to JS via a combination of Lisk and Fay.

I, for one, really like the idea of Lisk, but it's not very popular in the Haskell community, let alone maintained. Fay, on the other hand, is moving along quite nicely, and one of its main goals is to compile to readable JS. Both were authored by Chris Done.

Footlights answered 29/10, 2012 at 3:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.