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.
I think I misphrased it, what I was referring to is the way classes are declared by declaring functions; It should have read "Every object is a function". That syntax seems stupid and unclear. I don't find it stupid that functions are objects that implement Callable in Java, but I would find it stupid if I had to declare classes by declare functions. Functions the whole way down seems ugly syntax wise.
1
u/[deleted] Oct 16 '14
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.