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
tef
May 30, 2004

-> some l-system crap ->

MononcQc posted:

there's a risk in conflating dynamic typedness of the languages with all of the other poo poo a language like javascript lets you do that may have to do as much with other properties often intertwined like monkey patching, type juggling, and strong dependencies on evaluating pieces of script to make dependencies work. There's more possible, but nothing forces a given dynamic language to give into these features.

cf implicit casts being the work of the devil

and static type systems rarely allowing dynamic types

Adbot
ADBOT LOVES YOU

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

tef posted:

outside of c# this isn't that common as far as i am aware?

almost every language has some equivalent of Variant or Object or some other "put whatever poo poo you want in here" type.

tef
May 30, 2004

-> some l-system crap ->
all i want is to be able to express the constraints and invariants my program displays, have them enforced by runtime checks, and to be able to report any decidable failures

without having to use a toy subset that's trivially checkable statically

tef
May 30, 2004

-> some l-system crap ->

cis autodrag posted:

almost every language has some equivalent of Variant or Object or some other "put whatever poo poo you want in here" type.

that's not quite the same as `dynamicinvoke`

sarehu
Apr 20, 2007

(call/cc call/cc)

tef posted:

all i want is to be able to express the constraints and invariants my program displays, have them enforced by runtime checks, and to be able to report any decidable failures

I think you should only get that with the cost of a one character unary operator to announce the dynamic type conversion. In exchange you don't have to put a colon in front of everything.

Arcsech
Aug 5, 2008
oh cool, a types discussion

generally I prefer static typing, but it can be really bad, and some implementations of dynamic typing are pretty cool (elixir is nice)

gently caress monkey patching though. If it's in a language some moron is going to use it for something "clever" and it's going to eventually explode in some incredibly obtuse way

e: also gently caress implicit casts, yeah

gonadic io
Feb 16, 2011

>>=

lol sure and i'll exercise, eat healthily, and not spent 16 hours today on my laptop

uncop
Oct 23, 2010
IMHO the javascript object model would be positively mad genius instead of horrifying if the objects were immutable maps instead of mutable maps. Or should i go to the terrible programmer thread?

Mahatma Goonsay
Jun 6, 2007
Yum

uncop posted:

IMHO the javascript object model would be positively mad genius instead of horrifying if the objects were immutable maps instead of mutable maps. Or should i go to the terrible programmer

[quote="uncop" post="469789874"]
IMHO the javascript object model would be positively mad genius instead of horrifying if the objects were immutable maps instead of mutable maps. Or should i go to the terrible programmer thread?

immutable js is pretty good if you want something like this.

AggressivelyStupid
Jan 9, 2012

gonadic io posted:

lol sure and i'll exercise, eat healthily, and not spent 16 hours today on my laptop

woah let's not get crazy

Soricidus
Oct 21, 2010
freedom-hating statist shill

tef posted:

anyway what i was saying was that people who advocate static types are hostile to work with, much like the tools they advocate

wow rude. i just like my ide to be able to tell me what i can do with a variable, i'm not saying everyone who uses python should be rounded up and sent to a death camp

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Rice's theorem tells us that it is impossible to statically determine nontrivial semantic properties of programs that run on a Turing machine. Type systems produce simplified abstract models of programs which are (hopefully) tractable to analyze. In my experience, the utility of static typing relates to the scale and complexity of a program.

Short, simple programs fit inside my skull at once, and while static types may still be a useful mental discipline, I can do without them just fine. I can see why people who mostly work on small, independent programs would consider static type declarations needless overhead.

As programs become larger and are maintained by many people they no longer fit in my head at once. Static checks become extremely valuable indicators that global properties of a codebase are retained as I make changes. Tests can provide the same guarantees (and are the only way of verifying behaviors a given type system can't capture), but a compiler is far better at enforcing constraints consistently than programmers.

I think relatively simple static type systems (say, something like Pascal) capture much of the low-hanging fruit. As type systems become more complex, there's a diminishing return. Some programmers seem to become so caught up in building and exploring type abstractions that they lose sight of programming.

Bloody
Mar 3, 2013

static typists: I will reason about my problem and define it in such a way that this box can provide me with strong guarantees about correctness before I run it and find out

dynamic typists: pee pee doo doo stick it in a dictionary

AWWNAW
Dec 30, 2008

there's a reason Rich Hickey and crew are writing Clojure spec and it ain't because types suck

Cybernetic Vermin
Apr 18, 2005

is the point your trying to make that a language is not dynamic if it is possible to talk about the types of things within it? i think you may be rather far afield going that route

Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer
the other thing a good type system can give you is a more explicit modelling of your problem space
i stole this from some blog post, but you can see that in a couple of dozen lines it's possible to lay out what data you're going to be working with and what the relationships you care about are
code:
type Suit = Spades | Hearts | Clubs | Diamonds

type Rank = Two | Three | Four  | Five |  
            Six | Seven | Eight | Nine | 
            Ten | Jack  | Queen | King | Ace

type Card = Rank * Suit  
type Deck = Card list

type Player = { Name : string; Hand : Card list }

type Game = { Deck : Card list  
              Players : Player list 
              CurrentPlayer : Player
              DiscardPile : Card list }

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





AWWNAW posted:

there's a reason Rich Hickey and crew are writing Clojure spec and it ain't because types suck

clojure.spec isn't a static type checker though?

it's a way of adding (runtime) type information to your program. you can build a static type checker on top of it if you want i guess but the really interesting thing about clojure.spec is the ability to use type information to check type invariants at runtime. it's a really powerful and flexible way to assert, basically

clojure.spec is a prime example of something that is hard to do in a statically typed language but easy (ish) to do in a dynamic language. to do something similar in a static language you'd need something like idris' type provider system

i think there's a general lack of charity on both sides of the static/dynamic types debate. static type advocates think dynamically typed programs are the wild west where users just spray code and pray it works while dynamic type advocates see static typing as an inescapable straight jacket into which you must fit your code. the truth is that dynamically typed programs usually assert correctness at program boundaries and then rely on unit tests, asserts, structural typing and primitive type checking (like unused symbol warnings) to ensure correctness while almost every static type system has outs like `Object` in java and scala, `interface{}` in go and type holes in haskell for dynamic behaviour in their type checker and every moderately complex program in a statically typed language still has plenty of runtime type checking going on

i would love to use a statically checked language with the expressiveness of a dynamic language but as far as i'm aware there's no language out there that has a sound type system, row polymorphism, a good standard library and a solid runtime and compiler. elm is pretty close for a very limited subset of problems and rust has enough benefits to outweigh what it lacks in expressiveness but my experience with java, scala, c++ (all of which i've written professionally) and go (which i've only used personally) have sent me running back to dynamically typed languages (python, erlang, elixir, clojure, javascript) over and over again

Sapozhnik
Jan 2, 2005

Nap Ghost

comedyblissoption posted:

I think that some statically typed languages are abominable and less productive than some dynamically typed languages. I also think that OOP-mania in statically typed langs is really awful and most dynamically typed langs have thankfully shied away from that. so yah just simply using some static typing isn't a panacea, but a good static type system or staying away from the OOP-mania bits is probably a great boon to productivity.

modern java is about as object-oriented as modern china is communist

it's more of a Javanese Object Orientation With Functional Characteristics ideology these days

JewKiller 3000
Nov 28, 2006

by Lowtax

tef posted:

anyway what i was saying was that people who advocate static types are hostile to work with, much like the tools they advocate

absolute unmitigated nonsense

Malcolm XML
Aug 8, 2009

I always knew it would end like this.
Even Guido is all about types

tef
May 30, 2004

-> some l-system crap ->

JewKiller 3000 posted:

absolute unmitigated nonsense

thanks jew killer 3000

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

comedyblissoption posted:

I think that some statically typed languages are abominable and less productive than some dynamically typed languages. I also think that OOP-mania in statically typed langs is really awful and most dynamically typed langs have thankfully shied away from that

which dynamically typed languages are you thinking of exactly that aren't centered around object-oriented programming, because oop is pretty core to python, ruby, and javascript

Cybernetic Vermin
Apr 18, 2005

this could be the most primitive level of discussion seen in this thread so far, it'd be some kind of strawman argument but what is argued against has not quite progressed beyond the point of a single straw yet

JewKiller 3000
Nov 28, 2006

by Lowtax

tef posted:

thanks jew killer 3000

"people who use this thing i don't like are bad, much like that thing is bad!" what an insightful post, not made-up bullshit at all

what's actually hostile to work with is a program full of unnecessary bugs. when a static type checker points out a problem, it's not being hostile, it's being helpful!

although i'll admit i might start to get annoyed if one of my coworkers displayed such disrespectful unwillingness to learn the tools and techniques needed to do his loving job correctly

sarehu
Apr 20, 2007

(call/cc call/cc)

tef posted:

anyway what i was saying was that people who advocate static types are hostile to work with, much like the tools they advocate

you're a tool i advocate

<3

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
btw I've been writing a lot of SQL on postgres lately and man the error messages are so great sometimes, I think those are best hints I've seen in any programming language

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

sarehu posted:

you're a tool i advocate

<3

I'm a big fan of all the tools itt, even the ones I don't agree w/

JewKiller 3000
Nov 28, 2006

by Lowtax

Symbolic Butt posted:

btw I've been writing a lot of SQL on postgres lately and man the error messages are so great sometimes, I think those are best hints I've seen in any programming language

me too and yeah it's great! you can create those errors in your functions too: raise exception 'its broke' using hint = 'better fix it idiot';

FamDav
Mar 29, 2008

tef posted:

anyway what i was saying was that people who advocate static types are hostile to work with, much like the tools they advocate

tef posted:

i should get a job

tef
May 30, 2004

-> some l-system crap ->

JewKiller 3000 posted:

"people who use this thing i don't like are bad, much like that thing is bad!" what an insightful post, not made-up bullshit at all

what's actually hostile to work with is a program full of unnecessary bugs. when a static type checker points out a problem, it's not being hostile, it's being helpful!

although i'll admit i might start to get annoyed if one of my coworkers displayed such disrespectful unwillingness to learn the tools and techniques needed to do his loving job correctly


sarehu posted:

you're a tool i advocate

<3

hope you two enjoy working together

tef
May 30, 2004

-> some l-system crap ->
i'm not hostile, i'm not hostile, i yell into the green and black void

tef
May 30, 2004

-> some l-system crap ->
i mean i can go back to yelling about deferred type errors, or threesomes with blame, or row polymorphism, or higher kinded types

like, at least if you were arguing for total functional programming, you'd just be a little bit more consistent in the level of decidability of your types and your programs

i could write some long effort post like ttd about how things like runtime inspection of types is pretty neat, or how type systems need to handle versioning of types (hello protobufs, gob, etc, or i could hark on about how robust behvaiour comes from good error handling not bug elimination)

sure if i'm writing something with complex types, like a compiler, tbh, static typing is a useful dicipline,

and yet when you talk to static typing advocates they present it as a complete black and white problem "you do it this way, or you're wrong", or if you will you do it this way or you're showing such disrespectful unwillingness"

you fucks haven't even written a program in constraints and you're telling me to use this pissy little backwards rear end homebrew ad-hoc theorem prover to demonstrate some subset of correctness and you're the ones getting mad at me for not verifying my program in crayon

tef
May 30, 2004

-> some l-system crap ->
it is really such a contentious thing to suggest that type systems are both weak in what they can check and also unfriendly in terms of explaining errors and diagnostics, which a handful of exceptions here and there

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





tef posted:

it is really such a contentious thing to suggest that type systems are both weak in what they can check and also unfriendly in terms of explaining errors and diagnostics, which a handful of exceptions here and there

i think a lot of static typing fans just think things like row polymorphism and structural typing are inherently unsafe and that rather than sacrifice static types for increased expressiveness or striving for more powerful type checkers they'd rather just declare dynamic typing 'wrong'

Arcsech
Aug 5, 2008

tef posted:

i mean i can go back to yelling about threesomes with blame

text me

sarehu
Apr 20, 2007

(call/cc call/cc)
"expressiveness"

Brain Candy
May 18, 2006

so there's this problem

data from world
layer 1
layer 2
...
layer n

i really want any problems with the data to be handled right away. if it gets any farther into things, I'll have no idea where the problem is

null: a billon dollar mistake, etc.

i could also do this

AWWNAW posted:

there's a reason Rich Hickey and crew are writing Clojure spec and it ain't because types suck

because hey automatic insertion of asserts serves the same purpose of failing as soon as possible

but if you expect me to recheck the data by hand every time, gently caress you

Brain Candy
May 18, 2006

i mean maybe the crazy idea is that static typing is an optimization? which means it's sometimes appropriate and sometimes not?

Smoke_Max
Sep 7, 2011

the talent deficit posted:

i think a lot of static typing fans just think things like row polymorphism and structural typing are inherently unsafe and that rather than sacrifice static types for increased expressiveness or striving for more powerful type checkers they'd rather just declare dynamic typing 'wrong'

I'm not sure about structural typing, but row polymorphism can definitely be done in a type-safe way. An example of a language that does it is Purescript, where, as an added bonus, it can also be inferred.

Adbot
ADBOT LOVES YOU

abraham linksys
Sep 6, 2010

:darksouls:
i just treat static typing as a really smart linter. works out okay. typescript is basically just eslint except you add a few special bits to your code that get stripped away. also as an added bonus, my text editor can do smarter things like tell me how to use a method in a third party api.

there's other stuff i want from my tools that typing doesn't check. my biggest pain point as a web developer is that i wish i had checks that i'm correctly consuming or producing the resources for a REST API, and I want these checks to exist at runtime, too. you need to make a fuckload of assumptions to make this work well, though, so idk if it's a reasonable request. it's a nice dream though.

i've never worked anywhere that was very good at runtime assertions, tbh. i like react's propTypes thing, but like, i don't know how to apply that concept in the general. i'm terrified of all of our ruby code at work. like, absolutely scared out of my mind when i work on it. because it's rails and i have no idea what assumptions, if any, i can make about any of the code paths. that's not the kinda problem static typing is really gonna solve, i don't think. but i think static languages tend to have a more obvious design, for purposes of type checking, and that helps?

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