Application Design: Scala + HTML5

I would like to implement an application with Scala and HTML5. My idea was to create a "local" client-server architecture: Scala processes the calculations and generates HTML5 as a graphical interface.

In my opinion, there are two possibilities

  • Use the Java / Scala framework, which allows embedded HTML5. For example, SWT has a browser widget. JavaFX also seems good.
  • Distribute the program on the server and run it in a browser on local hosting.

Perhaps it would be most convenient to require an Internet connection and forget about the local host. Unfortunately, offline mode is required.

Now I would like to know how to do this correctly:

  • The first option seems easier to implement, but I wonder: how can I communicate with Javascript without the HTTP protocol?
  • The second approach was just an idea. Have you ever done something like this?

If you have tips or you know a good framework, please continue.

UPDATE:

I got an interesting idea: can I use nodejs to create something like server-server architecture?

Right now, the relationship between Scala and Coffescript seems to be the most problematic part. I'm still wondering how I can initiate an update from the Scala application. An HTTP request is a good way to exchange data. Unfortunately, as far as I know, in the β€œstandard” Coffeescript there would be no event hook for listening to HTTP messages on the server side.

I was thinking about using nodejs to listen for data sent by the server. Is that a good idea?

+4
source share
1 answer

As for the second option, you can explore Play! Framework or Lift . They automate the great work required to build a web application in Scala, including handling AJAX requests.

Although I have not tried packaging for local use, there used to be a Stack Exchange question about Lift packaging, which may make a difference. It should be possible with Play! also.

+1
source

Source: https://habr.com/ru/post/1394260/


All Articles