Tag Archives: javascript

modular d3 app with commonJS and webpack

Modular d3 app with commonJS and webpack

Creating modular d3 app with commonJS and webpack

In my previous post, I wrote about how to break up the d3 visualization app into different modules. It turns out that there is a better way to write modular d3 app, using commonJS and webpack.

Update on 6/May/2016:(webpack 1, deprecated) For a more idiomatic approach using webpack.optimize.CommonsChunkPlugin, visit webpack’s documentation on code splitting. The approach described in this post has the limitation of not being able to produce separate output files for app and vendor libraries, which is addressed by the idiomatic approach.

Update on 23/March/2017: (webpack 2, recommended) For a more idiomatic approach using CommonsChunkPlugin, visit webpack 2’s guide on code splitting. The approach described in this post has the limitation of not being able to produce separate output files for app and vendor libraries, which is addressed by the idiomatic approach.

Update on 12/Sep/2016: This post is gaining lots of popularity since d3.js v4 is released under npm. The approach described below should still work in theory although I have not tested it. Let me know if it doesn’t.

Continue reading

Web App

Web App is Not Simple – List of web technologies

Web App – The Beginning

When I was JC2 long time ago, web app was simple. When I googled for a tutorial on how to build a web app, the approach that I came up with was:

  • Proprietary server to host the app. I used Union Server because it has documented examples.
  • HTML, CSS, jQuery UI for the front-end user interface. (It seems that nobody uses jQuery UI anymore)
  • jQuery, JavaScript for handling user interactions.

Since the proprietary server has a JavaScript client, with very easy to use APIs, the development was quite easy. I thought I had known everything that I need to know to become a web developer, but I was so wrong. Continue reading

go lang gopher

Working with Go lang

During my internship at IBM Singapore, I am using go lang to develop the back-end of the software. It is a nice new language, with a lot of features that I found really useful. Previously I have mostly used Java and JavaScript in programming, and go lang has the best of both.

First-Class Functions

I have always liked the flexibility with functions in JavaScript, the fact that you can treat functions like any other normal objects and pass them around. This advantage made me hate Java where methods are just methods.

In go lang, functions are surprising quite flexible, they can be used as values and passed around, and anonymous functions with closure are supported. All of these are still on top of statically-typed nature of the language.

Multiple Named return values

This is a great feature in my opinion. For Java and JavaScript, functions can only return one value, causing a lot of troubles when you want to do error checking or simply need to return multiple values. In go lang, the ability to return multiple values makes all of these very easy. On top of that, the return values can be named as variables in the function signature and saves the trouble of declaring them in the function’s body.

And more

Go lang also has great packaging system, allowing reusable components to be packaged and easily integrated into other projects. It has OOP-styled types like struct and interface. It also supports encoding and decoding of JSON internally.

I have not had a chance to use the multi-threading and concurrency components of the language, and I shall wait to be delighted.