Adam Jenkins said:
to have to look at the source code to know if you're using it
correctly. My point is that I don't see the fact that C++ has separate
header files as being any advantage over Java, since unless the header
file is documented it's not going to be a substitute for looking at the
source anyway. And if it is documented, then Javadoc does just as well
or better in my opinion.
As I've already stated in my reply to what you are replying, I am
assuming the author has put comments in the header file (as they would
above the function definition in both C++ and Java, the latter of which
could be put through javadoc or an equivalent tool for C++).
Not everything gets put through javadoc or the C++ equivalent. Thats a
fact. Not all environments are like that. Some places don't even comment
the code (don't get me started on how stupid that is). I was commenting
on the fact that because the definition of the API is separate from the
implementation it discourages, and sometimes prevents people from
peeping under the hood. Thats a good thing.
The point is, in the absence of the autogenerated documentation, for C++
all you need is the header file (you can't peek at the source), for Java
and C#, that is not possible (although you have alluded to a javap tool,
that I assume generates a header file equivalent).
You are correct that complex APIs can usually only be used with proper
documentation, I wasn't claiming anything else. You claimed that (all by
implicitness) APIs can't be used without documentation. I stated and
demonstrated otherwise. Many commonly used APIs are container APIs. I
can't remember all the STL variants. As for using a database, I'd be
sure to lookup the documentation - how often do you write DB queries?
Not often, once they are done, thats it. Often unchanged for years. Why
would you bother remember the details of an API you don't use that
often.
In case you have mistaken this for a language war, it isn't. I use
assembler, C++ and Java regularly. I have used Modula-2 in the past, and
I write software tools supporting C++, Java and Python. One project I'm
involved with, we chose Java for platform independence, only to be
bogged down with native method calls to interact with hardware and
speech synthesis (we started that project in 1997). I am not a language
bigot.
I do happen to believe that C++ is superior to Java and C# by quite some
margin, but thats more to do with what you can't do with Java and C#
that you can do with C/C++ (low level stuff), and because of the way
Java has to be written you end up in certain stylistic straight-jackets
I don't like (in C++ you have the choice - of course thats the point of
Java and C# - to remove the choice (in the name of making programming
"easier")).
I also think both Java and C# (and any .net language) have serious
problems with synchronization that are brought about by the notion of
every object having its own monitor.
So far I have only seen one article in print (in MSDN of all places)
which describes these short-comings. I'm not going to get drawn into a
discussion on that - if you want to read the article search recent
issues of MSDN on Microsoft's website discussing monitors. The comments
in the article apply equally to Java.
Stephen