Java or C++?

P

Pascal J. Bourguignon

Hi to all,

I've to say that all these threads C++ vs the world are very
interesting.

I'am an amateur programmer, I do small MIDI and audio apps just for
fun,
mainly for my electronic music productions( always just for fun, no
talent at all, sigh... ;-)

All the statements made in recent threads make me think that all the
hours spent in
learning how to program in C and C++ were useless.

Not entirely. But to have fun developping small MIDI and audio
application, indeed I wouldn't consider C or C++ indicated.
So out of frustration I would like to ask to Java, 0Caml or whatever
else supporters:
How many POPULAR COMMERCIAL APPS in "real-time" fields like audio,
video or video-games
are made in Java or whatever else. I ask about these kind of apps
because they're the ones
I'm mostly interested in and because I would think they're the ones
where speed is of great importance.

Remember that real-time is not the same as fast. Real-time means that
the time needed to do some computation is bounded, the bound is known,
and is less than the period in which it must be computed.

For MIDI applications, that means that you need to compute one byte
every 1/3125 second = 320 microsecond. There's time to execute more
than 320000 instructions on a modern processor to compute that byte.
And a note on command is three bytes, meaning that you have more than
one millisecond to compute the next note on or note off... An eternity
on current processors.

[...]
So if EVERYTHING can be done more productively in Java or 0Caml ( or
whatever ) and the final result should
be even faster (??) than the C or C++ equivalent, WHY all pros in the
above mentioned genres are still using
obsolete languages?

McDonald vs. La Tour d'Argent.

Also, most often, it's not programmers who get to choose the
programming language, but the managers. And what matters to the
manager is not that programming be efficient or fun, but that they be
able to hire easily (ie. cheaply) a lot of monkeys^W "programmers".


Anyways, you're in the game for fun, not for money, so why should you
care what the so called "pro" do or don't? Choose a programming
language in which you don't spend time on trivial technicalities, and
with which you have fun programming your little applications.
 
X

xtrigger303

Not entirely. But to have fun developping small MIDI and audio
application, indeed I wouldn't consider C or C++ indicated.


VST plug-ins were built by sub-classing a C++ class (this a few years
ago,
don't know now)
Core Audio on the Mac is a C framework, with C++ wrappers
Programming on the Mac is mostly Obj-C (these days)

Remember that real-time is not the same as fast. Real-time means that
the time needed to do some computation is bounded, the bound is known,
and is less than the period in which it must be computed.


I don't know if an Audio Sequencer is a "real-time" app, for sure has
to complete
all its rendering functions in a given amount of time (forget about
buffering...)
The faster the code is, the better, isnt'it? For example, the amount
of audio plug-ins
that can work "simultaneously" is affected by the "speed" of the code.
If I were able to build Reverbs in Visual Basic I'm pretty sure that I
could run fewer of them at the same time, compared to ones written in
Java, C, C++
or whatever... Giving for granted that "equivalent" Basic interpreted
code
is slower... Is it?

For MIDI applications, that means that you need to compute one byte
every 1/3125 second = 320 microsecond. There's time to execute more
than 320000 instructions on a modern processor to compute that byte.
And a note on command is three bytes, meaning that you have more than
one millisecond to compute the next note on or note off... An eternity
on current processors.
[...]
So if EVERYTHING can be done more productively in Java or 0Caml ( or
whatever ) and the final result should
be even faster (??) than the C or C++ equivalent, WHY all pros in the
above mentioned genres are still using
obsolete languages?

McDonald vs. La Tour d'Argent.


I thought that Java was owned by Sun, while C and C++ are standardized
and
steered by independent committees...

Also, most often, it's not programmers who get to choose the
programming language, but the managers. And what matters to the
manager is not that programming be efficient or fun, but that they be
able to hire easily (ie. cheaply) a lot of monkeys^W "programmers".


So great games and apps are made by forcing sub-intelligent people
to work in ways they do not like and that are proven obsolete?

Anyways, you're in the game for fun, not for money, so why should you
care what the so called "pro" do or don't? Choose a programming
language in which you don't spend time on trivial technicalities, and
with which you have fun programming your little applications.


I care about what the pros use because it's the only criteria I have
to
choose the tool of the trade. If all the apps, technologies,
literature, examples,etc...
in a certain genre are made in C or C++, why would I choose something
else?

Actually I have fun with C++, probably I would have fun also with Java
or 0Caml. The problem is the TIME i have at my disposal.

Anyway thanks for the answer. One more thing: if you were in charge of
bulilding
the next crushing video-game engine for the PS3, what language would
you choose?

Ciao,
Francesco
 
X

xtrigger303

Not entirely. But to have fun developping small MIDI and audio
application, indeed I wouldn't consider C or C++ indicated.


VST plug-ins were built by sub-classing a C++ class (this a few years
ago,
don't know now)
Core Audio on the Mac is a C framework, with C++ wrappers
Programming on the Mac is mostly Obj-C (these days)

Remember that real-time is not the same as fast. Real-time means that
the time needed to do some computation is bounded, the bound is known,
and is less than the period in which it must be computed.


I don't know if an Audio Sequencer is a "real-time" app, for sure has
to complete
all its rendering functions in a given amount of time (forget about
buffering...)
The faster the code is, the better, isnt'it? For example, the amount
of audio plug-ins
that can work "simultaneously" is affected by the "speed" of the code.
If I were able to build Reverbs in Visual Basic I'm pretty sure that I
could run fewer of them at the same time, compared to ones written in
Java, C, C++
or whatever... Giving for granted that "equivalent" Basic interpreted
code
is slower... Is it?

For MIDI applications, that means that you need to compute one byte
every 1/3125 second = 320 microsecond. There's time to execute more
than 320000 instructions on a modern processor to compute that byte.
And a note on command is three bytes, meaning that you have more than
one millisecond to compute the next note on or note off... An eternity
on current processors.
[...]
So if EVERYTHING can be done more productively in Java or 0Caml ( or
whatever ) and the final result should
be even faster (??) than the C or C++ equivalent, WHY all pros in the
above mentioned genres are still using
obsolete languages?

McDonald vs. La Tour d'Argent.


I thought that Java was owned by Sun, while C and C++ are standardized
and
steered by independent committees...

Also, most often, it's not programmers who get to choose the
programming language, but the managers. And what matters to the
manager is not that programming be efficient or fun, but that they be
able to hire easily (ie. cheaply) a lot of monkeys^W "programmers".


So great games and apps are made by forcing sub-intelligent people
to work in ways they do not like and that are proven obsolete?

Anyways, you're in the game for fun, not for money, so why should you
care what the so called "pro" do or don't? Choose a programming
language in which you don't spend time on trivial technicalities, and
with which you have fun programming your little applications.


I care about what the pros use because it's the only criteria I have
to
choose the tool of the trade. If all the apps, technologies,
literature, examples,etc...
in a certain genre are made in C or C++, why would I choose something
else?

Actually I have fun with C++, probably I would have fun also with Java
or 0Caml. The problem is the TIME i have at my disposal.

Anyway thanks for the answer. One more thing: if you were in charge of
bulilding
the next crushing video-game engine for the PS3, what language would
you choose?

Ciao,
Francesco
 
F

fossilx

As both a python and c++ programmer, I personally would recommend c++
over java. My reasoning for this is simple:

---
If you choose Java...

Pros: You will be adding on the ability to easily create GUI
applications and use a quasi-compiled (into bytecode) language. Java
also has what I believe to be a well-documented library of functions.
It also provides the ability to create webpages easily (or so I
think).

Cons: Java code is compiled into bytecode which is run via a virtual
machine on the computer in question. Python is very similar in this
regard as it requires the python executable to run the files (which,
if i remember the semantics correctly, are also compiled to a form of
bytecode and only recompiled upon changes to the source files). As
far as I can see it, learning Java would do little for your skill
set. Python can already make webpages, python can easily be
integrated into many popular web servers (apache/lighttpd/etc). In
essence, learning Java would simply provide you with another language
that is similar in functionality to python (or at least in my
opinion).

---
Now, if you pick C++:

Pros: You can do...anything. You are limited by your imagination.
Once you learn the fundamental OOP concepts surrounding c++ you'll not
only be able to adapt it to other languages, but you will be able to
learn many other languages quickly. If you learn the basics of c and c
++ you will have the ability to create python modules. Now, while you
can use c++ to extend the java language, you are not asking about
python vs. java, but rather c++ vs. java.

Cons: Slightly longer learning curve. There are a few issues and
tricks that you'll need to get used to.

---

In short, I don't really think the question is 100% fair. Java and c+
+ were designed for slightly different jobs. There are a few jobs
(such as GUI development) that I would rather use Java for, and then
many things I would use c++ over Java. However, I would propose that
your question should be more along the lines of: Python or Java.

Since you already know python, the choice is obvious. Python can also
be made fairly fast if used correctly, especially if you use the pypy
python module/library to create c-versions of your code.

I have been programming both languages for 2-5 years (c++ for 5,
python for 2) and am completely self taught. I can honestly say that
I enjoy learning/working with c++ far more than my limited exposure to
java. And well, I love python, but you already now how useful/awesome
the language is.

---

I understand that I may have missed a few of the key pro's and con's
of the above. I have class in 5minutes so am trying to hurry, but I
do believe that I covered my opinion on the topic to an acceptable
extent.

Hope this helps.
Tony M.
 
P

Pascal J. Bourguignon

fossilx said:
As both a python and c++ programmer, I personally would recommend c++
over java. My reasoning for this is simple:

---
If you choose Java...

Pros: You will be adding on the ability to easily create GUI
applications and use a quasi-compiled (into bytecode) language. Java
also has what I believe to be a well-documented library of functions.
It also provides the ability to create webpages easily (or so I
think).

Cons: Java code is compiled into bytecode which is run via a virtual
machine on the computer in question. Python is very similar in this
regard as it requires the python executable to run the files (which,
if i remember the semantics correctly, are also compiled to a form of
bytecode and only recompiled upon changes to the source files). As
far as I can see it, learning Java would do little for your skill
set. Python can already make webpages, python can easily be
integrated into many popular web servers (apache/lighttpd/etc). In
essence, learning Java would simply provide you with another language
that is similar in functionality to python (or at least in my
opinion).

There are java "native" compilers, that is, java compilers that
compile to the Intel virtual machine (the one that is implemented as
microprogram over Intel processors such as Xeons or Pentiums)..

---
Now, if you pick C++:

Pros: You can do...anything. You are limited by your imagination.
Once you learn the fundamental OOP concepts surrounding c++ you'll not
only be able to adapt it to other languages, but you will be able to
learn many other languages quickly. If you learn the basics of c and c
++ you will have the ability to create python modules. Now, while you
can use c++ to extend the java language, you are not asking about
python vs. java, but rather c++ vs. java.

Cons: Slightly longer learning curve. There are a few issues and
tricks that you'll need to get used to.

There are C++ interpreters. Should we care about interpreted
programming language such as C++? </irony>


Now, in C++, you can do anything, as long as you can hold in your head
all the little details you must take into account when programming in
C++, like memory management. If you have a little head like me, you
may prefer a higher level programming language.


The choice of a programming language should not (only) be directed by
the kind of processor it runs on. It's rather easy to port a
programming language on another target processor, be it a virtual
machine, an interpreter or a compiler.

In short, I don't really think the question is 100% fair. Java and c+
+ were designed for slightly different jobs. There are a few jobs
(such as GUI development) that I would rather use Java for, and then
many things I would use c++ over Java. However, I would propose that
your question should be more along the lines of: Python or Java.
[...]

Right. The niche for C++ is very small.
 
E

Erik Wikström

(e-mail address removed) writes:
[...]
So if EVERYTHING can be done more productively in Java or 0Caml ( or
whatever ) and the final result should
be even faster (??) than the C or C++ equivalent, WHY all pros in the
above mentioned genres are still using
obsolete languages?

McDonald vs. La Tour d'Argent.

Also, most often, it's not programmers who get to choose the
programming language, but the managers. And what matters to the
manager is not that programming be efficient or fun, but that they be
able to hire easily (ie. cheaply) a lot of monkeys^W "programmers".

By that reasoning shouldn't most games these days be written in Java, as
far as I know that is what most monkeys^W programmers are thought these
days.
 
J

James Kanze

I've to say that all these threads C++ vs the world are very
interesting.
I'am an amateur programmer, I do small MIDI and audio apps
just for fun, mainly for my electronic music productions(
always just for fun, no talent at all, sigh... ;-)
All the statements made in recent threads make me think that
all the hours spent in learning how to program in C and C++
were useless.
So out of frustration I would like to ask to Java, 0Caml or
whatever else supporters: How many POPULAR COMMERCIAL APPS in
"real-time" fields like audio, video or video-games are made
in Java or whatever else. I ask about these kind of apps
because they're the ones I'm mostly interested in and because
I would think they're the ones where speed is of great
importance.
My understanding is that (correct me if I'm wrong ):
- Almost all today's audio technologies/apps (like Cubase, Logic, VST
and Core Audio stuff )
are written in C and C++. For an awesome audio app that is written
mainly in C++ check out
Propellerheads Reason.

I couldn't say, since I don't work in the field.
- 90% of todays video-game engines are written in C or C++. I'm
totally sure about Unreal Engine.
Plus I've seen source code for Quake and others. Never seen any Java
code for POPULAR GAMES.
- My personal favourite Metal Gear Solid for PS2 had its engine
written in C. I'm sure about MGS2,
cannot be sure about the others, but...
So if EVERYTHING can be done more productively in Java or
0Caml ( or whatever )

But it can't. I don't know about OCaml, but most things can be
done more productively in C++ than in Java.
and the final result should be even faster (??) than the C or
C++ equivalent, WHY all pros in the above mentioned genres are
still using obsolete languages?

C++ is hardly an obsolete language; in many ways, it's more up
to date than Java.

[...]
All this said I've to say that some Razii's thread are very
interesting...

If you like a lot of noise and no real information...
 
J

James Kanze


[...]
Now, in C++, you can do anything, as long as you can hold in
your head all the little details you must take into account
when programming in C++, like memory management. If you have
a little head like me, you may prefer a higher level
programming language.

The whole point of C++ is that you don't have to. You can
adjust the level of abstaction to what is needed, rather than be
forced to use one which isn't appropriate. Thus, for example,
there's no problem using garbage collection with C++ (although
it's not as essential as it is in Java; some C++ applications
manage to get the job done with no dynamic allocation
whatsoever).
The choice of a programming language should not (only) be
directed by the kind of processor it runs on. It's rather
easy to port a programming language on another target
processor, be it a virtual machine, an interpreter or a
compiler.
In short, I don't really think the question is 100% fair.
Java and C++ were designed for slightly different jobs.
There are a few jobs (such as GUI development) that I would
rather use Java for, and then many things I would use c++
over Java. However, I would propose that your question
should be more along the lines of: Python or Java. [...]
Right. The niche for C++ is very small.

You mean like everything from OS kernel code to large scale
application servers. Unlike Java, C++ is a general purpose
language, and can be used effectively for pretty much anything.
Java's specialized for a few specific application areas---it's
not really that bad, and it could actually be used for more
things that it is, but it still doesn't cover the broad range
that C++ does.
 
J

James Kanze

As for where Java dominates, one of the most significant uses
of Java is for Server Side web programming, Servlets, JSP and
EJB.

Definitly. First, of course, it's what the various frameworks
(Apache, BEA, WebSphere, etc.) support directly---there's
nothing like good environment support to make a language look
good. But such applications also usually conform to the type of
thing Java is good at: each program is small (so programming in
the large issues aren't relevant), the programs tend to be very
dynamic, written quickly, and not maintained for any long period
of time, and reliability isn't the first criteria---the programs
themselves don't manage any of the critical corporate data.

Generally, I tend to use Java when the program isn't managing
data, but presenting it. I've yet to find an equivalent of
Swing in C++, and of course, Java's libraries have a lot of
classes designed to integrate the program into a web
environment, and to facilitate communication with the programs
which actually manage the data. While our servers are 100% C++,
the monitor programs which display their various states are in
Java: a GUI, communicating with about 10 different servers,
displaying the links between them, and their states, but not
providing any critical functionality. The servers, on the other
hand, are not allowed to fail, and must ensure transactional
integrity of the data. So they're written in C++. (They're
still small enough that the program size issue probably wouldn't
exclude Java, but I've worked on much larger servers where it
would also have played a role.)
Embedded devices Cell phones, PDAs and set-top boxes.

Most cell phones run Symbian, I believe. Which is written in
C++, and provides the system API in C++. And typically, the
critical functionality (call handling, handover, etc.) will be
written in C++. Java is used for the games, and the flashy
interface.

Most real applications consist of more than one "program", and
will contain code written in several different languages.
Mobile Information Devices Profile (MIDP) uses Java run time
environment in cell phones, mobile tracking systems and other
traditional PDA devices. Java enabled application is key to the games
and services available in the mobile world. Designed for cell phones,
the Mobile Information Device Profile boasts GUI API, and MIDP 2.0
includes a basic 2D gaming API. Applications written for this profile
are called MIDlets. Almost all new cell phones come with a MIDP
implementation, and it is now the de facto standard for downloadable
cell phone games.

Exactly. For cell phone *games*. The critical functionality
isn't written in Java. And almost nothing in the cells
themselves will be written in Java (at least not here in
Europe).
GOOGLE is introducing a custom version of its Gmail email
service that can run on any phone with Java software.
Database:
Java is used in database programming with JDBC. Oracle embed
Java virtual machines into the heart of their Database
systems.

No. Java interfaces with the databases using JDBC. The actual
"language" involved is SQL (and that works just as well in
C++---unlike the case with GUIs, some of the C++ libraries for
interfacing with databases are actually pretty good, where as
JDBC is rather ordinary). The database itself is almost
certainly not written in Java.

Again: Java provides the flashy but non-critical front end, and
the parts which have to work are written in C++ (or, in the case
data bases, for historical reasons, still largely in C).
 
Y

Yakov Gerlovin

I've been programming Python for a couple of years now. Now I'm
looking to move on to either C++ or Java, but I'm not sure which.

Which one do you think will be a better transition for a Python
programmer? Which one will educate me the best?

Think of any programming language as just a tool. When building a
house for example, you first define a job (building the house) and
then you choose a set of tools to do this job. This set of tools may
be useless (fully or partially) for fixing your car, for example. The
same logic can be applied here.

When you need to build a server with garanteed fast response time,
that can handle a large amount of the connections you probably would
choose C++.
However, if you want to manage this server and need to build a nice
GUI in short time you will probably chose Java.

If you want to find a better job,for example, then you might want to
consider non-technical aspects, such as salary of Java programmer vs C+
+ programmer (or may be amount of job offers).

If you have an academic interest, C++ would be better choice (IMHO),
since it has a larger application domain and supports some
interesting concepts (like generic programming)

HTH,
Yakov
 
P

Pascal J. Bourguignon

Chris Thomasson said:
Chris Thomasson said:
Razii said:
On Mon, 21 Apr 2008 09:04:54 -0700 (PDT), James Kanze
As for where Java dominates, one of the most significant uses of Java
is for Server Side web programming, Servlets, JSP and EJB.

A surveye (BZ Research) on which languages people were using for AJAX
development had some interesting results. Java was the number one
language (50.5%). C# was second with 40.5%. C and C++ (combined) made
up 10.6%. See the graph
(http://www.oreillynet.com/xml/blog/2006/09/languages_used_in_ajax_develop.html
)
[...]

What are the most popular language(s) used to create
high-performance JVM's?

This definitely does _not_ prove anything at all, but it appears that
SUN uses C for their VM.

Yes, it proves something important: C is the best portable assembler
in the world.

Now, who wants to write an application in assembler, or assembler++?
 
J

James Kanze

Symbian is an operating system. The native language is C++
which is used for device drivers and other core components.
Symbian C++ programming has a steep learning curve. Symbian
cell phones support JavaME and HotSpot JIT compiler is
included.
This is a good example: if someone writes an app (let's say a
game) in C++ specifically targeting Symbian phone,

And your point is? Non critical components, like games, can be
written in Java, as long as they aren't too big. The critical
parts (the OS itself, but also the call handling, etc.) are
written in C++.
 
M

Matthias Buelow

Razii said:
What's new in Java RTS?

This is a C++ newsgroup; if people wanted to read java marketing stuff,
they'd do it on c.l.java.advocacy (if such exists).
 
L

Lionel B

It would be far better if you learn to use filters. The thread was no
started by me, and even though I tried to ignore the thread, just a
random click on a post, and I saw my name mentioned. As usual, Kanze was
posting his typical anti-Java stuff as he is well known for this, and
has been doing for years. I responded to his post. Why didn't you
complain about pro-c++ propaganda posted in the thread by several
people? In any case, it's pretty clear from the subject what the thread
is about. What exactly are you whining about? Right click on the thread
and click on ignore.

Eejit.

<plonk>
 
C

coal

I recommend learn C++ and Java all.

I disagree. I recommend picking one and learning it. They are
both big languages and it will be easier to keep your sanity if
you focus on one. I'd further recommend picking C++. When I
started working on an alternative to C++ serialization libraries,
I worked on supporting basic types and standard containers.
It wasn't until later that I started thinking about supporting user
defined types. I didn't think through what support for
user defined types would involve and just got to work on the basics.
Eventually when we added support for udts we realized
that we didn't want to repeat the code over and over every time
an object gets used as part of a message. So we needed to write/
generate methods that would be part of the class. Users
of the software simply add prototypes to their classes and the
implementation of those methods is written in a separate file. That
works fine in C++. We briefly considered adding support
for Java to our services, but we realized that Java's rule requiring a
class to be completed in the file it is started
would cause us headaches. We didn't want to attempt to add
computer-generated code to a file that has hand-written code
in it. What if we accidentally alter some hand-written code?
Plus it is simpler conceptually if you know everything in a
file is hand-written. Or it is all computer-generated. I'm
thankful to G-d for keeping us from investing a lot of time
in a language that has a rule like that. In my opinion the
rule is there as an attempt to force people who would
otherwise be able to compete with Sun to have to negotiate
with Sun. I'm happy to have stuck with C++ and think in the
long run it is the better choice.

Brian Wood
Ebenezer Enterprises
www.webEbenezer.net

"Where the Spirit of the L-rd is, there is liberty."
2 Cor. 3:17
 

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,776
Messages
2,569,603
Members
45,196
Latest member
ScottChare

Latest Threads

Top