Best of both worlds? Udash – A Scala framework that can compile Scala to JavaScript

© Shutterstock / By chombosan

Udash is a Scala framework that promises to make web developing as professional and safe as possible. Here, we have a look at some advantages and disadvantages of Udash.

Udash is a type-safe, open source framework that uses a shared Scala code and interfaces between front end and back end. The framework also offers the ability to compile Scala to JavaScript as well as use it with JavaScript libraries like Twitter Bootstrap or jQuery.

“A framework for building beautiful and maintainable Web Applications”

According to the official website , Udash offers type-safe layer over HTML, CSS and JS with powerful data binding into DOM templates, thanks to the cooperation with Scalatags and ScalaCSS libraries. The list of advantages and useful features goes as follows:

  • Reactive Data Bindings – Automatically synchronise user interface with your data model.
  • Type-safe RPC & REST – A client↔server communication based on typed interfaces. Bidirectional RPC via WebSockets out of the box.
  • User Interface Components – Twitter Bootstrap components enriched by Udash features.
  • CSS – Type-safe CSS definition in your Scala code with minimal JavaScript size footprint and server-side rendering.
  • i18n – Translations served by the backend or compiled into JavaScript.
  • Generator – Generate a customized application, compile and try it out in 5 minutes.
  • Open Source – The whole framework code is available on GitHub under Apache v2 license.
  • Backend independent – Udash provides a complete support for your web application and the communication with the server but does not influence your backend implementation.
  • IDE support – With any IDE supporting the Scala language. No extra plugin needed.

SEE ALSO: Clojure and Scala are less bug-prone, Python induces more defects, study shows

According to a Hacker News entry , Udash is the perfect choice for developing rich single page apps and big complex websites where you have to “share models and validations between front and back end”.

Let’s have a look at the classic Hello World example.

import io.udash._
import io.udash.css.CssView._
import io.udash.bootstrap._
import io.udash.bootstrap.alert._
import io.udash.bootstrap.button._
import io.udash.bootstrap.form._
import io.udash.bootstrap.modal._
import io.udash.bootstrap.utils._

import org.scalajs.dom

val name = Property("Udash")

    h1("Welcome to Udash!"),
      UdashForm.textInput()("Type your name: ")(name),
      UdashAlert.success("Hello, ", b(bind(name)), "!").render

Verbose and inefficient?

Nonetheless, there are some drawbacks in using Udash for your project. To begin with, there has been much criticism that Scala is not an efficient language for web developing in the first place. However, it is not the scope of this article to criticize Scala.

SEE ALSO: How well do you know your Scala trivia?

Concerning Udash in particular, a lot of feedback was given under the same Hacker News entry . According to the comments, apparent flaws of Udash are the following:

  • Runtime errors – it is difficult to avoid them, at least to the extent that Elm does (by design).
  • Complexity – designers should be proficient in Scala at least to the extent that they can fix compile errors in the page code, otherwise, it would be simply impossible to share a template.
  • Too much code? – some comments suggested that “It looks really verbose only to render simple html”.

Udash is still a new framework in the Scala ecosystem. There is still much room for review and improvement. The fact that it is an open source framework makes it a promising asset since users’ contributions and remarks can offer valuable insight for further and faster development and improvement.


JAXenter Magazine责编内容来自:JAXenter Magazine (源链) | 更多关于

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » Best of both worlds? Udash – A Scala framework that can compile Scala to JavaScript

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录