9 ms·
I really enjoy typescript and have been yearning for a typescript runtime but I can't help but laugh that I left java all those years ago to finally seek someth
by harshitaneja 2y ago
I really enjoy typescript and have been yearning for a typescript runtime but I can't help but laugh that I left java all those years ago to finally seek something a lot closer to java.
I guess we all just wanted java with JIT, more feature rich type system and gradual typing. Also for all the shortcomings of npm ecosystem, it is a lot less daunting and more fun to be using libraries in this ecosystem.
And surprisingly even though rust is on a different end of the language spectrum but yet it offers a similar feel.
Edit: JIT was not the right terminology to use. I lazily wrote JIT. Apologies. What I meant to convey was the difference in startup times and run time between running something in JVM and V8. Java feels heavy but in javascript ecosystem it feels so nimble.
- dagenix 2y agoJava does jit
- harshitaneja 2y agoYes, JIT was not the right terminology to use. I lazily wrote JIT. Apologies. What I meant to convey was the difference in startup times and run time between running something in JVM and V8. Java feels heavy but in javascript ecosystem it feels so nimble.
- sgammon 2y agoNative Java via GraalVM starts up in milliseconds.
- wiseowise 2y agoAnd it has to go through slow compilation step. With Node you can have a cake and eat it too.
- sgammon 2y agoIt does not "have" to go through such a step, by the way, because you can simply run such code on the JVM.
- ZhongXina 2y agoYou're saying it like it's an absolutely good thing. Some (many?) users would rather pay the cost upfront in compilation time (doesn't really matter if it's AOT or JIT) than pay the same cost many times over through a significantly slower runtime. JVM also scales up to supercomputers (and everything in between) if you want it to, so depending on your requirements a single-threaded alternative might not even be an option.
- DarkNova6 2y agoYou can't be serious about comparing the technological capabilities of the JVM and Node and objectively declare the latter as the winner. Compilation times are also an absolute non-issue. You don't compile for development. You do it for production (in the rare circumstances that you need it).
- deleted 2y ago[deleted]
- harshitaneja 2y agoThat's not what I am trying to convey here. JVM is amazing and it is a feat that java is as fast as it is and javascript and v8 are order of magnitude slower. Also even though I also found java too verbose, I kept believing that we need it to be so to write good software. I still enjoy java but it doesn't compare to the ergonomics of typescript for me. And nimbleness of the experience according to me plays a decent role. Currently for me, either I really care about performance and I default to rust for those applications or I need solutions where the product will evolve quickly over time and I need great DX over performance and I default to typescript for those. Java definitely has a role to play but its role in my work has certainly diminished.
- bufferoverflow 2y agoTypescript is way better than Java, in my experience. It's a lot less verbose. A lot more flexible.
- sgammon 2y agoThey are not comparable. If anything, Kotlin is the equivalent in the JVM universe.
- quonn 2y agoKotlin is much closer to Java than to TypeScript even in terms of flexibility.
- DarkNova6 2y agoTo me "Flexibility" sounds a lot like "The programmer always knows what he does".
- scotty79 2y agoFlexibility means for me more something more like, I think I know what I want to do but I also know that I'm probably wrong about that, so for now let's skip all the baroque protocol and let me make it work first. Once I'm sure I wrote what I actually wanted I'll add types if only to get rid of some bugs, consider edge cases and earn nice code completions and auto-generated docs.
- sgammon 2y agoSure, but Kotlin is to Java as TypeScript is to JavaScript, which is the point I am making.
- wiseowise 2y agoThat’s not even remotely true. TypeScript is a direct superset of JavaScript. Any valid JS is a valid TypeScript. If Kotlin is what TS to JS, then so is Groovy, Scala, Clojure and other JVM languages.
- bubblyworld 2y agoI'm very glad to use typescript over java, personally - the ergonomics are so much better! Especially if you stray away from the somewhat incomplete classes thing (type support for decorator arguments isn't great, for instance) and just focus on interfaces and functions. One thing I miss that java has is runtime reflection of types though. Typescript's ecosystem has a million different ways to get around that and they're all a bit ugly imo.
- zx8080 2y ago> we all just wanted java with JIT, more feature rich type system Java has JIT. How is TypeSript type system feature-richer than the Java one?
- VMG 2y ago1. *Type Inference*: TypeScript can automatically infer types from context, reducing the need for explicit type declarations. 2. *Union and Intersection Types*: Allows combining multiple types, offering more flexibility in defining data structures. 3. *Literal Types*: TypeScript supports exact values as types (e.g., specific strings or numbers), which can be useful for more precise type-checking. 4. *Type Aliases*: You can create custom, reusable types, enhancing code clarity and maintainability. 5. *Interfaces and Structural Typing*: Interfaces allow for flexible contracts, and TypeScript uses structural typing, where the type compatibility is based on the shape of the data rather than explicit type declarations. 6. *Mapped and Conditional Types*: These allow for dynamic type creation and manipulation, making the type system more powerful and expressive. 7. *Optional Properties and Strict Null Checks*: These provide better handling of undefined and null values.
- tpm 2y agoThat's just an copy-paste of some features, not a comparison with Java which does most of that too.
- afiori 2y agoUnion types, structural typing, and conditional types are like a big chunck of what makes typescript typescript. It is how TS is able to "type" a completely untyped language. Just the support for union types is something that not even Haskell or Ocaml have.
- nequo 2y agoI am not familiar with TypeScript. Is there something that you can achieve with union types that you can’t with sum types or type classes in Haskell?
- ninepoints 2y agoNot having an opaque tech stack encumbered by a patent minefield is another plus.
- qalmakka 2y ago> we all just wanted java with JIT Java was literally the thing that made the term "JIT" popular, so I really don't know what you were going for here. Also I just can't see how Typescript is in any way "closer" to Java - it's incredibly different IMHO. The only thing they have in common is probably the "Javascript" misnomer and the fact both support imperative programming, but that's it.
- seanmcdirmid 2y agoTypescript’s optional and unsound type system also does nothing for a JIT beyond what it could already do for JavaScript, you can’t do optimization if your types are unreliable. However, I really really like how Typescript’s type system super charges developer productivity (type errors via the compiler and feedback via the IDE), and don’t mind this part of the design at all.
- teaearlgraycold 2y agoYou can use typescript types to compile functions. You just might need to deoptimize when you actually hit the function.
- seanmcdirmid 2y agoI don’t know if Vortex-style compilation ever worked in practice.
- 38 2y ago> gradual typing AKA dynamic typing. Unless it's 100% static, it's dynamic
- debugnik 2y agoGradual typing could still keep some static guarantees if the static part were sound, e.g. you couldn't assign a dynamic-typed integer to a string-typed variable without checking the type at runtime first; which TypeScript isn't. Elixir's new type system does much better here, as it determines whether a function actually guards for the right type at runtime ("strong arrows") and propagates the guarantees, or lack thereof, accordingly.
- wiseowise 2y ago> Also for all the shortcomings of npm ecosystem, it is a lot less daunting and more fun to be using libraries in this ecosystem. God I wish they’d just integrate something lightweight like npm into JDK. It is beyond me why you have to install third-party heavy weight tool just to manage dependencies.
- jddj 2y agoI'm somewhere here as well. Personally I think what I want is the stdlib (without the current legacy/ all but deprecated bits) and ecosystem of c# but with the ease and power of structural algebraic types. AoT is fine, with option for single binary. Ideally runtimeless with clever trimming. If it also ran jitted in the browser all the better. I also want compiler/type checker niceties like exhaustive pattern matching.
- tomjen3 2y agoThe typesystem of Java was so laughably unpowerful that it severely constrained what you could write. In Typescript you have far more freedom, and all the benefits of strong types.
- DarkNova6 2y agoStrong types without strong typing that is.
- yen223 2y agoThe fact that Java forced you to write types, and then made everything implicitly nullable so that you still get NullPointerExceptions at runtime after writing out all those types, was probably a big reason why dynamically-typed languages became popular.
- lmm 2y agoJava's type system was just very limited, gradual typing is a poor tradeoff most of the time. I used to think there were advantages to something like Python, but once I found Scala I never went back.
- scotty79 2y agoGradual typing is the key. The problem with Java is that types are in your face way before you actually need them. With TS you can prototype with JS and only after you know what you are looking for you can start to add types to find bugs and edge cases and want to get nice code completions for your stuff.
- hot_gril 2y agoThe type system is a big part of what made Java cumbersome. It's loosened up a little over the years. TS itself may allow partial typing, but when team/company policies are involved, you'll often end up being forced to type everything.
- austin-cheney 2y ago> I guess we all just wanted java with JIT Oh god no. What an abomination. Greater than 95% of the incompetence in JavaScript comes from two camps. The first of those are people who absolutely cannot program at all. The second of those are Java developers who were taught Java in school and it’s all they can do, so everything must look like Java. The result of both tribes is pretending to do something they cannot do on their own. When you’re a pretender vanity becomes excessively important because everything is superficial, so you get layers of shit you don’t need that they cannot live without. Any attempts slice off the unnecessary bullshit always results in hyper emotional distress because people feel threatened when exposed. That right there is why I will never write JavaScript for employment ever again.