lainchan / λ

Langs that compile to JS

Faye Valentine · 2022-08-08 14:27
On my job i have to work quite a bit with javascript. Js let's you do some functional shanenigans but sometimes it get's in the way, Also the lack of a real type system leads to a lot of time debugging. I used to like typescript till i tried ReScript (https://rescript-lang.org/try) a bit. It's type system is far better than typescript BS and the lang itself is clear enough with a neat pack of features. It compiles to JS so i don't get in trouble. So far is a bit rough in the edges but i quite like it. Do someone has a better option or have a similar experience? Let's share
Dujour · 2022-08-08 14:49
There are things like CoffeeScript, ParenScript and ClojureScript (ClojureScript and TypeScript are the most popular). But I don't like JabbaShit at all. imo, JS is a ghetto language that's inconsistent and allows code that shouldn't be valid. Also, I don't want to run some random code in my web browser just to view a page. I would use Scheme or Ocaml/Standard ML for functional programming (but I understand that using these languages at work can be "challenging").
Chani · 2022-08-08 14:55
>>32230 indeed. At this point stuff that compiles to JS is my coping mechanism
Cat Mother · 2022-08-08 15:40
>>32230 >Also, I don't want to run some random code in my web browser just to view a page. It can't be helped, even your online banking site most likely requires JS.
Hououin Kyouma · 2022-08-08 21:18
>>32227 ReasonML is ocaml that compiles to JS. There is Elm too. I never looked into how readable the generated JS is.
Unnamed · 2022-08-08 22:41
just do yourself a favor and use Javascript. trying to look into alternatives to suit your needs will eventually put you up against a feature the alt-language that requires you to do some """low"""-level tinkering (jumping through hoops) to interact with the JS runtime and trigger the feature you wanted, and because the data structures are incompatible it probably won't be pretty.
Delilah · 2022-08-08 22:45
>>32236 *a lacking feature in the alt-language
Knuth · 2022-08-09 06:35
>>32233 Yes, but bank's website requires it for no reason. JS should be optional for most sites.
Mentat · 2022-08-09 08:18
>>32227 I like ClojureScript, but I'm also a Lisp fan and an FP junkie, and most people are neither. >>32240 I disagree. Javascript should only be present when it's mandatory for the site to function (or at least function well). It's purpose is to manually add functionality that HTML and CSS lack. Otherwise, it should just be pure HTML and CSS, since they're simpler and scale better.
Tyrell Wellick · 2022-08-09 22:36
>>32235 ReasonML is now native only and also more or less dead. The web people, without public discussion or even a serious explanation, took off and made a new language called ReScript. Then they acted surprised and hurt when people got mad that they lit a bomb and threw it into the Reason community. It's a shame all around. No matter how good Rescript is, I won't touch it until it's got enough momentum to survive its creators being dipshits.
Cereal Killer · 2022-08-10 06:16
You can compile nim into js
t · 2022-08-10 15:55
>>32255 > ReasonML is now native only and also more or less dead. What? What is even the point of that? Just use ocaml. Do you have a source or anywhere I can read abou the drama? I used the reasonML docs and discourse a few weeks ago and it looked normal. If it really is true I guess I will just use elm.
Nell · 2022-08-10 20:04
>>32227 >On my job i have to work quite a bit with javascript. [*] may your brain Rest In Peace [*]
Unsigned · 2022-08-15 09:07
>>32244 Javascript is bad, but thinking pure HTML and CSS could replace most of the stuff we have is absolutely delusional. The web was made from the start to read text and images, as soon as we started to make basically applications out of it we should had rewritten how html and css works, now its basically a point of no return and js is sadly essential.
Agent Smith · 2022-08-15 12:20
I'm surprised nobody has mentioned Haxe. It has a real type system because the compiler is written in OCaml. The abstractions it uses are zero cost and the Javascript it generates is human readable. It has seamless integration with Javascript. The neatest part? You can compile the Haxe code you wrote in C, Java, or hell even PHP! You have the advantage of only writing the code once for both the front and back end without ever touching NodeJS. >>>/lambda/30385
Nameless · 2022-08-20 12:36
>>32244 You're undoubtly right, they should've figured out something else as a protocol and dev env. to develop applications in a browser since the start, instead of hacking together dynamically generated HTML and CSS until it somehow worked. Both things could've easily coexisted.
Masami Eiri · 2022-12-29 21:05
>>32244 >Otherwise, it should just be pure HTML and CSS, since they're simpler and scale better if only the industry didn't trend away from multi-page applications, but with the growing popularity of SPAs this is impossible. at least with my work, i try to write all of the logic on the web server, i write as little typescript as i need to, page runs more quickly, & the typescript only deals with UX stuff (form validation, dynamic forms, etc etc)
Unidentified · 2022-12-30 06:57
>>32227 First time I'm hearing of ReScript, but it definitely looks OCaml-inspired. If you like it, you'll probably like OCaml, which can be compiled both to JavaScript and to native binaries. There's a bit of a standard library clusterfuck going on right now, but if you just use the Jane Street libraries you're going to be fine.