4 ms·
I'm a back-end developer (Java, Scala, some Rails) and when I first heard developers were using Node+JavaScript as a server stack I thought they were nuts to us
by deeg 9y ago
I'm a back-end developer (Java, Scala, some Rails) and when I first heard developers were using Node+JavaScript as a server stack I thought they were nuts to use a dynamic scripting language for enterprise software. TypeScript has a chance to turn that around, though, and might be the future: a mostly-typed language that also has the flexibility to be dynamic when called for.
I really like TypeScript and it has ushered me into the node environment.
- maxxxxx 9y agoSame here. I had to take over a node project and I can't imagine how anybody could maintain a large JavaScript codebase long term. It's way too easy to insert a simple mistake. The next version of our project will be slowly ported to TypeScript and I look forward to it.
- jondubois 9y agoThe root problem is that most companies don't spend any time planning their projects. It should only take a couple of days and yet companies just don't do it. The bad coding style that you sometimes see in JavaScript land is just a symptom of a greater problem that static typing masks but doesn't actually fix. I like dynamic typing because then I can see straight away if the project is crap or if the team is crap.
- maxxxxx 9y agoI think Javascript is definitely way too forgiving. I just had a situation where a property name was mistyped. The value was "undefined" which then can be compared against strings. So the code worked without warnings but the results were wrong. Took several days to track this down in a long promises chain. With a typed language this wouldn't even have compiled.
- jondubois 9y agoBut with JS you don't need to wait for your code to compile so you can test it much quicker. If you write tests then this is almost never a problem. With typed languages, I often lose my train of thought while waiting for the compiler. When warnings come up, I'm like a robot, I don't actually think, I just follow the line numbers. Statically typed languages make me lazy. I feel like I spend all my time and mental energy catering to the compiler. I like dynamically typed languages because it forces me to consider everything and keeps me on my toes.
- seanmcdirmid 9y agoYou can simply erase the types with TS and it’s ready to go. I think tsc does this automatically, but I’m not really sure because I always wait for the compiler to finish out of habit. It doesn’t seem to be incremental at all yet, so compilation times noticeably grow longer as your project does, unfortunately.
- maxxxxx 9y agoI guess it's all a matter of taste or what you are used to. I like relying on the compiler. The stricter the compiler the better.
- mixedCase 9y agoYou can't type things properly without considering the business logic. Once you have that figured out the correct logic comes easily. The compiler should be sparing you from wasting mental energy on menial things by telling you what to do, even when making large changes that would be disgustingly complicated in a dynamic language. If you feel like you're "catering to the compiler", then you're going about things wrong; because you're worrying about logic before nailing down the proper data structures.
- rk06 9y ago>But with JS you don't need to wait for your code to compile so you can test it much quicker. This is no loner a valid criticism as any decent IDE (or a mature Code Editor) can run static analysis as you type and warn you abut issue, before you even compile. Source: VsCode does static analysis on TypeScript.
- tobyhinloopen 9y agoJavaScript dev here. Type related Mistakes are common but A LOT of tests keep me safe. I avoid using the Object constructor for data that is passed around a lot and use functions as constructors to create common data structures to ensure their structure and properties are consistent. Simple example: function User (name, email) { this.name = name; this.email = email; } This simple solution prevents lots of common typing mistakes where object properties are inconsistent. Sometimes I include some specific development-only type-checks on the params as well We cant use Typescript, I would love to use it though
- the8472 9y agoThe issue with typescript is that it relies a lot on external type definitions for non-typed JS modules. And those are plain wrong or outdated at times, leading to lots of compiler errors (but correct code!) which in turn means you can't let your build fail when type errors are detected and you acquire some compiler error numbness over time. I mean it's better than no type checking at all, but it falls short of languages where it's actually baked in instead of relying on external definitions.