5 ms·
As someone who did the first ~2/3 of my career in Java, but have been in Node/Typescript for the past several years, can't say enough how much I think the struc
by hn_throwaway_99 4y ago
As someone who did the first ~2/3 of my career in Java, but have been in Node/Typescript for the past several years, can't say enough how much I think the structural typing of Typescript allows be to have much higher productivity than the nominal typing of Java.
Primarily it has to do with making refactorings much, much easier.
- dataflow 4y agoI can't help but wonder how much of your productivity boost was due to leaving Java vs. due to using Typescript. Java is just about the most unjustifiably verbose language I can think of off the top of my head.
- Supermancho 4y agoIt's not just verbose, but has bad choices that impact the language to have to be verbose (to maintain within it's own limitations) that results in inferior implementations. The "new object" paradigm for instantiation (instead of Class.new, or some other generator), the static keyword, the final keyword, no global scope (eg for singletons), the inability to do non-inheritance mixins without 3rd party libraries, a full pre-runtime to bypass some of these issues in the form of Spring. Many of these work against testability and JUnit just can't keep up. It's horrific and it's not going to get better anytime soon.
- kjeetgill 4y agoInteresting. I'd love to know a bit more about why these harm testability for you. I'm not sure I've felt the same way. Especially the global scope bit. Even statics fields are too much global scope in my opinion, not too little.
- chopin 4y agoStatic fields can get in the way of testability very quickly, in my experience. Even static methods can if they draw in dependencies.
- Supermancho 4y ago> why these harm testability for you They harm testability for me, because I have to use java to test them. There's a larger discussion about "what is testing" and "how to properly test" which I'm not going to get in to here, but would be happy to talk about in another forum. JUnit (and all the inferior alternatives) can't properly mock them or verify how/when they are called (despite running in a closed test container, which is how JUnit executes them). If you have ever tried to deal with native methods (or FAANG libs that like to use static final methods), there's a practical barrier to how much state you can avoid in testing. That barrier is java's ecosystem itself (JVM + syntax + tooling + ethos).
- kaba0 4y agoInteresting how Java manages to chug along for decades on backends with arguably the biggest code bases out there (running basically most of the services at FAANG as well as outside of it), when it is so “inferior”. Empirically I would say that it does very very well on maintainability’s count.
- Aloha 4y agoPHP is another one in that category.
- Supermancho 4y agoPHP is still extremely testable, for now. The slow migration toward another Spring-like preprocessor, via complex annotations, is worrisome.
- the_gipsy 4y agoI don't think maintainability is the reason, though.
- wiseowise 4y agoThat’s not achievement of Java language, but Java platform.
- kaba0 4y agoWell true, but then the answer one doesn’t want to read is that the “language doesn’t matter”, at least not in any significant way. Which is in line with the famous “No Silver Bullet” article.
- Supermancho 4y ago> the answer one doesn’t want to read is that the “language doesn’t matter”, at least not in any significant way. When you have an outrageous amount of effort to (what amounts to manual) testing in closed environments before release, you're fighting the language but you just don't care. > Empirically I would say that it does very very well on maintainability’s count FAANG companies don't even release data related to how program defects are detected and addressed (publicly), so the assertion is literally baseless. Given enough time and effort, you can overcome the inability to do simple things. That doesn't make the tooling better, just the perception. This is common, historically, in tech (re Mechanical Turk).
- Sohcahtoa82 4y agoTake my opinion with a huge pound of salt because I've only ever used Java for smaller projects but... A large part of Java's verbosity is optional, but it feels to me that people do it because "That's how you write Java!". But you don't HAVE to write an interface, abstract class, and factory for every class. You can just...write a class. You don't need to write a class that has nothing but an "invoke" function. You can just...write a function. You don't need 10 layers of abstraction for simple cases.
- dataflow 4y agoPeople exacerbate the problem but the language itself is pretty darn verbose too. Just look at how much code you need to instantiate a generic array for instance.
- deleted 4y ago[deleted]
- kaba0 4y agoMy experience is very much the reverse. Even at present I’m looking at different java to js compilers (teavm, j2cl) because I don’t want to write a frontend apps business logic part in js/ts..
- cxr 4y ago> I’m looking at different java to js compilers (teavm, j2cl) because I don’t want to write a frontend apps business logic part in js/ts I've seen people do this (rewrite a Java app in JS) and then go completely off the rails, instead of, you know, writing it just like they would have (read: already did the first time) in Java. Bonus points when it's followed by the conclusion that JS sucks. It hints towards irrationality on their part. It's as if the structure and order imposed by Java is the _only_ thing keeping them on the straight and narrow, because they themselves can't be trusted to act responsibly and simply follow the same principles on their own when no one is around forcing them to.
- kaba0 4y agoLanguages do have their respective idiomatic structure, you write JS differently than Java, and personal preferences may alter one’s decision. But the reason I plan on going down this road is that I don’t want to program the complex business logic twice, it is quite important that both backend and frontend reliably calculate the same results. It is much easier to handle it through a compiler that will uphold Java’s semantics, than trying to write the same thing in JS - where you might easily do float arithmetic when you didn’t intend.
- cxr 4y ago> Languages do have their respective idiomatic structure, you write JS differently than Java I object to this specifically as it relates to JS because the sort of code that mainstream "JS" programmers write nowadays ends up being passed off as idiomatic even though it really shouldn't. If you look at well-written JS in very large JS codebases with high standards (like Firefox, at least as it was circa ten years ago, or Apple's Web Inspector[1]), then you realize idiomatic JS looks a lot more like Java, C#, and Objective-C than what you find getting pushed to GitHub today—and (very soon after) discarded, since the half-life of an NPM-powered codebase is something like 2–3 years. The problem is that the style of development associated with the NodeJS+NPM crowd has cannibalized the JS ecosystem, so almost anyone gazing in on the situation today is going to have a _very_ skewed view of what "idiomatic" means. The perverse thing is that you will encounter more of an impedance mismatch with JS-the-language if you actually try to follow the crowd. This is a big driver for toolchain/framework churn—because they're all fighting the language instead of just going with it. 1. https://github.com/apple-oss-distributions/WebInspectorUI/search?l=javascript https://github.com/apple-oss-distributions/WebInspectorUI/se...