The Future of C++ ?

C

Chris Thomasson

blangela said:
[...]
Well note too that the bookstores are dumbing down the book selection to
commercial product manuals rather than computer science stuff. Today's
generation of "programmers" are closer to assembly line workers than
their predecessors.

Tony

I agree with you on this point. I know of a Java instructor at my
school who feels it is a waste of time to teach students data
structures or sorting algorthms -- Java provides different container
classes and sorting algorthms to select from, so why should the student
need to learn these topics. I disagree. I feel that there is still
room for the "science" in "computer science".

I completely disagree with the Java instructor as well. Data-structures and
sorting algorithms' are fundamental! Its sad that the current trend in
computer science seems to be aimed at very high-level languages which
abstract fundamental methods and techniques away to a dangerous point. It
can lead to a scenario in which a Java programmer might not now how to
create or even sort a linked list. The Java programmer might not even now
how to create a dynamic array from scratch... I feel your pain!
 
I

Ian Collins

Chris said:
I completely disagree with the Java instructor as well. Data-structures and
sorting algorithms' are fundamental! Its sad that the current trend in
computer science seems to be aimed at very high-level languages which
abstract fundamental methods and techniques away to a dangerous point. It
can lead to a scenario in which a Java programmer might not now how to
create or even sort a linked list. The Java programmer might not even now
how to create a dynamic array from scratch... I feel your pain!
How many new grads can build a system in asembly language?

As an field grows, one either has to specialise in a niche, or become a
generalist.

If they haven't done so already, CS degrees will follow that path.
 
E

Earl Purple

gn said:
Earl Purple schrieb:

Well - The problem here is that there is one java against many different C++ compilers.

Java 5 has some significant changes in it.
Normally one should think that if you are
programming C++ conform to the standard (and of course capsulating (I
still don't know the right word here in english) system functions) your
programs should compile at every platform where you have a C++
compiler. In reality thats not the case because many compilers are not
conform with the standard, especially concerning templates.

Well we are dealing with 3 situations:

- Open-source libraries. They need to build in your compiler but once
you've built it you can link it with your code easily. I much prefer
using open-source libraries. The only issue is when they're written in
macros because of all the different compilers they might be dealing
with, and particularly if they require you to set some define just to
have it compile standard C++. The situation should be that those who do
not have standard-complliant compilers should be the ones who have to
define something.

- Pre-built libraries. Now you have to get the binaries from the
vendor, and usually there are a certain number of header files but they
are basic enough to work for any compiler. The clash now comes with
linking against run-time libraries.

- Hybrids which could have the worst of both worlds, i.e. you need
compiler-specific defines and have to build with the correct runtime
library. Visibroker is the actual one I had problems with.
Additionally people who are using things like visual C++ or Borland C++
Builder are often not aware of using non standard libraries. You are
also right with the different GNU versions where I had some problems
with my template syntax.

It is incredible how many are still using VC6. Problem is of course, a
lot of their code would break on VC7/8 because it's full of "wrong" C++
that VC6 would compile.

The same is true for any modern C++ compiler, although GNU usually
allows specific switches for backward compatibility.
But all this is not a problem of C++, but of the compiler developers
(let's see what the next standard brings and how fast they are in
implementing it to all compilers). There are also many other things
that I am missing in current compilers (e.g. return value optimization
for recursive functions). I really think that C++ will become much
faster in the future because there are many such things to optimize
that is to complicated for todays compilers.

Runtime performance is not the main issue. Java has improved in that it
has improved its runtime performance to be adequate enough. Whether it
matches C++ is not always relevant, as long as it is adequate for the
task in hand. (In some cases Java can match C++ perfectly well or even
out-perform it).

The big issue here seems to be portability. C++ badly lacks a standard
runtime library in the way C has one, and a standard demangler so that
you can link GNU libraries with VC8 or Solaris ones on their specific
platforms without requiring a "C" interface.

In addition, I still feel that the reluctance of C++ to have a standard
for a network, threads, file-system, graphics device etc is something
serious lacking as part of its portability, even if there are 3rd party
libraries for many of these things, even open-source ones.
In the end everything depends on the specific tasks. For my field of
work (computational chemistry) it's simply no question to use anythingh
else than C++ or Fortran, because those quantum chemical calculations
are still to slow even on huge clusters and even for small molecules. I
also think for bigger projects in the software companies it should be
no problem to have C++ and java programmers working on the same
project. It's no problem if you have a good design.

For this there is always JNI which allows Java to interact with C. The
"D" programming language can also interact with C libraries. Once again
C++ is left out of the equation.
 
E

Earl Purple

Tony said:
If I was an instructor at a university, I would NOT put templates into a
first semester class. That's an advanced and additional paradigm and
requires choice to "buy into" IMO. I view C++ as a smorgasbord: I'll
eat what I want and like (no sushi for me!).

I would. Collections would be one of the first subjects I would teach.

One of the least important features of C++ is cin. I do not have a
single cin in any of my C++ production code. Yet it seems to be the
first thing programmers seem to learn.
Actually, even before C++, it would probably be better to take a
general studies course on programming paradigms! Then students can
take C++ as an course tailored to their needs. (No, that won't work,
cuz students by definition can't make that choice). Oh well, something
like that then.

Surely paradigms though must include handling collections.
 
E

Earl Purple

Greg said:
It may be instructive to draw some parallels between programming
languages and car transmissions. Programming in C++ is a lot like
driving a car with a manual transmission - both require "above average"
skill than the alternative available technology requires: be it
programming in a managed language or driving a car with an automatic
transmission.


Greg

A better analogy would be between building a car in Java or building
one in C++.

In Java, you would get all the components and put them together,
including the wheels.

In C++ though there is no standard for a wheel because there are some
vehicles, i.e .boats, don't have wheels so there is no need for a
standard. So you have to "reinvent the wheel" or fit one from a 3rd
party manufacturer, the only problem with that being that getting their
wheels to fit your vehicle is not always an simple matter, at least not
as straightforward as it is to fitting a standard one, because the
diagnostics of the wheels are such that they have side effects on the
rest of the manufacture of your car.
 
E

Earl Purple

I believe that developers are using templates too few.

The book I suggest to C++ beginners is Accelerated C++. I didn't
actually read it because by the time I found out about it I didn't need
it anymore. But I had a quick look through it to evaluate whether it's
good for my less experienced [ex]colleagues.

Unfortunately what looks great teaching material by those who know the
language well does not always prove to be the case. You have to try it
out on students and see how well they pick it all up.
And I think that Bob
Langelaan could use it to improve the course too, following the
suggestion of Alf P. Steinbach to start with standard library classes.

One of the more remarkable facts about the book is that template
functions are introduced in chapter 8 while classes are left for the
chapter 9. I think it's not because they are more important than
classes, but rather because they are easier to learn and they can
simplify your code.

What do they teach in chapters 1-7? Writing console apps with a lot of
cin statements?
Bluntly put, if you avoid using templates, you avoid one of the best
features of C++. You can work around that to some degree using
inheritance and virtual function overriding, but this introduces
unwanted dependencies, some (usually unimportant) performance
hit and you also lose some advantages of the static typing in the
process.

That is true but templates can also be used in the wrong place.
Template classes are often written where only a small proportion has
"dependent" code (i.e. code dependent on the template type). Such a
template should often be refactored to have a non-template handle the
non-dependent code.
 
E

Earl Purple

blangela said:
I notice that I have not seen a single post in this thread from an
instructor stating that their C++ classes are increasing in size
or even maintaining their size.

Ah, they are getting cleverer at not writing monolithic classes
anymore. Better refactoring
I know that I get students from UBC (one
of the 2 large local uniiversites, the other being SFU) who want to
learn C++. They complain that it is no longer available at UBC. Also,
when I first started teaching C++, there were several other local
colleges doing the same. Now I believe only BCIT (where I teach) is
still doing so.

Course in Java: Here is a computer. We will learn to write applications
that use all the modern features: GUI, hey we can run even in a
browser. Networking - no problem. And we can process concurrently...
Java is very useful because a lot of companies are writing brand new
software in it.

Course in C++: Here is a computer. Now let's get a DOS shell up and
write a console app. And even when you ask the user to type in a
number, there is no method to intercept the key as the user hits it, so
if the user types in "Blah" you have to go back and say "sorry that's
not a number". If we're lucky we might even write our source with the
vi editor where you have to carefully switch between modes because
there's no such thing as Ctrl or Alt so characters mean different
things at different times. C++ is very useful because there's lots of
legacy code out there written in it, usually very badly, and you can
get a job maintaining it.

Now if you are student which do you choose?

On the subject of maintaining a legacy app, yes it makes economic sense
to do so rather than go for the rewrite. You could say the same for the
language itself. Better to maintain it and even add some new features
rather than go back and write a new one from scratch which is simply
much better.

Now everyone in the C++ market seems to be claiming that the language
is used for device drivers or the "embedded" world. Now where is the
university course saying "here is a robot, now we are going to program
some C++ into its microchip". Might just be the way to make it a bit
more exciting. People would like to learn how to program robots. They
look modern. Instead of writing "hello world" and some horrible console
app with cin, we could program it to make us a cup of tea.
 
E

Earl Purple

Frederick said:
blangela:



Programming instructors don't tend to be of the highest proficiency.

They should be excellent teachers. The best programmers are usually out
there programming in it, not teaching it. But the best programmers
aren't necessarily good teachers either.
 
A

Alf P. Steinbach

* Earl Purple:
Ah, they are getting cleverer at not writing monolithic classes
anymore. Better refactoring


Course in Java: Here is a computer. We will learn to write applications
that use all the modern features: GUI, hey we can run even in a
browser. Networking - no problem. And we can process concurrently...
Java is very useful because a lot of companies are writing brand new
software in it.

Course in C++: Here is a computer. Now let's get a DOS shell up and
write a console app. And even when you ask the user to type in a
number, there is no method to intercept the key as the user hits it, so
if the user types in "Blah" you have to go back and say "sorry that's
not a number". If we're lucky we might even write our source with the
vi editor where you have to carefully switch between modes because
there's no such thing as Ctrl or Alt so characters mean different
things at different times. C++ is very useful because there's lots of
legacy code out there written in it, usually very badly, and you can
get a job maintaining it.

Now if you are student which do you choose?

On the subject of maintaining a legacy app, yes it makes economic sense
to do so rather than go for the rewrite. You could say the same for the
language itself. Better to maintain it and even add some new features
rather than go back and write a new one from scratch which is simply
much better.

Now everyone in the C++ market seems to be claiming that the language
is used for device drivers or the "embedded" world. Now where is the
university course saying "here is a robot, now we are going to program
some C++ into its microchip". Might just be the way to make it a bit
more exciting. People would like to learn how to program robots. They
look modern. Instead of writing "hello world" and some horrible console
app with cin, we could program it to make us a cup of tea.

Except -- for robots specialized control languages are better than
C++. And in the embedded world one uses restricted dialects of C++ that
aren't really C++. For example, when you remove exceptions from the
language you also remove the whole point of constructors, and what's
left isn't much more than a simple syntactical device (writing p->foo()
rather than p->vt->foo( p ) or CALL( p, foo, () )).

If I were to teach C++ today (I did many years ago) I'd focus on Windows
applications.

E.g., I imagine it's slightly difficult to do a Windows system tray icon
in Java, unless someone has made a C++ library for that for Java.

I think Windows applications comprise the last bastion of C++.

And it's crumbling: most new Windows applications will be .NET based,
and then better written in C#. That leaves C++ as a "glue" language,
e.g. writing those Java platform libraries. Oh well.
 
M

Mirek Fidler

Java references (e.g., strong thread-safe reference counting) in C++? No
problem:

http://appcore.home.comcast.net/vzoom/refcount/


This can be used as an alternative to Boost shared_ptr, which is only basic
thread-safe....

You got me interested. I briefly visited the site, but missed any
description on how to do that.

Can you point me in the right direction? (I guess we both understand
that using atomic operations to increment/decrement reference count is
far from lock free ;)

Mirek
 
C

Chris Thomasson

Earl Purple said:
I notice that I have not seen a single post in this thread from an
instructor stating that their C++ classes are increasing in size
or even maintaining their size.

Ah, they are getting cleverer at not writing monolithic classes
anymore. Better refactoring
I know that I get students from UBC (one
of the 2 large local uniiversites, the other being SFU) who want to
learn C++. They complain that it is no longer available at UBC. Also,
when I first started teaching C++, there were several other local
colleges doing the same. Now I believe only BCIT (where I teach) is
still doing so.

Course in Java: [...]
And we can process concurrently...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Java memory model is so damn strict that it makes it impossible to create
any high-end synchronization algorithms. Period. But then, does the average
Java programmer even know this fact? I bet 99% do not. Simple example of how
learning Java first can, and will, burn you:


Java teacher: Now we are going to learn about arrays. Java has this class
you see...


Student: How does Java actually implement that class?


Java teacher: I don't know. But, it works so lets start learning!


Student: What a fuc#king rip off!



Course in C++: [...]

C++ is very useful because

I can use it with Assembly Language to create a high-end synchronization
algorithms. I can use to create a full blown Java VM... I can use C++ to
prototype virtually anything for that matter. Can't use Java for any of
that.



there's lots of
legacy code out there written in it, usually very badly, and you can
get a job maintaining it.

I hope you don't think that the reason C++ is still around is because of
legacy code?



Now if you are student which do you choose?

C++ for sure! You should learn the fundamentals before you choose to
sacrifice yourself to very high-level language that is governed under a
"private" standard.
 
C

Chris Thomasson

Java teacher: Now we are going to learn about arrays. Java has this class
you see...


Student: How does Java actually implement that class?


Java teacher: I don't know. But, it works so lets start learning!


Student: What a fuc#king rip off!


Smart-Ass-C++-Student:

I know how they implemented the array class... They used C/C++ dip shit!!


lol...


;^)
 
M

Mirek Fidler

Phlip said:
In terms of language advocacy, C++ gives you the tools to build whatever
quasi-GC system you want (including a true GC). It doesn't bend you over and

Uh, no not really. Best you can hope for AFAIK is some sort of
conservative GC.

Mirek
 
K

Kai-Uwe Bux

Chris said:
Course in Java: [...]
And we can process concurrently...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Java memory model is so damn strict that it makes it impossible to create
any high-end synchronization algorithms. Period. But then, does the
average Java programmer even know this fact? I bet 99% do not. Simple
example of how learning Java first can, and will, burn you:


Java teacher: Now we are going to learn about arrays. Java has this class
you see...


Student: How does Java actually implement that class?


Java teacher: I don't know. But, it works so lets start learning!


Student: What a fuc#king rip off!

C++ teacher: Now we are going to learn about variable length arrays. C++ has
for instance the deque<> template, you see ...

Student: How does C++ actually implement that template?

C++ teacher: That is implementation defined according to the standard. All I
can tell you for sure are the following guaranteed complexity bounds...

Weak Student: What the heck, who cares about -- what did you call way too
complex bounds?

Strong Student: Cool, but (a) that does not answer my question and (b) why
are there no bounds on space?

Course in C++: [...]

C++ is very useful because

I can use it with Assembly Language to create a high-end synchronization
algorithms. I can use to create a full blown Java VM... I can use C++ to
prototype virtually anything for that matter. Can't use Java for any of
that.

I would like to see the C++ course completion of which will enable you to
create a full blown Java VM. Do you seriously suggest that, say, as a term
paper?
I hope you don't think that the reason C++ is still around is because of
legacy code?





C++ for sure! You should learn the fundamentals before you choose to
sacrifice yourself to very high-level language that is governed under a
"private" standard.

And you should learn to make screws from blocks of metal before you learn to
assemble chairs your order online.


Best

Kai-Uwe Bux
 
E

Earl Purple

Chris said:
I hope you don't think that the reason C++ is still around is because of
legacy code?

Of course it is. C++ beat all the other OO languages of its generation
because it supported all the company's existing C source. Read
Stroustrup's pages about the history of the language.
C++ for sure! You should learn the fundamentals before you choose to
sacrifice yourself to very high-level language that is governed under a
"private" standard.

And then you'd need to learn assembly too plus deep amounts of
electronics to know how all the hardware works.

What if, however, you are the typical student for whom university is
really only the unfortunately necessary and costly step between school
and getting a job, and that your primary aim of university is to be
trained to get a job afterwards, especially since you'll probably have
a big loan to pay off.

And it's the "private standard" that has allowed them to advance Java
to where it is, introducing generics (really templates) in the latest
standard, plus the equivalent of a foreach which looks a lot cleaner
than the 3 C++ options of having to either
1. write a loop
2. write a functor
3. try to create a functor on the spot with some horrible looking
syntax, involving binds, addresses of member functions and possibly
some funny looking _1 symbol.
 
M

Mirek Fidler

Phlip said:
You are responding to someone who said "C++ gives you the tools to build any
kind of GC system imaginable".

Ah, you mean building GC in C++ for Java? Or what?

Actually, I got impression that you suggest that you can build true GC
a library solution for C++. I argue that you cannot (at least not
without special C++ compiler, but that would be equal to adding GC to
language definition).

Mirek
 
C

Chris Thomasson

Mirek Fidler said:
You got me interested. I briefly visited the site, but missed any
description on how to do that.

Well, you can't use it as a 100% drop in replacement right now because the
interface is a little different. However, it does provides two smart
pointers:


ptr::global - used for strong atomic references
ptr::local - used for basic atomic references


Here is some brief info on their semantics:

http://article.gmane.org/gmane.comp.lib.boost.devel/149813

http://article.gmane.org/gmane.comp.lib.boost.devel/149818


You can start to experiment and tinker around when them now. However, the
library is in pre-alpha status... I would not use it for production code
yet. Experiments fine, production, wait for version 1 to come out... Oh
crap, I just noticed that I am going to be a little late for a meeting!
Damn, I need a couple of pots of coffee!



Can you point me in the right direction?

I have no time to say what I want to say right now, so here are some quick
links to relevant information:

http://search.gmane.org/?query=&aut...ERS=Gcomp.lib.boost.devel-Achris+thmasson---A
(deeper descriptions of how my refcount algorithm works)


http://groups.google.com/group/comp.programming.threads/browse_frm/thread/f2c94118046142e8
(lock-free patents...)


http://atomic-ptr-plus.sourceforge.net/
(Joe Seighs excellent work)


http://groups.google.com/group/comp.programming.threads/browse_frm/thread/4e8717d3bcdedfe9
(initial idea; pseudo-code)


http://groups.google.com/group/comp.programming.threads/msg/2f21a151d3916592
(mostly lock-free...)


http://groups.google.com/group/comp.programming.threads/msg/0022ef08ae26e2f3
(async-signal-safe aspects of my algorithm)


http://groups.google.com/group/comp.programming.threads/msg/667b1867c19e6288
(async-signal...)


http://groups.google.com/group/comp.programming.threads/msg/9ee468f341a33ee2
(adding more async-signal-safety characteristics'...)


http://groups.google.com/group/comp.programming.threads/msg/64a46f3ef24b786a
http://groups.google.com/group/comp.programming.threads/msg/e363f874241bcaf4
(possible improvements...)



Other that that... When I get back from the meeting, we should include c.p.t
in this conversation.


Well, got to go!
 
N

Noah Roberts

Frederick said:
blangela:



I think that a prerequisite to being a decent programmer is to have above
average intelligence. A minority of people have above average intelligence,
and so a minorty of people aspire to be an actual bonafide programmer
programming in languages such as C and C++.

No. Programming requires a certain thinking type, that is all. There
are plenty of brilliant people out there that can't program and will
never be able to program beyond the very basics.
For the less bright among us, there's Java.

Actually, for the less bright among us there's language bigotry.

Java programmers are not stupid. If you want to call people stupid you
should have a look at people that purposfully use the least productive
and secure components of a language when not necissary. Those that do
not make use of the tools at their disposal to make themselves more
productive and better programmers.
 
E

Earl Purple

Alf said:
Except -- for robots specialized control languages are better than
C++. And in the embedded world one uses restricted dialects of C++ that
aren't really C++. For example, when you remove exceptions from the
language you also remove the whole point of constructors, and what's
left isn't much more than a simple syntactical device (writing p->foo()
rather than p->vt->foo( p ) or CALL( p, foo, () )).

The ideal solution in my opinion is a "one-exception-type" exception.
That would probably reduce a lot of the overhead of exceptions. You can
then examine the exception if you want to do different things based on
what the error was.
If I were to teach C++ today (I did many years ago) I'd focus on Windows
applications.

E.g., I imagine it's slightly difficult to do a Windows system tray icon
in Java, unless someone has made a C++ library for that for Java.

I think Windows applications comprise the last bastion of C++.

And it's crumbling: most new Windows applications will be .NET based,
and then better written in C#. That leaves C++ as a "glue" language,
e.g. writing those Java platform libraries. Oh well.

So you are admitting that C++ is effectively dying as an application
programming language but will probably remain for the low-level systems
program for a non-embedded platform.
 

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

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top