JavaFX SVG Implementation Idea

36 views
Skip to first unread message

Vance Turnewitsch

unread,
Mar 27, 2019, 9:32:47 PM3/27/19
to Scala.js
Hi all,
Thank-you for taking the time to give this email a read. Also, thank-you all for providing an avenue to develop browser-based applications in a typed language! I've been learning Scala the last few months and one of the driving factors of my choosing it was knowing I could output JS (maybe someday I'll be employed doing so!) since it seems JS is eating the user application domain alive.

I am exploring the idea of building a library that allows using JavaFX in the growing home of user applications, desktop and mobile web browsers, and am looking for input on the idea. There are JPro and Glon, but it is a hard argument to win: let's use this paid for solution for our demo/app while there are the "free" and "cool" solutions from the JS ecosystem.

The end goal would be a library one could import many of the JavaFX classes yet when rendering is done we get DOM nodes in a browser environment. It seems like a monumental task to me, but my personal frustration with trying to learn and apply the churn of JS technology is sufficiently motivating to consider the idea.

My initial thought is to explore the JavaFX rendering pipeline and determine if there is a way to hack it so that Nodes/Containers/Controls produce SVG instead of whatever they produce now. Aside from trying to re-implement the JavaFX libs in Scala, do any of you know how complex of a process I am considering here is? Do you have any pointers or thoughts on the idea?

Sincerely,
Vance

Justin du coeur

unread,
Mar 28, 2019, 8:58:10 AM3/28/19
to Vance Turnewitsch, Scala.js
(Note that this mailing list is mostly dead at this point -- most Scala.js discussion nowadays takes place on Gitter.)

On Wed, Mar 27, 2019 at 9:32 PM Vance Turnewitsch <vance....@gmail.com> wrote:
The end goal would be a library one could import many of the JavaFX classes yet when rendering is done we get DOM nodes in a browser environment. It seems like a monumental task to me, but my personal frustration with trying to learn and apply the churn of JS technology is sufficiently motivating to consider the idea.

My initial thought is to explore the JavaFX rendering pipeline and determine if there is a way to hack it so that Nodes/Containers/Controls produce SVG instead of whatever they produce now. Aside from trying to re-implement the JavaFX libs in Scala, do any of you know how complex of a process I am considering here is? Do you have any pointers or thoughts on the idea?

I don't particularly know JavaFX, but this is setting off alarm bells for me.

Keep in mind that, while the Scala *language* is the same on the JVM and browser, the *environment* is totally different, and unrelated.  As a rule of thumb, JVM libraries simply don't exist in the browser environment unless somebody has specifically ported them.  (Which is true of a good chunk of the Java standard runtime, but not that much else.)  You can *write* a Scala.js program against a JVM library, but it will usually fail at link time, because the library doesn't actually exist in the JS world.

So I suspect that you're talking about a ground-up rewrite of JavaFX in Scala, so that it can be cross-compiled to JS.  Not impossible, certainly, but it's probably a lot bigger than just hacking one aspect of it...

Sébastien Doeraene

unread,
Mar 28, 2019, 9:18:21 AM3/28/19
to Justin du coeur, Vance Turnewitsch, Scala.js
Hi,

I believe your biggest blocker will be that JavaFX probably relies on synchronous callbacks and/or multiple threads, and that simply does not exist in a JS runtime. So even if you did go all the way to reimplement JavaFX in Scala.js, you would hit that hard barrier, and there's nothing you'll be able to do about it.

Cheers,
Sébastien

--
You received this message because you are subscribed to the Google Groups "Scala.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-js+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-js/CAO26FW33e3bDMQPq9koQZ6T5dF6GcpqeKLZJXGpR3Ja0ZbSWxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Florian Kirmaier

unread,
May 9, 2019, 4:48:27 AM5/9/19
to Scala.js
Some small corrections about JPro and Gluon (disclaimer: I'm from JPro):
 * JPro for web requires only a license in production, it can be used for a demo without a license and without any registration. It can be used for free for demos, open source, educational projects etc.
 * Gluon for mobile is opensource and can be used for free. You only have the option to pay for their libraries, which is recommended but optional.

What you are trying to do, sounds similar to what JPro is allready doing.
Fun fact: JPro uses scala.js to render the JavaFX scene graph in the browser.

Florian Kirmaier
Reply all
Reply to author
Forward
0 new messages