6 ms·
I like typescript as it fixes a lot of JS quirks - that's good when you have to write code transpiled to JS. However coming from languages where types are a fi
by dnpp123 6y ago
I like typescript as it fixes a lot of JS quirks - that's good when you have to write code transpiled to JS.
However coming from languages where types are a first element of the language (c++, rust, go...), I often miss a lot of features in typescript (e.g. type conversion overload, generic specialization, etc...)
I know that by design Typescript doesn't want those features and I understand the rationale behind it. I'm just wondering if I'm the only one in that case and if someone would know a language transpiling (not compiling) to JS more appropriate to my tastes (and hence with different goals).
- DylanSp 6y agoReasonML, Elm, or Purescript, perhaps? (Not sure what you mean by "transpiling, not compiling")
- dnpp123 6y agoReasonML looks cool, first time I hear about it. Thanks. Elm/Purescript syntaxes are not my kink. Open to other suggestions though.
- hocuspocus 6y agoScala.js, Kotlin.js.
- KitDuncan 6y agoReasonML is the one with the biggest support behind it. It's your best bet.
- thomasfortes 6y agoReasonML is a pleasure to work with, and if reveryui gets momentum I will surely write gui desktop applications with it (I already use it to write compiled applications, under the hood is just ocaml).
- metta2uall 6y agoAlso the Fable & WebSharper compilers for F#
- dominotw 6y agodon't forget clojurescript :D
- BillyTheKing 6y agoyou might want to give scala-js a shot? Unfortunately, I haven't really had the chance to use it much but it looks promising!
- dtech 6y agoBasically all web languages compile/transpile* to JS since that's the only thing with wide support, at least until WASM is 100% equivalent. What's your definition of transpiling and what are you looking for? * I personally find the difference meaningless, lots of languages use intermediate compilation targets like C or JS or LLVM IR or assembly so transpiling and compiling mean the same thing to me
- miohtama 6y agoOn the server-side, Deno is soon 1.0 and has native TypeScript support - no more transpiling https://blog.logrocket.com/what-is-deno/ https://blog.logrocket.com/what-is-deno/
- awesomepeter 6y agoDeno still uses a TS to JS compiler internally, but it's transparent to the user. Just adding as it might interest someone :)
- http-teapot 6y agoI was wondering how soon and found the associated PR which was created today https://github.com/denoland/deno/pull/5273 https://github.com/denoland/deno/pull/5273
- dwaite 6y agoDeno transpiles the code for you. It is not a TypeScript compiler, but interprets/JIT compiles the generated javascript.
- jdonaldson 6y agoCheck out haxe : https://haxe.org/ https://haxe.org/ For js, specifically : https://haxe.org/manual/target-javascript.html https://haxe.org/manual/target-javascript.html Coincidentally, Haxe Foundation announced a new version here today : https://haxe.org/blog/haxe-4.1.0-release/ https://haxe.org/blog/haxe-4.1.0-release/ (disclosure : member of Haxe compiler team)
- joeyjojo 6y agoI have been using Haxe for side projects for around 5 years now, and continue to be impressed at its power, despite syntactically being quite a simple language. It's refreshing for me to go back to a Haxe codebase after looking at Typescript or Swift code, and it highlights how bloated other programming languages are becoming. A spread operator would be nice though :)
- fbn79 6y agoPersonally, I prefer to stay with vanilla (not transpiled) Javascript parsed and validated by typescript via an IDE plus JS Doc documentation. The only language that would love to switch with the drawback of transpilation would be Purescript, but a too-small community and too low performance (compile and runtime) at the moment.
- jonathanaird 6y agoWhat you’re looking for is Dart. I’ve really, really enjoyed using it so far. Can be be aot compiled as well.
- rubber_duck 6y agoDart is much closer to TypeScript than C++/Rust in terms of static typing, it just fixes some of the JS painpoints because it's not designed to be a 1:1 mapping to JS.
- IshKebab 6y agoYes, although I'm pretty sure Dart also doesn't have specialisation. I could be wrong about that though.
- htfy96 6y agoDid anyone try the J2CL Java to Closure JavaScript transpiler (https://github.com/google/j2cl https://github.com/google/j2cl)? A side benefit of this is to completely eliminate Javascript vs Java joke
- thegreatpeter 6y agoCheck out ReasonML, created by the creator of React (Jordan Walke). It's powerful, stable, fast. Messenger.com is powered by Reason: https://reasonml.github.io/ https://reasonml.github.io/
- SaxonRobber 6y agoI wanted to like Reason, but it is now clearly a dead end. Its torn identity between JS and OCaml has killed the language.
- piazz 6y agoCan you give a concrete example of the kind of code you'd like to write that you can't write in Typescript? Types absolutely are a first class citizen in TypeScript. Especially coming from Go, which doesn't even support generics, Typescript is really quite powerful. It even has support for ADTs via discriminated unions, which gives you the same power of enums with associated types that you'd get in Rust/Swift. Is it possible the reason you feel like Typescript doesn't have Types as a first class citizen is because it leverages structural typing rather than nominal typing?
- mxz3000 6y agoNot op, but I have experience with TS and some things are more difficult than they should be. For me the biggest issue is the lack of typesafe deserialisation. This makes it super painful to do IO (of which there's _a lot_ of in the serverless infrastructure I'm currently working on). While you can validate with a manually written type guard, that's a pain... It would great if you could do JSON.parse<T>() and have TS auto-generate the type guard for you... There's also no easy way to switch on union types (à la ocaml), sure you can define an enum and use a JS switch, but that's not as nice, and enforcing exhaustiveness of the switch requires some type hackery with `never`...
- mixedCase 6y agoio-ts does this. Although it's the other way around: you write the type guard (API is similar to writing a type) and it gives you the type for free.
- The_rationalist 6y agoTypescript has type erasure meaning that after compilation all information about types is lost. This means that you loose: * runtime type reflection * Reified generics