In association with heise online

17 September 2012, 15:42

Dropbox replaces JavaScript with CoffeeScript

  • Twitter
  • Facebook
  • submit to slashdot
  • StumbleUpon
  • submit to reddit

Dropbox Coffeescript

The Dropbox cloud storage service has completely rewritten its browser-side codebase to migrate from JavaScript to CoffeeScript. In a post on the Dropbox Tech Blog, the developers say that they were able to reduce the lines of code needed by more than 20 per cent.

According to the team, the new CoffeeScript code is over 5,000 lines and 200,000 characters shorter than the original JavaScript code used by the cloud service provider. However, users are unlikely to notice the change because CoffeeScript must be recompiled into JavaScript to enable a web browser to execute the application. This is done by the js2coffee JavaScript to CoffeeScript compiler.

The Dropbox developers say that among the main advantages of the switch, which was completed within a week, are less typing work, better clarity ("being able to fit more code into a single editor screen"), a more legible syntax and the avoidance of errors. For example, they explain that the CoffeeScript compiler automatically begins JavaScript variable definitions with var to avoid the accidental generation of global variables.

At the end of their posting they state that their experiences when rewriting the web interface's existing 23,000 lines of code in CoffeeScript were so convincing that "Dropbox now writes all new browser-side code in CoffeeScript." However, the developers don't say much about their experiences with troubleshooting their application in the browser; this is done in the JavaScript code, and finding the corresponding CoffeeScript code will likely require extra effort. If the JavaScript source maps that are available in Chrome are enabled, they simplify this task.

CoffeeScript uses a syntax that allows elements such as functions and loops to be formulated in a very compact way. It also offers constructs for iterating via JavaScript objects. Similar to Python, it uses spaces to separate statements, but it is less strict than Python.

(crve)

Print Version | Send by email | Permalink: http://h-online.com/-1709470
 


  • July's Community Calendar





The H Open

The H Security

The H Developer

The H Internet Toolkit