473,789 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The Future of C++ ?

If you had asked me 5 years ago about the future of C++, I would have
told you that its future was assured for many years to come. Recently,
I have been starting to wonder.

I have been teaching C++ at a local polytechnical school here in
Vancouver, Canada for approximately 8 years. Six years ago, at the
height (or should I say volume?) of the internet bubble, I had 80+
students per semester in my C++ course. Now I am fortunate to have 15
students per semester. What has changed? I believe that students are
no longer interested in learning C++. They would rather learn .NET
languages or Java (my colleages who teach these courses seem to be very
busy!). I believe it is because these other languages are easier to
learn and/or are perceived to be more relevant today.

I do believe that C++ is more difficult to learn than many of these
other languages. Despite my best efforts to make them exciting, I see
the eyes of my students start to glaze over when I start explaining
pointers. When I ask them to tokenize an english sentence (using the
strtok() function) and print the token in reverse order (they need to
declare an array of type char * and save the addresses of the tokens in
this array), I experience near panic from many of my students. But
these concepts need to be taught in a responsible C++ course. As was
pointed out to me recently, Microsoft still requires applicants to
demonstrate a very good knowledge of string manipulation using C-style
strings (none of these fancy string class objects!) when recruiting C++
programmers.

The ironic part is there is still a large demand for C++ developers
here in Vancouver. In fact, the company that I believe employs the
most developers here in Vancouver, employs almost entirely C++
programmers. This company, Electronic Arts (if you have not heard of
them, I guarantee that your kids have -- they create video games) is
only one of several gaming companies here in Vancouver that employ
primarily C++ programmers. Other companies like Kodak, MDSA, Nokia,
MDSI, etc. also employ large numbers of C++ programmers. Not
surprisingly, I have talked to several companies here in Vancouver who
are complaining that they are having difficulty finding C++ developers
and are looking at trying to recruit from abroad (eastern Europe
primarily).

I believe that many of these companies will be forced to migrate away
from C++ in the near future, simply because they will not be able to
find C++ programmers in the future. Soon the baby boomer C++
programmers will begin to retire, then the proverbial @@@@ will really
start to hit the fan!

Please tell me I am wrong, and paint me a view of the future which
includes C++.

Nov 18 '06
190 8192

Earl Purple wrote:
Just a little space savings? We are talking about a whole community
here that does not use exceptions at all because of the enormous
overhead.
Yeah, I've talked to those people. As far as I can tell not a one has
any objective information to back up the claim that there even is any
overhead much less enormous overhead. Some have minimal experience
with some compiler they used in the 90's that handled exceptions poorly
and have never bothered to look at anything more modern...those are the
_most_ informed.

Nov 29 '06 #171

ACK! Those were crappy old versions...
Here is the newest ones:

..align 16
# int refcount_ia32_c as(
# refcount_ia32_t * volatile*,
# refcount_ia32_t *,
# refcount_ia32_t *)
..globl _refcount_ia32_ cas
_refcount_ia32_ cas:
MOVL 4(%ESP), %ECX
TESTL %ECX, %ECX
JE refcount_ia32_c as_failed
MOVL 8(%ESP), %EAX
MOVL 12(%ESP), %EDX
LOCK CMPXCHGL %EDX, (%ECX)
JNE refcount_ia32_c as_failed
MOVL $1, %EAX
RETL

refcount_ia32_c as_failed:
XORl %EAX, %EAX
RETL


..align 16
# int refcount_ia32_a dd_cas_weak(
# refcount_ia32_t * volatile*,
# refcount_ia32_t *,
# refcount_ia32_t *,
# int)
..globl _refcount_ia32_ add_cas_weak
_refcount_ia32_ add_cas_weak:
MOVL 4(%ESP), %ECX
TESTL %ECX, %ECX
JE refcount_ia32_c as_failed

MOVL 12(%ESP), %EDX
TESTL %EDX, %EDX
JE refcount_ia32_a dd_cas_weak_exe cute
MOVL 16(%ESP), %EAX
CMPL $0, %EAX
JLE refcount_ia32_a dd_cas_weak_exe cute
LOCK XADDL %EAX, (%EDX)

refcount_ia32_a dd_cas_weak_exe cute:
MOVL 8(%ESP), %EAX
LOCK CMPXCHG %EDX, (%ECX)
JNE refcount_ia32_a dd_cas_weak_dec
MOVL $1, %EAX
RETL

refcount_ia32_a dd_cas_weak_dec :
TESTL %EDX, %EDX
JE refcount_ia32_a dd_cas_weak_fai led

CMPL $0, 16(%ESP)
JLE refcount_ia32_a dd_cas_weak_fai led
LOCK DECL (%EDX)

refcount_ia32_a dd_cas_weak_fai led:
XORL %EAX, %EAX
RETL

Can you notice the difference between the crap code and this code? Hint...
It has something to do with redundant condition codes...
;^)
Nov 29 '06 #172
ACK! Those were crappy old versions...

Well, I must say that you are posting a lot of links to code, but
little explanation, I hope you would not mind if I place several stupid
beginner questions to get myself oriented... (I also do not have enough
time to harvest all informations over inet).
LOCK CMPXCHGL %EDX, (%ECX)
LOCK XADDL %EAX, (%EDX)

LOCK CMPXCHG %EDX, (%ECX)
LOCK DECL (%EDX)
Are these considered lock-free? Or they are used in "slow path" only?

If they are consideed lock-free, is there a performance difference
between CAS (LOCK CMPXCHGL %EDX, (%ECX)) and atomic increment/decrement
(LOCK DECL (%EDX))?

Mirek

Nov 29 '06 #173
"Mirek Fidler" <cx*@ntllib.org wrote in message
news:11******** **************@ 16g2000cwy.goog legroups.com...
>ACK! Those were crappy old versions...

Well, I must say that you are posting a lot of links to code, but
little explanation, I hope you would not mind if I place several stupid
beginner questions to get myself oriented... (I also do not have enough
time to harvest all informations over inet).
> LOCK CMPXCHGL %EDX, (%ECX)
> LOCK XADDL %EAX, (%EDX)

LOCK CMPXCHG %EDX, (%ECX)
> LOCK DECL (%EDX)

Are these considered lock-free?
Yes. They do assert the bus lock signal, but that different than using a
mutex:

http://groups.google.de/group/comp.p...d5c6aa62e8f876
(this might clear some thing up for you...)

Or they are used in "slow path" only?
The only place where my algorithm makes use of a lock is in the
refcount_ia32_a dd_load_strong( ...) function, and when the
refcount_ia32_s ub_strong(...) drops the reference count to zero. Other than
that, everything is 100% lock-free.

If they are consideed lock-free, is there a performance difference
between CAS (LOCK CMPXCHGL %EDX, (%ECX)) and atomic increment/decrement
(LOCK DECL (%EDX))?
Not really. Except you can't use atomic increment/decrement alone to get
strong thread safety.
Nov 29 '06 #174
Here is another link to some more info on my algorithm:

http://groups.google.com/group/comp....a6aff02b594e70
Nov 29 '06 #175

Chris Thomasson wrote:
"Mirek Fidler" <cx*@ntllib.org wrote in message
news:11******** **************@ 16g2000cwy.goog legroups.com...
ACK! Those were crappy old versions...
Well, I must say that you are posting a lot of links to code, but
little explanation, I hope you would not mind if I place several stupid
beginner questions to get myself oriented... (I also do not have enough
time to harvest all informations over inet).
LOCK CMPXCHGL %EDX, (%ECX)
LOCK XADDL %EAX, (%EDX)

LOCK CMPXCHG %EDX, (%ECX)
LOCK DECL (%EDX)
Are these considered lock-free?

Yes. They do assert the bus lock signal, but that different than using a
mutex:
Actually, I always thought that basic Win32 mutex (CRITICAL_SECTI ON) is
(in fast path) nothing more than single CAS operation...

Anyway, "LOCK CMPXCHGL %EDX, (%ECX)" is still about 400 times slower
than regular non-LOCK-ed operation, AFAIK.

I was sort of hoping that you found a way around this LOCK :)
If they are consideed lock-free, is there a performance difference
between CAS (LOCK CMPXCHGL %EDX, (%ECX)) and atomic increment/decrement
(LOCK DECL (%EDX))?

Not really. Except you can't use atomic increment/decrement alone to get
strong thread safety.
Confused a bit again.

Say I have COW String, I am serializing the accesses to it (mutex for
both read and write), I always thought that atomic increment/decrement
of shared count is enough to keep me safe?

Does strong safety here mean that I would be able to read and/or write
the String without locking?

( Who needs it? :-) )

Thanks for explaining.

Nov 29 '06 #176
"Mirek Fidler" <cx*@ntllib.org wrote in message
news:11******** *************@j 72g2000cwa.goog legroups.com...
>
Chris Thomasson wrote:
>"Mirek Fidler" <cx*@ntllib.org wrote in message
news:11******* *************** @16g2000cwy.goo glegroups.com.. .
>ACK! Those were crappy old versions...

Well, I must say that you are posting a lot of links to code, but
little explanation, I hope you would not mind if I place several stupid
beginner questions to get myself oriented... (I also do not have enough
time to harvest all informations over inet).
[...]
>
Are these considered lock-free?

Yes. They do assert the bus lock signal, but that different than using a
mutex:

Actually, I always thought that basic Win32 mutex (CRITICAL_SECTI ON) is
(in fast path) nothing more than single CAS operation...
Consider the fact that the interlocked instruction used for CRITICAL_SECTIO N
does not operate on the shared data you want to alter. It only operates on
the lock state. And, you have to take into account that a lock has to be
unlocked. Thats another interlocked instruction.

So, if you measure a 100% uncontended lock-free operation vs. a 100%
unconteded lock-based operation you get this:

lock-free update if a word
------------------------

1 interlocked instruction


lock-based update of a word
-----------------------------

2 interlocked instructions
1 store


-- The interlocked instruction in the lock-free performed the update
directly to the word.
-- The interlocked instructions in the lock-based performed the update on
the locks internal state. The store instruction actually updated the word...
IMO, the lock-free stuff is a winner... Now if you take contention into
account, well, the lock-based stuff might have to park threads in the
kernel! The lock-free will not...
Is this making any sense to you? I don't think that I am a very good
teacher, but I try... So try to bear with me here...

;^)


Anyway, "LOCK CMPXCHGL %EDX, (%ECX)" is still about 400 times slower
than regular non-LOCK-ed operation, AFAIK.

I was sort of hoping that you found a way around this LOCK :)
If they are consideed lock-free, is there a performance difference
between CAS (LOCK CMPXCHGL %EDX, (%ECX)) and atomic increment/decrement
(LOCK DECL (%EDX))?

Not really. Except you can't use atomic increment/decrement alone to get
strong thread safety.

Confused a bit again.

Say I have COW String, I am serializing the accesses to it (mutex for
both read and write), I always thought that atomic increment/decrement
of shared count is enough to keep me safe?
If you perform the atomic increments under the protection of the lock, then
you will be fine.

Does strong safety here mean that I would be able to read and/or write
the String without locking?
Once you acquire a strong reference to you string object, you can do
lock-free COW via. CAS.
Nov 29 '06 #177
Mirek Fidler wrote:
Chris Thomasson wrote:
Actually, I always thought that basic Win32 mutex (CRITICAL_SECTI ON) is
(in fast path) nothing more than single CAS operation...

Anyway, "LOCK CMPXCHGL %EDX, (%ECX)" is still about 400 times slower
than regular non-LOCK-ed operation, AFAIK.

I was sort of hoping that you found a way around this LOCK :)
Branch logic is almost as expensive as an inline LOCK. In multi-core
will become the norm, unconditional LOCK is probably the most efficient.
>
>>>If they are consideed lock-free, is there a performance difference
between CAS (LOCK CMPXCHGL %EDX, (%ECX)) and atomic increment/decrement
(LOCK DECL (%EDX))?

Not really. Except you can't use atomic increment/decrement alone to get
strong thread safety.


Confused a bit again.

Say I have COW String, I am serializing the accesses to it (mutex for
both read and write), I always thought that atomic increment/decrement
of shared count is enough to keep me safe?

Does strong safety here mean that I would be able to read and/or write
the String without locking?

( Who needs it? :-) )
Maybe not for String, but for the more complex data structures like
collections lock-free beats anything else out there in solving
the reader/writer problem.

--
Joe Seigh

When you get lemons, you make lemonade.
When you get hardware, you make software.
Nov 29 '06 #178
Once you acquire a strong reference to you string object, you can do
lock-free COW via. CAS.
The basic idea is:
pseudo-code
---------------

typedef std::string mystring_t;
typedef vzsync::ptr::gl obal<mystring_t mystring_gptr_t ;
typedef mystring_gptr_t ::local_t mystring_lptr_t ;
static mystring_gptr_t s_buf(new mystring_t("hel lo"));
void do_cow_cas(myst ring_t const &src) {
mystring_lptr_t xchg(new mystring_t), cmp;

do {
cmp = s_buf;
if (cmp) {
xchg->append(src);
}
} while(s_buf.cas (cmp, xchg));
}
or you can do a 100% lock-free swap like this:

void do_swap_weak(my string_lptr_t &dest, mystring_t const &src) {
dest->append(src);
s_buf = dest;
}
There are more tricks... However, are you having trouble understanding the
pseudo-code?

Nov 29 '06 #179
ARGHGGH!
void do_cow_cas(myst ring_t const &src) {
mystring_lptr_t xchg(new mystring_t), cmp;

do {
cmp = s_buf;
if (cmp) {
Need to add this of course!!!

xchg->assign(*cmp) ;
xchg->append(src);
}
} while(s_buf.cas (cmp, xchg));
}


sorry for any confusion!

;^(...
Nov 29 '06 #180

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

47
3668
by: David Eng | last post by:
> For many years now enterprise business application development has > been the core area for the use of C++. > Today a significant share to this segment has already been lost to > SUN's Java technology and with MS now abandoning C++ in favour if its > proprietery .NET and C# technology, how long can we except C++ to hold > on against these might competitors? > Has C++ become a dying language? > What is the future of C++? As I posted...
35
3360
by: GTO | last post by:
I do not believe that C# is the future of C++. I also do not believe that adding two thousand new library functions to the standard library is the future of C++. But what is the future of C++? Is it as good as a programming language can get? Like so many of you, I programmed speech recognizers, image recognition systems, a portion of a chess program, lots of numeric code using STL, and tons of other applications in C++, (even firmware...
9
2369
by: Lyle Fairfield | last post by:
It's confusing. Many people here and elsewhere make many different predictions: There's an introduction mentioning some aspects of this at http://msdn.microsoft.com/data/mdac/techinfo/default.aspx? pull=/library/en-us/dnmdac/html/data_mdacroadmap.asp revised Sep 2005 (upper case conversions are mine)
2
2169
by: | last post by:
Everything seems to be moving to .NET and VC++ seems to be adding a lot of managed code support every new release. The questions: is unmanaged code in VC++ beeing phased out in favour of managed code? And suppose I still program in VC++ 6.0, can I safely assume that the code I use in VC++ 6.0 will still be available in future VC++ versions. Finally will VC++ 6.0 generated executables be still be able to run on futur Windows versions and...
0
1856
by: Fuzzyman | last post by:
Hello all, The following is a copy of a blog entry. It's asking a question about future statements and the built in compile function. I'd appreciate any pointers or comments about possible approaches. `Movable Python <http://www.voidspace.org.uk/python/movpy/>`_ supports running both Python scripts and ``.pyc`` bytecode files. It does this by compiling scripts to bytecode, or extracting the code object from bytecode files, and then...
29
3134
by: Zootal | last post by:
My apologies if this gets asked/discussed a lot. With c# rampaging through corporate USA (and other countries), what impact will this have on the usage and future of c++? I've used both of them a bit. I'm in school, and our CS program does not use c#, but uses mostly c++ and a bit of java. C# is relegated ot the CIS programs. Out there in the real world, what kind of a future does c++ have?
6
14454
by: rohayre | last post by:
Im a long time java developer and actually have never done anything with java scripting. I'd like to write a short simple script for calculating a date in the future based on today's date and a letter. Can I use javascripting to create a webpage to allow a user to enter a letter and then click a button to find a future calendar date? I'm just not sure how much user interaction scripting allows. Does java scripting allow buttons, textfields...
5
3594
by: KimmoA | last post by:
Does C have a future? I'd like to think so, but nobody seems to agree with me. Of course, I don't use C in my profession, and maybe I wouldn't be using it if I had the pressure to actually produce things with deadlines and stuff. Hmm. That's a depressing thought. I can't stand OOP. Yes, it is beautiful in theory, and it might make sense for huge projects with many people involved, but I don't want anything to do with it. (I switched to C...
51
3437
by: Jon Harrop | last post by:
If Microsoft turn F# into a product and place it alongside C# and VB, will many people migrate from C# to F#? -- Dr Jon D Harrop, Flying Frog Consultancy http://www.ffconsultancy.com/products/?u
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5418
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.