News for hackers. Stuff that matters.
Re:Deno will stop using TypeScript by efficax on Sunday June 21, 2020 @11:43AM (#23592608)
there's plenty of huge software projects in dynamically typed languages.

There are also huge classes of bugs that exist in these projects that a statically typed language completely eliminates!

If they're running into trouble from having to have types, it's almost certainly design and architecture issue and does not make me think that deno is going to be a solid project.

Re:Deno will stop using TypeScript by snarfy on Sunday June 21, 2020 @11:57AM (#23592727)
For dynamically typed languages, the idea is you make up for that class of bugs by incorporating TDD and having lots and lots of unit tests.

So, instead of waiting a minute for the typescript compiler, you wait for the engineer to write tests.

Re:Deno will stop using TypeScript by waheoo on Sunday June 21, 2020 @09:32PM (#23596726)
If youre doing tdd or writing tests like this you have bigger problems.

Type safety is easy in a dynamic language. Stop mutating variables and stop mixing types. Suddenly that whole class of errors evaporates. No need to test things that are impossible.

And for those times you want some magic in your life, nothing is stopping you, no need for generics, just proceed with caution and test accordingly.

Re:Deno will stop using TypeScript by gameswithgo on Sunday June 21, 2020 @12:50PM (#23593198)
and you wait a minute for the tests to run every time you commit a change
Re:Deno will stop using TypeScript by dboreham on Sunday June 21, 2020 @01:05PM (#23593344)
You could arrange to have a program write those tests for you based on your description of the project's data model. Oh wait...
Re:Deno will stop using TypeScript by kybernetikos on Sunday June 21, 2020 @01:33PM (#23593591)
You know what, that would already be better than most type systems.

Firstly, they'd be written in the same language that you are coding in, not a weird, half baked type language, that adds visual noise to your code.

Secondly, they'd have much more power to define meaningful and useful behaviour rather than being restricted to talk about correct behaviour via types.

Thirdly, they'd run when you wanted the tests to run, and you could tier different tests to run at different times, so they aren't all slowing you down while you're doing fast iteration.

I used to like types, but then I realised that what matters is how quickly you see the bug. Seeing it in your code editor is brilliant, but if it's slower in time than hitting control S and seeing the actual app in the other pane auto reload, and fail or not, then it's worse.

These days I look on the idea that you know the exact types of all data your program will interact with at the time you write your code as the same sort of mistake that we made when we thought we understood the deep inheritance hierarchies of the real world.

Re:Deno will stop using TypeScript by goostavos on Sunday June 21, 2020 @06:30PM (#23595894)
That's an interesting take. To some degree, I think I agreeing with you.

I write a lot of Purescript and a lot of Clojure. Purescript, being basically a Haskell variant, is about closing down every last little part of the system into types. You _do_ pick up a lot of visual noise for this (like `liftEffect` ugh...). Whereas Clojure, is the polar opposite. It's about keeping the system open, using large chunks of data, and having functions take/change what they need and pass along everything else none-the-wiser to what's present.

Bouncing back and forth between these two worlds, I think I've begun to lean towards the opinion that I really only care about strict types at the boundaries of my program and certain very specific checkpoints along the way (generally, something like a module/namespace boundary).

Clojure has Spec, but it misses the mark in my opinion because it doesn't solve refactoring. It's not (currently) instrumented enough to help the me as a human make changes to the code without also just "bumping into the guard rails" to try and figure out what I broke along the way.

A middle ground orthogonal type system sounds really appealing to me. "Type coverage" is an idea I've been kicking around. Something like Spec in Clojure, but more symbiotic with the host code such that it can tell you things _about_ your code and help in refactoring, symbol resolution, etc..

That's a lot of words, but tl;dr I think I agree with you : )

Re:Deno will stop using TypeScript by kybernetikos on Tuesday June 23, 2020 @05:16PM (#23620418)
Thanks for treating my comment charitably, and for adding your experience. Type systems often seem to bring out the extremist in otherwise reasonable developers.

It's quite obvious that there are downsides to types that most developers are missing - because most developers seem to feel that they get massive benefit from types, but empirical studies seem to show that if there really are benefits, they are not massive.

I see the downsides in a few ways - they open up another avenue for 'architecture astronauting', they are not in fact accurate representations of the real world in many situations - you're dealing with files, or messages coming in from the network which are not typed, and even when they are (e.g. databases), they can change under your code while you're running. That's not to mention the points I made above around usually being an entirely different, hobbled language that gets sprinkled through your source code. Types encourage people to build ridiculous code generation pipelines during build time, and builds getting larger and flakier are about the worst thing in the world for fast iteration. I find the Smalltalk approach of coding in a live image really interesting, and I worry that obsession with types are closing off that kind of future. There's also the fact that your language, and particularly your type system constrains what code you write - like a programming version of Sapir Whorf, and most type systems are bad at expressing very high levels of abstraction. Scala had to invent a documentation tool that hid the real types of things because the type signature of higher order functions like map and reduce were scaring people.

I was interested in your opinion of Spec, because I'm aware of it and find it interesting, but I don't do a lot of Clojure so I haven't really used it practically. I liked that it aimed to address more than just verification - schemas, object generation for property testing, these things are all closely related to the general concept.

I think your ideas about a middle ground type system seem very interesting.

I saw recently that there's a version of Nim 'DrNim' that incorporates the Z3 theorem prover which allows you to assert and prove much more interesting things than typical type systems. It sounds fascinating.

Re:Deno will stop using TypeScript by ptx on Sunday June 21, 2020 @02:45PM (#23594254)
If your application has any structure at all, you can often just run the tests for the part you're changing while you're working and committing locally. Once you're ready to push it you should probably run all the tests first even if your language has static types.
Re:Deno will stop using TypeScript by ptx on Sunday June 21, 2020 @02:42PM (#23594212)
> you wait for the engineer to write tests

Which, if we're doing TDD, involves no waiting at all, since it was already written before the implementation. Ideally anyway.

Re:Deno will stop using TypeScript by mimixco on Sunday June 21, 2020 @11:51AM (#23592674)
I didn't read that types were causing problems. My understanding was TS, itself, was causing problems. Specifically waiting around for it to compile.

Strong typing is from OOPS, itself an optional programming methodology. There are many JS programs that simply access other (JSON) objects directly without going through an interface. In these instances, typing is counterproductive.

One of the beautiful things about JS (and Lisp) is that variables and functions are interchangeable and, the case of JS, both can be accessed directly without worrying about an interface.

Re:Deno will stop using TypeScript by jackjeff on Sunday June 21, 2020 @12:06PM (#23592792)
Just use Typescript static types where it is useful. If you access a bunch of JSON objects and you don’t need the typing, you can always declare as ‘any’ and move on.

At the end of the day those type exist in JavaScript. If you access ‘first_name’ instead of ‘firstname’ it will not work. The difference is that typescript would let you know before running the code instead of getting an obscure runtime error.

Re:Deno will stop using TypeScript by austincheney on Sunday June 21, 2020 @12:59PM (#23593289)
Deno is having problems with TypeScript, but TypeScript is not the cause of that problem. The problem is a self inflicted issue of a name collision of their choosing.
Re:Deno will stop using TypeScript by jorams on Sunday June 21, 2020 @01:11PM (#23593397)
Slow compile times are very much a problem caused by TypeScript.
Re:Deno will stop using TypeScript by austincheney on Sunday June 21, 2020 @02:17PM (#23593999)
You can do any manner of stupid things to make any compiler of any language to behave slowly, but that doesn’t mean all compilers are slow. If you want better output don’t deliver garbage for input.
Re:Deno will stop using TypeScript by eitland on Sunday June 21, 2020 @01:53PM (#23593768)
My 3 year old laptop has no problems with TypeScript (neither Angular nor React), and I am a rather impatient guy when it comes to computers.

I'm honestly wondering: What are people doing to end up in a position where TypeScript compile times are a problem?

Re:Deno will stop using TypeScript by austincheney on Sunday June 21, 2020 @02:26PM (#23594076)
It is something to do with a class in their code named something similar to header conflicting with a same named definition in their index.d.ts file that is closely related to that class instance.

If they dropped use of classes, or differentiated the names of the two things in collision the problem would appear to be solved.

To turn that around and blame TypeScript as the point of failure is an extremely bad omen suggesting their code style opinions are more important than product delivery. I could live with that nonsense if this were a framework or some minor dependency, which this application is not.

Re:Deno will stop using TypeScript by thomasrognon on Sunday June 21, 2020 @02:34PM (#23594144)
My compile time went from seconds to minutes when I made a recursive immutable type (which I reverted of course). Overall, I still love typescript.

Edit for the curious, here's the monster type that caused such pathological build times...

  type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
  export type Immutable<T> =
    T extends ImmutablePrimitive ? T :
    T extends [infer U]                                     ? readonly [Immutable<U>] :
    T extends [infer U, infer V]                            ? readonly [Immutable<U>, Immutable<V>] :
    T extends [infer U, infer V, infer X]                   ? readonly [Immutable<U>, Immutable<V>, Immutable<X>] :
    T extends [infer U, infer V, infer X, infer Y]          ? readonly [Immutable<U>, Immutable<V>, Immutable<X>, Immutable<Y>] :
    T extends [infer U, infer V, infer X, infer Y, infer Z] ? readonly [Immutable<U>, Immutable<V>, Immutable<X>, Immutable<Y>, Immutable<Z>] :
    T extends readonly [infer U]                                     ? readonly [Immutable<U>] :
    T extends readonly [infer U, infer V]                            ? readonly [Immutable<U>, Immutable<V>] :
    T extends readonly [infer U, infer V, infer X]                   ? readonly [Immutable<U>, Immutable<V>, Immutable<X>] :
    T extends readonly [infer U, infer V, infer X, infer Y]          ? readonly [Immutable<U>, Immutable<V>, Immutable<X>, Immutable<Y>] :
    T extends readonly [infer U, infer V, infer X, infer Y, infer Z] ? readonly [Immutable<U>, Immutable<V>, Immutable<X>, Immutable<Y>, Immutable<Z>] :
    T extends Array<infer U> ? ImmutableArray<U> :
    T extends ReadonlyArray<infer U> ? ImmutableArray<U> :
    T extends Map<infer K, infer V> ? ImmutableMap<K, V> :
    T extends ReadonlyMap<infer K, infer V> ? ImmutableMap<K, V> :
    T extends Set<infer M> ? ImmutableSet<M> :
    T extends ReadonlySet<infer M> ? ImmutableSet<M> :
    ImmutableObject<T>;
  type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
  type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
  type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
  type ImmutableObject<T> = { readonly [K in keyof T]: Immutable<T[K]> };
Re:Deno will stop using TypeScript by tigershark on Sunday June 21, 2020 @01:32PM (#23593579)
No, it’s not counterproductive to access JSON objects using a predefined schema, it saves your ass in case of typos.