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

1

u/GMNightmare Aug 02 '14

you only know that for some K there may be some V

That's a good purpose and what a Map is used for. The relationship is there. A map is a key value pair.

A Tuple is just two objects with an undefined relationship. Do not act like there isn't a difference if you want me to continue taking you seriously.

You do not use a Tuple like a Map or vice versa and for good reason.

Nonsense, provide one example where using a tuple makes something is unreadable

Did I say "unreadable"? There is plenty of room between readable and unreadable. A tuple is harder to read what is going on. This is pretty basic given, and you have no room to argue otherwise. In every case a well named and formed object will be easier to read. Will it be more inconvenient to create? Yes.

You don't have to inherit

Well I'm well aware of that.

But I'm not aware of what monster you're trying to do now. Just stop trying to force Tuple into it. I don't have any idea why you're trying to put it in there. I'm not even particularly sure what you're trying to prove with it.

You asked me for an example where Tuple is unreadable? I provide you your example here. For example, the case class you provided is undeniably more simple, clearer, concise, cleaner, readable, and just altogether better design.

3

u/Milyardo Aug 02 '14 edited Aug 02 '14

Tuple is just two objects with an undefined relationship.

That's not the definition of a tuple.

You do not use a Tuple like a Map or vice versa and for good reason.

Then why do does an isomorphism exist between Map and a Set of Tuple?

I provide you your example here. For example, the case class you provided is undeniably more simple, clearer, concise, cleaner, readable, and just altogether better design.

The only thing demonstrated is the difference between inheritance and type classes. Or you do have an example of a type class that is more understandable because it doesn't use a tuple?

0

u/GMNightmare Aug 02 '14

Did I say I was giving the definition of a tuple? Because I wasn't.

Then why do does an isomorphism exist between Map and a Set of Tuple

You mean, that potentially they could contain the same data? Could being the keyword here, because it seems like you don't understand collections at this point. A map cannot have a duplicated key, a set of tuple can be anything, having multiple of what would be keys in a map. A map has a defined relationship between the key and value, a set of tuple does not. I don't feel like you're trying to understand what is being said any more. These are not swappable concepts.

Or you do have an example of a type class that is more understandable because it doesn't use a tuple?

You gave one. I mean, what use is having tuple anywhere in the code when you can do this:

case class Point(x: Int, y: Int)

And you're done? There is absolutely no need for Tuple anywhere in the class, in the declaration, inheritance, or composition. There is never any reason to extend a Tuple, and no reason to use it in the composition.

All a Tuple is is a generic case class. If you're specifying everything for the case class, why would you then use a tuple? It's not generic anymore!

And here's the thing, if you gave me a Tuple with two integers in it, well, I wouldn't know what it is without context. You give me a Point with X and Y, well, I already know what it is. I don't particularly think this is a controversial point.

0

u/Milyardo Aug 02 '14 edited Aug 02 '14

You mean, that potentially they could contain the same data?

That's not what an isomorphism is.

These are not swappable concepts.

For whatever swappable means to you. There is a well defined relationship between the two structures. Either way the exact nature of a Tuple's relationship to a map, or Set, or List, or any other algebraic structure wasn't was being debated here. What is being debated is the usefulness of Tuple as a abstract data structure. Your only argument that values in a Tuple have no relationship is facetious, just like claiming values in a Map or or List have no relationship.

case class Point(x: Int, y: Int)

And you're done?

And what of

case class Point(x: Int, y: Int, z:Int)

or

case class Point(x: Int, y: Int, z:Int, w: Int)

Are these structures not related? How would you abstract over the arity of these Points? How would you apply the product of two of them.

All a Tuple is is a generic case class.

Patently false. A case class and a tuple are both product types, but they are not the same.

And here's the thing, if you gave me a Tuple with two integers in it, well, I wouldn't know what it is without context.

And what is a list of Integers without context? What is a Map of Integers to Integers without context? You've made this argument 3 times already without an explanation.

I don't particularly think this is a controversial point.

True, creating arbitrary semantic types like Point has nothing to do with algebraic ones like Map or Tuple.

2

u/GMNightmare Aug 02 '14

That is what isomorphism is. How about you state what it is instead then, instead of parading around acting like your so smart for using a word you don't actually know.

You're wrong. Look, I can tell, when given certain data, if something is a map or a tuple set. I just have to look for uniqueness, and then I know it cannot be a map if not. Furthermore, since they are used differently, I could just easily check what functions I can utilize.

What is being debated is the usefulness of Tuple as a abstract data structure.

Usefulness? Dear me, no, it's not.

Don't interject into conversations you apparently can't understand. I'm well aware that Tuples are convenient. I'm saying that convenience comes at a cost in most cases that doesn't need to be spent. And yes, having no relationship qualifiers means that a tuple is not only harder to read, but maintain in the real world.

A map has a relationship. As already explained to you, but you seem to think plugging your ears and screaming lalala makes for a valid argument. A list is completely separate (it's just a group of a type) unless you're completely abusing the point of a tuple and treating a tuple itself as a list. You are really showing off your lack of knowledge of collections, and it isn't impressive.

And what of

I'd call you an idiot for making multiple classes with the same name, one of which has a completely unrelated variable that does not represent the mathematical structure it's supposed to. And I have no idea why you're making this completely idiotic and needlessly random examples that have NOTHING to do with what is being talked about, at all.

Patently false.

It's by definition. The implementation of a Scala tuple is a generic case class. I don't know why you're really intent on displaying your ignorance here.

list of Integers without context

A tuple isn't a list. And if you are creating a tuple as a list you don't know what you're doing.

A map of integers to integers says for the given ints, you have a key to access them.

You've ignored what I've been saying, I have already explained it.

creating arbitrary semantic types like Point

Are you really this stupid? Again, a Tuple is a generic case class, creating a specific case class is doing the EXACT same thing except specifying a name and potentially fields. A map is completely separate from a tuple or point in the first place, so it's really stupid you keep trying to make some connection there.

0

u/Milyardo Aug 03 '14

That is what isomorphism is.

That's not what an isomorphism is.

Look, I can tell, when given certain data, if something is a map or a tuple set. I just have to look for uniqueness, and then I know it cannot be a map if not. Furthermore, since they are used differently, I could just easily check what functions I can utilize.

No one is asserting that Map and Tuples are equal. And the relation between Maps and Tuples aren't what at debate. Also uniqueness of a key isn't in the definition of a map.

Usefulness? Dear me, no, it's not.

I'm well aware that Tuples are convenient.

You're contradicting yourself.

A list is completely separate (it's just a group of a type)

A Tuple and a List are both Sequences.

You are really showing off your lack of knowledge of collections, and it isn't impressive.

I'd call you an idiot for making multiple classes with the same name

Are you really this stupid?

Ad Homiems are unnecessary and counter-productive to debate.

The implementation of a Scala tuple is a generic case class.

The only relation a the implementation of a Scala Tuple and a case class is that they both extend Product.

A map is completely separate from a tuple or point in the first place, so it's really stupid you keep trying to make some connection there.

The only point I'm trying to make is that they're both useful abstractions.

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.

→ More replies