|
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
|
# ? Apr 24, 2014 14:21 |
|
|
# ? May 31, 2024 07:48 |
|
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
|
# ? Apr 24, 2014 14:22 |
|
Tiny Bug Child posted:it should return 4. concatenation !== addition what should "2"+"2" be?
|
# ? Apr 24, 2014 14:25 |
|
pointsofdata posted:what should "2"+"2" be? segfault
|
# ? Apr 24, 2014 14:27 |
|
But yeah, loving that Tiny Bug Child doesn't realise it's PHP's strong type system that's doing all this wonderful stuff.
|
# ? Apr 24, 2014 14:29 |
|
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 ~
|
# ? Apr 24, 2014 14:30 |
|
Tiny Bug Child posted:it should return 4. concatenation !== addition ghci> (read "2") + 2 >>> 4
|
# ? Apr 24, 2014 14:31 |
|
MononcQc posted:s/strong/weak/ ~ type juggling ~ If you can't reinterpret cast it's a strong system
|
# ? Apr 24, 2014 14:33 |
|
we can code php in haskell!code:
|
# ? Apr 24, 2014 14:38 |
|
Malcolm XML posted:ghci> (read "2") + 2 ghci> "2" + (show 2) >>> "22" with OverloadedStrings (and Read a => IsString a) can get ur "2" + 2 = 4 as well
|
# ? Apr 24, 2014 14:39 |
|
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
|
# ? Apr 24, 2014 14:41 |
|
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.
|
# ? Apr 24, 2014 14:42 |
|
Malcolm XML posted:ghci> "2" + (show 2) need undecidable instances tho so just goes to show u how bad of an idea this is
|
# ? Apr 24, 2014 14:43 |
|
Malcolm XML posted:ghci> "2" + (show 2) this is way better than my one
|
# ? Apr 24, 2014 14:47 |
"2" + 2.toString()
|
|
# ? Apr 24, 2014 15:06 |
|
oh, another pedantic argument about types, must be a day that ends in 'y'
|
# ? Apr 24, 2014 15:08 |
|
java is a good language that makes it easy to do things correctly and outright prevents the worst programming offenses
|
# ? Apr 24, 2014 15:09 |
|
Shaggar posted:java is a good language that makes it easy to do things correctly and outright prevents the worst programming offenses
|
# ? Apr 24, 2014 15:13 |
Shaggar posted:java is a good language that makes it easy to do things correctly and outright prevents the worst programming offenses
|
|
# ? Apr 24, 2014 15:15 |
|
What are numbers? We just don't know.
|
# ? Apr 24, 2014 15:15 |
|
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
|
# ? Apr 24, 2014 15:15 |
|
hold on we had a leap second my JVM went spinning at 100% CPU forever gotta reboot all my prod services
|
# ? Apr 24, 2014 15:17 |
|
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
|
# ? Apr 24, 2014 15:20 |
|
So Java 8. What's really left to wish for at this point?
|
# ? Apr 24, 2014 15:31 |
|
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?
|
# ? Apr 24, 2014 15:34 |
|
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 i guess properties are nice-ish? i can live without them though.
|
# ? Apr 24, 2014 15:35 |
|
value types would be nice. (this time for sure they have datetime figured out)
|
# ? Apr 24, 2014 15:35 |
|
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.
|
# ? Apr 24, 2014 15:50 |
|
Our application server doesn't support Java 8 so it's going to be a while before get on that train
|
# ? Apr 24, 2014 15:55 |
|
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!
|
# ? Apr 24, 2014 15:56 |
|
Default methods are stupid, extension methods loving own Java is poo poo and checked exceptions violate the end-to-end principle
|
# ? Apr 24, 2014 16:03 |
|
checked exceptions own and if you don't like them you are a bad programmer
|
# ? Apr 24, 2014 16:07 |
|
2banks1swap.avi posted:So Java 8. all the other poo poo in scala. java ain't got pattern matching
|
# ? Apr 24, 2014 16:07 |
|
2banks1swap.avi posted:So Java 8. 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~
|
# ? Apr 24, 2014 16:12 |
|
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
|
# ? Apr 24, 2014 16:14 |
|
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.
|
# ? Apr 24, 2014 16:47 |
|
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:
(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>.
|
# ? Apr 24, 2014 16:50 |
|
Soricidus posted:duck typing is a nice idea in theory 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
|
# ? Apr 24, 2014 17:00 |
|
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. 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
|
# ? Apr 24, 2014 17:08 |
|
|
# ? May 31, 2024 07:48 |
|
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.
|
# ? Apr 24, 2014 17:10 |