Language:
switch to room list switch to menu My folders
Go to page: First ... 6 7 8 9 [10] 11 12 13 14 ... Last
[#] Fri Nov 07 2008 03:09:25 EST from Peter Pulse @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I don't mean it's literally const, I mean, it's this evil viral thing that you get pressured to use in your code, and once you use it in one spot, you have to change your code in a zillion spots. The way const is.

[#] Fri Nov 07 2008 06:28:07 EST from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I seem to recall that you are not a fan of type safety anyway.

[#] Fri Nov 07 2008 08:14:55 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Oh, I see, the const virus. Yeah, I'm not a big fan of const either.
Type safety yes, but const is a little too annoying for what help you get from it

[#] Fri Nov 07 2008 08:18:54 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Well, the java party is over. <Type> is the new const.

Oh, now I see what you're saying.
Heh. I have an easy solution to that (just as I supposed I had zillions of int *x = y; // deconstify in my code)
Eclipse is forever shoving ArrayList<E>() at me, so I type "Object"
And everybody is happy.
Stupid and annoying, yes, especially since a lot of the time I put all sorts of unsame things in my hashes and arrays...
Also, they added a thing in 5 you can say @SuppressWarnings("unchecked") so you can avoid the problem with one line in the source or the build script.
Tis a shame though, you're right.

[#] Fri Nov 07 2008 09:48:17 EST from Peter Pulse @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I don't have any problem with type safety in concept. But being able to decide your types later is sometimes necessary. Absolute type safety is a stupid idea that doesn't work. As we have discussed in the past, C++ dug in its heels for decades with the 100% type safety mantra, telling us we were bad programmers to disagree. Of course they were wrong, there were many legitimate needs for type ambiguity which C++ did not allow and these features were finally added, mostly in a noisy and ugly way. The Java designers were smarter and included a common abstract base class, a common String class, and common container classes that were easy and clean to use. But now after years of everything working fine they are adding this ugly C++ template syntax into Java. One day, I go to recompile and several thousand warnings spew out... So I have to fix all these old classes. Now of course I technically have to retest them all, since I changed their code.. but I'm not going to.
But one class caused problems for me. It uses a bunch of Hashtables including Hashtables that contain other Hashtables.. and methods that return Hashtables.
This resulted in a mass of <fucketyfuck,fuck,fuck,fuck> getting added all over my code.. but I could not get it right. If I fixed it here, it bitched there. After fighting with it for an hour or so I just went back to my old, MOSTLY type safe and entirely working code. I am sure there is some magic combination of <>'s and ()'s that will make it work.. but for now I will live with the compiler warning. I will have to figure it out eventually for no other reason than, now that the generics are here they will be used all over the place and like I said it is the new const, it is useless to fight it.

[#] Fri Nov 07 2008 11:49:28 EST from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


Ever program with Amiga E?

It had almost no sense of type safety. Kind of neat, and helped make things run very fast.

It could get interesting, though, to find the problems in your code. You had to test all code paths, and hope you found everything, to ensure you didn't pass the wrong variable somewhere.

I think type safety is very useful in certain situations, and a hindrance in others. Great tool, but like any other tool, you have to know when to use it. I don't tend to like it so much for GUI programming, but it's nice to have when you're working on a server.

[#] Fri Nov 07 2008 12:21:53 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


There are a handful of different ways to subvert the Java compiler and say "sorry, I don't care about correct generics right now."

One of those is to set your source compliance level to 1.4 and your target to 1.5 and just do it the old way.
Another way is to do it in 1.5 and disable warnings (either with Eclipse options, or @SuppressWarnings, or both.) Eclipse has fairly fine grained control over the types of generics warnings you want to see - there are different warnings that you can turn on or off, e.g., unsafe cast, assignment of a generic type to an unconstrained type, use of an unconstrained type in the first place... etc.
There is always using Collection<Object> instead of whatever,
And there is Collection<?> which is a magic incantation that says, "Compiler, I don't know what the type-parameter is or I just don't care to specify; please just make sure I always use the same type, within this method."

Collection<?> gets a little weird, I don't understand the full semantics, but occasionally it is essential. For example, java.lang.Class is now a template, java.lang.Class<T>, and all of the methods that used to return java.lang.Class, such as Class.forName(), now return java.lang.Class<?>

[#] Fri Nov 07 2008 15:27:36 EST from Peter Pulse @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Thanks. Good ideas. Setting the source compliance back is one I didn't think of, but really though I am complaining I realize there is no way to hold back time so I am going to have to make friends with generics. I realize that.
I had around 30-some-odd source files in this one project that was giving warnings on this, and I fixed all of them but one. The one that is still outstanding has the hashtable of hashtables stuff going on, with hashtables also being returned from methods.. so it got really nasty looking.. and didn't work. That's the one I regressed until I have the time to figure it all out.
Maybe I will set the source compliance on that one class so my stuff will compile without warnings. I really don't like to suppress warnings since they are often helpful but that one class is working and I don't need to worry about type safety as it is not changing any time soon and it works fine... One thing is for sure, that class code will be a lot uglier and a lot harder to read once generics are used... It is just like C++, it doesn't let you make a mistake and that's good because by the time you're done nobody can read it.

[#] Fri Nov 07 2008 15:54:14 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


well it's not suppress all warnings it's @SuppressWarnings("unchecked") so you only turn off that specific warning.

[#] Fri Nov 07 2008 16:26:48 EST from Peter Pulse @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I thought that was only in 1.6?

[#] Fri Nov 07 2008 16:27:58 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


No, it's also 1.5. Hmm, apparently it's 1.5.0_06 and later, although the annotation existed earlier but was ignored.

[#] Fri Nov 07 2008 16:52:26 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

MOSTLY type safe and entirely working code. I am sure there is some
magic combination of <>'s and ()'s that will make it work.. but for now


/usr/bin/javac -nowarn
nowarn is your friend. :-)
And the supress thing I mentioned earlier, I though you could put that on the command line, but apparently not so you have to put it on top of each java file.

[#] Fri Nov 07 2008 16:53:32 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


on top of each java file, or you can get more fine-grained and put it on a method...

[#] Fri Nov 07 2008 16:53:49 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

It had almost no sense of type safety. Kind of neat, and helped make

things run very fast.

If you wanna talk about insane type safety (or lack thereof) you must all bow to REXX.
Remember rexx? If you used a string of text in a line it would resolve as that string of text (without having quoted it in any way) unless of course you had previously assigned a value (of any kind) to that string of text, then it resolved to that value. Just astounding.

[#] Fri Nov 07 2008 16:55:32 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

And there is Collection<?> which is a magic incantation that says,

oooooh, that's interesting I never knew about that one. Sounds handy. I imagine eclipse has a button to figure out what type you actually use with it and it replaces for you in all cases, right? :-)

[#] Fri Nov 07 2008 16:56:23 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


oh wow. that yields INTERCAL-like opportunities for semantic confusion. almost like writing an entire C program in preprocessor to make it look like Pascal, except that you define BEGIN and END to mean something entirely different...

[#] Fri Nov 07 2008 16:57:41 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

on top of each java file, or you can get more fine-grained and put it

on a method...

yeah, but if you're going to bother doing that, you might as well just put in the <?>.

[#] Fri Nov 07 2008 16:57:57 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


Eclipse won't replace <?> with actual types if you've already added <?>, because <?> has a special meaning. But since you mention it, yes, Eclipse has a refactoring, and this is global and analyzes all files in your program, to add generics to any raw types you've used.

[#] Fri Nov 07 2008 16:58:48 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

yeah, but if you're going to bother doing that, you might as well just

put in the <?>.

Actually <?> has a narrower meaning than <Object> and imposes type-safety rules that <Object> does not. So you can't always use <?>.

[#] Fri Nov 07 2008 17:00:03 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Fair enough. That java.lang.Class<> thing doesn't sound pleasant.

Go to page: First ... 6 7 8 9 [10] 11 12 13 14 ... Last