Originally posted by Mac
Never been to Parola (that's a shame)...
It is really a nice museum with between 20 - 30 AFV's and an amored train as the main attractions. Even the ISU-152 is there. The gun section is nice too. I wouldn't want to ski around with one of those Lahti ATR's on my back!
None of my Swedish friends like sauna
.
Whimps!
RAII != GC. With RAII I can do guards (Java has synchronized), networked resources, file handles (Java supposedly does this), ... whatever nice things you can do with auto vars in block structures. C++ isn't perfect in RAII but templates do lend a hand already. Where are Java destructors and auto variables?
I take you mean that auto variables share the namespace of class variables? I have gotten used to use shorter names in methods and better qualified for class wide ones. And using "this." even when it is not required - which surprised myself when I noticed it.
Destructors: you can overide finalize [1] if you need, but I can't say I have ever used it.
[1]
http://www.jguru.com/faq/view.jsp?EID=13946
Garbage collector may be good when you prototype but it's not a licence to write stupid code.
Isn't that like saying RAII is good when you prototype? Using these makes much more readable and safe IMO and is not only for prototyping!
The feature was that the gc would not run and database connections lingered in garbage objects. That prevented database access (because of the max limit). Mind you this was not easy to detect because it occurred at seemingly random times. In C++ there would've been explicit release for sure.
Ouch. Perhaps adding a resource showing the number of free connections when asked would be a help here. Some would advocate forcing the GC to run, but it still is not a sure way and would probably only push the problem away till the code was running elsewhere.
That's not my job if I'm not the library author and I would not do it unless my career depended on it. Unfortunately I've had to do it to find the true cause to an obscure error in another library. I needed to know the exact path taken so I could avoid it in my code. Not fun. Besides some of the stuff (especially AWT) is native code ... you wouldn't replace because of performance anyway. Ok who wouldn't want to fix some stupid things like Stack inheriting Vector?
Not me!

Still, since the source is there you
can fix it if motivated to. Of course it is better when there are no bugs anywhere, but what I meant with the advantage for Java the plattform in the number of standard libraries is that if you have two different programs exchanging information you can be reasonably sure that this has been tested before. Using one socket library from vendor "A" and communicating with one using a library from vendor "B" increases the likelyhood of finding differences in implementation that matters to you (as the programmer using one of these).
Anybody ever wonder why J2ME doesn't have the containers (at least it didn't used to) so I'm supposed to write my own when doing something for a phone?
Resources constraint most likely [2] and something that will change over the years. Considering that the first linux based mobile phones are released it is my strong conviction that the future will lead to this device being the central in your life, e.g. not one phone, one PDA, one Laptop and one PC.
[2] Since there is even one C++ version especially created for embedded applications this is not really Java specific!
See
http://www.caravan.net/ec2plus/ for more on the rationale behind this.
I would argue your example is a library example not a language. Same goes for like mutating keys in Java maps etc. stupid code. There are a lot of language level issues which mean C++ is not an easy language. I don't have a Java standard so I cannot say what foo(i++, i) does
.
Fair enough! I have to look if foo(i, i++) is defined in the Java lang spec.
Umm... you don't always run in a debugger? If this is a release build then you have probably stripped the debug info anyway so you don't get the line info. And you need to have the logs like in other languages.
Not really. Usually I write code, compile and run in a cycle of perhaps 2 - 8 minutes. Since compiling is done in the background all the time (using Eclipse) there it is rather "coding & correcting" (compile in background) correct again, and run.
Eclipse as tool is the most impressive single piece of development support I have ever seen. Impressive support for productivity, refactoring and catching errors. Unfortunate sideeffect is that I use Emacs less and less

...
The release builds include line numbers. The code scrambled using an obsfuscator but you can define what should be left inside, like line numbers. An stacktrace from a user might look like:
java.lang.NullPointerException
at com.thuring.jasl.w.<init>(SourceFile:235)
at com.thuring.jasl.action.a.d(SourceFile:96)
at com.thuring.jasl.gui.K.a(SourceFile:140)
at com.thuring.jasl.gui.v.c(SourceFile:241)
at com.thuring.jasl.gui.f.actionPerformed(SourceFile:131)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
...
Well, looking up the name "com.thuring.jasl.w" in decoding table file I can quickly see that the null error occured in a specific file on the line indicated. I even see how the program landed there.
It is freaking cool for me as a developper and saves a lot of questions ("What did you do?", "What was the last the program did and so on?"). I wish I had this at work...
This is a trivial example and in my experience the operator overloads are used in trivial cases so there is rarely a problem. If you are using smart pointers whatnot you will know that you are using them. This example has ints so you will also know in C++ that the type is a simple type. If it were more complex you would also have to check the specifications in Java.
a.set(a.mul(10));
Does mul return a copy or not? Does it throw an exception? Does it throw an undocumented exception with my numbers? You do need to check it before you can write that. Once you read code like that you need to make some assumptions. You need to have the same info in your head in most cases. I for one prefer the readable version from operator overloads. I don't advocate weird dot or cross product operators for vectors because they are not easy to understand.
It was a trivial example, the problem gets much worse in longer methods. With "a.set(a.mul(10));
" you
see that there is a call with all what that entails!
Now, with overloading you can potentially have that problem in all lines of code. And if you do not know you have to check.
Defence exhibit A, word arbitary. Since when do programmers produce arbitary code?
Since not all programmers were "me"!

No, I mean what another person means with his overload will not always coincide with what I mean.
That kind of programmer wouldn't work for me
. C++ in my view limits operator overloading. I would like more enhanced capabilities to write my own operators etc.

In some cases I would perhaps agree that overloading is justified, say for mathematicians that want to be able express their rules more closely in the source code and equal cases. However, with unicode around the corner perhaps using different symbols would improve this, and for multi line expressions in the source (like for integrals etc).
But you see all exceptions are not specified even in Java (try NullPointerException for one)... and specifying exceptions explicitly leads into bad maintainability and also makes many templates incorrect, ... so they are not an easy issue.
Still, exceptions as such are a defined mechanism. "Undefined behavior" is the opposite. In some C user groups they even use expressions like "Demons flying out of your nose" to emphesize that the results are really undefined / unexpected.
see you,
Lars