Noah said:
Mishagam said:
Noah said:
Mishagam wrote:
f) You don't have to choose between char *, string, CString ... - String
is better (or same) than either of them and it is only choice.
Actually, you are in err. Java also has char[] and there is nothing
stopping someone from using it or designing a new String. Therefor
Java suffers from the same "problem" as C++ here except there are no
Java functions and tools to work with char[]...you have to write them
from scratch.
Yes, you can use char[] (or byte[]), but as you said it has no support,
so nobody uses it (as opposed to String, which is more heavily supported
than any C/C++ strings version). It is VERY rare Java programmer who
would spend time deciding which string representation to use. Everybody
just uses String. And the beauty it - it is really very close to optimal
choice. (as opposed too, for example, original Pascal strings)
Interesting statement. Just how close, in quantifiable values, to
optimal is it then? Also, optimal in what way?
For strings main feature is convenience. You can easily define strings,
you can easily make operations, especially concatenations, with strings.
You don't bother about allocating pieces of string. You can use strings
as keys. You can easily convert other type to strings, and simple types
from strings. Strings should be efficient.
C char * strings are very fast, have decent support and great
improvement over Pascal strings (not to mention Fortran), especially
because of sprintf / sscanf functions, but you always have to bother
where to allocate strings, and C strings are not safe.
STL string and CString are slower than C, but safe. They have some
support, but Java strings are supported better. You also always have to
choose which string to use, and different programs and libraries use
different strings. For example, part of pain of COM programming on
Windows was very frequent need to convert strings from one format to
another.
So Java String look better than any C/C++ strings version. This is what
I call close to optimal.
Cleverness is subjective. IMHO a lot of choices in Java where rather
dumb.
"Very close to optimal"...that seems like a fluff statement to me but
if you can quantify it I'll place more value in it.
Not having any choices doesn't seem to me to be that great.
I'm still looking for the can. You listed all the thing Java *can't*
do but haven't come with anything it can. I don't see much advantage
in *can't*.
Generally you can do anything on any general purpose computer language.
I can say you can write safe programs on Java, you can do GC on Java.
There is also very long list of things that is more easy to do on Java
(almost everything). For example.
Connect to databases.
Use http connections, requests and responses.
Write string to clipboard.
Write servlet (comparing to use CGI programs or ISAPI module).
and so on.