Let's say I want to use Scala.js to build, not an application, but a JavaScript library. The library exposes a JavaScript API that JavaScript code can call. The library's objects can be used in full from JavaScript. Can I do this with Scala.js? If so, how? Very few, if no, *-to-JavaScript cross-compilers can do this. For example, Dart might seem to be that language, but on closer inspection, it's not. Your library is…
Yes, this is possible. http://www.scala-js.org/doc/export-to-javascript.html
Scala.js no longer experimental
91–100 of 135 posts
Re: Scala.js no longer experimental
#92This sounds great. I have not really used Scala before. 3 questions: - How good do IDEs understand Scala these days? Compared to C#/Java, where IDEs instantly know a crazy lot about your code. I am looking at features like IntelliSense, marking wrong code, marking typos, marking unused code, telling me about unhandled Exceptions etc. - Is there any difference, on the IDE side, between Scala support and Scala.JS suppo…
- IDEs for Scala are pretty good, nowadays. They do all of what you mentioned (except unhandled exceptions, because that's a Java-specific thing). - There's no difference between Scala and Scala.js support. To your IDE, Scala.js is Just Scala. - There is a development cycle, absolutely, and it's pretty fast! With Workbench ( https://github.com/lihaoyi/workbench ) you don't even need to reload the page: it does so aut…
Re: Scala.js no longer experimental
#93This sounds great. I have not really used Scala before. 3 questions: - How good do IDEs understand Scala these days? Compared to C#/Java, where IDEs instantly know a crazy lot about your code. I am looking at features like IntelliSense, marking wrong code, marking typos, marking unused code, telling me about unhandled Exceptions etc. - Is there any difference, on the IDE side, between Scala support and Scala.JS suppo…
Let me contradict the other answers with my personal experience: the two IDEs for Scala I know, Scala-IDE (Eclipse based) and IntelliJ are relatively bad. - They are very slow. - They have poor refactoring support (Scala-IDE's support is still marked as experimental; all but the simplest refactoring will often randomly break code, either by not doing a full refactor, or by introducing gibberish). - Until the latest v…
- Yes, it's very slow.
- Refactoring is limited, will sometimes refuse to happen, and will sometimes randomly move 1 character into the wrong place in the file. So yes it does "break", but not in a way that's hard to fix.
- Variable inspection when debugging has always worked fine for me.
- Scala-IDE never gives a "full" spurious compilation error (one that shows up in the problems tab and with a full icon on the left) - or rather, no more than Eclipse in Java does (the kind where you have to refresh / clean the project do sometimes happen). On some constructs it will show a spurious "presentation" compiler error (red underline, simpler icon on the left), but it's easy to visually tell the two apart. I never think code is broken when it isn't.
- Autocomplete never stops working. It does sometimes get slow (several seconds)
- I have automatic compilation on save (no incremental config), manual/explicit saving. It's a workflow I'm happy with.
Re: Scala.js no longer experimental
#94Earlier quoted context omitted.
So here's my question, how come no browser has a way for a java applet to manipulate the DOM? We've got GWT compiling java to JS, we've got this compiling scala to JS.. and the JVM was originally built to run inside of a browser. Why can't we just close the circle? I guess people don't want their website visitors to see a "you must upgrade java" popup first thing?
Why can't Python? Why can't Ruby? Why can't Perl? Fundamentally, the languages able to run in the browser are only limited by what the browsers want to implement. It would be great if browsers could render QML, or could use or or whatever but that requires browsers to either depend on an external JVM or include on in the browser. Or you need to put the QML runtime in the browser or as a dependency. Or you have to put…
Re: Scala.js no longer experimental
#95Or, said another way, Scala now officially runs on both the JVM and in the browser.
Am I correct in my inference that Scala in the browser cannot import Java classes? Meaning this isn't some backdoor to a Java-to-JavaScript compiler?
Re: Scala.js no longer experimental
#96Or, said another way, Scala now officially runs on both the JVM and in the browser.
Am I correct in my inference that Scala in the browser cannot import Java classes? Meaning this isn't some backdoor to a Java-to-JavaScript compiler?
Re: Scala.js no longer experimental
#97I'm curious to know the size of a scala.js hello world program.
Re: Scala.js no longer experimental
#98I was very sceptical of Scala.js, but decided to use it in a low risk project ( http://github.com/underscoreio/doodle ) to render to the HTML canvas and I am shocked at how well it works. The community is moving very quickly as well, and many advanced Scala projects have had the necessary tweaks applied to run in Scala.js. Looking at broader trends, there is a clear movement towards static typing on the Javascript VM…
On the other hand the Scala people know how to write compilers. We're live, in production, with Scala since 2011 and it's a joy: it actually delivers what's promised. Heard the same thing from Twitter, LinkedIn and Netflix too.
So maybe it worth a try; especially if it will integrate with ReactJs / React Native. Sounds like a match made in heaven.
Re: Scala.js no longer experimental
#99Earlier quoted context omitted.
But you still can't use structurally shared data, which you need when you want to share large data-structures between threads.
The DOM is your structurally shared data. You just need to find a way to represent your data as (hidden) DOM nodes.
Re: Scala.js no longer experimental
#100I was very sceptical of Scala.js, but decided to use it in a low risk project ( http://github.com/underscoreio/doodle ) to render to the HTML canvas and I am shocked at how well it works. The community is moving very quickly as well, and many advanced Scala projects have had the necessary tweaks applied to run in Scala.js. Looking at broader trends, there is a clear movement towards static typing on the Javascript VM…
I'm skeptical of any x-to-JS compiler as usually I end up debugging 2 different codes, where the second one is machine generated. After that you try to work around on the first to make the generated one do what you want. On the other hand the Scala people know how to write compilers. We're live, in production, with Scala since 2011 and it's a joy: it actually delivers what's promised. Heard the same thing from Twitte…