News for hackers. Stuff that matters.
Re:TypeScript 5.0 by endisneigh on Thursday March 16, 2023 @02:17PM (#35185996)
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 least.

Re:TypeScript 5.0 by mrits on Thursday March 16, 2023 @02:28PM (#35186179)
That is a strange take. It sounds like you think the reason people don't use Typescript is because of performance and not what some would consider a irresponsible ecosystem of abandoned frameworks and a language that provides little actual safety while still being unpleasant to use.
Re:TypeScript 5.0 by quonn on Thursday March 16, 2023 @02:51PM (#35186541)
It‘s not strange at all. I think them same. The type system of TypeScript is in practice much more useful than the one of C# or Java.

Nothing is abandoned and in any case typically only a small set of libraries is needed which should be carefully picked.

Re:TypeScript 5.0 by TOGoS on Thursday March 16, 2023 @02:46PM (#35186466)
Good take if you ask me. When I want to flesh out an ontology, I find that TypeScript's type syntax more natural than anything else. Generally I find it to do an amazing job of bridging between a very expressive and flexible type system and a language that at runtime knows nothing about your types.

Want structural/duck typing? No problem; that's the default. Define new interfaces that old classes happen to implement without having to wrap them. I always wanted that feature!

Want nominal types? No problem; just declare a field indicating the type name!

  interface Square { classRef: "http://example.com/Shapes/Square"; width: number; }
  interface Circle { classRef: "http://example.com/Shapes/Circle"; diameter: number; }
  type Shape = Circle|Square;
(I like to express things in a way that can be easily translated to RDF, hence my use of URIs for type and attribute names)

Since TypeScript types don't runtime checks, you can even do it on atomic types!

  type USDollars = number & { [Symbol.for("http://ns.nuke24.net/Synx/unit")]: "USD" }
  type CanadianDollars = number & { [Symbol.for("http://ns.nuke24.net/Synx/unit")]: "CAD" }
  
  const someAmount : CanadianDollars = someExpressionReturningUsDollars; // Compile error!  Try doing that in Java!  I OFTEN WISH I COULD
Re:TypeScript 5.0 by TOGoS on Thursday March 16, 2023 @04:53PM (#35188404)
Addendum to my nominal types: For the 'fake' nominal types (you can't put a symbol on a number!) I like to make those fields optional, which makes the type less of a lie. "If this number did have a [unit symbol] property, the value would be 'USD'". That will still prevent accidental USD <-> CAD conversion, but allows converting to/from regular numbers without explicit casting.

A pile of thoughts on the subject from back when I first came up with it: http://www.nuke24.net/plog/32.html

Re:TypeScript 5.0 by triyambakam on Friday March 17, 2023 @02:30AM (#35193911)
Very cool
Re:TypeScript 5.0 by liminal on Friday March 17, 2023 @12:37PM (#35199387)
This is really great. I once spent a little time thinking about how to better represent RDF in Type/Javascript. These approaches seem like a good direction to go in. Would love to see these ideas developed further.
Re:TypeScript 5.0 by isleyaardvark on Sunday March 19, 2023 @11:30AM (#35219949)
I’ve seen several TS users describe that approach as “branding” (or “flavoring” if it is optional).
Re:TypeScript 5.0 by smt88 on Thursday March 16, 2023 @02:57PM (#35186635)
After using structural typing in TS, it's very hard to go back to nominal typing.
Re:TypeScript 5.0 by spion on Thursday March 16, 2023 @03:05PM (#35186742)
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), traits / approach to OOP, embedded tests, doctests and the relentless determination to add examples in the docs in general... Everything in Rust feels like "oh, they got this right too", which hasn't been the case for any other typed lanuage I've used in the past 15 years (including typescript, my previous favorite; purescript; go; haskell)

Re:TypeScript 5.0 by felipeccastro on Thursday March 16, 2023 @03:31PM (#35187100)
Have you tried Crystal? I got the same "oh, they got this right too" feeling about everything as well.
Re:TypeScript 5.0 by christophilus on Thursday March 16, 2023 @03:48PM (#35187370)
Crystal is excellent. I just can’t handle the sluggish compilation times. Has that improved?
Re:TypeScript 5.0 by felipeccastro on Thursday March 16, 2023 @04:58PM (#35188512)
Nope, but working with fewer/smaller dependencies (like Kemal) it seems more manageable. Also, the feedback from type system is much faster than the full build, so I've noticed I don't need to run the app to test every small change like I do with ruby. There is also an interpreter mode available for testing, but I haven't tried it yet since that currently requires building the language from source. I'm hoping the interpreter will solve that DX issue entirely once it's ready.
Re:TypeScript 5.0 by jdthedisciple on Thursday March 16, 2023 @03:19PM (#35186931)
Have you tried C#? Sounds like it would fit your needs perfectly, additionally benefitting form a huge ecosystem behind it.
Re:TypeScript 5.0 by rrishi on Thursday March 16, 2023 @05:21PM (#35188846)
How does the verbosity in C# compare to Java's? And are big C# codebases littered with annotations and "dependency inversion" Java Spring boilerplate-y crap?

I ask because I have never delved into C# only heard it's Microsoft's Java. And I am no fan of the original Java at all so C# gives me pause.

Re:TypeScript 5.0 by cutler on Thursday March 16, 2023 @05:42PM (#35189121)
C#11 defaults to nullability and has top-level functions giving it a big advantage over Java. The idiomatic Pascal case takes some getting used to but it's worth it.
Re:TypeScript 5.0 by rrishi on Friday March 17, 2023 @10:05AM (#35197219)
Thanks for the overview. Hopefully I can give the language a shot when time permits.
Re:TypeScript 5.0 by theshrike79 on Thursday March 16, 2023 @05:27PM (#35188922)
C# is pretty much Java done right.

Speaking as someone who started with Java 1.2 and saw all the crap that happened to it.

C# is currently lightyears ahead of Java in every way, especially now that MS is not Micro$oft to people on the internet any more =)

Re:TypeScript 5.0 by kaba0 on Thursday March 16, 2023 @07:04PM (#35190178)
> C# is currently lightyears ahead of Java in every way

Let’s not claim things that can’t be objectively proven. C# does have much more features than Java, but that is not necessarily a plus in case of a programming language. There are features that are definitely better, but I am not bought that the whole would be.

Plus, ecosystem-wise Java is much bigger and much more open-source. The runtime is also better on the JVM-side, though this is offset by C# expressing more low level details.

Re:TypeScript 5.0 by postdb on Friday March 17, 2023 @02:37AM (#35193951)
Also C# is really meant to run on MS servers (Azur). Yes you can compile C# asp core projects on Linux, but the hell of dll when the there are many projects in a solution is quit annoying. Development experience in C# without Visual Studio is quite cumbersome.
Re:TypeScript 5.0 by theshrike79 on Friday March 17, 2023 @02:45AM (#35194010)
Nope. This is the M$ == bad era thinking.

I've been doing C# on a MacBook with JetBrains Rider for years. Some code runs in Linux containers, some on AWS Lambda.

Re:TypeScript 5.0 by pjmlp on Friday March 17, 2023 @04:31AM (#35194602)
Nope, see you're using Rider, because VS4Mac and VSCode only offer a subset of Visual Studio capabilities for .NET development.

I rather do .NET than Java, but the FOSS story isn't as Microsoft sells it, hence why on our agency .NET is mostly used on Windows projects, and usually loses against Java or node in UNIX like RFP, even after .NET Core reboot, because of dependencies and existing enterprise tooling.

Re:TypeScript 5.0 by tester756 on Thursday March 16, 2023 @06:43PM (#35189942)
We don't do annotation-oriented-programming in C#

DI is almost always in web, but via constructor instead of annotations.

Re:TypeScript 5.0 by WorldMaker on Thursday March 16, 2023 @07:00PM (#35190146)
Recent versions of C# have expressly been working to minimize/eliminate verbosity. Things like namespace statements (rather than { } blocks), global usings, top-level statements, record types (by default structurally compared, immutable data structures defined often only by their constructor and nothing else), and much more.

Similarly recent libraries such ASP.NET have been working hard to use more of these things to eliminate their own boilerplate. The latest ASP.NET templates use top-level statements and some global usings and are getting very lightweight in terms of starter-level code.

.NET does have annotations and dependency inversion, but those too tend to avoid boilerplate more than create it. Few annotations are "required", depending on your domain and which libraries you are expecting to use. .NET now has a single, mostly standardized dependency injector that almost everyone has agreed to use (Microsoft.Extensions.DependencyInjection) at this point. It intentionally only supports a bare minimum of Dependency Injection needs and is nothing like the Kitchen Sink approach of something like Java's Spring. (For instance, zero out of the box support for wiring Dependency Injection via XML files. .NET's DI is always code driven, often in a Startup.cs, Program.cs, App.cs, or Main.cs file.)

I've been increasingly finding in C# that I'm writing new code with zero templates and almost no snippets-expansion. (There will always be plenty of legacy code out there with much more verbosity, of course.)

The easiest suggestion is to try it for yourself. The `dotnet` tool is cross-platform, generally an easy install, and its `dotnet new` command will help you try many easy template types. You can relatively easily work entirely in VS Code today (as opposed to older versions of C# often "needed" the full bulky Visual Studio install for templates, language servers, and other stuff).

Re:TypeScript 5.0 by rrishi on Friday March 17, 2023 @10:03AM (#35197207)
Thank you for such a well written and detailed response. Gave me a fair representation of C#.

I do hope to try it maybe in recent future.

Re:TypeScript 5.0 by MrJohz on Thursday March 16, 2023 @05:32PM (#35188991)
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.
Re:TypeScript 5.0 by roebk on Thursday March 16, 2023 @05:56PM (#35189332)
Pattern matching was recently added to C#. I can't say quite how well it's been embedded into the language. I always hear great things about F#, ADTs, pattern matching, nice type system and it integrates nicely into the rest of the .NET ecosystem.
Re:TypeScript 5.0 by physPop on Thursday March 16, 2023 @06:03PM (#35189426)
F# is great. Simple, small, straightforward, great interop with .NET
Re:TypeScript 5.0 by spion on Saturday March 18, 2023 @09:35PM (#35215081)
Also, the requirement to manually order the compilation units (files) in an XML file to ensure the compiler doesn't get confused.

They had me at features, lost me at manual compilation ordering.

Re:TypeScript 5.0 by WorldMaker on Thursday March 16, 2023 @06:05PM (#35189446)
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 by virtualwhys on Thursday March 16, 2023 @06:19PM (#35189620)
> 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 by spion on Thursday March 16, 2023 @06:24PM (#35189682)
I did, and I should've listed it. Its my third favorite typed language. At the time I was trying it, its type system wasn't as expressive as TS is today (no algebraic data types, no Result<T> error modelling in the type system etc), but LINQ with its clean syntax and ease of use is something I've missed in every language since (scala `for` syntax looks really awkward by comparison).
Re:TypeScript 5.0 by jpgvm on Thursday March 16, 2023 @06:01PM (#35189387)
For me that's Kotlin.

It's my general purpose language. I also use Rust everywhere Kotlin isn't suitable.

Re:TypeScript 5.0 by evntdrvn on Thursday March 16, 2023 @06:22PM (#35189664)
That’s basically F#. It’s great.
Re:TypeScript 5.0 by epolanski on Thursday March 16, 2023 @06:24PM (#35189689)
Well he said better than most, not best of every.
Re:TypeScript 5.0 by raincole on Thursday March 16, 2023 @06:33PM (#35189815)
Same here. Rust and TypeScript are the two my favorite type systems.

I totally accept there might be a better type system. But I think Rust's type system covers 99.9% sane use cases. (Not saying Rust itself should be used in 99.9% projects tho.)

I kinda hope TypeScript somehow compiles machine code. (I don't know how it can possibily work without VM, I'm just saying)

Re:TypeScript 5.0 by hatuthecat on Thursday March 16, 2023 @06:42PM (#35189915)
You’re basically describing Swift. Swift and Rust had a ton of cross pollination during their early years which led to those features developing similarly but memory management is a lot less targeted for extreme efficiency like Rust. Hopefully as the language continues to mature, the feasibility to use it outside of apple platforms also does because I really enjoy the language design.
Re:TypeScript 5.0 by noisy_boy on Thursday March 16, 2023 @09:19PM (#35191488)
Does Swift has pattern matching and equivalent of Option/Result enums? I tried it casually but the documentation didn't feel great and things felt like they assumed familiarity with Apple's ecosystem.
Re:TypeScript 5.0 by runeks on Sunday March 19, 2023 @10:41AM (#35219395)
Swift also supports enumerations with associates values, which is super useful: https://docs.swift.org/swift-book/documentation/the-swift-pr...
Re:TypeScript 5.0 by noisy_boy on Sunday March 19, 2023 @11:44AM (#35220122)
Thanks for the links - I did the Swift Tour and the language has indeed come a long way since I tried it last time; quite expressive and nice to write in. Hopefully it gains traction in non-Apple circles as well.
Re:TypeScript 5.0 by iainmerrick on Friday March 17, 2023 @05:48AM (#35195018)
I do really like Swift, but isn't it usually significantly slower than Rust?

Swift seems more in the Go or Java class, rather than being competitive with C/C++ like Rust is. If that's so, Swift is still appealing as a pretty-fast, safe language with a much more sophisticated type system than Go or Java. But... TypeScript is too!

I have a feeling in terms of raw performance, JS is probably closer to Swift than Swift is to Rust. The important difference between Swift and JS isn't performance as much as which platforms/APIs/languages they can integrate with.

(Maybe I'm underestimating Swift's performance, though, or overestimating JS -- corrections welcome)

Re:TypeScript 5.0 by bsaul on Friday March 17, 2023 @08:22AM (#35196119)
Agree. I feel like rust and swift will eventually converge with time, with swift providing more and more static guarantees and lifetime-related keyword, and rust improving its ergonomics. ( although recently swift definitely also went a completely different direction, adding as many concept as possible to the language)
Re:TypeScript 5.0 by jiggawatts on Thursday March 16, 2023 @06:42PM (#35189929)
I've been saying the same thing: We need an ahead-of-time compiled high level, business language. Something as efficient as Rust, but not designed for embedded microcontrollers or systems software.

I feel like the entire industry has had a "kneejerk reaction" to C++ and its abysmally slow compile times. Everyone jumped onto the interpreter bandwagon and ended up throwing the baby out with the bathwater.

It is definitely possible to have sub-second compile times for large, complex software! Just look at Jonathan Blow's Jai language. He can recompile and reload an entire 3D game engine in about that time.

We can have our cake and eat it to. We can have efficient, compiled languages and still have safety and fast compilation.

Re:TypeScript 5.0 by kaba0 on Thursday March 16, 2023 @07:01PM (#35190153)
> Everyone jumped onto the interpreter bandwagon

I can only think of Ruby and Python that use a strictly interpreter mode (in their most common runtime).

Java, C# use a hybrid solution, but for all practical purposes they are running as extremely efficient machine code, how is it not “efficient business language”?

Re:TypeScript 5.0 by jiggawatts on Thursday March 16, 2023 @07:03PM (#35190171)
They're both JIT compiled, not ahead-of-time compiled. This severely limits the type of optimisations that they can perform, because they have to do it "on the fly" during runtime.
Re:TypeScript 5.0 by kaba0 on Thursday March 16, 2023 @07:31PM (#35190464)
Being pedantic, both have AOT compilers readily available.

But sure, though I don’t really buy the argument that JIT compilers would “severely limit” the type of optimizations - there is no significant performance difference - if any - between AOT compiled managed languages and JIT-compiled ones. Sure, there are more constraints in case of a JIT, but it’s not like going in the other direction and letting gcc/clang chew 10x time more on the same program would give you a significant speedup, if any. Speculations (which are not possible AOT) may even reverse the fields.

D, Haskell, OCaml, Go are all in the same ballpark as Java and C#, and even JS, hell, they may be better.

Re:TypeScript 5.0 by jiggawatts on Friday March 17, 2023 @03:45AM (#35194379)
The AOT compiled managed languages are hamstrung in no small part by their fundamental design, which was intended for virtual machines. Java and C# were designed in the 1990s. Since then, hardware has changed. For example, indirect calls are much more expensive in relative terms, and the memory bloat introduced by template metaprogramming is much less of a limitation.

Imagine a language as easy to use as Python, with the strong typing of Typescript, but designed from the ground up to always be fully compiled and hence running as fast as C++, but with build times measured in fractions of a second... fast enough to feel interpreted.

Re:TypeScript 5.0 by kaba0 on Friday March 17, 2023 @04:04AM (#35194468)
The biggest speedup one could get on modern hardware (in single-threaded context) comes from effectively using the CPU caches and in certain cases, vectorization. Clever use of these can give you 10-100x speedups.

This extra optimization is somewhat offset by the very point of a managed language: the programmer don’t want memory layout details to leak into the design/APIs, but in the rare case it is needed it can be done just as well with the escape hatches they provide (byte buffers, value types also bring you quite far). But business logic seldom involve these scorching hot loops to begin with, so there may not even be anything to optimize in this manner.

Re:TypeScript 5.0 by eldenring on Friday March 17, 2023 @12:58AM (#35193321)
Sounds like OCaml.
Re:TypeScript 5.0 by kaba0 on Thursday March 16, 2023 @06:57PM (#35190111)
Scala 3, or perhaps OCaml.
Re:TypeScript 5.0 by cmrdporcupine on Thursday March 16, 2023 @08:17PM (#35190885)
You just described OCaml or StandardML.

Or as others have said, F#, or maybe Scala. Or if you're feeling really brainy, Haskell.

But Rust was, in its early days, basically inspired by the ML type system, its type inference model, and its pattern matching facilities. The first Rust compiler was written in OCaml.

Re:TypeScript 5.0 by spion on Thursday March 16, 2023 @10:18PM (#35192065)
Haskell doesn't (or didn't last time I tried it) have the documentation and example culture of Rust.
Re:TypeScript 5.0 by laurencerowe on Thursday March 16, 2023 @10:46PM (#35192297)
> 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.

This basically describes all of the recent ML – perhaps more specifically OCaml – influenced languages like Kotlin, Swift, F#. (Rust is also heavily influenced by OCaml but its distinguishing feature is manual memory management with lifetimes.)

I do wish we had a good Linux/Posix option with as good of a package manager as Rust's cargo. Kotlin and Swift have some support but are largely focussed on the JVM and MacOS respectively. OCaml itself is of course an option here but its syntax and smaller ecosystem is a stumbling block. Reason is an attempt at a more familiar syntax for OCaml but that community is mostly focussed on transpilation to JavaScript with ReScript.

Re:TypeScript 5.0 by spion on Thursday March 16, 2023 @11:13PM (#35192518)
Its not quite that simple. Some of the things that Rust gets right are subtle, but typically punted by many other languages. Documentation containing fully working examples due to thos examples being run by doctests, for example, is kinda rare.

Here is another more subtle but important example: flexible API for error conversion, powerful language features and macros together enable the language, in conjunction with libraries like https://docs.rs/anyhow/latest/anyhow/ which gets you the best of all worlds in error handling: concise `?` operator for writing error handling code, eas to add additional message context (using `with_context` from anyhohw), differentiating between functions that can and cannot throw in the types (Result<T>), and the ability to get exception style backtraces from Result, too (that last one seems to be rare)

Another subtle QoL which is often overlooked when implementing macros: `compile_error!` (and soon even more powerful diagnostic API). With that, macros can report custom errors back to the programmer via the compiler and language service, rather than becoming an incomprehensible mess. For example, the peg parser macro will mark errors with infinite left-recursive rules that don't have caching set up with custom error messages.

Re:TypeScript 5.0 by spion on Friday March 17, 2023 @09:08PM (#35204985)
And yeah I totally agree with you regarding `cargo`, in my mind thats also one of the things that don't seem to be related to the language but the quality of life improvements end up being huge.
Re:TypeScript 5.0 by throw_m239339 on Thursday March 16, 2023 @03:17PM (#35186904)
> 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.

Typescript types don't exist at run time, at all. So it's easy to be better when your language is merely about static analysis as it will not enforce any sort of type system during runtime. Java, Go or C++ have different constraints.

Re:TypeScript 5.0 by dimitropoulos on Thursday March 16, 2023 @03:32PM (#35187122)
that's a false equivocation in the sense that you just moved the goalposts by defining what "runtime" means.

There are no types whatsoever as far as processors are concerned. No types in assembly Not for Go or Java, not for C, and not for Rust. All you gotta do is keep compiling.

Re:TypeScript 5.0 by throw_m239339 on Thursday March 16, 2023 @03:35PM (#35187169)
> that's a false equivocation in the sense that you just moved the goalposts by defining what "runtime" means.

I disagree, Javascript does have types and runtime type errors, just not all the ones Typescript compiler has, it makes Typescript extremely leaky as a Javascript abstraction. Typescript compiler cannot represent every single Javascript type combination either, it will would have to be a Javascript interpreter at first place.

Re:TypeScript 5.0 by yencabulator on Thursday March 16, 2023 @05:43PM (#35189134)
Runtimes exist above processors, you know.

Here's types existing at runtime: https://go.dev/play/p/rc--yVzJ9bt

Re:TypeScript 5.0 by kaba0 on Thursday March 16, 2023 @07:16PM (#35190303)
To be honest, that’s the “default” way of type systems - without runtime reflection capabilities type erasure is just a normal phase of an AOT compiler, why would you store types?
Re:TypeScript 5.0 by hackandthink on Thursday March 16, 2023 @03:27PM (#35187042)
>If we could push JavaScript performance to be another order of magnitude faster

And it would speed up the TypeScript Compiler.

My bet is:

TypeScript typechecker in Rust:

https://github.com/dudykr/stc

Re:TypeScript 5.0 by epolanski on Thursday March 16, 2023 @06:29PM (#35189770)
TS is implementation-defined, it doesn't have a spec like C or Java.

It's simply impossible to keep up with TS for competing compilers.

Re:TypeScript 5.0 by rr888 on Thursday March 16, 2023 @03:52PM (#35187434)
I agree TS is great. Not really multi threaded kills it for me though.
Re:TypeScript 5.0 by jdlshore on Thursday March 16, 2023 @04:23PM (#35187937)
Threads are a function of the environment, and are available in TS and other compiles-to-JS languages:

Node.js: https://nodejs.org/api/worker_threads.html

Browser: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers...

However, threads are very rarely needed. The common use case in other languages is I/O, and JS environments handle that with async I/O—a superior choice, IMO.

Re:TypeScript 5.0 by illiarian on Thursday March 16, 2023 @04:42PM (#35188234)
Neither of those are proper threads, and they have various limitations placed on them.

And the language and the VM has been, and will be for any foreseeable future, single-threaded.

Re:TypeScript 5.0 by postdb on Friday March 17, 2023 @02:49AM (#35194047)
Deno supports vastly superior threading model (such as green threads). Again depending on what you are coding, threading may not be the best model. Look at Ngnix vs Apache (event driven vs threading).
Re:TypeScript 5.0 by illiarian on Friday March 17, 2023 @07:42AM (#35195678)
> Deno supports vastly superior threading model (such as green threads)

Whatever it supports, Javascript-the-language has no concept of threads. And workers are basically external processes with a somewhat awkward event-based communication and certain limitations.

Whatever Deno uses internally to implement them has no bearing.

Re:TypeScript 5.0 by 5e92cb50239222b on Friday March 17, 2023 @07:50AM (#35195782)
JFYI, apache httpd has had a similar event-driven request processing module for about 10 years, maybe more.

https://httpd.apache.org/docs/2.4/mod/event.html

Re:TypeScript 5.0 by mekster on Thursday March 16, 2023 @04:42PM (#35188248)
If performance is the only concern to pick a language, world is far simpler.
Re:TypeScript 5.0 by treis on Thursday March 16, 2023 @06:02PM (#35189409)
The jankiness of JS combined with the correctness of TS really is a powerful combo. Especially stuff like string keys and const arrays as enums make safe and readable code without a lot ceremony.

The big problem is the gap between TS and JS. User defined typeguards are a usable work around but it would be nice to be able to use a native isMyType function.

Also would be nice to have constraints natively in types. Like string lengths or max ints.

Re:TypeScript 5.0 by epolanski on Thursday March 16, 2023 @06:28PM (#35189742)
You can do all you list with effect-ts/schema.

Arguably the highest quality TS lib out there.

https://github.com/Effect-TS/schema

Re:TypeScript 5.0 by munbun on Friday March 17, 2023 @12:34AM (#35193156)
this looks like a better documented io-ts
Re:TypeScript 5.0 by epolanski on Friday March 17, 2023 @05:45AM (#35195001)
The author is the same of io-ts and t-comb, but capabilities go well beyond io-ts (including the experimental modules).

Being able to generate types, encoders, decoders, apis, guards and even arbitrary data is extremely powerful.

Re:TypeScript 5.0 by iainmerrick on Friday March 17, 2023 @05:52AM (#35195040)
At first glance this looks similar to Zod (which is listed as an influence). What does @effect/schema do differently/better?

I feel like the name could use a bit of work for a start! "schema" is way too generic.

Re:TypeScript 5.0 by chatmasta on Friday March 17, 2023 @07:03PM (#35204055)
In our project at work, we've been using superstruct since 2021, but if we started today we'd probably choose Zod. We also use fp-ts, and it looks like effect-ts is a recent project by the same author, which certainly gets my attention.
Re:TypeScript 5.0 by treis on Friday March 17, 2023 @09:30AM (#35196815)
The sibling post illustrate the problem. Lots of different libraries in this area and hard to know which one to pick. Also just kind of seems wrong to use a library for types in a language that is for types only.
Re:TypeScript 5.0 by epolanski on Thursday March 16, 2023 @06:23PM (#35189667)
Better is hard to qualify but I'll add my 2 cents:

- for functional programmers TS offers lots of flexibility and power many other languages including statically typed and pure don't

- TS functions or methods that throw don't show up in the type system (they do in Java)

I hope TS keeps getting stricter.

Re:TypeScript 5.0 by iainmerrick on Thursday March 16, 2023 @08:45PM (#35191164)
One thing I wonder is whether a “strict mode” subset of TS could be compiled to efficient code. Disallow “any” and most of the dynamic and meta programming features of JS so it’s fully typesafe.

The type system is really nice, so even without being able to use the full range of JS hacks and escape hatches, I think it’d still be a nice language to work in.

Re:TypeScript 5.0 by awestroke on Friday March 17, 2023 @04:40AM (#35194660)
TS by itself is not fully sound which could complicate such a compiler.
Re:TypeScript 5.0 by iainmerrick on Friday March 17, 2023 @05:30AM (#35194933)
Yes, those sorts of loopholes would need to be closed. I was imagining a subset of the language, but there might need to be some breaking changes to cover cases like that. Maybe it would end up being so different that it would be an entirely different language? I don't know! But it's hard for me to accept that non-soundness in TS is necessary for TS itself rather than just an unfortunate consequence of the JS language and library that it has to build on top it.