Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Java generics

Name: Anonymous 2007-01-25 3:56

I'm having a really hard time using generics in Java. Why are they so damn confusing? Real generics aren't this hard. Can someone break this down and explain this to me?

Name: Anonymous 2007-01-25 4:04

>>1
Ah, yes. This is a problem of misconception. Java is a static language. You can't really do things such as generics in static programmings and expect it to be usable and nice.

What you really need is a dynamic language, one that is not anal and stupid about data types and allows you to reuse code. May I suggest Python? If you don't like Python, you can try Ruby. If you don't like Python nor Ruby, commit seppuku.

Name: 93 2007-01-25 4:09

>>1
What about it is presenting problems for you? If you haven't yet, take a quick read of the generics tutorial.

http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf

Name: Anonymous 2007-01-25 8:57

Java's generics aren't confusing, just shit. If you wonder why they're shit, it's because the language was designed that way.

Name: Anonymous 2007-01-25 11:42 (sage)

>>2 is stupid.

Name: Anonymous 2007-01-25 15:48

Generics you say? How original, and look how cute it is:
List<Integer> myIntList = new LinkedList<Integer>();
And it's original, no one every thought about it before... *cough*c++templates*cough*

That's why I officially say to all my Java friends today:
#include <list>
using std::list;

is ten years old, Java is just a clone.

Name: Anonymous 2007-01-25 15:57

>>6
JAva generics are quite a different animal than c++ templates. dont confuse them.

Name: Anonymous 2007-01-25 16:52

>>7
Indeed. In C++ you can write

template<class T> T* single(T a) {
    T* l = new T[1];
    l[0] = a;
    return l;
}

but the equivalent Java code won't work, because Java is "type safe".

<T> T[] single(T a) {
    T[] l = new T[1];
    l[0] = a;
    return l;
}

Name: Anonymous 2007-01-25 17:42

>>7
different where? List<int> (in Java) and list<int> (in C++)? wow, that's different.

Name: Anonymous 2007-01-26 5:00

>>9

If you're just doing generic data structures, they're basically the same.  However, that's all Java can do.  C++ templates can do much, much more as they provide a general way to write "code that writes code" through metaprogramming.

Name: Anonymous 2007-01-26 6:16

>>9
I'm not speaking of cosmetic differences.

Name: Anonymous 2007-01-26 8:52

>>1
>>2
>>3
>>4
>>5
>>6
>>7
>>8
>>9
>>10
>>11

Lisp macros are superior.

Name: Anonymous 2007-01-26 10:29

>>12
I have never seen ONE single example that proves that, the only thing I have seen is something the smug Lisp weenies masturbate furiously over: reimplementing loops...

Name: Anonymous 2007-01-26 11:25

>>13
LISP macros seem to help securing your job position: there's no LISP. There's your LISP, his LISP, that guy's LISP, and all are different, so LISP is made for single-man projects. It makes single men be as productive as several, but it can't grow past that. Getting to work on a non-trivial LISP project means you need to learn a new language, and all the stuff you use may not work.

Name: Anonymous 2007-01-26 12:52

>>14
I heard there's some file in your home directory that true Lisp hackers fill with their personal macros that they then use in production code, is that so?

Name: Anonymous 2007-01-26 12:57

>>13
>>14
>>15
LOL java fags talking about lisp.
hahaha.

Name: Anonymous 2007-01-26 15:46

>>9

You can't do List<int> in Java

Name: Anonymous 2007-01-26 18:43

>>16
>>14 is not a Java fag, I demand apology juice and compensation for your injury.

Name: Anonymous 2007-01-27 5:13

>>17
so you're saying that Java is crippled and C++ is more useful here? I thought Java was the best and awesomest of all? I'm confused.

Name: Anonymous 2011-12-30 3:34

ENTERPRISE BUMP

Name: Anonymous 2011-12-30 3:54

                    ██████████████████████                                                                             
  ██████████████████                      ████            ██████████████    ████    ██    ██  ██████    ████    ██    ██
██                      ██                    ████  ████████████████████  ██    ██  ██    ██  ██      ██    ██  ██  ██ 
██                  ████            ██            ████    ██████████████  ██        ████████  ████    ██        ████   
  ██████████████████          ██████                ██    ██████████████  ██    ██  ██    ██  ██      ██    ██  ██  ██ 
                ██        ████    ██                ██    ██████████████    ████    ██    ██  ██████    ████    ██    ██
                ██████████        ██                ██    ██████████████                                               
                  ██          ████  ██              ██    ██████████████  ██████████  ██    ██  ██████  ██      ██     
                    ██████████      ██              ██    ██████████████      ██      ██    ██  ██      ████  ████     
                      ██        ████  ██            ██    ██████████████      ██      ████████  ████    ██  ██  ██     
                        ████████      ██            ██    ██████████████      ██      ██    ██  ██      ██      ██     
                        ██        ████              ██    ██████████████      ██      ██    ██  ██████  ██      ██     
                          ████████            ████████    ██████████████                                               
                                  ████████████      ████████████████████                                               
                                                          ██████████████

Name: Anonymous 2011-12-30 4:02

>>22
Consider them checked!

Name: Anonymous 2011-12-30 5:49

>>14
Getting to work on a non-trivial LISP project means you need to learn a new language, and all the stuff you use may not work.
In practice, that doesn't happen. When you follow the widely-accepted BEST PRACTICES OF COMMON LISP MACRO WRITING, you end up with a small set of useful macros that extend the language in non-surprising ways (as in, not fucking up things around them, not polluting the namespace with random crap).

Sure, it's possible to make strange magic happen in unexpected places, but why would you want that? It would be like one of those IOCCC entries that #defines everything to mean something totally different.

Name: Anonymous 2011-12-30 6:15

>>24
#define if(x) if(!(x))

Name: Anonymous 2011-12-31 9:52

1. Java generics are somewhat limited but they are slowly walking towards C# generics which are more permissive.
2. Type safety is considered a good thing by Java/C# programmers.
3. You cannot instantiate a generic type with int (List<int>) because int is a value type, or whatever you want to call it, you need to use the int wrapper class Integer. Wrapper classes or type boxing is not done automatically as it is in C# (this might be a good thing, since it has a cost and at least forces programmers to face potential efficiency issues).

Name: Anonymous 2011-12-31 15:31

>>26
>(this might be a good thing, since it has a cost and at least forces programmers to face potential efficiency issues)
It's going to be removed in the next edition obviously, programming these days means not thinking

Name: Anonymous 2011-12-31 17:07

>>27
Really now? I won't have to write EatShitAndDie<Integer> anymore then?

Name: Anonymous 2011-12-31 17:28

>>14
I'm assuming you're speaking from experience, right? How many large Lisp projects have you contributed (or tried to contribute) to?

Also, how is learning other people's macros different from learning other people's functions?

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2011-12-31 18:51

>>29
How many have you done you idiot? Believe it or not, I actually interned a US firm that ran a dialect of Lisp on their mainframe computers.

Name: Anonymous 2011-12-31 18:57

>>30
stop lying kodak, you haven't done anything important in your life

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2011-12-31 19:01

>>31
Seriously. There is a US based airline whose reservation system is implemented in Lisp.

Name: Anonymous 2011-12-31 19:02

>>32
That's why I don't fly with US airlines.

Name: Anonymous 2011-12-31 19:02

>>32
name

Name: Anonymous 2011-12-31 19:26

>>34
It's probably ITA Software. They got bought out by google ;_;

Name: Anonymous 2011-12-31 20:35

>>32

this is so cool. I'm jelly that you got to use lisp in a professional setting.

anyways yall, common lisp has plenty of features in it that will let you easily do anything you could in java, given that you are willing to learn lisp and leverage its features, and also read lisp code.

Name: Anonymous 2011-12-31 20:49

>>36
too bad LISP IS SHIT

Name: Anonymous 2011-12-31 21:08

>>37

lisp is only shit when people don't know how to use it appropriately, or when no one knows how to use it, or when no one uses it.

Name: Anonymous 2011-12-31 21:08

>>38
No, no, it really is shit.

Name: Anonymous 2011-12-31 22:00

Java's generics aren't generic given they can only hold references  to an object.

See:

valid:

List<Integer> list = ...

invalid:

List<int> list = ...

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2011-12-31 22:03

Java's generics aren't generic given they can only hold references  to an object.

That is incorrect. You want to try again you mental midget?

Name: Anonymous 2011-12-31 22:10

>>37,39
No.

Name: Anonymous 2011-12-31 22:13

>>41

are you retarded?

kodak_gallery_programmer

oh yes.

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2011-12-31 22:17

>>43
Listen you hourly worker, Java generics can hold more than references to an object. This can be demonstrated in a few lines of Java code. To say that generics only hold references to an object demonstrates the person has no clue as to what they are talking about.

Now you don't you shut the fuck up and write some code that shows what I'm talking about instead of jerking off on shit you pretend to know, but really don't.

Name: Anonymous 2011-12-31 22:32

>>44
Go scrub another midget, faggot.

Name: Anonymous 2011-12-31 22:35

>>45
Go impress the retarded 15 yr old girls with your technically incorrect statements about generics you mental midget.

Name: Anonymous 2011-12-31 22:39

>>46
I did. They were so impressed that they came.

Name: Anonymous 2011-12-31 23:40

>>39

yes, you are right. It is shit. But it is only shit when you are aware of alternatives that are not shit.

Name: Anonymous 2011-12-31 23:45

>>44
>>41
kodak_tripfag_programmer trying to win over a point via low insults and fake threats of daring to write java code

We get it, you're a a troll and you can't even program. You just like to insult others to feel good about yourself.

Name: Anonymous 2011-12-31 23:47

>>49

please stop fighting! I don't want to have to clean up broken bottlesBBCode again!

Name: Anonymous 2012-01-01 0:03

>>49
You're just upset because your mom won't have sex with you.

Name: Anonymous 2012-01-01 0:06

>>51

please stop fighting! It isn't worth getting the last insult in! It will only make you feel more empty inside! Can't we all hug instead!

Name: Anonymous 2012-01-01 0:09

>>52
Go hug a tree, faggot-hippie-Stallman-Randall.

Name: Anonymous 2012-01-01 0:14

The jews are after me.

Name: Anonymous 2012-01-01 6:07

>>51-53
huge fucking faggots. all three of you.

Name: Anonymous 2012-01-01 10:40

>>51-53
huge fucking faggot. you.

Name: Sgt.Kabu᣼슶kimanᅓ찚 2012-05-28 22:05

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List