Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Soricidus
Oct 21, 2010
freedom-hating statist shill

these abbreviated burns are getting obscure

Adbot
ADBOT LOVES YOU

redleader
Aug 18, 2005

Engage according to operational parameters

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

gonadic io
Feb 16, 2011

>>=

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

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
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.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

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

A common task is to take an existing type and make each of its properties optional:

code:
interface PersonPartial {
    name?: string;
    age?: number;
}
Or we might want a readonly version:
code:
interface PersonReadonly {
    readonly name: string;
    readonly age: number;
}
This happens often enough in Javascript that TypeScript provides a way to create new types based on old types — mapped types. In a mapped type, the new type transforms each property in the old type in the same way. For example, you can make all properties of a type readonly or optional. Here are a couple of examples:
code:
type Readonly<T> = {
    readonly [P in keyof T]: T[P];
}
type Partial<T> = {
    [P in keyof T]?: T[P];
}
And to use it:

code:
type PersonPartial = Partial<Person>;
type ReadonlyPerson = Readonly<Person>;

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER

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 “

Sapozhnik
Jan 2, 2005

Nap Ghost
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

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
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.

ThePeavstenator
Dec 18, 2012

:burger::burger::burger::burger::burger:

Establish the Buns

:burger::burger::burger::burger::burger:

Shaggar posted:

powershell is bad but its probably the least bad shell scripting language

Sometimes the Shaggar voice is right

Soricidus
Oct 21, 2010
freedom-hating statist shill

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

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
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.

cinci zoo sniper
Mar 15, 2013




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.

so i'm gonna consolidate to js.

which js though :v:

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

cinci zoo sniper posted:

which js though :v:

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.

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
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.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

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 learned js first, so I don't even know if it makes sense to pick up typescript without js.

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.

animist
Aug 28, 2018
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

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
rls going stable shook my faith in rust a good deal

Soricidus
Oct 21, 2010
freedom-hating statist shill
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

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
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

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

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.

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

imagine putting in all this effort to convince yourself you're not doing web dev

Aramoro
Jun 1, 2012




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 learned js first, so I don't even know if it makes sense to pick up typescript without js.

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.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

DONT THREAD ON ME posted:

rls going stable shook my faith in rust a good deal
agreed. that made very little sense, a bit like "we're giving up, let's just call it stable and be done with it"

gonadic io
Feb 16, 2011

>>=

animist posted:

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

omg gently caress rls

don't touch that garbo and use intellij instead

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik

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?

brap
Aug 23, 2004

Grimey Drawer

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

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

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.

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

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

Beamed
Nov 26, 2010

Then you have a responsibility that no man has ever faced. You have your fear which could become reality, and you have Godzilla, which is reality.


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.

but they just reaaaally had to check that 'great ide support by default' box on the marketing page.

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?

Qtotonibudinibudet
Nov 7, 2011



Omich poluyobok, skazhi ty narkoman? ya prosto tozhe gde to tam zhivu, mogli by vmeste uyobyvat' narkotiki

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

crazysim
May 23, 2004
I AM SOOOOO GAY

gonadic io posted:

omg gently caress rls

don't touch that garbo and use intellij instead

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.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

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?
here is his reasoning. I don't know if people use it. I certainly don't, not because I don't want to but because it's unusably broken

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

Soricidus
Oct 21, 2010
freedom-hating statist shill

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"

gonadic io
Feb 16, 2011

>>=

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

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



man the pdf spec is some impenetrable nonsense :shepface:

cinci zoo sniper
Mar 15, 2013




Krankenstyle posted:

man the pdf spec is some impenetrable nonsense :shepface:

it’s a/nonsense

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



cinci zoo sniper posted:

it’s a/nonsense

lol :hai:

gonadic io
Feb 16, 2011

>>=

Krankenstyle posted:

man the pdf spec is some impenetrable nonsense :shepface:

this is your daily reminder that pdfs are fully turing complete and contain executable code to produce your document

floatman
Mar 17, 2009
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.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



do not tempt the gods

Adbot
ADBOT LOVES YOU

FlapYoJacks
Feb 12, 2009

floatman posted:

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.

hmmm, I think you should store the data in MongoDB using a Java interface.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply