What happened?

I used to be so enthusiastic about C++, but when i got into my 4. semster, we started using c# for web development, and i got some kind of a job as a Android application developer using Java, and i stoped using C++.
I used to loath java users for using their "easy" langueage with their carbage collectors and not having pointers, but now that i use it, its just so convinient not having to worry about dealocating memory, having that "quickfix" thing in Eclipse which lets you select a classfunction from a object which is just being made, exampele: new Object().someFunction(); or something like that

how clould i just move on like that?
C++ is not the best language for every task. Your job sounds like it's best done with Java, and that's fine.

Holding emotional attachments to (or against) tools that could prevent you from being flexible about jobs is, on the other hand, not so good.
How could you move on? You make it sound like your wife died and you're sleeping with your hot neighbour after years of guilt ridden lust. It's just a tool, C++ will still be there when you need it, if some other tool is better fitting then use that instead.
I can't stand the lack of reference-to-reference in Java. In C++ I have lots of convenience functions that return a reference so I can assign to the return of the function. In Java, this is not possible.

Not to mention, Strings are immutable, and so are the primitive wrapper classes.

And what's with erasure? Why would they make the language convoluted just to support legacy code...?

I like the rest of Java, I just hate the things that are missing and the things that just make life harder.

If I could I would wish C++ to have Java's labeled break and continue statements, those are quite handy with complex nested loop structures.

As you see, C++ is my current tool of choice for what I use it for. Obviously I would use Java for something such as a short applet...C++ is a PAIN for doing anything graphical. So why are you upset? It sounds like you now know THREE good-to-know languages: C++, C#, and Java. You now can use whichever one is easiest for the tasks thrown at you ;)
Last edited on
Why would they make the language convoluted just to support legacy code...?


The great irony here is that you aren't trying to describe C++.
I'm not saying C++ didn't make the same mistake as Java ;p but I see the irony now XD

I can't stand the lack of reference-to-reference in Java. In C++ I have lots of convenience functions that return a reference so I can assign to the return of the function. In Java, this is not possible


What forbits you returning an object from a function? Returning a reference to a certain mutable part of an object is bad style and contradicts encapsulation.


Not to mention, Strings are immutable, and so are the primitive wrapper classes.


Immutable strings are a *good thing* and only noobs think mutable strings are better.


And what's with erasure? Why would they make the language convoluted just to support legacy code...?


Yep, erasure is ugly. But anyway, at least it allowed for implementation of covariant and contravariant generic types in Scala. Could be done better (as in C#), but it is not that bad as one might think at the beginning. Especially when 2.10 will have partially reified generics.

Real pains of Java are:
1. lack of value types support in JVM, especially for tuples (including stack allocation)
2. only partial megamorphic call site inlining
3. lack of object inlining
4. lack of all cool things that are in Scala

The first three are probably the only reasons that sometimes you can't get Java programs as fast as C or C++.
They are fixable at the JVM level, without changing the language, and as far as I know, point 2. is currently being worked on and others have some prototypical, experimental implementations (probably Excelsior's JET does these optimisations, because it was able to beat C++ on a few Great Language Shootout benchmarks). The 4. point is easily fixable: just use Scala, don't use Java.
Last edited on
Consider this code:
1
2
3
4
5
6
7
8
9
string CurrentList;
map<string, vector<string> > Lists;

vector<string> &List(){ return(Lists[CurrentList]); } //utility func

//now this can be done for convenience:
List().push_back("Hello");
vector<string> v; v.push_back("Bye");
List() = v; //Can you do this in Java? 


So, apparently I am a noob. Why are immutable strings better? If you ask me the idea of having the same strings share the same address in the string table doesn't sound more beneficial than being able to change one letter in a string without making an entirely new one...
When looking at your code, the question "Why do C++ programmers make things so complicated?" strikes me back again...
Why not just have a method "setCurrentList" taking a vector as its only argument? Much more readable than tracking which pointer points where...

How is better this:
 
List() = v


Than this:
 
setCurrentList(v);


?


than being able to change one letter in a string without making an entirely new one...

What you forget is that in Java you *can* change one letter in a string *without* making an entirely new one, in the very rare cases you need it. Just use mutable StringBuffer then. In all others, immutable Strings are better: safer, faster and more memory friendly.


Last edited on
Topic archived. No new replies allowed.