Hacker News new | ask | show | jobs
by dvt 2213 days ago
> Javascript is great. But... in saying that it has a few quirks and can work in some unexpected ways.

Typescript has just as many[1] (in fact more, as it's a superset) quirks than Javascript. I like using it (and it makes JS type-safe-ish), but it's not really some kind of paradigm shift.

Not sure how I feel about import maps. They are quite literally the same thing as package.json. In fact, converting between the two takes about 20 lines of code[2]. I'd bet my bottom dollar that everyone's going to use them, which is going to lead to exactly the same types of problems as Node.

[1] https://blog.asana.com/2020/01/typescript-quirks/

[2] https://github.com/WICG/import-maps/issues/60

3 comments

Frankly I find TypeScript with strict mode turned on to be a safer and saner than C# and Java because of explicitly nullable types alone. I _never_ get null pointer exceptions in my own TypeScript code. Combined with fairly strict ESLint you get something that catches a lot of problems at compile time.

Of course it's still far cry from being as safe as for example Rust.

And yeah the inconsistency of JavaScript/TypeScript can be frustrating for sure. I think my dream language is one that is simply TypeScript cleaned up to be made consistent and sheds a lot the features and retains a simple core.

C# 8 has support for non nullable references.

For lower C# versions and Java you can get your strict mode turned on via static analysis tools.

I have been using Sonar on CI/CD builds since 2008. Static analysis errors break the build, plain and simple.

Also quite convenient for writing sane C and C++ code by the way.

> I think my dream language is one that is simply TypeScript cleaned up to be made consistent and sheds a lot the features and retains a simple core.

I agree. I think this probably looks a lot like a Rust-lite (GC instead of lifetimes for memory management) or a Go with generics or a mature ReasonML?

Have you tried Kotlin?
Kotlin.js perhaps.
In regards to that first link, discriminated unions are awesome in general, it is a pattern that occurs all over the place in real world code and having compiler support for it is very nice.
100% agree that typescript has it quirks and definitely agree about import maps most likely going to be the way you use deno.

However there are tradeoffs with everything you use.

It really comes down to which tradeoffs are the right ones for you, which may not be the same for someone else.