Fork me on GitHub

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


search for “unsound” here ( for some relevant parts


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


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?


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


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


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


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


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


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 🙂


That sounds like optional typing to me


If the compiler defaults all types to any


Then its optionally typed


Which is the same as typed clojure


The question is though, is it gradually typed?


Which would be similar to typed racket


i don't see the difference then


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


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.


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


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


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.


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.


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


also, dev hours


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


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 🤑


> developed and maintained by Microsoft


imo, that's it.


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


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


Right, I see 🙂


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


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


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


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.


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)


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.


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


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.


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


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.


yes they have sum types


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?


TypeScript is quite different than Java, I can tell you


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


it also has support for higher-order functions etc.


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


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.


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


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


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”


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


Eh, sorry. I can see how it could be frustrating. I was mostly triggered by and used that as my source of knowledge to start off with.


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.


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


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


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


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


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


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.


gah, my ipad keyboard is killing me


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


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.


😁 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


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


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 👌


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.


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


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.


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


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


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


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


refactoring in TS is much easier than refactoring in JS


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


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


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.


it's worst case is the normal case in JS


so its either purely better or the same


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.


i also miss out in typed stuff 🙂


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


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


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


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


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"


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


is great value beyond just the ideas and concepts


the integration with VS Code is also a killer feature


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)