Why doesn't C++ have comprehensive API like Java?

S

somebody

No, I'm not a troll, just angry. I just started learning
C++, and find it extremely lacking compared to Java.
For example, I had to write my own functions to do something
as simple as a case insensitive string comparison, and a
substring search. Then I found that there are no networking
classes to speak of (except sockets). After I thought about
it, C++ really pales by comparison. Java has a rich set of
networking classes, regular expressions, JSP, micro edition,
security classes, imaging, swing GUI, etc., etc. I can also
build executables for several different platforms with one set
of source code.

One thing that Java cannot handle is promiscuous sockets.
I began writing a port sniffer type program in Java, and
found it has no support for this. Still, I'm somewhat
disappointed with C++, and wish they would add some more
standard functionality like networking or HTTP type classes.
Well, there's my rant, I feel better now. If I'm wrong,
I just don't see it.
 
P

Phlip

somebody said:
No, I'm not a troll, just angry.

Nope. Anyone who shares a strong opinion with the 'net that disagrees with
mine is obviously a complete troll. ;-)
I just started learning
C++, and find it extremely lacking compared to Java.

Java is extremely lacking, period. Try Ruby.
For example, I had to write my own functions to do something
as simple as a case insensitive string comparison

Because that's just stricmp(), you might not yet know how to browse the
various documentations.
and a substring search.

strstr(). But both of those functions are essentially hacks, grandparented
into C++ due to wide use in pre-existing applications.

To write unhacked versions, you have a wide variety of locale, regular
expression, and string management libraries to choose from. Unifying all
this wealth just to put it into a single distribution would be a pyrrhic
victory. Here's why...
Then I found that there are no networking
classes to speak of (except sockets).

We are discussing 3 C++'s here. The raw C++, defined by the ISO Standard,
contains the _minimum_ that C++ implementations must implement to be allowed
to call themselves Standard. And Standard C++ should be implementable on
platforms as diverse as cell phones and satellites, so we can't ask for the
ISO committee to throw in the kitchen sink. (That's available at
www.boost.org ;)

The second C++ is the distribution you are actually using. It will come with
numerous extensions and numerous hooks into your platform. Those hooks
include locale stuff, to get case-insensitive string comparisons right
across a wide variety of locales, each with differing opinions what "case"
means.

The third C++ is the union of all the compatible libraries you could Google
for and re-use. Go nuts.
After I thought about
it, C++ really pales by comparison. Java has a rich set of
networking classes, regular expressions, JSP, micro edition,
security classes, imaging, swing GUI, etc., etc. I can also
build executables for several different platforms with one set
of source code.

Right. And that largesse limits the platforms that can run complete Java,
_and_ the platforms that can run a stripped-down version.

But you don't care; you just want to write desktop applications. That's
fine. For C++, download a library like wxWidgets.

Gee, wxWidgets comes with networking classes, regexps, JSP, security stuff,
graphics stuff, a complete GUI, etc. etc. You can also write source that
compiles for several different platforms with one set of source code.

The point is the language and the platform are different things, and
expecting each language to always support one favored platform is specious.

Now try Ruby. Because it comes with a monolithic platform, based on GNU, it
satisfies your checklist too. And this raises a new question: Unless you are
writing a new database engine or videogame engine, why are you trying to use
C++? It's not the best language for minor applications.
If I'm wrong, I just don't see it.

To put it simply: If you weren't "wrong", then a huge number of companies
who have come to rely on C++ _not_ enforcing a monolithic platform would be
completely screwed.
 
S

somebody

Nope. Anyone who shares a strong opinion with the 'net that disagrees with
mine is obviously a complete troll. ;-)


Java is extremely lacking, period. Try Ruby.

I don't understand at all how you can arrive at that conclusion.
Have you seen Java's API documentation?
Because that's just stricmp(), you might not yet know how to browse the
various documentations.


strstr(). But both of those functions are essentially hacks, grandparented
into C++ due to wide use in pre-existing applications.

Yes, I struggled my way through the stricmp() and strstr() dilemma,
and found that these were not standard functions, leading me to
write my own. C++ has been around long enough, and should have
standard classes to handle such trivial things.
To write unhacked versions, you have a wide variety of locale, regular
expression, and string management libraries to choose from. Unifying all
this wealth just to put it into a single distribution would be a pyrrhic
victory. Here's why...


We are discussing 3 C++'s here. The raw C++, defined by the ISO Standard,
contains the _minimum_ that C++ implementations must implement to be allowed
to call themselves Standard. And Standard C++ should be implementable on
platforms as diverse as cell phones and satellites, so we can't ask for the
ISO committee to throw in the kitchen sink. (That's available at
www.boost.org ;)

Well, Java just went to Mars, and can run on cell phones and numerous
other devices, yet it has ten times the functionality "out of the box"
as C++.
The second C++ is the distribution you are actually using. It will come with
numerous extensions and numerous hooks into your platform. Those hooks
include locale stuff, to get case-insensitive string comparisons right
across a wide variety of locales, each with differing opinions what "case"
means.

The third C++ is the union of all the compatible libraries you could Google
for and re-use. Go nuts.


Right. And that largesse limits the platforms that can run complete Java,
_and_ the platforms that can run a stripped-down version.

But you don't care; you just want to write desktop applications. That's
fine. For C++, download a library like wxWidgets.

Gee, wxWidgets comes with networking classes, regexps, JSP, security stuff,
graphics stuff, a complete GUI, etc. etc. You can also write source that
compiles for several different platforms with one set of source code.

I've read a bit about wxWidgets. I'm a bit apprehensive about using
3rd party libraries for any major development tasks. They could be
here today, gone tomorrow. This is the type of functionality I'd
like to see standard in C++.

The point is the language and the platform are different things, and
expecting each language to always support one favored platform is specious.

Now try Ruby. Because it comes with a monolithic platform, based on GNU, it
satisfies your checklist too. And this raises a new question: Unless you are
writing a new database engine or videogame engine, why are you trying to use
C++? It's not the best language for minor applications.


To put it simply: If you weren't "wrong", then a huge number of companies
who have come to rely on C++ _not_ enforcing a monolithic platform would be
completely screwed.

What I'd like to see are more standard classes for C++, similar to Java.
Then the functionality would be there if you wanted to use it, or not.
 
V

Val

| On Mon, 02 May 2005 02:46:56 +0000, Phlip wrote:
|
| > somebody wrote:
| >
| >> No, I'm not a troll, just angry.
| >
| > Nope. Anyone who shares a strong opinion with the 'net that disagrees with
| > mine is obviously a complete troll. ;-)
| >
| >> I just started learning
| >> C++, and find it extremely lacking compared to Java.
| >
| > Java is extremely lacking, period. Try Ruby.
|
| I don't understand at all how you can arrive at that conclusion.
| Have you seen Java's API documentation?
|

You can count on it that Phlip and many other C++ coders have "seen" the Java API documentation :).

But you missed the whole point.
If you don't write system applications, or low level code in general like engines, you (or anyone) shouldn't be bothered by C++ to
start with. Java has it's merits. And so does Ruby (if you like OO). But so does C++. I stick with it because I have more options
to code more OO like. More then with Java. Some coding is required, but I won't do for less. In fact, I am seriously considering
to make the step towards Ruby for desktop apps :).
Anyway, it doesn't make sense to compare the Java functionality with C++.
wxWidgets is here to stay. In fact, new developments are highly promising again. Try downloading wxDev-Cpp:
http://wxdsgn.sourceforge.net/
It has a much better GUI designer than any other commercial GUI design interfaces. Your C++ compiler would be fairly up-to-date as
well.

But it the end, it is up to you see the beauty of all kinds of programming languages.
- Val -
 
P

Phlip

somebody said:
I don't understand at all how you can arrive at that conclusion.
Have you seen Java's API documentation?

Language advocacy is a sad USENET addiction. All languages suck. However...

Here's the Ruby code to invoke a function on another computer:

require 'drb'

class TestServer
def doit
"Hello, Distributed World"
end
end

aServerObject = TestServer.new
DRb.start_service('druby://localhost:9000', aServerObject)
DRb.thread.join # Don't exit just yet!

Here's the trivial server-side code:

require 'drb'
DRb.start_service()
obj = DRbObject.new(nil, 'druby://localhost:9000')
# Now use obj
p obj.doit
I have heard that's harder to set up and run in Java. I suspect it's
extremely difficult in C++.
Yes, I struggled my way through the stricmp() and strstr() dilemma,
and found that these were not standard functions, leading me to
write my own.

So what if they are not "standard"?
C++ has been around long enough, and should have
standard classes to handle such trivial things.

They are _supported_, meaning you are just as encouraged to use them as if
they were Standard. You are not thinking of writing a program portable to
cell phones, right?
Well, Java just went to Mars, and can run on cell phones and numerous
other devices, yet it has ten times the functionality "out of the box"
as C++.

You are still not connecting. Not _all_ of the core of Java went to Mars.
Enforcing a single platform from an ISO Standard would _limit_ that
Standard's applicability. _Not_ extend it.
I've read a bit about wxWidgets. I'm a bit apprehensive about using
3rd party libraries for any major development tasks. They could be
here today, gone tomorrow. This is the type of functionality I'd
like to see standard in C++.

Okay. You want someone else to appoint what library you _should_ use.

How can you write a program that does _anything_?
What I'd like to see are more standard classes for C++, similar to Java.
Then the functionality would be there if you wanted to use it, or not.

Sounds like www.boost.org again. Ask them why they don't do GUIs or various
other things on your list...
 
B

block111

I learned java long time ago in college, and recently when I tried to
program in java I also hated it :) it doesn't have so many nice things
I like about c++, but I didn't go to comp.lang.java because I was angry
with java :)
I don't understand at all how you can arrive at that conclusion.
Have you seen Java's API documentation?


Yes, I struggled my way through the stricmp() and strstr() dilemma,
and found that these were not standard functions, leading me to
write my own. C++ has been around long enough, and should have
standard classes to handle such trivial things.

Who told you that strstr isn't standard? There's a lot of libraries
around that can help you do what you want. One thing to note - string
insensetive comparision is very easy for us/english locale to write,
but is very complicated think in general for all locales
I've read a bit about wxWidgets. I'm a bit apprehensive about using
3rd party libraries for any major development tasks. They could be
here today, gone tomorrow. This is the type of functionality I'd
like to see standard in C++.

You are free to make such proposal...
GNU, it
ly on C++ _not_ enforcing a monolithic platform would be
What I'd like to see are more standard classes for C++, similar to Java.
Then the functionality would be there if you wanted to use it, or
not.

make this proposal as well
 
P

Phlip

Val said:
You can count on it that Phlip and many other C++ coders have "seen" the
Java API documentation :).

Actually, I have not. I'm probably quite rare. I'm thinking of bragging at
the top of my resume, "Java Free Zone".

While I admit to a few flight hours with Java, what I know about it comes
from reading tens of thousands of posts, blog entries, magazine articles,
and books about it.

Java is one company's successful attempt to populate web browsers with a
stable and useful thick-client solution using virtual code. If Java had not
been invented just when web browsers exploded in popularity, you would never
have heard of it.

To hit that sweet spot, Java competed only with C++ and simpler languages,
like the Basics. It did not compete with Smalltalk, Perl, or the functional
languages that were investigating a new aspect of Object Orientation. Those
languages typically permit virtual methods without inheritance from a common
base. Put another way, a language with dynamic typing inherits all classes
from a magic class called Object, with the potential for every method. That
permits much faster coding (at the expense of a little runtime speed).

Next, such languages support block closures. They are are more than a
convenience: Variables must always have the narrowest scope possible, and
variables linked to a block, such as x, have the narrowest conceivable scope
over an indefinite lifespan.

To whit:

Binding events to GUI controls is the heart of GUI architecture, and the
best bindings are block closures. Not many languages provide these,
including many inexplicably popular languages designed specifically to
support GUIs. To learn about them, add an experiment to our Temporary
Interactive Test:

X = 42

oval.bind('Button-1') {
|event|
doc(event)
puts x.inspect()
}

Ruby statements between { and } (or begin and end) form an object, called a
block, which passes into any method on its left. That method can evaluate
the statements inside the block immediately, and can store the block as an
object, called a Proc, so something can call it later. The block links to
instances of variables seen from functions around it, such as our x, even
after such functions return. Each instance of the block links to a parallel
instance of each variable, so such variables persist until the block itself
destroys. Languages such as Perl and Smalltalk also use these "block
closures". They are more than a convenience: Variables must always have the
narrowest scope possible, and variables linked to a block, such as x, have
the narrowest conceivable scope over an indefinite lifespan.

Ruby executes the above statement by calling bind(), and passing into it a
handle to the block that starts on its right. bind() stores the block in the
oval control's private memory. Control Flow then enters Tk.mainloop(),
paints the window, and waits for hardware events. When we click on the oval,
Tk constructs an event object, and passes it into our block. It arrives in
our |event| parameter variable, and we drop it into a function called doc(),
which displays what makes it tick.

Now, why might a C++, C#, or Java user never have heard of dynamic typing or
block closures? Because really big companies push C++, C#, and Java, while
only newer, more experimental languages support dynamic typing and block
closures.

This wouldn't be such a bad situation, except that all the generic OO books
these days use Java as their reference language, "because everyone else was
doing it." So such books don't cover dynamic typing or block closures. They
limit their value, and they don't show how simple some code could be.
 
I

Ioannis Vranos

somebody said:
No, I'm not a troll, just angry. I just started learning
C++, and find it extremely lacking compared to Java.
For example, I had to write my own functions to do something
as simple as a case insensitive string comparison, and a
substring search. Then I found that there are no networking
classes to speak of (except sockets). After I thought about
it, C++ really pales by comparison. Java has a rich set of
networking classes, regular expressions, JSP, micro edition,
security classes, imaging, swing GUI, etc., etc. I can also
build executables for several different platforms with one set
of source code.

One thing that Java cannot handle is promiscuous sockets.
I began writing a port sniffer type program in Java, and
found it has no support for this. Still, I'm somewhat
disappointed with C++, and wish they would add some more
standard functionality like networking or HTTP type classes.
Well, there's my rant, I feel better now. If I'm wrong,
I just don't see it.


I wonder how many times we will face this. :)


When people mention "Java" they are actually talking about two things. The Java language
(syntax) and the Java framework (JVM). The last is open only to the Java language. So when
you are programming for the JVM you are targeting only one platform, the JVM.


If JVM was open to other languages like C++, then C++ programmers would also target it,
and thus would also have the same JVM facilities (like garbage collection etc).


This is what is happening with other virtual machine frameworks, like .NET (a CLI
compliant VM). C++ .NET applications are always targeting the framework and thus always
have the garbage collection and other facilities of the framework.


So in few words, C++ takes advantage of all facilities a system provides. If you target a
virtual machine you get all the facilities of the virtual machine, if you target a native
machine you get the facilities of the native machine.


I hope this makes things clear.
 
O

Owen Jacobson

Now, why might a C++, C#, or Java user never have heard of dynamic typing
or block closures? Because really big companies push C++, C#, and Java,
while only newer, more experimental languages support dynamic typing and
block closures.

I object to your assertion that only "newer, more experimental" languages
have features present as far back as the original Lisp.
 
A

abecedarian

Ioannis said:
When people mention "Java" they are actually talking about two things. The Java language
(syntax) and the Java framework (JVM). The last is open only to the Java language. So when
you are programming for the JVM you are targeting only one platform,
the JVM.

You are right. C++ is a language not a framework. But what prevents the
C++ community to provide a set of useful libraries as in Java, Python,
Perl, ...? I don't mean contrieved template hackery a la Boost and I
don't think that 'we' should wait and hope for the next C++ Standard
(to be finished probably in 2034). Perl has CPAN, PHP has PEAR, Python
has ... and C++ has nothing in this vein.

A.
 
P

Peter Koch Larsen

the JVM.

You are right. C++ is a language not a framework. But what prevents the
C++ community to provide a set of useful libraries as in Java, Python,
Perl, ...? I don't mean contrieved template hackery a la Boost and I
don't think that 'we' should wait and hope for the next C++ Standard
(to be finished probably in 2034). Perl has CPAN, PHP has PEAR, Python
has ... and C++ has nothing in this vein.

A.
Do you think so? There's CORBA and several GUIs (e.g. wxWidgets as mentioned
above) just for a start. Also boost - even if you do not like templates -
has offerings for lots of low-level stuff. Math, regular expressions,
strings,.....
All in all, there are lots of high quality libraries out there.

/Peter
 
I

Ioannis Vranos

You are right. C++ is a language not a framework. But what prevents the
C++ community to provide a set of useful libraries as in Java, Python,
Perl, ...? I don't mean contrieved template hackery a la Boost and I
don't think that 'we' should wait and hope for the next C++ Standard
(to be finished probably in 2034). Perl has CPAN, PHP has PEAR, Python
has ... and C++ has nothing in this vein.


At first I would like to state that C++ is suitable for application development. It takes
advantage of all facilities that a system provides (virtual machine facilities, OS
facilities, multithreading facilities, GUI facilities, networking facilities etc).

Now the question arises. Why C++ doesn't come with its own built-in framework? The answer
is simple:

Apart from application development, C++ also aims to be a *systems programming language*
and one major goal of its design is maximum space and run-time efficiency.


In .NET for example you can do:

int x;

String *p= x.ToString();


This is possible because all built in types are structs with their own methods inheriting
from the base type Object.


Here is about int (System::Int32):

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemint32memberstopic.asp


However this is not part of the language itself because this implies overhead, and C++ is
used from small, unseen, embedded devices to large mainframes and in applications under
*severe* time and space constraints (Operating Systems, weather simulation and
forecasting, telephone systems, writing virtual machines like the JVM (it is written in
C++), etc.


So the goals of Java and C++ are different. Java language (syntax) aims for application
development on a specific virtual machine (and do not confuse the JVM's facilities with
the language syntax itself), while C++ aims for application development *everywhere* and
direct systems programming on *all* hardware.


So under the limits (I consider them as limitations) of the Java goals, Java is OK to be
used for them.


About .NET, with VS 2005 C++ becomes the systems programming language of .NET:


Some references:

http://msdn.microsoft.com/msdnmag/issues/05/01/COptimizations/default.aspx

http://pluralsight.com/blogs/hsutter/archive/2004/10/05/2672.aspx

http://blogs.msdn.com/branbray/archive/2003/11/07/51007.aspx

http://www.accu.org/conference/pres...Relevant_on_Modern_Environments_(keynote).pdf


And a page of mine:

http://www23.brinkster.com/noicys/cppcli.htm


If you want to see how is application development with C++ under .NET, you can download
the free Visual C++ Express 2005 Beta 2 from http://msdn.microsoft.com


I am sending attached a screenshot of Beta 1 in a subsequent message.
 
A

Alf P. Steinbach

* somebody:
No, I'm not a troll, just angry. I just started learning
C++, and find it extremely lacking compared to Java.
For example, I had to write my own functions to do something
as simple as a case insensitive string comparison, and a
substring search.

You don't have to: the wheel has been invented umpteen times.

Then I found that there are no networking
classes to speak of (except sockets). After I thought about
it, C++ really pales by comparison. Java has a rich set of
networking classes, regular expressions, JSP, micro edition,
security classes, imaging, swing GUI, etc., etc. I can also
build executables for several different platforms with one set
of source code.

The Java libraries are wrappers around C/C++ libraries.

One thing that Java cannot handle is promiscuous sockets.
I began writing a port sniffer type program in Java, and
found it has no support for this. Still, I'm somewhat
disappointed with C++, and wish they would add some more
standard functionality like networking or HTTP type classes.
Well, there's my rant, I feel better now. If I'm wrong,
I just don't see it.

C and C++ provides freedom to choose whatever library you want,
or make it yourself; Java provides canned functionality. When
what you want to do is covered by the Java libraries you'll have
higher productivity. C++ isn't deficient in libraries (it's the
other way around: more libraries exist for C++ than probably for
any other language, since C and C++ are the OS implementation
languages), but C++ is very deficient in some important areas that
you haven't mentioned: module support, Unicode support, thread
support, some way to make Template<B> a subclass of Template<A>
when B is a subclass of A (needed to e.g. create Java reference-
like smartpointers), and perhaps more. So your instinct is right,
that there is much room for improvement, but example is decidedly
poorly chosen since libraries is the one thing _not_ lacking.
 
G

Gernot Frisch

C++ isn't deficient in libraries (it's the
other way around: more libraries exist for C++ than probably for
any other language, since C and C++ are the OS implementation
languages)

I don't think there's anything C++ lacks behind Java. However a few
things should be added, so the interfaces of libraries around would
fit together better:
- build in types like: __int64, __int32, __int16
- a 'typeof' operator

Just my .02$,
Gernot
 
W

whisper

You can try stl, boost, ace, wxWindows, etc
C++ is different from java, we should not compare them
 
P

Peter Koch Larsen

Gernot Frisch said:
I don't think there's anything C++ lacks behind Java. However a few things
should be added, so the interfaces of libraries around would fit together
better:
- build in types like: __int64, __int32, __int16
- a 'typeof' operator

Just my .02$,
Gernot
By requiring such types to be available restricts the portability. Having
them available if the platform supports them might be nice, though. On the
other hand... how often are these types needed? Is it not only rarely you
use these types in portable code?

/Peter
 
P

Phlip

abecedarian said:
You are right. C++ is a language not a framework. But what prevents the
C++ community to provide a set of useful libraries as in Java, Python,
Perl, ...?

The C++ community prevents the C++ community from providing them.

And they already exist. We have already told you several cross-platform
libraries that compete in Java's space.

The C++ community declines to _enforce_ them. We won't detain all
programmers who use the "wrong" library.

About CPAN and PEAR, C++ supports more platforms, making a cross-platform
magic installer much harder.

But systems like GNU come with "autoconf" routines that provide a relatively
standardized installation cycle. For GNU platforms.

Owen said:
Phlip wrote:

I object to your assertion that only "newer, more experimental" languages
have features present as far back as the original Lisp.

Oh dear. The entire arc of my argument just collapsed. Folks, C++ needs a
Standard Platform, enforced by statism.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top