Post AX7FHMKS9vVzSbLLaC by icedquinn@blob.cat
(DIR) More posts by icedquinn@blob.cat
(DIR) Post #AX7ENL0rrfFjA8TANk by pimeys@social.nauk.io
2023-06-27T11:44:13.041638Z
0 likes, 0 repeats
So here I am, a seasoned #Rust developer, starting to learn #programming with #TypeScript a few months ago. Today’s the day when my first TypeScript library is released.It’s definitely a weird language. You have the wild west of #JavaScript, a language designed in a few weeks back in the 90’s, which is now the most popular language in the world. On top of it, some very smart people designed a type system that most of the time is helpful and gives quite cool tooling for building things that (hopefully) do not break all the time. Rarely people talk about what you really can do with the type system. For example, defining a function where the input type can define the fields of the output type, this is something you cannot do in Rust, but is quite possible with TypeScript.My next project goes even further to the depths of TypeScript. The sad part is that all these crazy things you can do with the types, people don’t really talk about it as they do about React or the latest frontend framework. They are minimally documented, and you just have to read the sources of open libraries to understand their usage. It’s very overwhelming. And documentation seems to be for the losers, which differs a lot from what I’m used to with Rust.
(DIR) Post #AX7ENLzUEHk4C8pZrs by icedquinn@blob.cat
2023-06-27T11:46:08.723352Z
0 likes, 0 repeats
@pimeys best part about javascript is it was almost hypertalk (a popular scripting language of the 90s.) it was futzed up because management was obsessed with "that java language from sun" and wanting to cram buzzwords in to netscape navigator.
(DIR) Post #AX7ExOMmsDmfzKujLM by pimeys@social.nauk.io
2023-06-27T11:48:16.807344Z
1 likes, 0 repeats
@icedquinn Yeah, and you build this extremely advanced type system on top of it. It’s still the same language, with some extensions, but still the same weird quickly defined language is what fuels the whole ecosystem.With TypeScript, you can define types in a way that will not be that readable for anybody else after a while, or for yourself if I’m completely honest:export type BlogCollectionFetchPayload< S extends BlogConnectionSelect | null | undefined> = S extends BlogConnectionSelect ? BlogConnectionFetchPayload<S> | null : never// Payload to return a subset of fields of a user.export type UserFetchPayload<S extends UserSelect | null | undefined> = S extends UserSelect ? { [P in TruthyKeys<S>]: P extends 'blogs' ? BlogCollectionFetchPayload<S[P]> | null : P extends 'address' ? AddressFetchPayload<S[P]> | null : P extends keyof UserNode ? UserNode[P] : never } : never
(DIR) Post #AX7ExPCBn6tuYkxmSm by icedquinn@blob.cat
2023-06-27T11:52:39.092469Z
0 likes, 0 repeats
@pimeys i think type systems probably lead to madness. a little bit of component/trait composition and some light lisp macros do wonders :blobcatjustright: though honorable mention to nelua and euphoria for having hilarious type systems that consist of like. just resorting to a scripting language :blobcatlaugh2: nelua type concepts are seriously just something you register with the compiler, as a lua script, that gets to inspect the type passed in and returns true/false if it matches. meaning type checks are literally just really basic lua and can validate anything you want :comfymelt:
(DIR) Post #AX7FDfwTIOrH8CMyY4 by pimeys@social.nauk.io
2023-06-27T11:54:13.316988Z
1 likes, 0 repeats
@icedquinn I think right now the most interesting idea is the comptime in Zig. I haven’t tried it yet, but it looks like you can just write normal imperative Zig to define for example, that the int parameter for your function must be more than zero…
(DIR) Post #AX7FHMKS9vVzSbLLaC by icedquinn@blob.cat
2023-06-27T11:56:17.382900Z
0 likes, 0 repeats
@pimeys i disagree with zig when it comes to operator overloads. i like to use those where they make sense, like geometric algebra code. so i don't really know what they have been up to.people seem to like zig though.