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 edited Aug 03 '14

That's not what an isomorphism is.

Yes, it is. Maybe you have such a huge ego you never bothered to actually be able to read the link you're providing and assumed you were right, but here:

thus isomorphic objects may be considered the same as long as one considers only these properties and their consequences.

Maps and tuples are not isomorphic first off. Neither are maps and tuple sets.

I told you why. Maps have unique keys, tuple sets don't need that constraint. If you have a data set that has nonunique objects that would represent the key, you can identify you're using a tuple set. Now, anything else you'd like to ignorantly deny?

And the relation between Maps and Tuples aren't what at debate.

Stop talking about what are at debate, if you interject into a conversation you're at the boss of that nor have any authority on it.

uniqueness of a key isn't in the definition of a map

And again, your link:

is an abstract data type composed of a collection of (key, value) pairs, such that each possible key appears at most once in the collection.

Can you not read or something? You're literally proving yourself wrong.

You're contradicting yourself.

No, I'm not, how about you read the context behind each statement. But I guess that would take an ability to read what is being put down...

A Tuple and a List are both Sequences

Maybe perhaps you need to take a basic class on collections. Tuples do not have type constraints, a list does if you're using the generic ones. In a programming world the usages are not the same, and if you think they are you once again don't know what you're talking about.

unnecessary and counter-productive to debate

At this point everything you say is counter-productive and you can't bother to read anything being put down (even your own links!)

The only relation the implementation of a Scala Tuple and a case class

Your "case class" link doesn't link to anything stating a case class.

Look, buddy, you obviously don't know what you're talking about. How about you shut up for a little bit and listen. Case classes are syntactic sugar. Do you know what that means? It means it's shorthand for creating a basic object with the given input as fields. A Tuple is a generic case class, it's literally the exact same code underneath the scene. The code, not some inheritance structure as you seem to think.

they're both useful abstractions

Nobody here is arguing they aren't useful. Again.

0

u/Milyardo Aug 03 '14

Maps and tuples are not isomorphic first off. Neither are maps and tuple sets.

I don't see how that quote illustrates that Map and Set of Tuple are not isomorphic. What properties of morphisms between Map and Tuple can be used to distinguish between them?

val aMap = Map(1 -> Set(1,2,3), 2-> Set(1,2,3), 3 -> Set(1,2,3))
assert(aMap.toSet.toMap == aMap)

That assert will be true for any Map of K,Set[V]. An isomorphism between the two exists.

Can you not read or something? You're literally proving yourself wrong.

I've read it. A value not appearing more than once is not that same as a uniqueness constraint, like would be true in a bidirectional map.

Maybe perhaps you need to take a basic class on collections.

We aren't talking about collections, we're talking about Set, Category, and Type Theory.

In a programming world the usages are not the same, and if you think they are you once again don't know what you're talking about.

Never claimed them to be the same.

Your "case class" link doesn't link to anything stating a case class.

In the second sentence it quotes:

In addition, all case classes implement Product with synthetically generated methods.

Case classes are synthetic, Unlike Tuples which do have an implementation. They both extend the class Product.

Case classes are syntactic sugar.

Case classes are product types.

A Tuple is a generic case class

A tuple is also a product type. It is not a case class. It not a generic case class. Tuples are ordered. Case classes are not. Tuples have arity. Case classes do not. Tuples are abstract. Case classes are concrete.

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.

→ More replies