News for hackers. Stuff that matters.
Re:Valtan: Common Lisp to JavaScript Compiler by hashkb on Friday April 03, 2020 @11:25AM (#22770163)
There are too many incomplete lisp-on-js solutions. No, CLJS doesn't count. It would be so awesome if one ever made it to actual usable maturity.

Is it too hard? Is there something that makes everyone give up? Or is lisp just too academic for most people to care?

Re:Valtan: Common Lisp to JavaScript Compiler by aidenn0 on Friday April 03, 2020 @12:50PM (#22771308)
1. Common Lisp is a fairly big specification for a lisp

2. People doing webdev in lisp have solutions that work "well enough" for them.

3. It's not obvious how to compile a lot of commonly used CL constructs into efficient javascript. Discarded multiple values, for example, are extremely efficient on bare-metal implementations, but will have measurable overhead when not inlined in any javascript implementation.

Re:Valtan: Common Lisp to JavaScript Compiler by taeric on Friday April 03, 2020 @09:35PM (#22775489)
I'm curious why the same tricks can't be used on discarded multiple values?
Re:Valtan: Common Lisp to JavaScript Compiler by phs2501 on Friday April 03, 2020 @11:47PM (#22776062)
If I recall correctly they typically involve manipulating the execution stack; that's not something you can do in JS obviously.
Re:Valtan: Common Lisp to JavaScript Compiler by taeric on Saturday April 04, 2020 @11:56AM (#22779007)
Fair. I was assuming you could do something at the evaluation layer that was somewhat equivalent. But it makes sense the bare metal ones are doing something at the machine code layer.
Re:Valtan: Common Lisp to JavaScript Compiler by Turing_Machine on Friday April 03, 2020 @11:27AM (#22770195)
If you include Scheme under the heading of Lisp, BiwaScheme is pretty darned good.

https://www.biwascheme.org/

Re:Valtan: Common Lisp to JavaScript Compiler by madmulita on Friday April 03, 2020 @03:33PM (#22773170)
I don't think I ever saw it mentioned in HN, but Hop[1] based on Bigloo[2] seems so much more than just a Scheme to Javascript. If I'm not mistaken, Hop (now hop.js) could even compete in a lot of use cases with Electron.

[1] http://hop.inria.fr/home/index.html [2] http://www-sop.inria.fr/mimosa/fp/Bigloo/

Re:Valtan: Common Lisp to JavaScript Compiler by hashkb on Friday April 03, 2020 @11:38AM (#22770309)
I do. Checking it out.
Re:Valtan: Common Lisp to JavaScript Compiler by aidenn0 on Friday April 03, 2020 @12:51PM (#22771314)
I find it somewhat arbitrary that you accept scheme but not clojure as a lisp.
Re:Valtan: Common Lisp to JavaScript Compiler by hashkb on Friday April 03, 2020 @02:53PM (#22772797)
I accept Clojure as a lisp. Didn't mean to start a holy war. I just don't personally want to deal with it and its ecosystem, which includes Java. I need your average web developer to be able to clone the repo, run yarn, and go.
Re:Valtan: Common Lisp to JavaScript Compiler by slifin on Friday April 03, 2020 @03:34PM (#22773181)
I understand your point, CLJS is a superset so it's ideal to understand the substrate that it's based on, it's more complex than just JS from that point of view but usability wise:

  lein new re-frame myapp
  lein run
or

  git clone https://github.com/jacekschae/shadow-reagent.git && cd shadow-reagent
  yarn install
  yarn dev
It is very much fire and go in a way that a typical JavaScript developer might grok
Re:Valtan: Common Lisp to JavaScript Compiler by aidenn0 on Sunday April 05, 2020 @03:57PM (#22788131)
Ah, I don't use CLJS, and I had thought it was self-hosting.
Re:Valtan: Common Lisp to JavaScript Compiler by rini17 on Friday April 03, 2020 @01:57PM (#22772199)
It could be done using WebAssembly. But AFAIK all existing Common Lisp implementations want to manipulate the stack in ways that WASM disallows.
Re:Valtan: Common Lisp to JavaScript Compiler by pjmlp on Friday April 03, 2020 @04:20PM (#22773565)
There is schism if you are into Schemes, but it does rely on experimental support for tail calls and reference types.

https://github.com/google/schism

https://www.youtube.com/watch?v=V7IxiMjKWZM

Re:Valtan: Common Lisp to JavaScript Compiler by register on Friday April 03, 2020 @04:04PM (#22773434)
Can you be more specific about the peculiar way in which CL manipulates the stack? Where to find more details about CL internals?
Re:Valtan: Common Lisp to JavaScript Compiler by rwallace on Friday April 03, 2020 @06:34PM (#22774586)
In CL, if you catch an exception, you have the option of trying to fix the problem and then letting the code continue from where it left off. This is only moderately difficult to implement in machine code, but somewhere between problematic and impossible on a high level platform that has already implemented exceptions by stack unwinding.
Re:Valtan: Common Lisp to JavaScript Compiler by tachyonbeam on Friday April 03, 2020 @04:43PM (#22773770)
You mean call/cc type of manipulations?
Re:Valtan: Common Lisp to JavaScript Compiler by slifin on Friday April 03, 2020 @11:30AM (#22770223)
Why doesn't CLJS count?
Re:Valtan: Common Lisp to JavaScript Compiler by PuercoPop on Friday April 03, 2020 @06:23PM (#22774515)
For the record, CLJS does count. And the tooling although painful is on par with the one found in JS (webpack). Maybe even a little less painful.

But one problem that ClojureScript avoids by virtue of being a 'hosted language' and not having a spec is having to implement its own numeric tower. Numbers can just be floats and move on.

CL mandates integers. Not just fixnums, like WebASM provides, but bignums. As well as rationals. That is a lot of code your run-time will have to provide.

iirc Whalesong (the Racket to JS implementation) bundled a numeric tower that implemented integers using strings).

Re:Valtan: Common Lisp to JavaScript Compiler by hashkb on Friday April 03, 2020 @11:37AM (#22770303)
Because I don't want Clojure. It's too opinionated. Also CLJS has (had? been a minute) painfully slow tooling.
Re:Valtan: Common Lisp to JavaScript Compiler by frompdx on Friday April 03, 2020 @02:26PM (#22772513)
> painfully slow tooling

On the topic of tooling, I found the tooling to be slow as well. However, a lot of my pain points were alleviated when I really embraced using the REPL for developing. Tools like figwheel make developing fairly painless although startup times are still slow.

Whenever I go back to using Common Lisp I'm always surprised how fast the startup time is by comparison.

Re:Valtan: Common Lisp to JavaScript Compiler by chrisjc on Friday April 03, 2020 @12:49PM (#22771290)
I think his question is why is CLJS an incomplete lisp-on-js solution?

Not why you don't like or use it.

Re:Valtan: Common Lisp to JavaScript Compiler by iLemming on Friday April 03, 2020 @01:58PM (#22772207)
I completely disagree with that assessment. Disclaimer: I've been doing front-end for a long time. I've tried all sorts of ways to transpile/compile/deal with Javascript. I've tried Coffeescript, Typescript, Babel, Traceur, Fay, Haste, GHCJS, looked into Elm, Purescript and Reason, KotlinJS and ScalaJS. Clojurescript is one of the most stable and better choices for writing production-ready web-apps.

Clojure, currently is the most widely used Lisp dialect in the industry. Lots of people trying it and find it massively productive. Just because some lispers "don't like it", doesn't make it less valuable technological choice.

Re:Valtan: Common Lisp to JavaScript Compiler by virtualwhys on Friday April 03, 2020 @09:01PM (#22775348)
> Clojurescript is one of the most stable and better choices for writing production-ready web-apps.

Why? TypeScript, for example, is used pretty much everywhere these days; all the other languages are completely niche. I dislike the language (mutability everywhere, no standard lib), but it's dominating the frontend world ATM.

I've been using Scala.js in production apps for around 3 years now. Curious in your experience what advantages Clojurescript has over Scala.js. I ask because you often hear things like "best in class" when Clojure devs talk about the frontend development experience.

Re:Valtan: Common Lisp to JavaScript Compiler by iLemming on Friday April 03, 2020 @09:42PM (#22775516)
The REPL. Just like with any Lisp, true REPL makes a huge difference in the workflow. Anyone who never had honest and heartfelt experience with any Lisp or Smalltalk, would never understand how nice it is to be able to evaluate any expression and sub-expression without any kind of ceremony. Aficionados of non-homoiconic languages keep saying stuff like:

- "oh, we can probably do this and that and get the same experience...", or

- "give [their favorite language] five to ten years, it'll get the same..."

It's been over six decades. Non-homoiconic languages still don't have "true" REPLs.

Re:Valtan: Common Lisp to JavaScript Compiler by armitron on Friday April 03, 2020 @03:17PM (#22773028)
"Clojure, currently is the most widely used Lisp dialect in the industry."

Citation needed.

I would bet money that this isn't true. There are a lot of places using proper Lisps that stay out of the public eye.

Re:Valtan: Common Lisp to JavaScript Compiler by iLemming on Friday April 03, 2020 @04:57PM (#22773882)
Facts do not cease to exist because they are ignored.

- Every PL ranking from RedMonk to TIOBE index indicates that what I'm saying is true;

- Clojure today has more conferences, books, podcasts, jobs and meetups. More than any of other language in its category of languages with strong FP emphasis. It is more popular than Haskell, Elm, Purescript, F#, Elixir, OCaml. Latest JVM survey indicates that it surpassed Scala and has become third most popular JVM language after Java and Kotlin;

- Clojurescript is the most popular alt-js choice (if you don't count Typescript as alt-js). Elm and ReasonML are far less popular;

- If you count by lines of code on Github and Gitlab, Clojure potentially may come second after Emacs Lisp (which is almost four times older than Clojure). Other Lisps wouldn't even be near their numbers.

- And please stop calling it an "improper Lisp." None of the authoritative Lisp scholars have ever indicated this even remotely to be true, in fact many have endorsed Clojure. Clojure can be viewed as a next evolutionary step in development of Lisp. Whether you like it or not, it is slowly spreading wide and beyond JVM (the platform it was initially intended to run on)

Re:Valtan: Common Lisp to JavaScript Compiler by yogthos on Friday April 03, 2020 @04:47PM (#22773799)
It's quite rare to see postings for CL jobs, yet plenty of companies are actively using and hiring for Clojure. It's certainly a far more popular choice for green field development nowadays. Sounds like you're the one who needs to provide citations here and not the other way around.
Re:Valtan: Common Lisp to JavaScript Compiler by ken on Friday April 03, 2020 @03:38PM (#22773209)
If you mean Common Lisp, that’s a Lisp-2 (actually Lisp-N), while JS is a -1. That means there’s no universal obviously “correct” way to do JS interop. It’s complicated...

Closure is a Lisp-1, as is Scheme, and (despite it being at least as “academic” as CL) there are lots of Scheme-in-JS implementations.

Re:Valtan: Common Lisp to JavaScript Compiler by kazinator on Friday April 03, 2020 @04:24PM (#22773600)
There is somehow a pretty obvious way to do C interop from Common Lisp, even though C has one namespace for functions and variables.
Re:Valtan: Common Lisp to JavaScript Compiler by Scarbutt on Friday April 03, 2020 @12:51PM (#22771311)
Maybe this is the one.

IMO, Babeljs could be leveraged to create one much faster.

Re:Valtan: Common Lisp to JavaScript Compiler by hashkb on Friday April 03, 2020 @02:54PM (#22772817)
My thoughts are along these lines, too. If it's not incrementally adoptable in webpack/etc projects, it won't see significant adoption.
Re:Valtan: Common Lisp to JavaScript Compiler by zelly on Friday April 03, 2020 @05:37PM (#22774169)
The latter. Lisp is too academic for anyone to care to do it. Compilers need to be dogfooded, i.e., the people who work on it also write non-compiler programs with the compiler. TypeScript and Emscripten are mature because they are used to create real web applications. No one uses Lisp to write regular applications, much less web applications. Web applications in Lisp are unlikely to be its hidden niche after all these years, so very few people bother altogether.
Re:Valtan: Common Lisp to JavaScript Compiler by wglb on Wednesday April 08, 2020 @10:57PM (#22819381)
> No one uses Lisp to write regular applications, much less web applications.

These are both false. This site is just one example. Here is another: https://wigflip.com/signbot/. And another: https://wigflip.com/roflbot/. (Base domain is https://wigflip.com/).

Grammarly is Lisp.