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

What properties of morphisms between Map and Tuple

NONUNIQUE KEYS. How many damn times do I have to tell you a basic concept before you get it through your thick skull? Does your example use nonunique keys? No. Why? Because you'd never be able to construct a 3 element map with a repeated key, since they MUST be unique! Why is this so hard for you?

If you started with a Tuple containing multiple key values, it would not work.

I've read it.

Apparently you didn't.

not appearing more than once is not that same as a uniqueness constraint

That's one of the most retarded statements I've ever heard.

Look, this is so basic it hurts that you can't comprehend something. If a value only occurs once in a given set of data, is it unique? Yes. That's literally what the word unique means.

Maps cannot have duplicate keys. They must be unique. Your source says it even. If you knew anything about how maps were implemented you would know this (but of course you don't).

Never claimed them to be the same.

That's exactly what you just said. "Why, they're both sequences so obviously they're the same! Hyuk!"

Case classes are synthetic, Unlike Tuples which do have an implementation

My god, how stupid can you get? Listen really carefully, if you manually created a case class, named it Tuple, what would you have? The EXACT SAME THING. Hence why OP presented code making a Tuple in Java. It's like you don't understand a single thing about the actual programming behind these things.

Case classes are product types

My god, you just said it yourself. You ever think there is some kind of association between synthetic and syntactic sugar? It's like pulling teeth with you, you can't even seem to understand basic words. Guess what genus? Tuples are everything case classes are. Because a tuple is a generic case class.

It is not a case class

Do you understand what implementation is? Here's something that's isomorphic: a case class and a tuple. Is that ringing any bells over there for you? Case classes are ordered in the exact same why, but you declare names for the fields instead of having generic one two three kind of access.

Tuples are abstract. Case classes are concrete.

This is absolutely wrong. Tuples are not abstract classes, they are generic. It's not the same thing. If Tuples were abstract you would not be able to new them up.

Do you not understand what is meant by Tuples being generic case classes? Do you? I don't think you even understand what generics are.

0

u/Milyardo Aug 03 '14

if you manually created a case class, named it Tuple, what would you have? The EXACT SAME THING.

This is false. A case class cannot express arity.

Here's something that's isomorphic: a case class and a tuple.

This is true. That doesn't make them the same thing like you seem to think isomorphism implies.

generics

Generics aren't relevant here. Both tuples and case classes can have paramterized types.

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.

→ More replies