Regarding Java

Pages: 123... 6
I hate to say it. It makes me ill even thinking about it. But. I've become more comfortable with java than I am with C++. I'm sorry, it's not my fault. It was forced upon me, my brain was violated. And...and now...I can't program in C++ without thinking of how pretty Java looks to me. I feel dirty...
Ok.
@firedraco : lol that was a long response.

@Seraphimsan: Nothing wrong with java, nothing at all. (well maybe a few things, like the lack of c++ and stuff)
Java is good alright. But I choose to stay with C++ and kill my brain.. lol
Honestly if I hadn't been forced to learn it for school I wouldn't have gotten good with the Android API since it's all java (and with good reason). But I had a realization today while lurking the general c++ bbs that java has become more aesthetically pleasing to me :O it was wrather depressing.
Have you made anything awesome for the droid yet?
closed account (3hM2Nwbp)
I agree that Java seems a bit more syntactically "clean" than C++. The reason that I switched to C++ as my weapon of choice is because of how Java deals with memory. The lack of multiple inheritance is also a shortcoming in my opinion, though others would argue against that point. I guess that I just like to have enough rope to shoot myself in the foot as they say...
Last edited on
@ulti: Depends on your definition of awesome. I wrote a launcher/home replacement that was very simple, it was basically a List that you scrolled through that looped at the bottom and supported widgets. It was lightweight and that's what I wanted, as I was/am running 2.3 on a G1, Overclocked it still has some hiccups with heavy duty multi tasking. And as I like keeping the home in memory I needed something light weight.


That's more or less the most amazing thing I've done so far.
Seraphimsan wrote:
I hate to say it. It makes me ill even thinking about it. But. I've become more comfortable with java than I am with C++. I'm sorry, it's not my fault. It was forced upon me, my brain was violated. And...and now...I can't program in C++ without thinking of how pretty Java looks to me. I feel dirty...


You almost sound like a rape victim... @_@

Honestly, though, Java is a nice language. I personally don't like it much because of the many trade-offs that were required to make it as comfy as it is to program in, but I don't blame you one bit for liking the language at all.

-Albatross

EDIT: I had a quip to make somewhat at my expense for the purposes of turning this into a joke, but I'll keep it, as it's a bit mean.
Last edited on

The lack of multiple inheritance is also a shortcoming in my opinion


What lack of multiple inheritance? Java has multiple inheritance of interfaces. It is enough for most cases, and when not, Scala allows you to have code in interfaces (called traits). I've yet to see a valid design using C++ multiple inheritance that could not be made simpler using Scala's traits.


The reason that I switched to C++ as my weapon of choice is because of how Java deals with memory


Well, this is just an opinion, but IMHO, if you exclude real-time applications, for large and complex applications the Java way of memory handling is easier and more efficient. If you just try a little to tune it, you can easily create applications that spend less than 1% doing GC and require not more than 50% GC memory ovehead (which is often comparable to C++ allocator fragmentation overhead).
Last edited on
I love Java. It's just another tool in the toolbox in my opinion...
I agree that Java seems a bit more syntactically "clean" than C++
It may seem that way because precisely that is the case. Java IS a more clean language than C++. Can't help it, in C++ the choice was made to sacrifice cleanliness for the sake of backwards compatibility to C.

The lack of multiple inheritance is also a shortcoming in my opinion, though others would argue against that point.
How about, for example, the fact that there is multiple inheritance in Java? Sure, you can only do that with interfaces, but in most cases you don't really need more anyways.

I personally use C++ over Java because I happen to like it more. I personally would say though, if I had to choose a language of the two that is more appropitiate for teaching people how to program, Java would definitely win, simply since you won't have to spend all your time explaining your students all the counterintuitive aspects of C++.
@seraphimsan a Java infection will turn you into a zombie programmer... better to be killed than to turn and infect your friends! It's a lazy man's language of choice, but I admit it has it's uses. Java will always be a slower language thanks to the JVM and other issues, but the sheer size of the JDK alone makes it attractive for rapid development of systems, "There's a class for that", along with it's cross platform nature. I do find Java is a bit cleaner, but honestly it depends on the programmer really. The average person will find it more easy to read in most cases.

As far as the complaint about a lack of multiple inheritance... I don't know why this is always mentioned. While there is a work around in Java, how often do you ACTUALLY use multiple inheritance in your projects? I've seen it maybe once or twice in the past 10 years.

Now that I spend my days converting applications from Java to C# my only real interest in the language has become Android development.

It may seem that way because precisely that is the case. Java IS a more clean language than C++.


That is true, however Java is not that clean as it seems right from the start. Actually it has its own set of sharp edges:

- nulls
- static class members
- primitive types, boxing and unboxing
- no operating overloading, but a special + operator
- generic type erasure
- special syntax for array access []; arrays are not collections
- special syntax for creating arrays inherited from C
- type variance of arrays is different than that of collections
- too many kinds of constructors (c'mon, why have three if one is enough?)
- private is only class-private and cannot be made instance-private
- probably some more I forgot now

Scala fixes most of these shortcomings; and if you look only at the OOP side of this language it is much simpler and powerful than either Java or C# (I don't talk about the outstanding FP support that you won't find in Java, C# or C++ at all).


It's a lazy man's language of choice, but I admit it has it's uses.

Well, actually laziness is a very important feature of a good programmer.

Last edited on

Well, actually laziness is a very important feature of a good programmer.

true, if we weren't all too lazy to do it we would still write everything in assembly nowadays.
In my opinion, java's main caveat is it's cross platform nature. anything that can support a port of the JVM can run a java program (with minor changes for user input in most cases) personally I prefer the amount of control I get C++, but I like java as well. The one thing I DONT like though, is the speed and unresponsiveness of java applets run from a web browser. I have yet to see an applet that wasn't terribly slow. But besides that I like the language.
I get mad at try/catch blocks when I program in java, its ugly, and using exceptions just to control the regular flow of the program feels so wrong to me.
Last edited on
When do you use exceptions to control the regular flow of the program?
closed account (3hM2Nwbp)
I'd also like to stick in here that in a few clicks, any proprietary java application (that hasn't been hit with an AoT compiler) can be reduced back into it's original source. Obfuscation helps, but it can still be reverse engineered.

Regarding the way memory is managed, I ran into a large problem with garbage collection when I was writing real-time networking applications in Java. The problem didn't start until about 48 hours up-time under a moderate load, but having the main application thread pause for 3 seconds to collect garbage wasn't really acceptable in my case. The sessions that were forming were being moved to the old generation after being active for so long and weren't being collected until the full collection was invoked. I still haven't found a solution for how to tune the collector to avoid the pauses. Apart from that, Java's a nice language to use. Especially being able to add constraints to template arguments.
1
2
3
4
class X<T extends S>
{

}


When do you use exceptions to control the regular flow of the program?

I'm not sure if I'm interpreting this right, was the stressed point "regular flow"?

But for example opening a socket in Java can throw I believe 3 different exceptions and won't compile (rightfully so) unless code is set up to handle each exception that's thrown (or lobbing them all into the base exception class). I suppose the exceptions are considered regular flow as well?
Last edited on
I suppose the exceptions are considered regular flow as well?
I wouldn't say so. The exceptions in that case are just that, exceptions. I have seen an example where exceptions were used in the regular flow (that was an example for using the composite and the iterator pattern, where a operation that made only sense on nodes would throw an UnsupportedOperation exception. In the iterator the function was called without checking whether the object was a node or another composite, and the UnsupportedOperation caught so it would esssentially result in a no-op for composites. The authors justified this choice with
A) They wanted the composites to throw exceptions when calling that method, just to make clear that the method doesn't make sense for composites and
B) They didn't want to perform a check with instanceof, because that would result in a loss of transparency ) - in that, it was completely (IMHO) justified. I don't think never do this, never do that rules are particularily useful.
Pages: 123... 6