|
crazysim posted:mypy? these abbreviated burns are getting obscure
|
![]() |
|
![]()
|
# ? Jun 7, 2023 23:49 |
|
crazysim posted:mypy? so as i understand it, flow and anders hejlsberg's personal type playground (typescript) have type systems designed specifically to express js idioms safely, and to be able to make it easy to write these langs by having good type inference. the former is why ts/flow have things like union types (which are not a thing in real langs like java) and string literal types (which are just odd). given that these langs are more mature, i'd expect them to be more thorough and robust than e.g. mypy i was idly wondering how much you could take from the ts/flow type systems and apply to another dynamic lang like python, given that these are known to work well with one very dynamic type system. obviously there are some problems beyond relatively superficial syntax/library differences - inheritance models, python's metaclasses, language idioms, ..., but if your core type system works with one plang, couldn't it work pretty well with other plangs? although thinking about this while i wrote this post led me to the conclusion that that idea makes no sense and is stupid and i'm just a simple idiot
|
![]() |
|
redleader posted:although thinking about this while i wrote this post led me to the conclusion that that idea makes no sense and is stupid and i'm just a simple idiot different p-langs would have very different type systems - the way js and python treat values and existing "what can pass where" constraints aren't similar afaik
|
![]() |
|
I'm not sure about the technical part (what limits mypy compared to typescript/flow) but I know the motivations were different. js typing is hella "weak" compared to python (think of how 1 + "1" is "11", you don't get much of that in python) so there wasn't the same desperate urge to put everything into a static typing wrapper in python for a long time.
|
![]() |
|
ts does some stupidly advanced compile-time magic that I'm not sure would be at all straightforward to map to a different runtime with a different representation of objects like look at this poo poo: https://www.typescriptlang.org/docs/handbook/advanced-types.html posted:Mapped types
|
![]() |
|
gonadic io posted:different p-langs would have very different type systems - the way js and python treat values and existing "what can pass where" constraints aren't similar afaik as much as I like using python for small fart apps as much do I dislike the duck typing and of course the whole js thing of “where we’re going we don’t need ints “
|
![]() |
|
yeah i used mapped types in TypeScript to build a high-order React component the other day. you could wrap a table rendering component with a table hoc together with some comparison functions and the inner component would receive an object with callbacks it could bind to header click events that change the sort order. and intellisense works with this object-of-callbacks. but it took a very long time to get the types right because the hoc has to take a props type for the inner object, slice off one set of props, add another, and pass everything else through verbatim. ts typing is structural but there's an idiom for making it nominative by making the compiler pretend at compile time that there's some extra properties on say a string or something, so you can use type checking to make sure you don't pass a widget id to a function expecting a customer id even though they're both just strings with no extra properties at run time literal types are fantastic and neatly slot into a whole bunch of other typescript features like union types and intersection types and keyof. things like tagged unions aren't even an explicit typescript feature, they just arise naturally out of literal types and union types and the fact that the compiler tracks and modifies the type of a particular variable through different paths through a conditional statement or expression depending on what that expression proves about the particular instance you're dealing with. it's actually kind of hosed up how good typescript is
|
![]() |
|
i put together a fairly complicated backend that requires a lot of domain knowledge to build the request, so i thought, "hey, i'll make life easier putting together a small typescript library to help in reducing some of the pain." boy was that a mistake. i soon learned that typescript is barely better than javascript, the build system is insane, and trying to get a map implementation that works with non-string, non-int types is a tremendous poo poo show. i promptly uninstalled the node and yarn packages from my system.
|
![]() |
|
Shaggar posted:powershell is bad but its probably the least bad shell scripting language Sometimes the Shaggar voice is right
|
![]() |
|
Sapozhnik posted:it's actually kind of hosed up how good typescript is I’d be tempted to try it but that would mean doing webdev and/or interacting in any way whatsoever with the node ecosystem, and those are my two programming red lines
|
![]() |
|
i decided recently that i'm going to start to take javascript a little bit more seriously. i need one scripting lang that i'm solid with, and right now that's ruby. but i also need to know a good deal of javascript by virtue of working with web tech. so i'm gonna consolidate to js.
|
![]() |
DONT THREAD ON ME posted:i decided recently that i'm going to start to take javascript a little bit more seriously. i need one scripting lang that i'm solid with, and right now that's ruby. but i also need to know a good deal of javascript by virtue of working with web tech. which js though ![]()
|
|
![]() |
|
cinci zoo sniper posted:which js though es6 with some notion of how to use typescript, probably. i'll get familiar with node but not gonna learn any js web frameworks because fuuuuuck youu.
|
![]() |
|
is it possible to just learn typescript before js? if so, you should do that. I think js is going to be dead in like a year or so compared to typescript and webassm+whatevers I learned js first, so I don't even know if it makes sense to pick up typescript without js.
|
![]() |
|
Finster Dexter posted:is it possible to just learn typescript before js? if so, you should do that. I think js is going to be dead in like a year or so compared to typescript and webassm+whatevers i've always been really skeptical of typescripts ability to really isolate you from javascripts bullshit. but apparently it does a good job. but i realized that imo the most unique part of javascript is learning about the browser runtime environment. as long as typescript doesn't isolate you from learning about that, i dunno, yeah, maybe you can just skip js. but also you're eventually going to need to tinker around in a browser that doesn't support TS and it's probably good to know how to do things.
|
![]() |
|
i remember nim having nice editor tooling last time I poked at it, which was a pleasant surprise although it's possible my baseline for "nice" has been skewed by RLS which works approximately 1/10 of the tine
|
![]() |
|
rls going stable shook my faith in rust a good deal
|
![]() |
|
lua status: ugh why do metatables let you override equality but not hashing, so it is literally impossible to create a type that is suitable for use as a table index
|
![]() |
|
typescript doesn’t isolate you from poo poo all. your errors will still be in another language often enough to matter. and a lot of your dependencies will be too so I hope those never have problems or require reading and understanding
|
![]() |
|
Sapozhnik posted:yeah i used mapped types in TypeScript to build a high-order React component the other day. you could wrap a table rendering component with a table hoc together with some comparison functions and the inner component would receive an object with callbacks it could bind to header click events that change the sort order. and intellisense works with this object-of-callbacks. but it took a very long time to get the types right because the hoc has to take a props type for the inner object, slice off one set of props, add another, and pass everything else through verbatim. imagine putting in all this effort to convince yourself you're not doing web dev
|
![]() |
|
Finster Dexter posted:is it possible to just learn typescript before js? if so, you should do that. I think js is going to be dead in like a year or so compared to typescript and webassm+whatevers I think because your libs will be in JS it does pay to know your JS. But that said you could probably get pretty far with Typescript and typescript maps for debugging. I've really just started using typescript coming from a Java/Java script background and Typescript is a god send really. We have to support IE11 so being able to transpile into ES5 is great, not having to worry about globally scoped events between Chrome and Firefox etc.
|
![]() |
|
DONT THREAD ON ME posted:rls going stable shook my faith in rust a good deal
|
![]() |
|
animist posted:i remember nim having nice editor tooling last time I poked at it, which was a pleasant surprise omg gently caress rls don't touch that garbo and use intellij instead
|
![]() |
|
Soricidus posted:lua status: ugh why do metatables let you override equality but not hashing, so it is literally impossible to create a type that is suitable for use as a table index IIRC you gotta do it with a special table and __index / __newindex. You can't make an object that specially hashes with regular tables. Out of curiosity, what exactly are you trying to do here?
|
![]() |
|
redleader posted:ts/flow have things like union types (which are not a thing in real langs like java) ... i'm just a simple idiot
|
![]() |
|
Sagacity posted:agreed. that made very little sense, a bit like "we're giving up, let's just call it stable and be done with it" like i woulda been totally fine with it sucking as long as it's unstable, that's just responsible development. it's not like I have to depend on it in my build, so i don't mind it being unstable. but they just reaaaally had to check that 'great ide support by default' box on the marketing page.
|
![]() |
|
CRIP EATIN BREAD posted:boy was that a mistake. i soon learned that typescript is barely better than javascript, the build system is insane I had a similar experience, the build system was too complicated back then and I had limited time so I decided to just go back to regular javascript
|
![]() |
|
DONT THREAD ON ME posted:like i woulda been totally fine with it sucking as long as it's unstable, that's just responsible development. it's not like I have to depend on it in my build, so i don't mind it being unstable. the dev responsible said he just wanted a way for more people to start trying it, which.. man. i dunno. do they even use it?
|
![]() |
|
Soricidus posted:lua status: ugh why do metatables let you override equality but not hashing, so it is literally impossible to create a type that is suitable for use as a table index constant lua status: dear god what were the designers thinking
|
![]() |
|
gonadic io posted:omg gently caress rls i thought it was interesting that the original developer of the plugin has since left jetbrains and is working on an rls successor. he seems a lot more reluctant to call it stable.
|
![]() |
|
Beamed posted:the dev responsible said he just wanted a way for more people to start trying it, which.. man. i dunno. do they even use it? at least the intellij plugin is written by someone who understands how to write a language plugin, simply because it wasn't his first attempt
|
![]() |
|
Zaxxon posted:IIRC you gotta do it with a special table and __index / __newindex. You can't make an object that specially hashes with regular tables. Out of curiosity, what exactly are you trying to do here? i was just trying to use a 64-bit integer as a table index, but it turns out lua doesn't have a native 64-bit integer type (or rather, isn't guaranteed to, it depends how you compile it!) and the int64 type i've been using is actually a userdata with a metatable that makes it behave almost exactly like any other number except in this one specific case! the solution i went with was just to convert them to strings before using them as indices. i like the idea of a special table that removes that step, didn't think of that, and i've already got a special table with __index and __newindex anyway because i also want a consistent iteration order. florida lan posted:constant lua status: dear god what were the designers thinking nah i know what they were thinking. it was, in every case: "we're trying to make a language that's easy to implement, not a language that's easy to use. gently caress users, just do the simplest thing that can possibly work"
|
![]() |
|
Soricidus posted:nah i know what they were thinking. it was, in every case: "we're trying to make a language that's easy to implement, not a language that's easy to use. gently caress users, just do the simplest thing that can possibly work" in true p-lang style. i consider go an honourary p-lang
|
![]() |
|
man the pdf spec is some impenetrable nonsense ![]()
|
![]() |
Krankenstyle posted:man the pdf spec is some impenetrable nonsense it’s a/nonsense
|
|
![]() |
|
cinci zoo sniper posted:it’s a/nonsense lol ![]()
|
![]() |
|
Krankenstyle posted:man the pdf spec is some impenetrable nonsense this is your daily reminder that pdfs are fully turing complete and contain executable code to produce your document
|
![]() |
|
Can I use JavaScript in a PDF to expose a REST interface to access the pdf data? It would be cool if I could just turn on directory browsing on a web service and "update my webservice" by using PUT requests to drop in restful pdf files.
|
![]() |
|
do not tempt the gods
|
![]() |
|
![]()
|
# ? Jun 7, 2023 23:49 |
|
floatman posted:Can I use JavaScript in a PDF to expose a REST interface to access the pdf data? hmmm, I think you should store the data in MongoDB using a Java interface.
|
![]() |