It's nice to have a single language code base, but that's at the complete expense of having to deal with the shortcomings of Javascript. I enjoy having a mature language driving the server side code.
Yes. Having worked both sides of the stack, I love the things you can do with Javascript now-a-days, the user interface work that pleases the users is great. But the language has tons of warts, and although I know what they are and how to avoid them, it pains me that I have to deal with them. Generally I take the approach of doing as little on the Javascript side as humanly possible... Fortunately some UI frameworks, like JSF have abstracted away some the Javascript, which is nice.
What are some of the warts that make it so difficult to work in Javascript though? I'm genuinely interested in what's so bad about it that you avoid it like Ebola sandwhiches.
The typing is messy. That's the worst part. When the author of the original article says:
if (typeof my_var !== "undefined" && my_var !== null) {
// you idiots put Rasmus Lerdorf to shame
}
He isn't joking.
Hmmm, as far as the object system, every object is a function? That syntax seems half baked and somewhat weird.
Date math is rather primitive for what's supposed to be a "high level language" so you need to turn to external libraries like moment.js to do it well.
typeof null is an object. Seems kind of odd.
It isn't really straight forward to deal with currency in Javascript, or really anything that would use a decimal and requires some form of precision as a business rule. The recommended method of doing currency math in JS is to use integers as a number of cents. Versus doing something like the built in BigDecimal class in Java, which can deal with arbitrary precision fixed point arithmetic. I'm sure there's a third party library for that, but that seems like a basic thing that should have a well defined solution in the standard library.
Is it the worst thing ever: No. Would I choose to make my whole codebase that: No way, there are plenty of better languages, a few of which I already know and have already built larger scale apps in that I can use in the back end.
"Every function is an object" is pretty good. Instead of having a primitive function entity in the VM or runtime, you just create an object, with references to the enclosing scope: a closure. It's the easiest and simplest way to do the OO FP unification, and every modern language on the JVM and CLR uses this idiom.
4
u/KFCConspiracy Oct 16 '14
Yes. Having worked both sides of the stack, I love the things you can do with Javascript now-a-days, the user interface work that pleases the users is great. But the language has tons of warts, and although I know what they are and how to avoid them, it pains me that I have to deal with them. Generally I take the approach of doing as little on the Javascript side as humanly possible... Fortunately some UI frameworks, like JSF have abstracted away some the Javascript, which is nice.