News for hackers. Stuff that matters.
Re:Announcing TypeScript 3.9 by dnpp123 on Wednesday May 13, 2020 @09:38AM (#23166752)
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).

Re:Announcing TypeScript 3.9 by jdonaldson on Wednesday May 13, 2020 @11:10AM (#23167612)
Check out haxe : https://haxe.org/

For js, specifically : 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/

(disclosure : member of Haxe compiler team)

Re:Announcing TypeScript 3.9 by joeyjojo on Wednesday May 13, 2020 @07:12PM (#23172956)
I 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 :)
Re:Announcing TypeScript 3.9 by thegreatpeter on Wednesday May 13, 2020 @12:16PM (#23168446)
Check 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/
Re:Announcing TypeScript 3.9 by SaxonRobber on Thursday May 14, 2020 @11:45AM (#23180901)
I wanted to like Reason, but it is now clearly a dead end. Its torn identity between JS and OCaml has killed the language.
Re:Announcing TypeScript 3.9 by dtech on Wednesday May 13, 2020 @11:01AM (#23167522)
Basically 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

Re:Announcing TypeScript 3.9 by miohtama on Wednesday May 13, 2020 @12:09PM (#23168346)
On the server-side, Deno is soon 1.0 and has native TypeScript support - no more transpiling

https://blog.logrocket.com/what-is-deno/

Re:Announcing TypeScript 3.9 by dwaite on Wednesday May 13, 2020 @12:36PM (#23168673)
Deno transpiles the code for you. It is not a TypeScript compiler, but interprets/JIT compiles the generated javascript.
Re:Announcing TypeScript 3.9 by awesomepeter on Wednesday May 13, 2020 @12:27PM (#23168564)
Deno still uses a TS to JS compiler internally, but it's transparent to the user.

Just adding as it might interest someone :)

Re:Announcing TypeScript 3.9 by http-teapot on Wednesday May 13, 2020 @12:29PM (#23168587)
I was wondering how soon and found the associated PR which was created today https://github.com/denoland/deno/pull/5273
Re:Announcing TypeScript 3.9 by jonathanaird on Wednesday May 13, 2020 @11:23AM (#23167748)
What you’re looking for is Dart. I’ve really, really enjoyed using it so far. Can be be aot compiled as well.
Re:Announcing TypeScript 3.9 by rubber_duck on Wednesday May 13, 2020 @12:34PM (#23168651)
Dart 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.
Re:Announcing TypeScript 3.9 by IshKebab on Wednesday May 13, 2020 @11:38AM (#23167947)
Yes, although I'm pretty sure Dart also doesn't have specialisation. I could be wrong about that though.
Re:Announcing TypeScript 3.9 by fbn79 on Wednesday May 13, 2020 @11:16AM (#23167669)
Personally, 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.
Re:Announcing TypeScript 3.9 by DylanSp on Wednesday May 13, 2020 @10:00AM (#23166938)
ReasonML, Elm, or Purescript, perhaps? (Not sure what you mean by "transpiling, not compiling")
Re:Announcing TypeScript 3.9 by dnpp123 on Wednesday May 13, 2020 @10:08AM (#23167003)
ReasonML looks cool, first time I hear about it. Thanks.

Elm/Purescript syntaxes are not my kink. Open to other suggestions though.

Re:Announcing TypeScript 3.9 by KitDuncan on Wednesday May 13, 2020 @11:11AM (#23167624)
ReasonML is the one with the biggest support behind it. It's your best bet.
Re:Announcing TypeScript 3.9 by thomasfortes on Wednesday May 13, 2020 @11:18AM (#23167696)
ReasonML 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).
Re:Announcing TypeScript 3.9 by hocuspocus on Wednesday May 13, 2020 @10:39AM (#23167298)
Scala.js, Kotlin.js.
Re:Announcing TypeScript 3.9 by metta2uall on Wednesday May 13, 2020 @10:55PM (#23174773)
Also the Fable & WebSharper compilers for F#
Re:Announcing TypeScript 3.9 by dominotw on Wednesday May 13, 2020 @11:13AM (#23167638)
don't forget clojurescript :D
Re:Announcing TypeScript 3.9 by piazz on Wednesday May 13, 2020 @02:35PM (#23170116)
Can 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?

Re:Announcing TypeScript 3.9 by mxz3000 on Wednesday May 13, 2020 @04:53PM (#23171716)
Not 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`...
Re:Announcing TypeScript 3.9 by mixedCase on Wednesday May 13, 2020 @05:34PM (#23172090)
io-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.
Re:Announcing TypeScript 3.9 by The_rationalist on Thursday May 14, 2020 @02:44PM (#23183623)
Typescript has type erasure meaning that after compilation all information about types is lost. This means that you loose: * runtime type reflection * Reified generics
Re:Announcing TypeScript 3.9 by BillyTheKing on Wednesday May 13, 2020 @10:37AM (#23167288)
you might want to give scala-js a shot? Unfortunately, I haven't really had the chance to use it much but it looks promising!
Re:Announcing TypeScript 3.9 by htfy96 on Wednesday May 13, 2020 @11:55AM (#23168180)
Did anyone try the J2CL Java to Closure JavaScript transpiler (https://github.com/google/j2cl)? A side benefit of this is to completely eliminate Javascript vs Java joke