Category Archives: Programming

Why I Chose Javascript Part 2

In part 1 I discussed why I found HTML/CSS so easy to work with. In this article I’ll look at javascript.

Code verbosity

If there was any one thing that stands out as the dividing line between javascript and my previous experience with java it is all the extra typing.


Compared to

I remember that it took months before I was able to start writing a program without having to check back for a refresher on how to start a program in Java. Javascript was just much simpler to get something up and running.


Similarly import statements were completely mystifying.

Sure the more general import helped, but only if you knew how that worked. Combine that with the fact that that both of the below are necessary because awt.event is a completely separate package from awt. All of this is a sure way to make a beginner give up.

Initializing Objects

I think this is pretty self-explanatory.

Extra typing comes at a cost

You might point out that its just a little extra typing. But part of the problem is the added complexity, especially for someone starting out. Understanding why you need public static void main is a problem and if you are taking a course they just tell you to accept it and move on. The same is true of objects not only did it feel incredibly redundant to type out <String> twice. I had no clue what most of the syntax was doing which made it even harder to remember it accurately.

I’m not saying that javascript doesn’t at times feel awkward or redundant, but as a whole it was easier to type the code. Which also meant that when there was an error it was less likely to be in some part of boilerplate that I mistyped because I didn’t know what it was in the first place.


This is more of a general point on the difference between compiled versus scripting languages. In javascript except for 6 distinct primitives everything is an object. Java for instance has 10 types of numbers. Which is great if you are writing something that depends on the performance and memory difference between using a byte and int, but many applications don’t need the that level of optimization.

I don’t want to repeat the hundreds of articles out there arguing for or against static types. But I know personally var was easier to code with because again less complexity made it easier for me to focus on the problem I was trying to solve.

Some final thoughts

Ironically I didn’t really understand objects and OOP until after I started using prototypal inheritance in javascript. One day when working with javascript object it just clicked how OOP was supposed to work. In Java I tended to get so bogged down in syntax that it I never quite got a good grasp of what the whole point was.

Another pain point was when trying to work with regex and strings. Java’s implementation is  more complicated. I wrote a program centering around string manipulation in both javascript and java. Java’s was limited and error prone whereas the one written in javascript was easier to develop and much more stable.

One key thing is the accessibility of developing in the browser. I found it so easy to get up and running. Related to that is the amount of information on the web. Not everything on the web is of the same quality, but there were tutorials, code examples, and articles in abundance. Which is great because almost any problem you run into someone has written something about it.

Finally I’m not saying that Java has no place. What I am saying is especially for someone new to programming javascript presents a lot fewer barriers to entry. Add to this the fact that the power behind languages like Java and C++ is overkill for many programs being written today. Personally despite its quirks I have come to enjoy programming in javascript. I’m not sure I ever was going to be able to say that about Java.

Why I Chose Javascript Part 1

As discussed in my about page I really started programming in Java, but I later switched to javascript. There were two primary reasons for this. This article is about the first.

User interfaces

Ironically this is not about the relative strengths/weaknesses of java versus javascript, but on the ease of design with HTML and CSS. I’m pretty sure everyone who learned to program and enjoyed it wanted to create something that people could use. I was no different, but while I could construct a program my interface options were command line, manipulating files with predefined names or clunky painful to code (probably to use as well) GUIs created in NetBeans.

Now some of this was just a lack of knowledge and skill on my part, but as a beginner to programming the goal of creating an application usable by nontechnical people seemed hopelessly out of  reach. Until I started using HTML/CSS. I was almost immediately hooked. For all the browser quirks and DOM idiosyncrasies I found it so easy to take an idea and start seeing results immediately. This was combined with benefit of not needing a special program to help me build a UI. I could open Notepad and a browser and create something that didn’t need build steps or dependencies.


Another problem I quickly ran into was trying to distribute .jar files. It is one thing for something to work on your computer, but getting it to work on another computer was a whole problem in and of itself, not to mention issuing updates. Different OSs, Java versions or no Java at all was a headache. Some of this I will cover in part 2, but the big thing is the browser was universal and easy to target on multiple platforms. There is the giant caveat that was IE6, but even then for the most part the basics of HTML and CSS worked on all platforms.

I remember having a conversation with a friend about this, and one of the things I said was I wished that they had methods to build a UI that were as simple as HTML/CSS. I’m sure that there were/are simpler methods, but while I was too new to recognize or understand the concept of separation of concerns I appreciated the simplicity of it.

Fast forward a number of years and now I am no longer a novice at programming. During that time I found that CSS did have some pain points and HTML does have some limitations, but I still feel that HTML/CSS is great for beginners and still flexible enough for advanced uses such as SPA. Of course many advanced UIs use some kind of virtual DOM, while this does blur the line between code and content. Many implementations of virtual DOM have syntax that looks similar to HTML.

In part 2 I’ll look at why javascript made sense to me.