Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

There is a lot of buzz around Dart recently, often questioning Google motivation

ID: 641887 • Letter: T

Question

There is a lot of buzz around Dart recently, often questioning Google motivations and utility of Dart as replacement for JavaScript. I was searching for rationale of creating Dart rather than investing more effort in ECMAScript. In well known leaked mail its author is saying that

Javascript has historical baggage that cannot be solved without a clean break.

But there is only one concrete example given (apart of performance concerns) of "fundamental language problems", which is an

existence of a single Number primitive

So, my questions are:

How an existence of a single Number primitive can be a "fundamental problem"?

Are there other known "fundamental problems" in JavaScript?

Explanation / Answer

1) All Javascript numbers are specified to behave as per the IEE-754 double precision floating point specification. This means that

You can't opt to use normal integers (for conciseness or speed). Your best bet here is having your compiler optimize this behind the scenes (but at the cost of perhaps having to add runtime checks and other annoying things)

There are no bignums built-in. If a Javascript Number "overflows" it starts losing precision.

There are no decimals so its annoying to work with currency and other cases that require more precision.

There is no operator overloading so you can't overcome these problems in a library (without having ugly, ugly syntax)

2) What are the other warts of Javascript.

Having been created in a 2-week hurry back in 1995 its actually surprising Javascript turned out to actually be pretty useable language. However there are lots of little mistakes around that we now have to live with in order to preserve backwards-compatibility with ancient browsers. Some of the more egregious problems:

There are no modules and no native way to provide encapsulation. The most common solution involves managing namespaces by hand in the global scope.
OO-style programing is kind of weird. It uses a prototypical model but has a very weird pseudo-classical syntax that serves only to confuse. The this special variable doesn't have lexical scope and can clobber the global scope in some cases (in non-strict mode).
You can probably find a more comprehensive list in any good Javascript reference. I recomend Javascript: the Good Parts as a good book to both learn the language and about some of the warts and wtfjs if you want little snippets of the weirdest corner cases.

Now for the Dart part I will get a little more subjective. In my impression, Dart looks less like a "Javascript-sucessor" and more like an evolution of the Google Web Toolkit, a set of tools that allow web apps to be written in Java. The heavily class-oriented mindset in Dart and its type system are very Java-like and I don't think this is really the kind of "revolutionary break" that would be expected from a candidate be the next ruler of the web landscape.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote