Scala.js vs Scala GWT for client web development?

I am planning to write a web application. However, I want to write both the client and server side in Scala. Should I choose Scala.js? or should I go for GWT. What are the cases where I have to choose one over the other? Also, are there any other Scala frameworks that can be used for client web programming aside from the two?


None of those two should be used.

  • ScalaGWT has been abandonned for more than a year.
  • Scala.js is experimental and requires your users to download a 16Mo library (it will improve, but it is unacceptable except for some game apps).
  • [edit] the library has been downsized and this statement is no longer true at this time.

    Other technologies are available, but choosing one depends of the kind of app you want to write. If you plan to develop a thin client, using a templating technology (like JSP or JSF), you could consider using Play templates, Lift, Scalatra, ...

    To help you consider your needs, here is a few thoughts:

    You'll need widgets and stuff to design your UI and those things are typically component-oriented and event-driven. In such a case FP doesn't offer much advantage over OOP.

    In a standard enterprise application, scala.js would be useful to design a clean functional library for js code. This kind of library definitely has much to offer but it won't be the core of your client-side code. Instead widgets, MVC infrastructure, and a layer for integration with the back-end will be what you'll spend most of your time working on.

    GWT has been around for a long time. I consider it a mature and proven technology. You'll have to learn a few tweaks and patterns to be able to fully exploit its potential, but in my opinion, much less than what is needed to write clean and maintainable js code.

    GWT doesn't require you to know js at all (although we all agree it's always best to know a bit about what happens in the browser). You won't go far with scala.js if you don't know what you're compiling to.

    If you already know javascript well, it's going to be easier to directly type your scala code as if it were some kind of scala-enabled js .

    It's much easier for large teams to work with GWT than with js, as you can factor you code easily, favoring code testing and reuse at the same time.

    GWT is definitely object(widget/model/view/controller)-oriented and event-driven. If you have plans to design an interface in a fully functional way (for games or very specific apps), I think it will get in the way of your design.


    GWT

  • Mature
  • It's a full-fledged toolkit
  • GWT-specific patterns and good practices are well-documented
  • Easy integration with a java/scala back-end
  • Development scales well over big teams
  • Best if you don't know js yet
  • Object-oriented, GWT goodness is there (dependency injection, MVP, Async, i18n, JSR-303 validation ...)
  • Will optimize and compile your code to a small js file

  • Scala.js

  • Quite new, work-in-progress
  • Not a toolkit, but a compiler .
  • Hence you'll need to be aware about js good practices, design patterns and libraries, since your scala code will be interacting with js (quite) directly
  • Need to write/wire a layer for integration with the back-end yourself
  • Much harder to handle a big team
  • No need to know GWT :-)
  • Functional programming, Scala goodness is there (trait, patterns, case classes, ...)
  • [edit] At the time the question was asked, required a 16 Mo library

  • Final advice

  • Do you need widgets and complex interactions betweens UI components or is it enough for you to use a templating technology ?
  • Use ScalaGWT at your own risk.
  • You could use scala.js for js library design, experimental projects, games, ... You can call the js code compiled from scala.js from your GWT app (if you get past the 16 Mo library)
  • 链接地址: http://www.djcxy.com/p/73970.html

    上一篇: 在方法定义中使用$ 1,$ 2等全局变量

    下一篇: Scala.js vs Scala GWT用于客户端Web开发?