Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala to JavaScript compilation effective?

I just read about the java 2 javascript parser and the demo with scala.

Do you have any experience with this framework?

What about performance?

Can i use existing JS code/frameworks?

I appreciate any help.

EDIT

This is a very good scala to javascript cross compiler: https://www.scala-js.org/

like image 447
Alex Avatar asked Jun 21 '11 14:06

Alex


People also ask

Can Scala be compiled to JavaScript?

Scala. js lets you write Scala code that is compiled to JavaScript code that can then be used in the browser. The approach is similar to TypeScript, ReScript, and other languages that are compiled to JavaScript.

Is Scala good for backend?

Today, Scala is our language of choice for writing backend services.

Is Scala a front end framework?

You can use Scala for frontend development, but you're no longer forced to work with Node. js for the backend because you want to maintain shared code between your server and your frontend.

Is Scala like TypeScript?

Scala. js belongs to "JavaScript Compilers" category of the tech stack, while TypeScript can be primarily classified under "Templating Languages & Extensions". Scala. js and TypeScript are both open source tools.


2 Answers

I did this more than a year ago. Performance is ok, but code size tends to be big. I would not recommend it for production, but can give away the code if usefull. There are other efforts to run Scala on the browser. Best would be to create a JavaScript backend to an existing Scala compiler.

Here are some other projects to look after:

http://greedy.github.com/scala/

https://github.com/scalagwt

https://github.com/alvaroc1/s2js

https://github.com/kripken/emscripten

http://jscala.org/

like image 181
Wolfgang Kuehn Avatar answered Oct 11 '22 22:10

Wolfgang Kuehn


I've never found these "language X to JavaScript" tools to be worth using. Debugging, quality of code generation, interfacing and using native JS libraries, etc., etc. mostly get compromised. CoffeeScript is an exception, because it is a new syntax for JavaScript, not an entirely separate and unrelated language.

If you need to use JS (or another language for that matter), embrace it and learn it.

like image 39
Dean Wampler Avatar answered Oct 11 '22 22:10

Dean Wampler