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
coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Tiny Bug Child posted:

next try the advanced case of adding "2" and 2.

should it return 4 or "22" though

or are you not fussed as long as it doesn't complain

Adbot
ADBOT LOVES YOU

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror
it should return 4. concatenation !== addition

e: that's the ideal case. returning "22" is acceptable as long as that behavior is clearly defined as what happens when you try to add a string number to a regular number. it's silly to think that's an error though

distortion park
Apr 25, 2011


Tiny Bug Child posted:

it should return 4. concatenation !== addition

e: that's the ideal case. returning "22" is acceptable as long as that behavior is clearly defined as what happens when you try to add a string number to a regular number. it's silly to think that's an error though

what should "2"+"2" be?

Zombywuf
Mar 29, 2008

pointsofdata posted:

what should "2"+"2" be?

segfault

Zombywuf
Mar 29, 2008

But yeah, loving that Tiny Bug Child doesn't realise it's PHP's strong type system that's doing all this wonderful stuff.

MononcQc
May 29, 2007

Zombywuf posted:

But yeah, loving that Tiny Bug Child doesn't realise it's PHP's strong type system that's doing all this wonderful stuff.

s/strong/weak/ ~ type juggling ~

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Tiny Bug Child posted:

it should return 4. concatenation !== addition

e: that's the ideal case. returning "22" is acceptable as long as that behavior is clearly defined as what happens when you try to add a string number to a regular number. it's silly to think that's an error though

ghci> (read "2") + 2
>>> 4

Zombywuf
Mar 29, 2008

MononcQc posted:

s/strong/weak/ ~ type juggling ~

If you can't reinterpret cast it's a strong system :colbert:

gonadic io
Feb 16, 2011

>>=
we can code php in haskell!

code:
ghci> import Data.Dynamic
ghci> :set -w -- who cares about warnings
ghci> instance Num Dynamic
ghci> toDyn "2" + toDyn 2 -- typechecks!

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Malcolm XML posted:

ghci> (read "2") + 2
>>> 4

ghci> "2" + (show 2)
>>> "22"

with OverloadedStrings (and Read a => IsString a) can get ur "2" + 2 = 4 as well

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

Zombywuf posted:

But yeah, loving that Tiny Bug Child doesn't realise it's PHP's strong type system that's doing all this wonderful stuff.

we were talking about static vs dynamic not strong vs weak. i don't think strong/weak typing even has a real definition. people who like the idea of types just use "strong" to mean "good" most of the time

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

pointsofdata posted:

what should "2"+"2" be?

4. those are numbers. again, "22" is acceptable if the language clearly defines that's what it's gonna do in this case, but this is why you really should have separate addition and concatenation operators.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Malcolm XML posted:

ghci> "2" + (show 2)
>>> "22"

with OverloadedStrings (and Read a => IsString a) can get ur "2" + 2 = 4 as well

need undecidable instances tho so just goes to show u how bad of an idea this is

gonadic io
Feb 16, 2011

>>=

Malcolm XML posted:

ghci> "2" + (show 2)
>>> "22"

with OverloadedStrings (and Read a => IsString a) can get ur "2" + 2 = 4 as well

this is way better than my one

double sulk
Jul 2, 2010

"2" + 2.toString()

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison
oh, another pedantic argument about types, must be a day that ends in 'y'

Shaggar
Apr 26, 2006
java is a good language that makes it easy to do things correctly and outright prevents the worst programming offenses

Sapozhnik
Jan 2, 2005

Nap Ghost

Shaggar posted:

java is a good language that makes it easy to do things correctly and outright prevents the worst programming offenses

double sulk
Jul 2, 2010

Shaggar posted:

java is a good language that makes it easy to do things correctly and outright prevents the worst programming offenses

gonadic io
Feb 16, 2011

>>=
What are numbers? We just don't know.

MononcQc
May 29, 2007

Shaggar posted:

java is a good language that makes it easy to do things correctly and outright prevents the worst programming offenses

like NULL pointer errors

MononcQc
May 29, 2007

hold on we had a leap second my JVM went spinning at 100% CPU forever gotta reboot all my prod services

Shaggar
Apr 26, 2006
the jvm is the best vm and minor bugs that affected a handful of people around the world aren't even close to the garbage caused by the existence of p-langs

Fuck them
Jan 21, 2011

and their bullshit
:yotj:
So Java 8.

What's really left to wish for at this point?

Shaggar
Apr 26, 2006
I still haven't used java 8 and may not ever cause all my new development is in c#. i wanted properties. did they add properties?

Sapozhnik
Jan 2, 2005

Nap Ghost
no but they basically imported the few things that c# did right without importing its multitudinous fuckups in the process so it's all good

also its new datetime api is :swoon:

i guess properties are nice-ish? i can live without them though.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

value types would be nice.

(this time for sure they have datetime figured out)

Shaggar
Apr 26, 2006
i wonder how many exceptions im completely ignoring in this c# code? well, who cares. if they were important I'd be forced to check them.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
Our application server doesn't support Java 8 so it's going to be a while before get on that train :(

qntm
Jun 17, 2009

AlsoD posted:

What are numbers? We just don't know.

the largest number is forty-five billion

but some mathematicians believe there may be even higher ones!

zokie
Feb 13, 2006

Out of many, Sweden
Default methods are stupid, extension methods loving own
Java is poo poo and checked exceptions violate the end-to-end principle

Shaggar
Apr 26, 2006
checked exceptions own and if you don't like them you are a bad programmer

Damiya
Jul 3, 2012

2banks1swap.avi posted:

So Java 8.

What's really left to wish for at this point?

all the other poo poo in scala.

java ain't got pattern matching

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

2banks1swap.avi posted:

So Java 8.

What's really left to wish for at this point?

anything and everything to do with primitives needs fixing (specifically the 17 different variants the stream api has to declare when it varies return type), though how to do it w/o breaking backwards compatibility idk

and type reification

and automatic type inference, though apparently that's intentionally not happening

and ive heard terrible things about JNI but haven't used it myself so~

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

Shaggar posted:

checked exceptions own and if you don't like them you are a bad programmer

i don't get the hate for them, if you don't want it checked just make it a runtime exception since if you don't want it checked it better not be recoverable

Sapozhnik
Jan 2, 2005

Nap Ghost

zokie posted:

Java is poo poo and checked exceptions violate the end-to-end principle

Not that I necessarily disagree, but what does this mean, exactly? if an outer layer throws a checked exception from an inner layer then that's just lovely design on the outer layer; if it really can't handle whatever went wrong then it ought to wrap that condition in a checked exception class of its own (or maybe even in an unchecked exception)

There are situations in which a given operation may fail to produce meaningful output, whether through your code or through code that you depend on to accomplish this result. How you react in those situations is something you have to think about : sticking your head in the sand or violently keeling over are certainly valid ways to handle them, but not necessarily good ones.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Sweeper posted:

i don't get the hate for them, if you don't want it checked just make it a runtime exception since if you don't want it checked it better not be recoverable

recoverability is pretty rare in practice, because it means you need to be effectively transactional in all your operations, or a thrown exception leaves you inconsistent. there are relatively few places in a program where you can throw away meaningful chunks and be in a consistent state; many fewer places than there are method calls.

the "have to type something to shut up the compiler" ergonomics are really bad, and leads to way more swallowing IMO. if the exception specification told you more about the context of the failure to guide recovery it might work better, but the Java type system isn't really expressive enough to do a good job there. it might be a better situation if type erasure didn't mean this:

Java code:

try {
  throw new MyException<PolicyBob>();
} catch (MyException<PolicyAlice>) {
  // this will catch all MyException<>s
} catch (MyException<PolicyBob>) {
  // won't run, ever
}

(not being able to parameterize a class' error model the same way you parameterize the class is another gripe)

this means you end up with a billion useless little classes whose only purpose is to have a different type signature, and wrapping exceptions all over in bespoke ways. take Runnable.run (please): everything is forced through RuntimeException because you can't be more descriptive in the signature of your own implementation. the prevalence of things like Guava's Throwable.propagate is a sign that the checked-exception experiment is a failure, IMO. maybe with grownup generics it would be OK, because then the type system would help you distinguish RemoteException<HostNotFound> from RemoteException<VersionMismatch>.

JewKiller 3000
Nov 28, 2006

by Lowtax

Soricidus posted:

duck typing is a nice idea in theory

like in java it's ridiculous that there are methods in the standard library that require a StringBuffer and i can't pass them a StringBuilder instead

but it's not clear that it makes up for losing static type checks

i kinda like how ocaml mixes the two, but nobody uses objects in ocaml so i guess it probably isn't that great in practice?

nobody uses objects in ocaml because once you have algebraic data types with type inference and a real module system, you find that you don't need or want to do object-oriented programming anymore

Cybernetic Vermin
Apr 18, 2005

Subjunctive posted:

recoverability is pretty rare in practice, because it means you need to be effectively transactional in all your operations, or a thrown exception leaves you inconsistent. there are relatively few places in a program where you can throw away meaningful chunks and be in a consistent state; many fewer places than there are method calls.

the "have to type something to shut up the compiler" ergonomics are really bad, and leads to way more swallowing IMO. if the exception specification told you more about the context of the failure to guide recovery it might work better, but the Java type system isn't really expressive enough to do a good job there. it might be a better situation if type erasure didn't mean this:

JewKiller 3000 posted:

nobody uses objects in ocaml because once you have algebraic data types with type inference and a real module system, you find that you don't need or want to do object-oriented programming anymore

good posts on this page

Adbot
ADBOT LOVES YOU

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Mr Dog posted:

Not that I necessarily disagree, but what does this mean, exactly?

so the end-to-end principle means that in a communications protocol, the intermediate nodes should be ignorant as to the meaning of the data being passed through them.

in the case of checked exceptions, every function in the stack between the throw() and the catch() needs to know about the exception, which means if the type of the exception is altered at the throw() end then every function up to the catch() needs to be altered.

a form of checked exceptions that'd satisfy the end-to-end principle (at least from the programmer's perspective) would be if the compiler automatically inferred the checked exceptions a function could throw, and only complained if any of them would be able to reach the bottom of the stack without being caught.

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