Skip to end of metadata
Go to start of metadata

JavaScript

JS has gained a lot in the last 3 years, owing to these developments:

ResearchSpace currently uses the following popular libraries

  • jQuery (used by Exhibit)
  • Dojo (used by RForms)

AngularJS

If we decide (or you force us ) to use JS as the basis of RS, here's a library that could become our foundational framework.
(This below is compiled from a discussion between me and Krum Georgiev)

AngularJS is a web app framework by Google that seems very well put together.
Clean model/view separation (separation of concerns through a variation of MVC); very clean markup (declarative templates with data-binding); dependency injection, keep model & view automatically in sync; define application "routes" (URL mappings) and support deep (bookmarkable) links; attach to specific pieces of your page (doesn't want to own the page); define your own tags in html ("directives") and create components easily (providing a HTML compiler for creating your own DSL in HTML: "what HTML would have been, had it been designed for building web-apps.")

That doesn't mean we won't use other JS libraries like jQuery, Dojo, Prototype, Underscore, Backplane, etc. AngularJS doesn't try to be the only framwork, and plays well with other frameworks.
It's an MVC (MVP, MVVM, etc.) framework, that could be of real help when dealing with numerous spaghetti callbacks (jQuery or similar). The greatest benefit is that the app can more maintainable, and able to add arbitrary features much more easily. Krum: javascript MV* frameworks are a must for every mid to large JS based project.

AngularJS maybe allows you to create a web app completely within the browser, and relegate the role of the backend to manipulating and serving data, but not creating UI.
All submits in AJAX, and no normal submits needed anymore

Links

Examples

Downsides: quite steep learning curve; novel and untried. Although the tutorial is very clear on how you use it, the backend workings of it sound like black magic: some of the "wiring" is accomplished through naming convention, as in Rails.

GWT

Google Web Toolkit (GWT) is used by Google to build many of their apps, eg GMail. Programs using GWT are written in Java, which is translated to JavaScript for execution on the browser.

Discussion on the angular.js forum "When is GWT appropriate, when is AngularJS appropriate?"https://groups.google.com/forum/#!topic/angular/9P4RD3IbQwk
The most significant post is by Adam Bender:

GWT Pros

  • Mature, well tested, highly engineered solution for producing pure client side applications.
  • Lot of examples/documentation/support available
  • Highly efficient/performant, both in terms of app delivery size and runtime performance (they now even benefit from the closure compiler)
  • Written using staticly-typed, well tooled language. In my case this is important as our app is safety critical (people can die if it screws up) so the idea that we have the compiler checking for a class of errors means one less set of tests I have to write.
  • Great Development environment that makes you productive even though you have a compile step in your build
  • The ability to use Google Guava library. Don't underestimate the power of having robust utility libraries to do things like argument assertions, collection traversal, exotic data structures etc. There really is nothing better than Guava when it comes to this kind of stuff. Of course because Guava is used by the GWT dev team it means that you dont have to worry about it surviving the JRE emulation - it will just work!
  • The single greatest thing about GWT for me was the programming model of Activities and Places - more commonly known as Model, View, Presenter (MVP). This programming model is a perfect fit for web application in particular where you may want to reuse logic to power different shaped views (read phone, tablet, laptop etc.). GWT really embraced this pattern to great effect

GWT Cons

  • It's still Java. No matter how you slice it, and how ironic it is, Java just isn't web-ui friendly. Java is not a good choice for anything programming problem that involves a lot of click handlers, or one-off listeners. Anonymous Inner Classes are just not the right way to do it!
  • Even with the speed ups you have to avoid compiling as much as possible. On my laptop (late-model quad core mac book pro) compile times range into the 2 - 3 minutes time frame. It is twice as slow on a dual core machine. That really is a long time to wait between making changes and seeing a result. Even though the GWT team have done a great job making compilation less necessary during day-to-day development it's still manages to suck time out of my dev cycle. Also, like taxes and my waist - compile times only seem to grow with time.
  • Adapting 3rd party libraries is possible, but not fun and you end up writing this weird mix of "javascript-in-java multi-line comments" which never seems to format correctly in IDEs and is completely opaque to syntax highlighting apparently.
  • GWT applications cant support dynamic module loading easily. Think of a portal like iGoogle where you want to include many modules, perhaps only determining which ones at run time. GWT will fight you every step of the way because GWT, due to the extreme optimization it does, likes everything in the world to be known at compile time. This means that you can't link code up in the browser which means you lose out on what I think is one of the greatest features of the web.
  • Related to that last point, GWT is not very modular in and of itself. While there is the ability to do code splitting to improve load times, you still end up sucking down a lot of GWT library stuff for even the simplest hello world app. Now this may or may not matter to you, but if you have mobile dev in mind, every byte counts!

Angular Pros

  • Angular is "of the web" It embraces core web technologies and make it easy to write your app using standards.
  • JavaScript is a great language for UIs. I find that the Functional/OO duality of JavaScript makes it a great target UI development.
  • Angular - owing if I recall correctly to it's Flex influence - has a fantastic programming model with binding, DI, promises, and Dumb views. Some might call it a MVVM approach, but it still seems like MVP to me and so just like I loved it with GWT I also love it with Angular.
  • The use of the MVP model also help mitigate the traditional problem with JavaScript apps. Namely that they become impossible to manage at a certain size. By keeping things contained in small controller/service/directive buckets you have a clean way to manage your applications growth.
  • Integration with 3rd party libraries is a snap thanks to the public exposure of $apply and $digest. You can actually improve other libraries by extending binding capability directly to them using core Angular methods.
  • Angular is nice a modular framework and works to build small apps all the way up to multi 10s of thousands lines apps - don't know about anything bigger than that cause I havent worked with it but I think it should work.
  • Angular has a healthy and vibrant community where any question you have can be answered pretty quickly.
  • Testability, testability, testability! If you are going to write code in a dynamically typed language then you have to have a fantastic tests story and Angular has created one. Both due to it's use of core test-enabling patterns like DI but also through the development of the Scenario Tester that lets me write Selenium style end-to-end tests using JavaScript as my language of choice.

Angular Cons

  • JavaScript is a notoriously difficult language to manage large teams and projects in. Its great strength as a flexible, almost assembly code of the web, is also the source of many problems when people do simple things like rename a variable or use constructs like

    As I mentioned before I think Angular can help a lot with the marco organization problem and even some of the micro code issues, however it is still JavaScript and it is possible to make a serious mess. Note that tooling is getting better especially in Intellij/WebStorm so perhaps these kinds of issues wont be a problem for long.

  • Angular is new in a crowded space. Although I believe it is the first framework to truly get what is required to build "Application in the Browser". It remains to be seen whether enough mind share can be established to create a growing and sustainable community - one that shines in the face of a fickle JavaScript development community.
  • Part of being a young project means the docs and examples out there aren't quite polished down which can be quite annoying. However, this problem is getting better by the day and as far as I am concerned Angular has exceptional docs given it's limited exposure to public consumption.
  • Angular has been knocked for its dirty-checking for binding approach. While I cant comment on the alternatives to much I think for the most part this is a non-issue for most apps but you'd have to evaluate your applications binding needs. This is something that we should keep in mind - dirty-checking can cause major performance problems if there is more information. For example 2000 pieces of information to a human on a single page. Anything more than that is really bad UI, and humans can't process this anyway.
    For more information check this link: http://stackoverflow.com/questions/9682092/databinding-in-angularjs

Bottom Line

If you have only Java developers - use GWT. If you would prefer to have a compiler help catch some, but by no means all human errors - use GWT. If you need to rely on extensive examples or documentation, for now GWT is better but that will change. If it is going to be a very large, long lived application - something static typing an the Java tooling ecosystem may help with then GWT is your option.

However, if you want to build apps from small to large and you are comfortable with JavaScript as a programming language - not just a way to make animated transitions - then Angular is the first framework to give you the power to build a proper application. One where you stop thinking about the incidental complexity and can therefore focus on the essential complexity. With Angular you can be as big or small as you want, as dynamic as you want and really use the web to its fullest potential. Don't forget that the JavaScript tooling ecosystem is getting better every day- I can even put my JS app in Sonar now, build it with maven, run JSHint in my IDE and more. So the days of JavaScript being considered a toy language which no real project can be done in are long gone. Using Angular you can really put the lie to that line of argument.

Personally, having discovered Angular I don't think I would ever recommend GWT as a place to start for a web app. While GWT represents a truly amazing engineering success, I think it is an idea whose time has come and gone. I look forward to a future building AngularJS apps and solving problems for customers in a way that not only makes them happy, but keeps me from wanting to know my finger tips off!

Bootstrap

Backbone

DART

Google is working on a new web language: http://www.dartlang.org.
It is a competition to JS that allows safer and more scalable programming. It has native implementations (Chrome, maybe Mozilla, node.js) but also a translator (dart2js) to JS to allow deployment on more devices.
The native implementation already outperforms V8 by 20-30% (see slide 39).
But it doesn't yet have enough libraries.

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.