Live data from Hacker News

TypeScript 5.0

devblogs.microsoft.com

191–200 of 332 posts

Re: TypeScript 5.0

#191
post #172

Earlier quoted context omitted.

Have you tried C#? Sounds like it would fit your needs perfectly, additionally benefitting from a huge ecosystem behind it.

C# doesn't have algebraic data types and pattern matching though, right? I'm not the same person, but at least for me that's one of the big advantages of Rust, and it's one of those features that outside of Rust you only really find in ML-family languages. I know it's possible to simulate it partially using sealed classes in some languages, but that's always seemed like a lot of boilerplate in comparison.

C# has a lot of pattern-matching support today, including an expression-switch form: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals...

C# can fake algebraic data types in some ways/some cases. Though if you are expecting to do a lot of it you are still better off in F# or C#/F# hybrid projects. (F# of course being a proper ML-family language.)

Re: TypeScript 5.0

#192
post #5

> How? There are a few notable improvements we’d like to give more details on in the future. But we won’t make you wait for that blog post. the typescript project continues to set the bar extremely high in terms of changelog and clear communication. love you so much, drosenwasser and co!! > Decorators are an upcoming ECMAScript feature that allow us to customize classes and their members in a reusable way. huh. i tho…

I don't think decorators being a proposal matters at this point. I know I've been using them for 5+ years now, and libraries such as NestJS already use them extensively. If you like them, you're probably already drowning in them. Me, personally, I could take them or leave them.

What do you use decorators for? I've never used them and I'm curious what the usecases are. The logging thing looks helpful.

Re: TypeScript 5.0

#193

Earlier quoted context omitted.

if (typeof s === 'number' && Number.isInteger(s)) {

What do you expect me to do with this snippet provided with no context?

That's what I was wondering when I saw yours.

What I was showing here is that this solution is simpler than yours and just as good. Rather than add a utility function and a faux primitive type, I just do the normal workaround for TypeScript not supporting this, which is to redundantly check that something is both a number and an integer.

Re: TypeScript 5.0

#194
post #125

I wish MS will fork Typescript into a new language altogether that transpiles to JS or compiles to WASM. In that case, they can remove all JS weirdness from it, simplify it, add a proper standard library, and add other good parts from other (especially functional) languages to it. My wish list for such a language (in addition to what is already in Typescript), in no particular order: - Generic object literals (Why sh…

> Deep support for an alternative to exceptions using a Failable type

Is there a good library for this currently?

I've been looking for one and a Maybe library. The Maybe one I use is pretty small.

Re: TypeScript 5.0

#196

Earlier quoted context omitted.

What do you expect me to do with this snippet provided with no context?

That's what I was wondering when I saw yours. What I was showing here is that this solution is simpler than yours and just as good. Rather than add a utility function and a faux primitive type, I just do the normal workaround for TypeScript not supporting this, which is to redundantly check that something is both a number and an integer.

The point of having a utility function is that you don't have to do the redundant checks every time you want to make sure it's both a number and an integer.

The critical bit is that you need to define a new type for `integer`s distinct from `number`s to allow reusing the code in a way that doesn't break the type system on the negative path, as Ryan and I demonstrated.

Re: TypeScript 5.0

#197

Earlier quoted context omitted.

I mean, that could be changed. Currently: either string OR number Possible: either string | number OR just number

"string | number | number" is just "string | number" to Typescript.

The OR doesn't indicate | in TypeScript, it indicates the result of the possible future type guard.

Re: TypeScript 5.0

#199
post #172

Earlier quoted context omitted.

Have you tried C#? Sounds like it would fit your needs perfectly, additionally benefitting from a huge ecosystem behind it.

C# doesn't have algebraic data types and pattern matching though, right? I'm not the same person, but at least for me that's one of the big advantages of Rust, and it's one of those features that outside of Rust you only really find in ML-family languages. I know it's possible to simulate it partially using sealed classes in some languages, but that's always seemed like a lot of boilerplate in comparison.

> it's one of those features that outside of Rust you only really find in ML-family languages

Or in Scala, technically not an ML, but is as close as you'll get in a nominally typed language.

    enum RGB:
      case Red, Green, Blue

    def log(x: RGB) = x match
      case Red => print("red")
      case Green => print("green")
      // error, not exhaustive
Obviously Scala can do a lot more, including GADTs, which Rust will never have until HKTs are supported.

Ton of powerful languages to choose from these days, good times...

Re: TypeScript 5.0

#200
post #87

I have a strange take - I think Typescript types are better most other languages, including Java, C++ and Go. It's strange since TypeScript is adding types to a weakly typed language. If we could push JavaScript performance to be another order of magnitude faster it wouldn't be necessary to use other languages, imho. Of course, pushing it that far without effectively creating a new one would be difficult, to say the…

I used to think so too, until I tried Rust. By comparison, JavaScript (and by extension, TypeScript) is still lacking fundamental features and the library ecosystem situation is pretty bad. I wish there was a modern language that took all the good non-manual-memory-management things from Rust and added a GC and some immutable data structures. Error handling, enums, macros (with compile_error! / diagnostics API), trai…

That’s basically F#. It’s great.
Post reply on HN