ISO C++ Committee Approves C++0x Final Draft
Randyll writes "On the 25th, in Madrid, Spain, the ISO C++ committee approved a Final Draft International Standard (FDIS) for the C++ programming language. This means that the proposed changes to the new standard so far known as C++0x are now final. The finalization of the standard itself, i.e. updating the working draft and transmitting the final draft to ITTF, is due to be completed during the summer, after which the standard is going to be published, to be known as C++ 2011. With the previous ISO C++ standard dating back to 2003 and C++0x having been for over eight years in development, the implementation of the standard is already well underway in the GCC and Visual C++ compilers. Bjarne Stroustrup, the creator of C++, maintains a handy FAQ of the new standard."
Enough said!
-Chris
My collection of C++ books from Addison Wesley (who has apparently cornered the market for C++ books above intro level) has just become obsolete. Most likely new editions for most of them will be coming out over the next couple years.
C++ just keeps on going, eating the brains out of anyone who dares to use it. When template metaprogramming was invented, the language should have been internationally banned by treaty. Now with lambdas, garbage collection, rvalue references, and a host of other features, C++ should be officially classed as a Weapon of Mass Destruction.
...faints...
As someone who has written software using GObject, FUCK YOU.
I've been reading about C++0x for years now, and never realized that the 0x referred to a new revision of C++ to be released in 200X, until I just now saw the FAQ entry about C++1x. I assumed it was some odd inside reference to hex number prefix that I just didn't get. I thought the Y2K bug incident had purged everyone who didn't use full dates :)
Ref: http://gcc.gnu.org/ml/libstdc++/2005-11/msg00219.html
sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
Even naive C++ is much, much, much faster than Python and is even capable of supporting multiple threads.
It's much faster than C# and slightly faster than Java code as well.
Mod me down, my New Earth Global Warmingist friends!
>Python
You spelled "Lisp" wrong.
If C++ is cancer to C's something, that something is also cancer. Or maybe AIDS.
I have a love-hate relationship with C++, but one thing that I more-on-less don't waver on is the fact that I would much rather write in C++ than in C for... basically anything.
Nothing comes close to C++ in terms of versatility, features, speed and overall professional appeal.
I cheat. I write python code that writes its own plain C code, compiles it then executes it. this way, I work once to write a C template, that I then reuse through a high level language. and when I combine the advantages of python (sympy for instance) with the speed of C, I get stuff that is ridiculously faster than what I did before. in the sense that I don't work a lot to write it, and I don't wait around a lot for it to actually run afterwards.
working with numerical simulations, I'm allowed to cheat this way...
new sig
TL;DNR
http://www-users.cs.york.ac.uk/susan/joke/cpp.htm
This one still makes me laugh
moi
Borland has also had support for parts of the C++0x spec for some time now.
Given all the negative comments about the complexity and misfeatures of C++, I one day decided to take a good look at D programming language.
I know Ruby, Python and Common Lisp, and as I have used Ruby's NArray and NumPy quite much, I appreciate that D language has first class Array objects and vector operations for arrays built into the language. D is also compatible with C and has two-way bridge for Objective-C. The version 2 also supports functional programming.
Overall, D seems to have taken good influences from dynamic programming languages like Ruby and Python.
I wonder why D isn't more popular? Maybe the division of the standard libraries is a big factor?
PS. I have been looking a similar library to NumPy for Common Lisp, but GSLL just doesn't cut it and Matlisp only handles two-dimensional matrices. Of course you can use map, but iterating even slices of two-dimensional matrices with map can be a hassle and is much more verbose than having a good iterator abstraction.
The way you put that, the uneducated reader may have mistaken it for a compliment.
So basically, you get around Python's performance limitations... by using C instead.
Way to go!
Mod me down, my New Earth Global Warmingist friends!
Actually I'm looking forward to re-learning C++ after GCC et. al. are updated and the spec is finalized. They've added a great deal to the standard libraries, the syntax, and the collections/containers since I last worked with C++. I've no need for C++ -- it's just something I want to do for fun.
I do not fail; I succeed at finding out what does not work.
Please do tell which languages do you believe are "simpler (and arguably better" than C++.
Yes, you hate C++. We get it. Instead of complaining about it so much, just don't use it, stick to your own favorite language, whatever it may be, and leave C++ alone. There are plenty of us who love C++ and wouldn't give it up for anything. We mind our own business, write great code, and try to avoid complaining about whatever it is you are using. Please try to do the same.
We need to be able to write &T::T, just like we can do &T::somemethod and finally build dependency injection in C++.
Clearly we see something about it you don't. You are welcome to love your "interesting modern languages", while we love our C++. We certainly have no obligation to help you with yours.
Scheme, Java, Ruby, Python, D, C.
I can't understand why anyone would start a new project in C++. The only reason anyone could seriously consider it is if they have to maintain or enhance an existing C++ code base.
Stick Men
I think you can easily determine the competence of any programmer by how much they hate their primary language. I've never seen this rule fail when it comes to C++. Almost every expert modern C++ programmer I've met thinks C++ is unsurpassed in a few important areas - yet they can bitch about the language for as long as you keep them talking.
As someone who spends all day developing a C++ library for massively parallel engineering simulation.... I'm really excited about this announcement. My team has played with some of the early C++0x features in Intel's compiler and GCC and we're definitely going to be adopting a few of them, but can't commit ourselves until they are a bit more universally available.... which now, they hopefully will be.
C++ certainly still has it's strong points over many other languages... especially when you need that cross section of good OO design and performance (like we do). There are many things I love using Python for but there a also a TON of times I need complete control over everything in order to get the most out of the machine I'm using.
You're right. Like back to C or pure assembler.
Ah, it's articles like this that make me so glad I'm retired!
C++ programmers have it too easy. Why, in C we had to code our own bugs. C++ programmers just inherit them!
I can't understand why anyone would start a new project in C++. The only reason anyone could seriously consider it is if they have to maintain or enhance an existing C++ code base.
While I agree with the sentiment, the reason people keep using C++ is pretty clear: habit. Everyone knows C++ or some very similar language, there is a lot of legacy C++ code, and people are still being trained to write code in C++ (or some similar language). If you were starting a new project and you said, "Let's use Scheme," half the people in the meeting would say they had never written a single Scheme program, and that they did not have time to learn it, and that it would be easier to just use C++ (or something similar). You could list every technical advantage that Scheme has over C++ and it would not make any difference.
Do not underestimate the friction that you face when it comes to C++ and similar languages.
Palm trees and 8
Some monster warts not addressed, like no designated intializers, no flexible arrays. Some backwards progress like the idiotic narrowing errors in cases like { 1, 2 } for an array of floats. But in general, a better language, I switched to -std=gnu++0x a few months back.
Have you got your LWN subscription yet?
You're right. Like back to C or pure assembler.
Indeed. There's so much you can do with well-written C and good libraries quicker, more reliably, more simply and much more efficiently than in C++.
With C you have a chance of being able to read and understand your source code 6 months after you wrote it. The syntax is relatively clean, If you're into syntax-highlighting editors, they usually get it right.
There aren't the ABI headaches that come with C++. The compiled code is smaller and faster.
C can fit inside your head. Unless you have an IQ of 250 and infinite time, you are never going to learn enough of C++ to become an expert.
C programs are more likely to run correctly.
Don't get me started on C++ references and const....
I write C++ when I am paid to. I write everything else for fun (mostly C and bash).
Stick Men
Yes, because the world needs more segmentation faults. And BTW I have been forced many times to use C++ in my work. I know a shitload about it, especially the various tricks about the template system; the removal of concepts from the standard proves that C++ is, has always been, and will always been a mismatched bunch of tricks held together with duct tape.
Of course you are entitled to your opinion; I know many great programs/programmers exclusively made/working with C++, so I am not implying that the language forces bad programs or diseducates developers. Unfortunately I believe that the absence of a clean idiomatic C++, the proliferation of more or less incompatible coding styles, the confusing compatibility with C (C++ is often used as "C with classes") and the excessively small standard library (I believe that anything found in Boost should never be removed from the language) make C++ an ugly creature. Once again, though, great and fast programs have been made with it, so I understand how many developers might love the feeling of power and control that C++ gives with respect to safer but more constrained languages such as C# or Java or even further ML or Haskell...
My book: Friendly F#, fun with game development and XNA; my game: Galaxy Wars by VSTeam; my gamedev language: Casanova.
Just to play devil's advocate, I'd like to argue for C++ a bit. I don't completely buy my arguments here, but at the same time, I don't think it's ridiculous to use C++ for some stuff, and for some rare projects, it's a decidedly reasonable choice.
C++ sits in an area that is reasonably unique amongst languages. It is very performant (unlike Scheme, Ruby, and Python), but it also has an ability to support very rich abstractions (unlike Java and C). What other language doesn't not give you closures, but yet gives you enough syntax to make an approximation that is even as close as, say, boost::lambda? There's no reference counting provided by the C++ runtime, but it gives you enough tools that you can build your own reference counting.
There are very few languages that can claim both the speed and flexibility of C++. The only one that would be familiar to most programmers is D -- and the tool support there is not exactly stellar. About the only other languages I would say has characteristics comparable to those are Common Lisp and Haskell.
As a final point, I find it interesting that you put C into your list. If you said "I want you to do this project, and you can pick between Java and C++" or "between Python and C++" I'd have to ask for more details first, and think about it. I think I disagree with a lot of people on this point, but if you gave said "you have the choice between C and C++", I'd pick C++ in an instant with almost no qualifications. Yes, C is simpler than C++ -- but I don't think it's worth it. RAII alone is enough of a killer feature to mean that I will likely never choose plain C for any project where I have any freedom in the matter.
Almost any computer language is simpler than C++. If you don't know that, you haven't explored it much. As for better... well I have switched pretty much exclusively to C++ now. Love, hate.
Have you got your LWN subscription yet?
Agree 100% with your post.
Although technically you simply cannot do many types of programming projects with most of those languages because they are not systems-level like C/C++ are. So one may argue that those languages can't be compared to C++... except for one: D, a vastly superior language to C++ and which is also systems-level.
Just because the U.S. is a republic does not mean it is not a democracy. Democracy/republic are not mutually exclusive.
Do not underestimate the friction that you face when it comes to C++ and similar languages.
I was in exactly this situation this week on a training course where we had ~12 hours to do an entire project.
We had 1 non-programmer on the team (of 6), one "software architect" and the other 4 of us were "software engineers." 4 of them wanted to use C++. I convinced them to do it in bash. Only one had sort of done some bourne shell a long time ago.
We got it done, and it worked. If we'd done it in C++ I dare say we'd still have been struggling to get it to compile by the deadline.
I organised things and coached them. They were impressed, and very surprised at how simple it turned out.
Stick Men
If you were writing an triple-A game from scratch, including a new game engine and tools and targeting multiple platforms, the most likely language would be C++. Garbage collected bytecode languages are too slow, while C does not provide adequate support for programming in the large.
C++ sits in an area that is reasonably unique amongst languages. It is very performant (unlike Scheme, Ruby, and Python), but it also has an ability to support very rich abstractions (unlike Java and C).
True, but it hasn't been done at all well in C++. That's why I said that C++ had to happen so that people could see which ideas would work and which wouldn't.
I'm not at all convinced by these arguments. I'd much rather write performance-critical code in something like C, and the clever stuff in a much higher language.
For a trivial and contrived example, I get a lot done on my personal projects in C and bash.
I've used PERL, looked at scheme, python and ruby. I've done a bit of Java, and for quickly hacking together OOP stuff, I love it. It's so easy, it's wonderful.
I've had to learn a lot about C++ for my work. Luckily, I only have to use it mostly for writing unit tests, but some of our code base is in (not very pretty) C++ hacked together in a hurry.
Sometime soon I will try writing some D. I've done some background reading, and I really like what I see so far.
Your devil's advocacy is dutifully acknowleged.
Stick Men
After years of work, we are pleased to announce the++, a successor to the hugely popular english determiner "the". Although many people in recent times have been happy to use "the" as a determiner, we have worked hard to extend the semantics into verb, adverbial and noun forms. Thus; The the the the.
We have strived to create a professional and expressive tool and sincerely hope that english speakers and writers alike will get as much pleasure from using the++ as we had in creating it.
In closing, the++ allows the the the and the the. It is the correct the the the if the the the the clearly understood.
It's time to move on.
If you want to write efficient code (have control of all allocations, etc) with some OOP sugar, C++ is a fairly decent choice...
And with some coding guidelines, C++ is not bad for application development either... I would rather use Qt/C++ than C#/Windows.Forms for GUI applications... Mainly because of Qt though, but C++ is not dead... It's a perfectly fine tool for many projects... Choose a tool that is right for the job...
And C++ is certainly still an important tool, what other well established fairly-low-level languages with OOP support do you find ?
I hate C++. I have so many objections to it that I can't even list them here reasonably.
However, there is nothing that can replace it. Everything fails on some account or another. C++ lets you have high level power without sacrificing extremely low level control. No virtual machine, sandbox, or GC'ed language can do that.
So yes, it's a horrible language. But yes, I'm on a team writing an OpenGL based game engine, and we're using C++, because it's the only reasonable choice. We need exact control over bitfield layouts, we need inline assembly, we need good GL bindings, and so on.
Neither Java, Ruby nor Python are true contenders to C++ when it ever comes down to raw performance. They are surely more elegantly designed languages, although they have their own sets of flaws. D is an interesting language with many good ideas, but there's no decent IDE support for it and there's the standard library confusion as well (and the incompatibilities between D1 and D2). Once compilers like GDC are mature enough it'll actually be usable for serious work.
Well, C is sort of fine if you stick to really procedural code and don't do things like reinventing OO like gtk+ does (I hate that). And I really can't say anything about Scheme.
Bottom line; There's a place for C++ in between all of these languages you name: C++ programs can be amazingly fast if done right (no virtual machine and more importantly, no GC getting in the way at exactly the wrong time) and easier to get right than equivalent C programs if you're able to sacrifice some performance - you're able to do that in 90% of your code on average).
http://www.moonlight3d.eu/
It's a very nice idea which brings the best of both worlds. FEniCS, an open-source finite element framework , uses pretty much the same technique to allow one to set up the simulation in Python, yet get the speed of hand-optimized C++ code.
And using Python capabilities one can write code which is much closer to the underlying math, which significantly improves the usability. Here's the core of an example using FEniCS:
When calling solve() the problem is converted to C++ code, compiled as a module, imported and executed, all on the fly. The C++ generator can optimize for special cases, for example in the code above it knows that "f" is a constant function.
Why treat everything as a nail when you don't have to?
Enough said!
-Chris
Incorrect. The year 2011 A.D. is 7DB Hexadecimal A.D. Ergo, if you're going to abbreviate the numeral using the last two digits you should be heralding C++'DB or simply shorten it to C++'B.
Note: Due to the fact that legacy versions are abbreviated as YEAR mod 100 in radix (base) 10, the new hexadecimal notation should include the a prefix or suffix indicating the radix in use. For quite some time there has existed such a hexadecimal radix prefix in C and C++: 0x
Thus: /* WTF! */ };
Hurray for C++ 0xB;
(Also note the above line does not parse as valid statement in C++, even though the ++ operator actually does take a dummy int parameter as the right-hand-side to differentiate it from the ++C; prefix increment operator.
operator++(int){
For meatball's sake people, even the ++ operator is a kludge in C++? ( "C++" translates to "C (with kludges)" to me.)
Even without any #define macros present, I still can't tell what a single snippet of C++ code is going to do. (Does the simple statement: C++; open a temporary file, and record the number of increments or throw an exception? Should I wrap all such statements in a try / catch block!?) If you haven't studied the entire inheritance graph of the type that the C variable is declared as, there is really no way (beside a debugger) to know what will happen next. (What if a pointer is to a polymorphic class? *my_ptr->operator++(42); Now, it's not supposed to do anything with that "dummy" 42 value, the base type doesn't but a subclass might...)
Don't get me wrong, I code in C++ every day, and prefer it to C, but it surprises me just how messed up things have been allowed to get because we're shoe-horning in features into an existing syntax instead of just creating a new language that has less kludges.
int main() { //Constructed an int "object" by calling it's "constructor" // DOES NOT call the int object's empty constructor. // ERROR, the previous line declares a function. ... }; ARGH.
int my_var_a( 1 );
// ^^^ Uh.. OK ints are object-ified now.
int my_var_b();
my_var_b = 10;
return my_var_a;
}
^^^^^^ Declares a new function in the function/method body WTF? (because C lets you do that, for better or worse... )
use: int myvar; to "instantiate" a new int "object" using the empty constructor instead... So, why can't I subclass an int? class my_number : public int {
Look, it's clearly time to stop hacking extra features into the language, or stop letting it be hindered by legacy C conventions / syntax. I think that C++ could be much better than it is if it weren't pandering to C coders... It's too bad that we started down that path with C++, there's far too much time and energy invested to reboot it now.
I'm glad for some of the new C++ features, but at this point there's not much to celebrate for me -- Doing without for so long has caused us to create our own systems: the C++0x garbage collector is incompatible with my multi-threaded hybrid strategy (pool / slab & heap-like) memory manager (thank Spaghetti Monster, theirs is optional), I already have a ton of code that uses my cross platform multi-threading libraries, we've been using a HashContainer for over 10 years in our company...
C++0x7DB adoption to us means: "Oh great, they finally got around to standardizing all these things we've needed for years and made ourselves -- It's going to be a headache writing new code that conforms to the new standard while remaining compatible with our current code-base."
(And there was much rejoicing: "... yay... ")
I've also had quite a bit of success with this approach. For my programs, there's a small kernel of operations that need to be really fast, while the remainder is either limited by disk speed or not executed that often. By implementing the stuff that needs to be fast as C modules, I gain a massive speed boost without adding lots of complexity to everything else.
Starting with some high level scripting language and working down to low level is also a nice way to get a functional design up and running first before concentrating on making it fast.
Ita erat quando hic adveni.
I would agree with you...if people were willing to not use C++ when another language is a better choice. Unfortunately, all too often people refuse to write code in a language other than the one they were trained to use, and too many people are trained to use C++. It is fairly routine for an early design meeting to go like this:
"Let's use [insert non-C++ language], since it is the best fit for this project."
"Wait a minute! I don't know that language, and I do not have time to learn it! Nobody except for you has ever written a program in that language! Let's just stick with what we know!"
C++ and friends (mainly Java and C#) are routinely chosen out of habit, and the result has been an industry that has been very slow to move on to more modern (and simply better in some cases) methods of programming.
Palm trees and 8
Also note the above line does not parse as valid statement in C++, even though the ++ operator actually does take a dummy int parameter as the right-hand-side to differentiate it from the ++C; prefix increment operator.
My mnemonic for remembering which version of ++ takes the dummy int is that postfix ++ is "ugly" in the sense that you shouldn't use it*, so the postfix ++ operator takes the ugly dummy int.
This doesn't justify the syntax which is admittedly horrid, but maybe it'll help people who have this problem.
* Take "you shouldn't use postfix ++" with a small grain of salt, though I do mostly believe it. With rare exception, I really really dislike increment operators mixed in a larger expression, which means with rare exception they are standing on their own, acting as statements. And in that context, prefix and postfix ++ do the same thing, and you should use prefix for the traditional efficiency arguments.
Declares a new function in the function/method body WTF? (because C lets you do that, for better or worse... )
What I like best about that is the standard's rule "if a statement can be interpreted as a declaration, than it is" rather than making declarations actually look different from statements. That's pretty awesome.
and slightly faster than Java code as well.
Can java pack mmx registers now? I'm highly dubious of that.
Um, that's what serious programmers do. Have always done. C#, Java, Haskell, Python - if it's a serious language it allows calling exported functions from shared libraries. There's no silver bullet language, and using 1 bottom-tier language for all your code is masochistic. GP's project would be as speedy as yours, way smaller, written in 1/5th the amount of time.
Self-compiling C code is... eh, questionable though, even with the "tiny" C compilers out there. Good for quick prototyping I guess.
And isn't it ? Sure, it suffers from feature bloat - to say the least. And it suffers from a lack of a coherent structure of libraries and tools - it's nothing like java. But if you want to combine high-level programming with access to low-level features. There are C++ operating system kernels that actually use the boost and/or standard libraries. You could even make the claim that a C++ program, like a C program *is* a kernel, in the sense that it can start meaningfully on bare metal (this requires 2 things for a language : being compiled, and no "runtime" that needs to be started and has all sorts of weird startup dependencies). This means it works with C (but only if you are extremely careful) and C++ (again, you can make a few stupid mistakes, but it can work)
Try doing that with Ruby, Java or PHP.
Bell Labs is gone, and the two most popular variants of Unix aren't officially Unix, but C++ lives on. Embedded in the name is the quirky operator that Dennis Ritchie invented some 40 years ago, as a way of shaving a few instruction cycles in inner loops from a high level language.
'nuf said.
Actually I'm looking forward to re-learning C++ after GCC et. al. are updated and the spec is finalized. They've added a great deal to the standard libraries, the syntax, and the collections/containers since I last worked with C++. I've no need for C++ -- it's just something I want to do for fun.
Have at it. If I have to use C++ I'll stick to LLVM/Clang/LLDB/Libc++
I call BS!
Ok here is the deal in very very simple examples C++ is faster. Namely because you can override the safety nets. For example if I access memory using pointers. BUT if I add bounds checking, and other things that C# gives me C++ is not faster. I write MonteCarlo code in C# and have found there are things you do and don't do in C#. If you stick to those things there is absolutely ZERO advantage to C++. In fact I found that if you are very careful you can almost match raw C++ (about 10% slower). Remember the real problems in C++ are not the structural things, but the wennie that allocated memory incorrectly writes over a single byte that is used 1,000 cycles later...
What gets my goat with C++ is that I have seen this debate before. Namely I used to write Fortran code in University (hated every moment as I wanted to write C++). And in those days Fortran blew the doors off C++. But with C++ you got many things that were just downright painful in Fortran. Well we are at the same moment in time with C++.
Anybody who starts a new project in C++ is really missing the boat. There is zero reason to use it unless you are doing very low level things. If you understand what is fast and slow in Java or C# then those languages are perfect.
"You can't make a race horse of a pig"
"No," said Samuel, "but you can make very fast pig"
Please do tell which languages do you believe are "simpler (and arguably better" than C++.
error:Unexpected end of line.
Now the problem is to wait for one's customers to move to the latest compilers that support this. Having a big customer that uses Visual Studio 2005 can be a headache when you want to use a new feature in your tools.
That's very interesting. To elaborate on your post, I think it would be very useful to have a native python compiler backend that's fed an RTL-like intermediate structure. Out comes a blob of machine code with a module interface. It doesn't have to be quite as low level as GCC RTL, but could be something closer to C++ with typing, function names, variable names, etc, so closer to the front end. (It could be expanded to GCC-like RTL in a first step of course.) Hooks could be used to apply application-specific optimizations. It should be quite possible to use gcc as a starting point for this.
C is a good low-level language. If you are not addressing a problem that requires a low-level language, then you should not be using C. C++ manages to combine all of the disadvantages of a low-level language with all of the disadvantages of a high-level language.
I am TheRaven on Soylent News
^ this
A lot of people seem to be very black-and-white when it comes to C++. Some love it and think it's the best language ever, some hate it and want it abolished. C++ has its place, the gaming industry knows it extremely well and there is absolutely nothing out there to compare to it (unless you count the mobile sector, but that's a different kettle of fish). I wouldn't use C++ for a lot of things, where other languages have been created to make certain types of development easier, but where you have any kind of gap or hole that doesn't have a "tailor-made" language, C++ is there and gives you the ability to do what you've set out to do.
+1 IDisagreeSoHeMustBeATrollOrAnAstroturferOrAShill
There's also an OS kernel written in Java, that doesn't mean it's a good idea or an area where Java excels. You use the runtime argument yet mention boost... in this context libC and libstdc++ are runtimes, or see how far you get without them.
I dispair that C++ is used in applications, I don't want critical system level stuff done with a language where there's so many pitfalls. IMHO, C++ outgrew it's boots in that regard back when C++ compilers evolved beyond preprocessors that generated C code. Let's put it this way; Mozilla are looking to replace parts of their C++ codebase with JIT'd javascript!
Q: Your code is so beautiful, how do you do it?
A: I write the first version in C++, and then I chisel away everything that is not C.
I couldn't agree more ... strange ...
Why do I have this feeling that it's somewhere between 15 and 20 years ago, and that you're about to get flamed by the sysop?
Required reading for internet skeptics
How do you pronounce 'C++0x', and why does my modem keep resetting when I type it?
The new standard is very function-style friendly. C is dead meat.
Even without any #define macros present, I still can't tell what a single snippet of C++ code is going to do. (Does the simple statement: C++; open a temporary file, and record the number of increments or throw an exception? Should I wrap all such statements in a try / catch block!?)
It's quite simple: it increments the variable C, but evaluates to the value of C before incrementing it. The fact that someone may create an operator++ that does something else isn't a problem with the language but with the programmer. C++'s operator overloads are syntactic sugar for regular function calls. Do you really know what postfix_increment(C) does anymore than operator++?
That's like that couple who has been together for 20 years
and has a couple of high-school age kids
telling you that they just decided to get married.
And yet despite all the hype I find C# incredibly more cumbersome and verbose and when I'm at work I truly can't wait to get home to work on my c++ hobby project. Part of it will be in javascript too, because it is better for some of the parts of my project.
There is no such thing as an universally simpler and better language, and some of c++ features that people love to hate such as RAII, templates (not those half-assed generics that c# offers) and operator overloading permit to make some complicated things much simpler than anything you can achieve in most of those more recent languages.
Brilliant. It was bad enough in job interviews when they try to catch you out on your knowledge of the obscure bits of C++ that nobody ever uses, and now there's a whole new level of complex syntax, pitfalls and gotchas to deal with. C++ is turning into a warty freakshow. I could even start to forgive Python's idiotic indentation nonsense at this rate.
Cress, cress, lovely lovely cress
Even without any #define macros present, I still can't tell what a single snippet of C++ code is going to do. (Does the simple statement: C++; open a temporary file, and record the number of increments or throw an exception?
to be fair, all the other 'oo' languages don't let you do that either, and C can give you the same problems if you're using #defines (C's equivalent to operator overloading :) )
At least in C++, you can look at the header file for the class definition and see what its doing. In languages like C#, those overloads can be anywhere - not even associated with the class itself. Scripting languages can be the same,
Still, I don't think C++ needs more low-level features, it really needs a higher level library of useful stuff - like boost but even higher level than that. And you're right - it really needs more consistency, even if that means breaking a bit of older code. Your examples show that the language is dying of old age now, its not the lean and fit language of its youth, especially as they're adding more wrinkles to it now. This is the thing that worries me (as a C++ dev) most.
I can see why there's so much favour towards D.
On the other hand, there was the time recently that I reimplemented some old C++ simulation code in Python just for the fun of it, only to find that the Python version ran nearly 90 times slower. Of course I expected it to be a lot slower, being an interpreted language and such, but wow.
well, for now I've only done it for stuff where the C source is tiny (using gcc), and compiling doesn't take that long. anyway, I'm talking about cases where you can't really compare the running time (> 2 minutes) to the compiling time (1 second); and for serious work only the running time will increase. in practice the time cost for dressing everything in Python (and using sympy to generate formulas in the C source) is more important (but still negligible next to the time spent running the C generated executable).
however, it is true that for one particular problem I'm already compiling a C library (it's for computing certain classes of polynomials, so I generate individual libraries for individual classes if they're not already there), and then I'm loading it with cdll from ctypes. it's a general enough class of functions that it's worth the trouble to do it. it's also relevant that the functions themselves take a number and return another number, whereas it might be more efficient to run external code when I need to generate a large amount of (binary) data.
in terms of what serious programmers do, you have to realize that, when it comes to physical sciences (I'm a physicist myself), programming abilities can be (and usually are) very limited.
new sig
You should see a psychiatrist. That level of masochism is really unhealthy.
Brilliant! I assume they've got rid of those things called header files by now.
And before anyone moans that "header files provides a good overview of a project", well, it should be up to the IDE to display information (much better presented) about a project and its classes and members. Even Bjarne Stroustrup said that header files were a kludge,
Break backwards compatibility a little bit and you can do so much stuff better. Otherwise you ultimately have a dying language.
Why OpalCalc is the best Windows calc
I think you can easily determine the competence of any programmer by how much they hate their primary language.
It depends as much on the language. I don't trust the competence of any PHP programmer who actually likes PHP... likewise with C++, Java, and several others.
On the other hand... Talk to the true Ruby wizards, and they won't shut up about the glory and wonder of Ruby. It also holds with Smalltalk, some Lisp flavors... and so on.
With machine-centered languages, like C, C++, PL/I, Ada, etc., to truly grok the language comes from doing battle with it. For programmer-centered languages (Ruby, Scala, Smalltalk, etc.), to truly grok the language comes from loving it for every little quirk
Then you have the languages objectionable to both programmer and machine (BASIC, Pascal, COBOL), which one doesn't discuss in polite company.
To understand recursion, you must first understand recursion.
Actually when porting code to python there's a huge performance penalty. Rewriting the code the "pythonic" way usually yeilds unexpected performance boosts. There's a Guido text on python performance, check it out.
This is also common in matlab code (ie. code with loops when ported versus properly vectorized code).
Just as a side note, regarding "objectified int" - the term "object" in C++ standard actually comes from plain C, and doesn't have much to do with objects in OO sense. I'll just quote the C99 spec:
3. Terms, definitions, and symbols ...
For the purposes of this International Standard, the following definitions apply.
3.14 object
region of data storage in the execution environment, the contents of which can represent values
to be fair, all the other 'oo' languages don't let you do that either
C# has operator overloading. Granted, it prevents you from doing certain particularly stupid things (such as overloading == but not !=, or overloading &&. In case of ++, it will require the return type to be the same as argument type, but the precise meaning is still controlled by the implementor.
So basically, you get around Python's performance limitations... by using C instead.
Way to go!
Why not? Use the right tool for the job. Though I'm curious if the parent has tried Cython. It seems like it might be a better fit for what they're doing.
The wise follow a damned path, for to know is to be forsaken.
I cheat. I write python code that writes its own plain C code, compiles it then executes it. this way, I work once to write a C template, that I then reuse through a high level language. and when I combine the advantages of python (sympy for instance) with the speed of C, I get stuff that is ridiculously faster than what I did before. in the sense that I don't work a lot to write it, and I don't wait around a lot for it to actually run afterwards. working with numerical simulations, I'm allowed to cheat this way...
Might be a silly question, but have you given Cython a shot? It sounds like you're doing something very similar to what their project was built to do.
The wise follow a damned path, for to know is to be forsaken.
I certainly agree that it's amazing how many things in c++ flagrantly violate the principle of least surprise. A good example: read these two articles about the assignment operator and weep. The author (who by no means could be accused of being biased against c++) concludes:
I'd have to disagree with you about c++0x though. While there is additional complication, many of the added ideas seem to have few "gotchas" relative to most of c++, and it even manages to eliminate a few "gotchas." I didn't learn c++ until last year (mostly have done my programming in Java and MATLAB, with little bits of everything from C to Scheme along the way), and I ended up using gcc's c++0x option because there were a bunch of ways in which c++0x made things less painful and made c++ seem less braindead.
The big problem with vanilla C is that you still have manual memory management, but no RAII to automate it. Now you have to clean up on every exit path, or do the usual "foo(); if (errno) goto error: ... error: if (p) free(p); if (q) free(q)" dance in every single function you have. This is nothing but tedious plumbing that takes a lot of fun out of writing code, and makes it that much easier to make an accidental mistake.
I'd kill for C with scope guards on language level, so that I could write something like
There's so much you can do with well-written C and good libraries quicker, more reliably, more simply and much more efficiently than in C++.
Indeed; one needs not look any further than Gtk+ to see a proof of that! ~
n/t
I'm going to take a wild guess and assume that you didn't have (or use) the "restrict" keyword?
Did he just go crazy and fall asleep?
So, does Garbage collection work on C++ now or is that just another point on the list of features that sound good, but never worked?
Just like overloading operators, which only works for some operators. Or copy constructors.
You do realize how a JIT compiler works right? Might want to pay more attention in that comp sci 101 class there chief.
I did it once, and I got a huge C file. I didn't even have the patience to go through it, but I saw that a lot of stuff was defined that I didn't actually need. and it was for something relatively trivial. I decided it's safer to write my own C code, at least I can read the C source if there's a problem. and it's mostly just generating a couple of formulas using sympy, and then plugging them into a C template (that I write explicitely as strings in the Python file).
Cython might be good when you try to translate a large piece of Python into C, but that's not what I'm trying to do. for me, running time for the Python script is negligible when compared to the running time of the generated executable, and I'm pretty certain that if I use Cython, overall efficiency will go down.
new sig
have you heard of ctypes? write the number crunching stuff in C, and then make the OO stuff in Python. but keep in mind that in Python there is a (large) constant cost to calling any function, so you should try to call as little Python functions as possible. see my above comments (repplies to "C'mon Python users tell us why") if you're interested: I generate C code, then compile and run it through Python.
new sig
As for speed, sure, C++ is faster in the same way that assembly is faster than C++, and where appropriate (i.e. you've profiled it and seen that function x is taking so much CPU time) by all means write particular functions in C++. But writing a whole program in it for "performance reasons" is the worst kind of premature optimization.
I am trolling
There's also an OS kernel written in Java, that doesn't mean it's a good idea or an area where Java excels. You use the runtime argument yet mention boost... in this context libC and libstdc++ are runtimes, or see how far you get without them.
The big difference between C++ libraries and other languages libraries is just that they work without runtime.
And btw : there are *no* java operating systems. At least not the java you know. There are "compiled subset of java" kernels, which is not the same thing at all.
C is not better than C++. Quite the opposite: Most (not all, though) of C++'s problems are actually C problems. C is actually one of the worst languages I've ever seen. I cannot see why anyone would use C if he can use C++ and avoid at least the worst part of C.
Of the other languages: :-)), however the fact that it is dynamically typed is a distinct disadvantage for larger programs.
Scheme is definitely a great language (if one isn't allergic to parentheses
Java IMHO is definitely not better than C++, period.
Ruby I don't have any experience with, so I cannot tell anything about it. However, AFAIK it's a scripting language, and thus not applicable to all problems.
Python I've up to now avoided to learn because I simply dislike dependence on amount of whitespace. The amount of whitespace is too fragile to depend on it.
The Tao of math: The numbers you can count are not the real numbers.
Please do tell which languages do you believe are "simpler (and arguably better" than C++.
error:Unexpected end of line.
You need to update your parser. The actual error is an unbalanced parenthesis in the quote. Except in poetry, line endings are not significant at all in the English language.
The Tao of math: The numbers you can count are not the real numbers.
"Certainly, lack of standardization hasn't prevented other languages, such as Java in the past, but look what happened there. Microsoft was litigated out of the market, and now Oracle is sueing Google and possibly others. This is not very commercial compiler friendly."
On the other hand IBM has its own JVM and wasn't/isn't paying licensing fee to Sun/Oracle.
The license only prevents incompatible forking. As a Java developer, I don't think it's a bad thing.
I've no need for C++ -- it's just something I want to do for fun.
Thank you. I'm the same way.
C++ is such a terrifyingly complex language that you can spend 5 years writing serious code with it and still be learning new things. Not algorithms or general things that can apply in any language. New things that apply only to C++. And they're all neat as hell, impossible in most other languages, and actually useful.
This is a turn-off for most people, but some of us find it fun. The trick is in knowing how to reel it in before you piss off your co-workers with something so incomprehensible it might as well be Perl.
It is great!
I don't know why people whine about it so much - it isn't that hard, and if you don't like it use something else.
I am very small, utmostly microscopic.
*puts on sun glasses*
BOOST productivity.
YEEEEEEA...etc, .etc.
My -1 Troll is actually a +1 funny. And my -1 flame is actually a +1 insightfull.
Only if the programmer intentionally obfuscated the code. But then, he doesn't need operator overloading of #define; tell me, what does "increase_by_1(C);" do?
Oh, and if C is an int (or another incrementable builtin type), the statement C++; will indeed increment C, with certainty.
The Tao of math: The numbers you can count are not the real numbers.
C is not better than C++. Quite the opposite: Most (not all, though) of C++'s problems are actually C problems.
C++'s problem is that it tries to be all things to all people, and fails.
C++ started out trying to be a superset of C. That was the first mistake. They soon found out that it wouldn't work, but had to keep most of the C features for all that old C++ still to work.
People still try to pretend that it's a "good idea" to recompiled your C source in a C++ compiler (which involves a non-trivial porting effort that they sweep under the carpet) so that you can start to "benefit" from the new C++ features.
C++ syntax is terrible and they keep making it worse. Since they tried to keep it backwards-compatible with C (and failed) they tried all sorts of dirty hacks with the syntax to put in the new features.
The older I get, the more I'm convinced by using the right language for the job. If that means Java, Ruby, PERL, C or whatever, then so be it. C++ is not usually a good choice unless you have to work with and on existing C++ code.
A language I looked at when I was 15/16, which really taught me how to write good code was Modula-2. It's spirit lives on in Borland's Object Pascal/Delphi (whatever it's called nowadays).
For an entertaining and insightful look at many of the problems with C++, have a look at the C++ Frequently Questioned Answers which is organised like (and in response to) the C++ FAQ Lite.
Finally, here is a collection of links to various criticisms of C++.
In summary, C++ is too big and too complicated, and it keeps on getting worse.
Stick Men
Please do tell which languages do you believe are "simpler (and arguably better" than C++.
error:Unexpected end of line.
You need to update your parser. The actual error is an unbalanced parenthesis in the quote. Except in poetry, line endings are not significant at all in the English language.
Since when did parser errors ever reflect the actual error? :p
"Convictions are more dangerous enemies of truth than lies."
Why don't C programmers program in assembler...?
Their reasons for preferring C over C++ are equally applicable to "C-vs-assembly language" so I don't understand why they use C....anybody?
(Be aware that any answer you give will be instantly reworked to fit "C++ vs. C" so you'll lose by default...)
No sig today...
Sure, it suffers from feature bloat - to say the least.
So...which features could you remove without harming the language and making a whole lot of people's jobs more difficult?
I can only think of one - C++ arrays. new[] and delete[] are a dangerous blight (the C++ FAQ calls them "evil") and are made obsolete by std::vector.
And it suffers from a lack of a coherent structure of libraries and tools - it's nothing like java.
That's mostly because the world will never agree on one that's 'best'. There's plenty to choose from but none has ever become The Standard. The user interfaces in Java have only managed become the standard for mediocrity (if you disagree then where's the shrinkwrapped Java applications?)
The one thing that's hurt C++ more than anything else is the lack of a smart pointer class. It would have helped C++ a lot if a good reference-counted pointer had been in the ISO standard. Yes, there's Boost but most programmers are overwhelmed by the style of Boost and all they want is a pointer, not a new lifestyle.
No sig today...
Why don't C programmers program in assembler...?
Their reasons for preferring C over C++ are equally applicable to "C-vs-assembly language" so I don't understand why they use C....anybody?
Portability and productivity are the first things that come to my mind.
(Be aware that any answer you give will be instantly reworked to fit "C++ vs. C" so you'll lose by default...)
And quite rightly so. Some problem spaces are best suited for assembler, some better suited for C, others more suited for C++ and still others for Java/C#, etc. It boils down to the best tool for the job (with technical considerations as well as programmer availability, expense, etc. all factors to be considered).
Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
Because even for the best developers, super-large projects would be a nightmare to code in assembler. Therefore, you'd get a juicy speed increase indeed, but the human mind isn't yet *that* good.
Why OpalCalc is the best Windows calc
There is no such thing as an universally simpler and better language
You see, that attitude is when we give up and stop trying to improve languages. There are loads of cases where you can improve stuff, and unify two approaches into one which is fast, consistent and terse. If C# is more cumbersome, then perhaps there's a way to make it less so while keeping flexibility and power.
Have you looked at D? For all its drawbacks, that surely seems to combine the advantages of C and C++ without many of the drawbacks of both of those.
Why OpalCalc is the best Windows calc
Multithreaded programs don't really exist in Python due to the GIL, you moron.
Mod me down, my New Earth Global Warmingist friends!
Have any C++ programmers tried using Google's Go programming language? Any opinions?
Do you really know what postfix_increment(C) does anymore than operator++?
Yes, unless the programmer was deliberately setting out to obfuscate things it is very unlikely they would call a function postfix_increment unless that is what it actually did and even then it would be a pretty strange way to name a function and an immediate red-flag.
In all the langauges I have experiance with there is a very limited set of operators. The result is where there is no operator that is a good fit the programmer must either give up on operator overloading entirely or (ab)use an existing operator which is a poor fit. This forced descision make operator overloading a dangerous tool. Used properly and sparingly it can make code clear and concise. Overused it will make code smaller but harder to follow.
Below are a couple of examples from the standard library of what I consider to be bad uses of operator overloading:
The streams code overloads to use to output stuff. This makes outputting stuff a little more concise but also means you have to manually keep track of variable types to tell the difference between outputting stuff and shifting bits. To make things even more confusing they made the operator return the stream so users can chain the operations.
auto_ptr uses = for assignment but has rather weird symantics which break the normal assumptions that people are likely to make about the behaviour of an assignement operator. In particular assigning something to an auto_ptr effectively destroys the original (either immediately in the case of an assingment from one auto_ptr to another or when the auto_ptr goes out of scope in the case of an assingment from a plain pointer to an auto_ptr).
note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
"C++ is an octopus made by nailing extra legs onto a dog."
If C# is more cumbersome, then perhaps there's a way to make it less so while keeping flexibility and power.
I only can see two clear advantages to c# over c++: garbage collection and reflection. Everything else boils down to syntactic preferences or minor features. And there's a lot of useful things that c# is missing compared to c++.
I'm sure in time both things will make their way into C++ in a way or another (garbage collection is half-way there).
I don't think that D is a good answer to the shortcomings of C++. I'm not a fan of the "let's add in everything and the kitchen sink" approach.
I'd kill for C with scope guards on language level, so that I could write something like
Actually, if you are using gcc you sort of can. You see gcc supports special cleanup attributes that let you specify a function to be run if a variable goes out of scope. Thus you can do things like:
This example being pointless, but hopefully gives you the idea. A few #defines to make things pretty and you can thus do whatever RAII style thing you wish.
Craft Beer Programming T-shirts
That's neat (though free-form code blocks would be even better).
Now to get this into the Standard...
Where can I donate money to help the victims?
"You can't allow somebody to commit the crime before you detain them." [Condoleezza Rice]
You have to keep in mind that one of the major advantages of C++ and most likely the thing that made it a wide used language, is it's backwards compatibility with C. And that's not because C programmers had a hard time learning C++, but because there exist enormous quantities of C legacy code that would have to be completely re-written if C++ wouldn't provide this backwards compatibility. With the C++ compiler you could continue the work on these projects with the added benefit of finding a few bugs that you didn't even knew were there.
Of course, some of the monster constructs that are allowed in C++ should not be used, they are there just so your old C code compiles. That is the reason best practice books exist, so you know what features of the language to use and when.
Instead of hating on C++ (and now C++0x) because of the features it offers, maybe decide which of those feature to use and which not in your project.
Like C++ is compatible with C, C++0x is compatible with C++, so I don't see any reason why existing projects in C++ shouldn't compile. Maybe I'm wrong here, but I'm under the impression that all the C++ code-base should compile in C++0x without modifications and should work exactly the same.
Bang: You're dead! Assumptions have that effect. My point stands that certainty is only derived from reading every flipping line of code that is ever "included" -- Who does such things? Masochists. Who designs language traps such as these? Sadists.
Only if the programmer intentionally obfuscated the code. But then, he doesn't need operator overloading of #define; tell me, what does "increase_by_1(C);" do?
Oh, and if C is an int (or another incrementable builtin type), the statement C++; will indeed increment C, with certainty.
Unless someone has overloaded the global ++ operator for int types... Your "certainty" assumptions amuse me.
You, my friend, have arrived at the heart of the matter, and thus was my initial point:
C++ is to be regarded as "a different language than C", not as C with extensions. However, C++ was surely developed by adding features to C, then calling it a new language after the fact.
My point is that the basic C syntax could have been kept in C++ without having to limit C++ to old language constructs. The main point is this: The C++ language itself has no business compiling C code. If C++ libraries need extern "C" { ... } to provide C interfaces for their functions, then why not REQUIRE a wrapper convention for any and all C code in a C++ project, then simply let code not wrapped in a "Parse this as C" block have whatever semantics are required -- Including those that break C syntax.
You see -- C++ could have both retained a close tie with the popular C language, while at the same time isolating itself from the older C syntax.
I've actually developed a few toy scripting languages that are "somewhat" C like... In fact, my favorite of these scripting languages has this very parse_as "C" { ... } construct, which simply extracts the code, invokes a C compiler on it to build a shared C library from all such blocks, and dynamically loads those libs at run time. (The VM translates these code blocks into a "load_shared_c" instruction, followed by op codes that add function names to the context's symbol table. These symbols contain functors that call the shared C lib's function by function pointer.)
In short: It is possible to retain the power of C, and take advantage of the C install base, WITHOUT polluting your language with the C language's syntax...
math' = parse_as( "C" )'(){
#include <math.h>
long multiply( long a, long b){
return a * b;
}
double divide( long a, long b){
if ( b != 0 ) return a / (double)b;
return -INFINITY;
}
}
args' = ( 6, 7 );
ans' = math.multiply( args );
say( "Multiply: " + args + " = " + ans );
say( "also, " + args.join( " / " ) + " = " + math.divide( args );
----- output -----
Multiply: 6, 7 = 42
also, 6 / 7 = 8.57142857e-1
You cannot overload the global operator++ for int types. It is explicitly forbidden by the C++ standard, and if your compiler really allows it (I strongly doubt it), it's time to get a better compiler.
The Tao of math: The numbers you can count are not the real numbers.
Just as a side note, regarding "objectified int" - the term "object" in C++ standard actually comes from plain C, and doesn't have much to do with objects in OO sense. I'll just quote the C99 spec:
3. Terms, definitions, and symbols For the purposes of this International Standard, the following definitions apply. ...
3.14 object
region of data storage in the execution environment, the contents of which can represent values
Yes, and the instance of a Class is a "region of data storage" used in the execution environment, the contents of which can "represent" a "value". Literals are also stored in regions of data storage, and used in the execution environment, with contents that can represent values... So also may a variable of an enumeration type, or even functions (which have stack frames) for meatball's sake! -- So once again, the multi-headed snake is happy to eat any of its myriad of tails.
I don't object to the object of object oriented programming; However, I do object to, "object" being the chosen term for objects in any programming language.
It's as if the object of choosing "object" to name objects were to cause confusion and ambiguities, not resolve them. (Clearly this must be some sort of bad joke, no?)
If it were one of the objectives of an object oriented programming language, to help provide clarity of concept, one would think that the creators of such languages would have been a bit more objective and chosen less objectionable terms, such as Entity, native type, idea, concept, form, pattern, formula, design, etc.
C++ is marketed as an "Object Oriented Language". IMHO, the term "object" is a very overloaded in English -- Like C++ functions can be...
"Object Oriented Programming" could describe a language that revolves around the concept of Objections -- Like C++ does (Exceptions).
"Object Oriented Programming" could describe a language that focuses on the objectives of the logic, not the data model, similar to the procedural aspects one uses in a language such as C++.
"Object Oriented Programming" could even describe a language that allows one to group data and behavior into a single unit, like C++ classes do...
Finally, given your citation of the ambiguous "standards", C++ being capable of "Object Oriented Programming", could mean that one spends most of their time reprogramming the syntax of the language to provide different behaviors for standard built in "primitive objects"... Like C++ operator overloading does...
You know what, I take it back, "Object" is a perfect term for C++ -- It's opaque, ambiguous, and ill-suited for its purpose, in other words, par for the course in C++.
( Don't even get me started on "classes" -- Are we talking classification system, or training of AI algorithms? Perhaps we mean that classes are where you must go when the compiler objects to your code in order to learn WTF the object of the object's objects are. )
Well I must apologize, I was wrong. language native primitive types can't have global operators overridden...
So I guess there's only one predictable set of operations you can do in C++, work with the primitive types. Except, you can't really predict the size or range of the primitive types until runtime, unless you know the specifics of the platform the code will be compiled on.
I grepped my code, and couldn't find a singe use of an int, long, char, etc... Turns out that we all use stdint.h types to provide cross platform capabilities (even though it's C not C++) -- typedefs for all the primitive data types, such as uint32_t are used in place of int, because sizeof( int ) is platform dependent... Now, quick, say you're on a 32 bit system. Without looking in the stdint.h file, prove that uint32_t is not really a class that implements all the int operators, has an internal state 4 bytes in size, and can cause the following statements to do any arbitrary operation.
#include <stdint.h>
int main( void ){
uint32_t C = 0;
return C++;
}
Use tricks with Templates? xxx_cast, etc? Typeinfo? All those things work at compile time -- looking at the code, and only the code, without compiling it and running it, there's no way to tell what the hell it's going to do.
Say you do read through the stdint.h and discover that uint23_t is an alias for int... ON YOUR SYSTEM. Who knows what stdint.h will define uint32_t as on anyone else's system -- Faith is a required virtue of C++ coders. On an 8 bit system, uint32_t may be a class that wraps an array of 4 ints (8 bit each == 32bits), and simulates 32 bit integer operations... or perhaps they open network connections and ask a mainframe what the answer is... I still can't really tell what's going to happen when that simple code executes... hell, even if I take for granted a "standard" stdint.h file being available, the semantics of #include <stdint.h> vs #include "stdint.h" are platform dependent -- some compilers will look in the current directory first regardless of the angle brackets or quotes.... so... Is there a stdint.h in the local directory? Only looking at the code, I can't tell... Is it really so hard to give a C++ programmer even the most basic tools, such as a few guaranteed size integer types? ( isn't in my C++ compiler; Is it in yours? -- stdint.h is C, not C++ )
I admit that I'm wrong about the special case where you actually use the platform dependent language primitive types such as int, char, etc, however, just because sizeof uint32_t == 4, doesn't mean that's a primitive type, and short of using typeid or other such compile-time or run-time operations, I'm not sure I can predict what that code will do without reading the typedef and/or class implementation of the uint32_t type.
Conversely, in languages that don't allow operator overrides, I can be sure that +, --, ++, and other mathematical operators operate on numbers, or at least perform defined operations given a set of parameter types.
Yes, and the instance of a Class is a "region of data storage" used in the execution environment, the contents of which can "represent" a "value". Literals are also stored in regions of data storage, and used in the execution environment, with contents that can represent values... So also may a variable of an enumeration type, or even functions (which have stack frames) for meatball's sake! -- So once again, the multi-headed snake is happy to eat any of its myriad of tails.
Literals are not stored in regions of data storage, except for string literals - and yes, those are objects (same as any other array). Variables of enumeration type are also objects - I don't see why you feel there's a contradiction here (did you mean to refer to enumeration members instead? they're not objects because they don't have any storage backing them). Functions are not objects, because they do not represent a value (though in C++ this is explicitly clarified in the spec, unlike in C).
C++ is marketed as an "Object Oriented Language".
If someone markets it to you that way, then they're clueless. C++ is a multi-paradigm language which offers OOP among many other approaches, without forcing any on you.
Oh, and even so, there's a common understanding of what OOP means in the field. You can come up with your own differing definitions, but it doesn't prove anything, as they're not the ones actually used in practice by anyone.
You know what, I take it back, "Object" is a perfect term for C++ -- It's opaque, ambiguous, and ill-suited for its purpose, in other words, par for the course in C++.
"object" is not a C++ term; it's a C term that was inherited in C++ simply because most C++ programmers were also C programmers, and it would be more confusing to change the terminology that they're using.
As for C, arguably, the term "object" there was used before OOP went truly mainstream.
Don't even get me started on "classes" -- Are we talking classification system, or training of AI algorithms?
Same as "OOP". This one has many meanings, but there is a very well established one in the context of C++, which everyone understands. There's no confusion here other than what you try to artificially induce.
Well, there are guaranteed minimal sizes, and rarely you need the exact size (unless you are doing very low-level stuff, but then you should better know your platform anyway).
Given that stdint.h is a C header, it will of course define it to whatever it is defined to be in C. Of course if using a compiler you always need to put faith in the provider that he doesn't do stupid things, or have glaring bugs in the compiler or associated library.
stdint.h is a standard C header, and therefore cannot use any operator overloading.
But even if it were a user-defined type, unless the programmer writing it was a complete moron who should not have been let closer than ten miles to a compiler (of whatever language), you can expect that any operator works exactly as expected.
The original C89 didn't have it either. And the next version of C++ will adopt it from C. But as I said, if you need specific sizes, you obviously do low-level programming, in which case you better know your platform (which defines the sizes of C integer types) anyway. Therefore a header with pre-defined specific-size integer types, while certainly useful, is not really essential.
And in languages that don't allow user-defined functions I can be sure that multiply(a,b), if defined, does indeed multiply a and b. We really should disallow user-defined functions; they can completely mislead you!
The Tao of math: The numbers you can count are not the real numbers.