Fork me on GitHub
#off-topic
<
2019-06-04
>
didibus00:06:34

Aren't types optional in type script? And also unsound?

drone00:06:45

search for “unsound” here (https://www.typescriptlang.org/docs/handbook/type-compatibility.html) for some relevant parts

drone00:06:27

I think the answer to your first question is no. the second is yes

didibus01:06:41

Oh interesting. I thought Typescript was optionally typed. How does it handle any JS dependencies otherwise? Is it trying to re-impmement a full stack all the way down? And not use any of the JS standard libs?

dpsutton02:06:54

I thought it was. And a easy way to start is to rename the file extension from js to ts

lilactown02:06:07

It is typed js. Like other typed langs, if you don't know the type just specify "any" 😁

lilactown02:06:34

The compiler has different options to automatically fill in anything it doesn't know about as any

lilactown02:06:10

The type system is unsound, but for the purposes of "tell me wtf this prop obj might be," it's ok

lilactown02:06:02

I think it's not great for doing more type-level programming a la ML / Haskell

lilactown02:06:55

It's goals are to be able to specify most of the JS ecosystem

Drew Verlee15:06:44

Thoughts on strange loop pre-conf options? i'm leaning towards TLA+ or PWL.

Drew Verlee16:06:22

it looks like TLA+ is aimed at the TLA crowd and not a wider audience, i doubt i would be able to get much out of it given that 🙂

didibus18:06:47

That sounds like optional typing to me

didibus18:06:58

If the compiler defaults all types to any

didibus18:06:09

Then its optionally typed

didibus18:06:43

Which is the same as typed clojure

didibus18:06:56

The question is though, is it gradually typed?

didibus18:06:06

Which would be similar to typed racket

dpsutton18:06:27

i don't see the difference then

didibus18:06:43

Gradual typing means that runtime checks are added at runtime between typed and untyped code as well

didibus18:06:46

So static typed would be that all things must have a type or be explicitly made the type of all types. That type can be inferred, but not inferred to the any type. The compiler would complain for all things that can't be inferred or don't have an explicit type declaration. This would extend to even your dependencies. Thus everything must be typed all the way down and up the stack.

didibus18:06:23

That would be Java, C#, C++, Haskell, OCaml, etc.

dpsutton18:06:48

ah i see. i missed the runtime checks versus just unification at compile time

didibus18:06:26

Optional type means that everything is of the type of all types (like any or Object) by default. But if some things are explicitly declared or inferred to be of a more specific type, when they are used with other things that are also declared or inferred to be of a specific type, then the compiler will validate at compile time that they are compatible.

didibus18:06:23

Yup, and gradual is like optional, except that at runtime, it will add a check for things that have a declared or inferred more specific type so that even when used with things of the default compile time type of all types they at runtime are checked against the actual specific runtime type.

didibus18:06:02

I'm wondering what compromise TypeScript made that somehow makes it more likely to be used then TypedClojure. I think its soundness. Because typed Clojure didn't want to compromise on soundness, it had to compromise usability I think

lilactown18:06:09

also, dev hours

lilactown18:06:39

typescript has a ridiculous amount of people working on it compared to typedclojure

didibus19:06:45

Hum... I don't buy that one, unless you can specify what that translates too in terms of features or bugs. Though I could buy into the marketing hour argument 🤑

3Jane19:06:08

> developed and maintained by Microsoft

3Jane19:06:29

imo, that's it.

didibus19:06:10

Let me clarify, I don't mean, why is TypeScript more popular then ClojureScript.

didibus19:06:04

I'm mean, why with people already using Clojure/Script did Typed Clojure not gain the same kind of popularity as TypeScript did with regard to JavaScript users

3Jane19:06:51

Right, I see 🙂

didibus19:06:52

Given ClojureScript users are already okay using something developed by a minuscule team of open source volunteers.

didibus19:06:42

Ya, I have no doubt that ClojureScript, even if typed, will never compete against TypeScript in total user share

didibus19:06:48

But for example, as someone who finds ClojureScript awesome and already more featured or smarter featured then JavaScript, even though it has like 100 times less (if not more) the dev power behind it. I just can't buy into dev power being the issue

didibus19:06:58

Personally, I suspect it's due to JavaScript being way worse then Clojure to begin with, and thus types being way more useful in that context. And to the fact that typed Clojure went for a sound type system, which meant also that it is more complicated to type things with it. Whereas I think type script is going for more of a simple Java like type system.

lilactown20:06:36

TypeScript's system is quite a bit different than Javas. it supports structural type system and many more dynamic things, e.g. external interface extension (similar to Clojure protocols)

didibus05:06:31

I still consider those simplistic type systems. Maybe Java's is even simpler, but then let's take C#, which supports those. What I mean by complex type systems are when you have support for heterogeneous typed data-structures, support for typing higher order functions, things like that. I mean, maybe TypeScript has that as well.

didibus05:06:22

So, I'm not 100% sure about this. But from what I understand, this is where sound vs unsound comes into play.

didibus05:06:16

For example, with TypedClojure, as I understand, either you can type the function in a way that doesn't allow for any runtime type mismatches, or the function is not typable at all.

didibus05:06:13

But I think I might be missing something here. As I can't really come up with an example of such scenario

didibus05:06:22

But, say I go back to my heterogeneous example. In C# or Java, you would declare it as a List of Object. But in TypedClojure, you can say it's a List of String, Int, or other Maps of Longs and Keywords.

lilactown15:06:07

yes they have sum types

lilactown15:06:36

this convo is getting to the point where I don’t know how much more my words can help; maybe try TypeScript out if you’re so interested?

lilactown15:06:02

TypeScript is quite different than Java, I can tell you

lilactown15:06:34

Java is purely nominal typing. TypeScript has great support for structural typing, which is IMO the only thing that makes it tenable to use with existing JS

lilactown15:06:06

it also has support for higher-order functions etc.

lilactown15:06:23

I would suggest giving it a try if you’re interested in learning more

didibus15:06:31

Okay, interesting. I didn't know that. I do have it on my todo list, but I have a lot of things before that 😋. I'm more fascinated by the motivation of users of JS to adopt TypeScript then TypeScript itself. Since in Clojure land, the promesses of optional types failed to motivate users. And that's purely my curiosity at play, I have no practical reason to need to learn about this.

didibus15:06:05

Thanks for helping out with some clarification about TypeScript.that I didn't know.

lilactown15:06:16

right, it’s just frustrating to participate in a discussion when you

lilactown15:06:10

whoops, sent that before I finished: it’s a bit frustrating to participate in a discussion about it when I say, “here’s my opinion based on my experience,” and you say, “well I don’t buy that”

lilactown15:06:24

I don’t take it personally, just giving you the feedback that my desire to continue pontificating about it kind of wore out when it felt like you disregarded my experience without validating it or your own thoughts with a bit of research

didibus15:06:43

Eh, sorry. I can see how it could be frustrating. I was mostly triggered by http://frenchy64.github.io/2018/04/07/unsoundness-in-untyped-types.html and used that as my source of knowledge to start off with.

didibus15:06:48

That article make it sound like TypeScript made some compromise to simplify the Type System in order to provide a better UX to users, at the expense of safety.

lilactown15:06:36

I do think that soundness is one attribute that may have contributed to TypeScript’s rise in popularity

lilactown15:06:45

but I don’t think it’s the whole story

lilactown15:06:30

another comparison to make is Flow (another “typed JS” language) and TypeScript

lilactown15:06:24

Flow is sound, and quite a bit less popular now than TypeScript. but for awhile, it was the de facto standard for Facebook-adjacent projects (since it’s developed by them). it has fallen in favor in the last year or two

lilactown15:06:07

some people make the argument it’s the sound vs unsound property of the two, but many others argue that it’s actually due to horrid mismanagement of the team, lack of bug fixes and features, and the state of tooling for it compared to TS now

didibus15:06:22

Which I am still under the impression that it is true. Though I didn't know how complete the type system was. It's possible those simplification are a big reason for it succeeding where core.typed failed as well.

lilactown15:06:54

gah, my ipad keyboard is killing me

lilactown15:06:27

for an example of a completely sound type system with positive uptake, look at ReasonML + BuckleScript

didibus15:06:31

Right, I can see that. I'm just not sure it's true of core.typed. Which is pretty easy to get started with. And the author of it is amazing. But the thing is, I don't know how awesome the TypeScript tooling and experience is. So I should probably try. Maybe if I did I'd realize core.type also lacks polish.

lilactown15:06:26

😁 experience trumps theory. would suggest giving it a try on a dummy project. even better if you have a JS project that you can try converting

lilactown15:06:49

note I’m definitely not here to shill for TS. ultimately, I didn’t find it as productive as Clojure(Script) nor as compelling in terms of future-state as ReasonML + BuckleScript. but if I needed to wrangle some JS project at work, it would be my choice of tool

didibus16:06:00

Ya, actually you motivated me to try Typescript a lot more. So I'm going to have and bump it up a few notches on my todo list 👌

didibus16:06:07

Reason and BuckleScript look awesome. Though for now, I'm still a Clojure/Script fanboy. What I've been wondering is if that last remaining itch for types when using Clojure/Script could be scratched if it had a type system inspired by TypeScript, which might be unsound in places, but because of it, could provide much better convenience and usability. Anyways, I'll stop bothering you 😁, and I'll investigate TypeScript first by trying it before I comment on it anymore. Thanks again. Sorry if in parts of it I sounded a bit stubborn and misguided.

didibus19:06:00

Though, maybe having Microsoft add types to all of the core JS libs, where in typed Clojure, no one spent the time to do that plays a big role. And that could be attributed to dev power maybe

Jimmy Miller19:06:39

You also have a lot of people who are forced into the frontend using typescript. People who don't want to touch javascript and are more comfortable with C# and Java. Not saying that is the only group. But I do think it is a sizeable one.

kulminaator19:06:57

i still think ts is a weird beast ... even if popular ...

didibus19:06:32

The biggest issue I've heard from people who used Typed Clojure in prod is that it just wasn't worth the effort

didibus19:06:00

Like they found it provided little value, while adding too much overhead when coding.

didibus19:06:37

I wouldn't be surprised if most people who like TypeScript is just because of auto-complete in IDE 😋

dpsutton19:06:27

refactoring in TS is much easier than refactoring in JS

didibus19:06:45

Personally, that's also like the only thing I miss in Clojure when it comes to types. Its not really the type checking, but the possible tooling support

didibus19:06:37

For the refactoring, you're not afraid you missed some stuff that were untyped?

didibus19:06:09

I feel knowing that not everything has to be typed, I'd be worried and still would do a regex search over the project just in case.

dpsutton19:06:19

it's worst case is the normal case in JS

dpsutton19:06:35

so its either purely better or the same

didibus19:06:28

Ya, I guess so. Even in Java I always do a regex search as well, because there's always one or two weird reflective access or just plain strange use that the refactorer misses on. And there's the issue of dependent packages too.

kulminaator20:06:21

i also miss out in typed stuff 🙂

kulminaator20:06:48

it just eliminates one source of errors, it isn't a magic wand

kulminaator20:06:06

i still typehint whenever i feel there's a need .. but i get more and more often annoyed in java-land when i have to generate useless types and subclasses just to get through some gates

lilactown20:06:20

my point is that: even if TypedClojure and TypeScript are built on the same concepts, that the amount of features and polish that TypeScript can deliver is going to be far above what TypedClojure can deliver

lilactown20:06:58

when you start talking about typing, that's mainly a dev UX thing.

lilactown20:06:01

so TypeScript being able to say, "We've developed enough features into the type system that we can infer 80% of the types, 10% of the types you need to be explicit, and the other 10% you just any it"

lilactown20:06:19

"also, our dev tooling is very fast and gives good feedback, with lots of documentation + resources to help solve common issues"

lilactown20:06:37

is great value beyond just the ideas and concepts

lilactown20:06:11

the integration with VS Code is also a killer feature

lilactown20:06:33

if we say there are three types of development: Prototyping, Plumbing and Polish. TypeScript is able to keep adding new features (Prototyping), great integrations with existing tech and libraries (Plumbing), and great tooling, error messages, docs, across many platforms (Polish)