days
1
2
hours
0
7
minutes
2
8
seconds
4
1
Pros and cons of Udash

Best of both worlds? Udash combines forces of Scala & JavaScript

Eirini-Eleni Papadopoulou
scala
© Shutterstock / By chombosan  

Udash is a Scala framework that promises to make web developing as 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")

UdashJumbotron(
  div(BootstrapStyles.container)(
    UdashBootstrap.loadBootstrapStyles(),
    h1("Welcome to Udash!"),
    UdashForm(
      UdashForm.textInput()("Type your name: ")(name),
      UdashAlert.success("Hello, ", b(bind(name)), "!").render
    ).render
  )
).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 a new framework so there is still a lot of 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.

asap

Author
Eirini-Eleni Papadopoulou

Eirini-Eleni Papadopoulou

All Posts by Eirini-Eleni Papadopoulou

Eirini-Eleni Papadopoulou is an assistant editor for JAXenter.com

Comments
comments powered by Disqus