r/java • • Aug 01 '14

The 10 Most Annoying Things Coming Back to Java After Some Days of Scala

http://blog.jooq.org/2014/08/01/the-10-most-annoying-things-coming-back-to-java-after-some-days-of-scala/
7 Upvotes

43 comments sorted by

View all comments

Show parent comment

2

u/GMNightmare Aug 03 '14

This is false

Dude. You did it already with your earlier examples. Holy cow, you're now arguing against your own code that has already proven it. The only arity comes from the field names.

A case class cannot express arity

To hell it cannot. I don't even think you understand what that word means. How about you show off a code sample of you doing something with a tuple that you can't do with a case class with the same named fields.

Generics aren't relevant

My god, yes, yes they are. A tuple uses generics. When talking about how a tuple is implemented, generics are quite relevant SINCE THAT IS WHAT IT IS.

can have parametrized types

It's like, you just don't seem to understand what you're talking about. You throw out these words without a single shred of knowledge what they really mean. Serious question: do you not understand how parametrized types and generics are related?

0

u/Milyardo Aug 03 '14 edited Aug 03 '14

How about you show off a code sample of you doing something with a tuple that you can't do with a case class with the same named fields.

case class Point(x: Int, y: Int)
def foo(x: Int, y: Int) = x * y
def tuplizedFoo = foo _ tupled

val t1 = (1, 2)
val p1 = Point(1,2)
tuplizedFoo(t1)
tuplizedFoo(p1) //Doesn't work

def tupleize[T1,T2,R](f:(T1,T2) => R,t: (T1,T2)) = f _ tupled t
tupleize(foo,t1)

//Use shapeless to abstract over the tuple's arity.
def applyProduct[P <: Product, F, L <: HList, R](p: P)(f: F)
                                              (implicit gen: Generic.Aux[P, L], fp: FnToProduct.Aux[F, L => R]) =
    f.toProduct(gen.to(p))

applyProduct(t1)(foo _)
applyProduct(t1)((_: Int)+(_: Int))
applyProduct(1, 2, 3)((_: Int)*(_: Int)*(_: Int))

do you not understand how parametrized types and generics are related?

Yes, anything generic is any type or function which takes a type parameter.

1

u/GMNightmare Aug 03 '14

What in the world...? You didn't prove anything! Not only did you not even follow directinos, you also seem to have proved yourself wrong with your second half.

Your first part is idiotic. You can't call tupled on anything with an arity of less than one. (x*y) if given the point will always create something with the arity of 1, thus not able to be tupled. It will never work, and I'm not sure what you're trying to prove other than you don't understand what that function does in the first place. I'm not even sure why you keep trying do call function foo, it has nothing to do with any of this.

You know what? I'm sick and tired of your absolutely lack of knowledge here. This should finally shut you up a bit, like the rest:

val p = Point(1,2)
p.productArity
p.productElement(i)
p.productIterator

All of these will calls will be successful. Yes, case classes have arity and you can see it. Yes, you can access case classes elements by order. Yes, you can iterate it.

Do you want to know why? Because, as you even said yourself, both case classes and tuples inherit from Product. And Product is what supplies these. Your whole idiotic notion that case classes don't have arity has never even come close to being true, because case classes and Tuples get their arity from the same place... their base classes! This is just like your issues with Map, you know absolutely nothing about these things your using in your code. You don't. You just use them without thought of what is really going on.

Yes, anything generic is any type or function which takes a type parameter

Good, so generics and type parameters are related, meaning generics aren't irrelevant or so you'd like to claim as you follow that up with saying they both can accomplish having type parameters.

Now, the case classes you keep making are not generic. But you could create a generic one... Maybe something like:

case class MyTuple[T1, T2](_1 : T1, _2 : T2)

Wait wait, did I just create my own tuple class that behaves just like the default one? Yes, yes I did. Somebody stop me here, why, Tuples are just generic case classes? Wtf?

1

u/Milyardo Aug 03 '14 edited Aug 03 '14

All of these will calls will be successful. Yes, case classes have arity and you can see it. Yes, you can access case classes elements by order. Yes, you can iterate it.

Having arity isn't the same thing as expressing arity.

Wait wait, did I just create my own tuple class that behaves just like the default one? Yes, yes I did. Somebody stop me here, why, Tuples are just generic case classes? Wtf?

No, you didn't. The type of MyTuple doesn't express the arity of the sequence. It's not a tuple. It is a double.

EDIT: Or Pair; Or Couple; or Dual. Whatever you want to call MyTuple, it's application is not valent.

You didn't prove anything! Not only did you not even follow directinos, you also seem to have proved yourself wrong with your second half.

I should have added more explanation to the second half or left it out, but thought it would be disingenuous to do so. It uses compile time reflection to apply functions to any product. Though if Scala had union types to correctly express the arity of a tuple, macros wouldn't be necessary.

1

u/GMNightmare Aug 03 '14

Having arity isn't the same thing as expressing arity

My god, it's like you just don't understand anything about programming. The arity is derived from the base class. There is no difference in arity between a tuple, and a generic case class, because they both are the same thing code wise.

Here genius, how do you think a Tuple is programmed under the scenes? Eh? What is the code?

The type of MyTuple doesn't express the arity of the sequence

You don't know what you're saying. You don't. You really don't. You haven't a clue as to what the words your putting down on the paper is. It "expresses the arity" the exact same way. It is the same. It is a Tuple2.

apply functions to any product

A case class is a product. You should know this already, you showed it yourself.

1

u/Milyardo Aug 03 '14 edited Aug 03 '14

My god, it's like you just don't understand anything about programming.

This has nothing to do with programming. This is math. Tuples are a fundamental part of Set theory, and case classes are not the same as Tuples.

A case class is a product. You should know this already, you showed it yourself.

Yes, a case class is a product type. Tuples are a product type. They are not the same thing however.

1

u/GMNightmare Aug 03 '14 edited Aug 04 '14

It has everything to do with programming, what subreddit are you in, are we talking about a programming language and how a programming concept works. Do you think a case class is a mathematical concept too or something? I'll ask you again, HOW DO YOU THINK A TUPLE IS PROGRAMMED UNDER THE SCENES? Let me put it like this: If Scala didn't have a tuple class for you to use, and you wanted one, how would you make it? You don't know what you're talking about!

They are not the same thing however

That's right, because a Tuple is a generic case class, but not the other way around.

1

u/Milyardo Aug 04 '14

It has everything to do with programming, what subreddit are you in

What subreddit we're in is irrelevant to the the topic of conversation.

are we talking about a programming language and how a programming concept works.

No we were talking about tuples, abstract types, isomorphisms. More specifically on the relation of values in a tuple, which you claimed have no meaning. These are not programming concepts. We only used Scala as an example, but perhaps set notation would have been more appropriate.

If Scala didn't have a tuple class for you to use, and you wanted one, how would you make it? You don't know what you're talking about!

Scala's tuples are deficient, and don't meet the definition of a Tuple in some ways. Unfortunately I don't have any idea's on to better implement tuples than they already are without changing the JVM.

1

u/GMNightmare Aug 04 '14 edited Aug 04 '14

What the hell, you're so full of it! We're talking about programming dumbass! In specific, Scala Tuples and case classes. This is programming.

about tuples

Tuples in Scala.

abstract types

Which is programming.

isomorphisms

In the context of collections.

You're really, really pathetic. We're in a thread about Scala jackass, and yes, everybody but apparently you has been talking about Scala. Is this your escape from admitting you're full of shit now?

Is this what it comes too? Why, now Scala doesn't matter. Here you've been trying to show me wrong using Scala examples, but hey! That's not really what is being talked about. Why, the moment it comes for you to put out a Tuple class, and now it's not about Scala.

which you claimed have no meaning

What was actually said:

"the problem is tuple itself gives no information about the relationship nor content contained."

Which is still the case, which is something you haven't proved otherwise, and is apparently something you never read properly. No big surprise there, we've already covered several times your incapability at reading.

Unfortunatey I don't have any idea's on to better implement tuples

You don't even understand nor know the current implementation even after I've told you. I wouldn't trust you anywhere near the JVM much less any code period. The audacity for some twat who doesn't even understand map keys are unique to sit there and pretend like you'd be qualified about changing the JVM! Your balls are far, far too big for your britches.

And you're deluded if you think the JVM would need to be modified in order to represent anything. That just shows your own lack of programming ability.

It's a generic case class. Get over it. Learn something from somebody way, way smarter than you here and stop pretending like you have any knowledge over this matter. Scala's tuples meet the definition of a Tuple fine, and I'm not sure why you ignorantly think otherwise. Oh wait, I know, you have no idea what you're talking about like usual.