C++ 2011 and the Return of Native Code
snydeq writes with an editorial in InfoWorld about the resurgence of native code. From the article: "Modern programmers have increasingly turned away from native compilation in favor of managed-code environments such as Java and .Net, which shield them from some of the drudgery of memory management and input validation. Others are willing to sacrifice some performance for the syntactic comforts of dynamic languages such as Python, Ruby, and JavaScript. But C++11 arrives at an interesting time. There's a growing sentiment that the pendulum may have swung too far away from native code, and it might be time for it to swing back in the other direction. Thus, C++ may have found itself some unlikely allies."
For learning purposes, I find C++ to be a very good language.
Its confusing enough that most people not up to it will leave once you cover the basics of pointers, yet not so difficult or complicated that it would take too long to learn.
For instance, Java takes forever to understand as compared to C++, and no playing around with pointers either
New hardware has bought us the ability to use managed code for most (not all) software. Isn't this much better than expecting every programmer to perfectly manage his memory every time? Just wait a couple more years and we won't be feeling the hardware pinch even on phones.
Author doesn't know the difference between languages intended for system programming and application programming.
Intron: the portion of DNA which expresses nothing useful.
Native was never away. It always has its place. It is just that performance/efficiency is not always top priority.
Modern programmers have increasingly turned away from native compilation in favor of managed-code environments such as Java and .Net, which shield them from some of the drudgery of memory management and input validation.
So if you wanted to be shielded from the drudgery of memory management in C++ why weren't you using the features of the language that provide you automatic memory management to make this less of a pain? It's not as if you don't still have to do memory management in say .NET especially since the IDisposable pattern is needed all over the place in user-written code to clean up non-memory resources like file handles, GDI handles, etc held within your objects.
Last I checked you could use .NET in C++. So use .NET for the gui and networking frameworks and use C++ to do hardcore number crunching. Also there are native data structures in .NET and Java you can use in your program if you need performance. Most amature programmers never look in the math or collections libraries.
http://saveie6.com/
Carmack remarked about this on his Twitter account today: "iOS did a lot to 'save' native code on mobile platforms. Prior, there was a sense that only Neanderthals didn’t want a VM."
Apple is even backing down on Cocoa garbage collection with their new Automatic Reference Counting feature, in which the compiler determines object lifetimes and inserts the needed memory management calls. ARC will be the default for new Xcode projects. I think there was a hope that computing power would catch up and make VMs a competitive alternative to native code.
Look at Objective C or Vala -- just as easy as C# or Java, but none of the headaches of a virtual machine runtime.
There's no -1 for "I don't get it."
Using native code was never something which contradicted using scripting languages (in my case: python, perl, matlab, tcl) or java. Mixing them in the right way does the trick.
My approach was: use whatever tool is suitable. Write native what needs to be done native (and preferably use ANSI C for it), write guis in (preferably java or tcl).
...choose the tool that's best for the job, don't choose the job that's best for the tools you know already.
Game developers, for instance, are among the guys who write the most performance sensitive code out there, and they use a mix of C, C++, C#, Lua/Python for the various parts of the game. Usually the inner, tight loop is written in C/C++, higher level modules are written in C# and designer/modder scripts are written in a very high level language such as Lua. There is no best language in general, and whoever says otherwise is often an idiot.
My book: Friendly F#, fun with game development and XNA; my game: Galaxy Wars by VSTeam; my gamedev language: Casanova.
General rule to be followed but not strictly:
If your code is to be maintained by junior programmers, then choose a managed code environment.
If you organization's primary business is not software production, then choose a managed code environment.
If your application is mainly implementing business logic, then choose a managed come environment.
If you are implementing a UI, then choose a dynamic language.
Only if none of the above apply should you choose native code.
>>Modern programmers have increasingly turned away from native compilation
Uh, not me.
I never saw the benefit, only the pain.
The so-called "managed" environments solved a problem I didn't have while adding complexity I didn't need.
I very much doubt that C++11 heralds any kind of new interest in native code. Rather, native code in general has been getting more attention recently and C++11 just happened to be finalized around the same time. (Disclaimer: C++ is my second-favorite language. I want it to be liked and used, but I'm realistic.)
Nearly off-topic in the article is this gem of a paragraph:
This is most certainly not news, but I find it refreshing to see the blindingly obvious repeated again. IT shops that "standardize" on one language (or framework, even) are simply zapping themselves with low-voltage-yet-eventually-lethal tasers. Managers, take note. Again.
But does anyone know if or when there's going to be a book (you know, one of those paper things that you physically hold in your hands and actually have to turn pages to read instead of looking glaze-eyed into the glow of a computer monitor) that covers C++11 fairly exhuastively, such as how, for comparison, Stroustrup's "C++ Programming Language" covered the previous standardized version relatively thoroughly?
Thanks.
File under 'M' for 'Manic ranting'
With ARC, there really isn't a need for a garbage collector. I've used both, and the only things that happen in ARC that bite you are things that happen in Java, et al. I.e. you can still use a null pointer and such and get an error.
The only place I have been truly surprised is that some of the Foundation stuff can perform weird or unexpectedly. That's more that ARC is fully Cocoa ready and that you need to tread carefully when using toll-free stuff. But then ARC warns you, and then you need to just follow some simple rules of thumb about giving ARC a hint about how you plan to use the Foundation object. I suspect that might get resolved later.
All in all, I am *very* impressed with ARC. It makes life so much easier, and it gets you almost all the advantages of GC--or at least all the ones that matter or people really use.
"Doubt your doubts and believe your beliefs." -- Switchfoot, Ode to Chin
if C# goes down.. i'm going down with it
C++ got a very bad reputation, Do to the helpless little script kiddies, That thinks memory management is something a real programmer is concerned about. And now you tell me that; these dime a' dozen script kiddies are coming back! ARGH! :(
"Men will never be free until the last king is strangled with the entrails of the last priest." - Denis Diderot.
The article perpetuates the myth that native code has to be "unsafe". That's an artifact of C and C++. It's not true of Pascal, Ada, Modula, Delphi, Eiffel, Erlang, or Go.
Nor does subscript and pointer checking have to be expensive. Usually, it can be hoisted out of loops and checked once. Or, for many FOR loops, zero times, if the upper bound is derived from the array size.
One of the sad facts of programming is that there should have been a replacement for C/C++ by now. But nothing ever overcame the legacy code base of the UNIX/Linux world. Every day, millions of programs crash and millions of compromised machines have security breaches because of this.
Gimme an algorithm or any other job and I'll implement it in 'C' - I don't need no pussy language that makes parsing text easier (Perl) or web back ends easier (Python) or worry about the mythical write once run everywhere languages like Java.
And back in the day of the old PS2, every goddamn game development house started out their dev cycle by reimplementing mip-maps because it wasn't supported directly by the hardware. Fucking insanity. If there's a tool that has been developed for text parsing, and 99% of your program's functionality is text parsing, then use something that was DESIGNED FOR TEXT PARSING instead of having to reinvent the goddamn wheel.
Tools are made because they make life, or at least a specific task, easier. They should be used for that purpose. They should not be used for things they are not designed for. C++ was designed for low-level access to the hardware, which is fine if your program needs low-level access to the hardware, but it shouldn't be used for every task just as Java, or Perl, or Python, or any other tool shouldn't be used for things they weren't designed for.
I think it's funny that Stroustrup took one of the syntactically simplest computer languages, C, and turned it into one of the one of the most syntactically elaborate computer languages imaginable.
The only good thing is that you can ignore most of its esoteric features most of the time.
And not the 32 bit shit, but pure adulterated porn-filled XXX 64-bit God-Loves-AMD assembly(er) !! Instant doubling of speed right there. So it takes 30 times long !! It is twice as FAST !!
C++ is "native", huh? And here I was thinking I need a compiler for every platform I want to run it on. Silly rabbit.
all I'm seeing in these comments is blah blah blah managed code memory management.
What about blah blah blah poorly written managed code doesn't expose remote code execution, while poorly written native code does.
Even almost perfect native code can expose massive security holes.
Meanwhile, other people will actually ship on time and within their budget by not being a moron who thinks the only thing important in development is computational efficiency.
If I can just reach out with my words and touch a butthole, just one, it will all be worth it.
Is there anyone these days writing applications in one language in exclusion to any other? I'm feeling old. I wrote applications in ASM because it was exclusive. Then I wrote applications in Fortran because it was easy. Then basica because it was way easer. Then Pascal because it was the shiznit. But then applications became more complex because of these GUI things and stuff. That is when the OO languages like C++ kicked ass. Now days it is so "normal" to write something that communicates with the actual interface (ie. HTTPD and the browser. SMTP and the reader...). It doesn't matter what you write it in as long as it is fast and works in conjunction with some dynamic language. I like the additions 11 has brought to C++, regex, threads, pretty much anything boost has added. I'm using C++ today, despite not learning OO programing until I was in my 40's. As someone who has watched people fall in and out of love with languages I have to wonder why so little attention is payed to D2. Most of the additions to 11 are in D2. er I think. Did I mention I'm old?
Having to work for a living is the root of all evil.
... never distinguished between "native" and "managed" code.
Write the damn code according to the rules and idioms of the language in use, let the language implementation deal with the rest. If you're an application developer and care about *how* your code is being run, you're doing it wrong.
From the article;
But the most important thing to remember is to always choose the right tool for the job. No one wants to go back to the bad old days of wrangling text data for the Web using CGI scripts written in C. On the other hand, shoehorning every application into the same interpreted language or managed code environment, irrespective of the task at hand, isn't the right way to go, either.
This is the most important take away from the article. There are times when native languages will solve a problem far better than scripted/interpreted languages while other problems are not. I've been programming for just over 25 years and there has always been a crowd that insists we all use cause it's the greatest new thing in the world of computing when really it's a break though for a particular situation that doesn't fit with the previous set of tools. I always disagreed arguing there should be tons of tools and languages to suit each need. Does a handy man have only one tool in his belt? A mechanic only one size wrench? No, and the same is true for developers. Each language/platform has benefits and draw backs. Each is suited for a given problem. There should be a rule that the next time some one talks about how is the greatest solution to all our problems and we should all convert now, the rest of us get to beat that person senseless with two by fours with protruding rusty nails. It really is OK if we all do our own thing.
I think a replacement 'native' language should focus less on academic correctness and fads, and more on things that make scripting languages nice to work with. I don't *mind* OO features, but I find their exclusiveness in java, for example, a litlle limiting. And in C++ a little overbearing. Rather, I'd see C extended with supple string handling and regexes, for example. On top of a class model, obviously.
Religion is what happens when nature strikes and groupthink goes wrong.
Given two developers of equal talent the developer using .NET or Java is likely to outproduce the developer using C/++ in nearly every meaningful measurement to a business. There are exceptions, of course, in places where managed languages don't fit well (or at all) such as device drivers, real time software, etc. Developers keep forgetting how expensive their time is, and more importantly their real role within the business.
On top of that, unfortunately we'll always be working alongside poor quality developers and in spite of our arrogance will occasionally make "poor quality" code even if we're pretty good developers. Personally, I'd rather deal with the aftermath of some poorly written Java code than some poorly written C code.
Check out my lame java blog at www.javachopshop.com
Nintendo dropped the ball big time when they used a string comparison function for evaluating the digital signature hash. String functions terminate early (with success!) for strings where the first byte is null. All an attacker had to do to fakesign a Wii application is brute force change some random unused byte until it caused the first byte of the hash to be 00.
:(){
...yes, BUT - with superphones and super computers - who cares about optimizing? the sad truth is (much like with Flash), the solution for a slow, hiccup-py technology (like virtual machines and ...again... Flash) has been and IS: faster computers!!
it's ridiculous that it took a 1.2 GHZ dual core processor in a "phone" to get rid of lag in browsing and just traversing device menu... that's Java for you :( so very sad.
You can't just throw out some outlandish statement like this without providing evidence.
So I call bullshit.
Believe it or not, 2011 could be the year of C++.
Starting in August? Maybe we can also make it the Year of the Linux Desktop starting, say, on Christmas.
VMs add overhead, as you add overhead you'll run longer and burn more power on the CPU.
A lot of applications running on smartphones are limited by the speed of the connection to the Internet or by the speed of the user, not by the speed of the CPU. For these, I'm told the LCD backlight uses far more power than the CPU. Or by "embedded", did you mean an environment even smaller than a phone?
People tend to lump lots of things as if they were all the same thing, but they're really completely independent:
Does the language run in a virtual machine, or is compiled down to native assembly in advance?
Is memory management done explicitly, or is there a garbage collector?
Does it allow direct access to memory (necessary for some parts of system programming)?
Does it check for common errors, such as going past the ends of arrays?
There are garbage collectors for C++. C# runs in a virtual machine, but still permits direct access to memory. STL collections in C++ check for out of bounds indices. So here is how I would categorize different languages, roughly ordered from "most native" to "most managed":
C++: Incredibly complex, lots of bug opportunities, very verbose, very fast, suitable for system programming
D: Some complex, some bug opportunities, some verbose, very fast, suitable for system programming
Objective C: Some complex, some bug opportunities, some verbose, fast, suitable for system programming
C#: Some complex, some bug opportunities, some verbose, fast, suitable for system programming
Java: Some complex, some bug opportunities, some verbose, fast, not suitable for system programming
Scala: Very complex, few bug opportunities, not at all verbose, fast, not suitable for system programming
Python: Fairly simple, some bug opportunities, not at all verbose, slow, not suitable for system programming
"I'm too busy to research this and form an educated opinion, but I do have time to tell everyone my uninformed opinion."
I'm pretty sure not even the xbox runs .net code
Xbox Live Indie Games are 100% pure .NET code. Native code won't even load in the sandbox where Indie Games run.
There is no best language in general
Unless your platform limits which languages may be used. For example, languages that compile to native code (such as standard C++) or rely on Reflection.Emit (such as IronPython) won't run in Xbox Live Indie Games. This limits such games to pretty much just C# and languages with pure C# interpreters such as the XNua dialect of Lua.
I took C++ up to Data Structures. I'd like to pick up again, but learn real programming concepts before learning a language's syntax. What would you recommend for this route?
If the hardware exists, there's a 'C' compiler for it or an assembler.
I doubt there is a C compiler for this chip, possibly not even an assembler, given that the chip was designed to implement Forth.
http://www.ece.cmu.edu/~koopman/stack_computers/sec4_5.html
Awesome furniture, accessories and cabinetry in Santa Rosa, CA: http://humanity-home.com/
Smalltalk was an experiment -- can everything be done with message passing?
The answer is "yes". (but, of course, this may not be desirable).
Conditionals ("if") fall out of sending messages to boolean objects.
boolean is sent message "if" with argument "a block of code".
IF the boolean is the "true" instance, return the value of evaluating the code block. IF the boolean is the "false" instance, return NULL.
If tail recursion is added, WHILE becomes just as easy.
Which means that the syntax degenerates to "send message to object with arguments", and "define a code block".
A pleasant result -- there is no special syntax to IF/WHILE or anything else.
The Smalltalk compiler may, of course, optimize this stuff (and usually does).
But, the NICE effect of this is that "boolean" and control structures are NOT CONCEPTUALLY PRIMITIVE -- they are defined in terms of "OOP" or message passing, giving the possibility of defining your own control structures. If the C do/while is not available in a Smalltalk implementation, it is easy to add, and (sharing a trait with LISP) the implementation looks the same as the "default" control structures.
doWhile method for "false" - execute code block and return.
doWhile method for "true" -- execute code block, evaluate condition code block, if "true", recurse, else return (and, please note that the conditional is a message sent to the boolean result of the conditional code block).
Of course, you got me on "boolean instance". Since code can only be put into a class, the "true" and "false" instances are actually subclasses of a boolean class.
Of course LISP is yet simpler... But I agree, Python gives almost the ideal balance for most programmers (personally, I like the LISP approach though -- I think Gambit-C SCHEME with "six" syntax is better than Python, but that's just me).
Just another "Cubible(sic) Joe" 2 17 3061
It's not only about being easier, but also proven. I would rather use a lockless thread-safe multi-reader/writer queue than implement it myself only to have a possible race-condition. It would be fun to learn it some day when I have free time, but enterprise code? No Way. I'll let engineers with PHDs and tons of testing figure out the hard stuff.
We don't have passengers in the cockpit flying our commercial airline planes. We have expert pilots flying our planes who have thousands of hours logged training. It's too important to have just anyone flying planes, lives are at stake.
When it comes to software, it's nonstop amateur hour. There is hardly any urgency about the lives at stake when it comes to software.
In my estimation, there is very little robust native code, written large, in the world. QNX, the JVM, maybe Apache HTTP (although that seems creaky to me and the config system is a hot mess.)
The linux kernel seems robust to me based on how it's maintained, but I am not an expert. All of the browsers have some varying degree of swiss cheese holes to them, with giant attack surfaces, and poorly written plugins (including Java's.) I pity the security teams on those products.
I don't trust your native code. I hear people tout their soup du jour language/vm as robust, sane, battle hardened. The more shared libraries and DLL's your code relies on, the less I believe you. If your favorite system easily/readily/commonly links in more native code as it rolls along, then I hope you understand that your battle hardened tank has cheese cloth armor that should never go to war.
I don't trust Microsoft code, especially their new products - a permanent bullseye is tattooed on their hineys. Yes, they've made security advances in recent years, they're still horribly vulnerable due to the legacy baggage which is core to their business. Microsoft code is bubbly poison at its deep, dark, dank core. IE is terrifying to me.
When it comes to me, I consider the code I write to have my name attached to it. Why wouldn't I give myself every opportunity to look good? A crash bug in native code to me is the most serious form of professional failure.
Maybe a lot of you just tinker and love your micro-optimizations in C and Assembly. Good for you, go spin that propeller on the beanie on your head, very neat. If you write for games or embedded systems and need the speed of native code, fair enough, but I'm dubious C# or Java isn't fast enough for most of that. Otherwise, please, PLEASE stay out of the native code cockpit when it comes to commercial/professional work unless you've got your thousands of hours of flight training. Lives are at stake.
Which will cause your company to lose money as customers want computational efficiency.
We've missed you.
I've done years of Java, .Net, then the past few years have been mostly objective-c. Now i'm about to take a job that is all c++.
My pointer is eight bytes into a buffer allocated on the stack six functions above this one.
Perhaps the thinking is that pointers should be stored as two separate machine words: the pointer to the start of a buffer, and the offset into that buffer. That's how managed languages handle iterators.
And then what do you do?
Unwind stack until you catch the exception.
So your web browser would have to know *IN ADVANCE* the names of all the files you are going to download?
No, but it should know *IN ADVANCE* the name of the folder to which they will be downloaded (for example, /home/pino/Downloads) and how much space in that folder is available.
C++.
Yes, you get a little bruised when it comes to pointers, but that is very much worth it in the long run.
Students that don't learn about pointers and such early on (e.g. got Java first) tend to have a harder time in the upper classes where lower level languages are required. So, you can either "man up" and get the hard stuff learned early when it won't interfere with the classwork, or have your upper level classes being diverted in order to teach the stuff they should have learned earlier on and then not get to learn as much of the upper level material as they should have.
Truth is like the sun. You can shut it out for a time, but it ain't goin' away. - Elvis Presley (source: imdb.com)
The JVM and other intermediate machines attempt to use another "non pointer" model, and then convert the code into native code safely (if you trust the intermediate machine coding).
So do things like Google Native Client. The program is compiled to bytecode that's a verifiably memory-safe subset of x86 instructions. The (trusted) verifier uses a "non pointer" model, and after that's done, the bytecode executes on the CPU.
The CLR is a memory manager and JIT compiler.
So is the HotSpot implementation of the JVM. Perhaps the only substantial difference is the cache of the JIT compiler's output.
Yes, but still, "in general" applies here. In this case C# and F# are the best choices (I have used both for XBLIG games and they can be fast at runtime and cheap in terms of dev time).
In other cases/platforms you will have other best choices.
In game development, the idea is this:
If you have 20+ devs, 3 years of dev time and 5+ million dollars, then great, go with C++.
If you have 3 devs, 3 months of dev time and 5 dollars to buy snacks every other day, go with C#.
My book: Friendly F#, fun with game development and XNA; my game: Galaxy Wars by VSTeam; my gamedev language: Casanova.
Why not just make a new user account that has access only to those resources that a given program may access, and then run the program as that user? That's what iOS for iPhone and IOS for Wii do, I've read.
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
The demise of native programming has been greatly exaggerated.
I swear to God...I swear to God! That is NOT how you treat your human!
So what if I have 3 devs, 3 months, and I want to release on both Xbox 360 and Mac? Or Xbox 360 and Android (assuming the game design is flexible to allow for both touch- and gamepad-based input processing)? Sometimes, different platforms have disjoint sets of preferred languages.
At the rate WP7 market share is declining, it will be a rounding error.
Are BlackBerry phones also headed toward rounding error? Flash and HTML5 JavaScript are managed environments; are they likewise headed toward rounding error?
But you have a point - if your two-class divide comes about, people are going to shun the small guy or gal because his or her code will eat into their battery life.
So how are small guys supposed to get promoted without leaving their support network of friends and family behind to move to, say, southern California or Washington to seek a job with the big guys? As CronoCloud put it, "if you want to be a star on Broadway, you're going to have to go to New York City."
Your contradicting several studies on the subject. I trust the studies. In your case, the studies clearly showed what you're depicting (at least at that time), is a by far a minority.
This may come as a shock to you, but believe it or not, there are large deployments of Windows servers with developers developing on Windows. Shocking - I know.
Citations for the studies please. I've been working on Java (mostly) since 1998, from implementing custom network stacks with it, to CORBA, to almost every stuff under the enterprisey umbrella, in 7 different companies in different industries (healthcare, finance, re-insurance, manufacturing and defense), from the very small (a 5-pple medical dictation automation startup) to the very large (40k multinational).
What lehphyro described pretty much matches what I've seen in my line of work. So either the studies are faulty, or you are misrepresenting them.
Talking about studies (and insisting in a reply on the same studies) without providing at least one reference, that's just weasel words and hand waving.
Also, regarding this:
Furthermore, the vast majority of this Java software can not run anywhere without additional code changes because of programmer short sightedness or just simple mistakes
That's an oxymoron. Such a condition is an indictment on the programmers' part, not on the concept. That's like saying OOP, the concept, is flawed just because people keep writing procedural spaghetti with OOP languages. I mean, c'mon, it is possible to write many types of non-trivial systems in C or C++ in a manner that is portable. Unfortunately, for that class of systems, C/C++ programmers fail miserable because they make mistakes and due to human short sightedness. Does that mean that C or C++ (the languages when used under a specific type of constrains) are not portable?
Same with Java. In 13 years of working with Java, I've only come across (first-hand experience) with two systems that were not portable:
1) a java implementation of the DNP protocol stack that I had to write moons ago using the javax.comm serial communication API. That stuff can only work on three platforms (Solaris, Linux and Windows) out of the many others that the JVM run. It won't work (and probably never will) if you drop it in a HP-UX hosted jvm for instance.
2) a web application hosted on WebLogic 8 SP2 that we could not deploy on WebLogic 8 SP4 and up. It contained a weird dependency on apache xerces that was also colliding with any version of WL 8 SP4 and up. I never stuck around long enough to find out if it was a problem with apache xerces itself, with WL 8 SP2 (or SP4 and up) or with the application (even after we did a serious code audit on it.)
The former out of necessity due to dealing with native libraries. The later due to a programming error somewhere. That's it. In 13 years, that's all I've ever seen. Yes, you can create a web application with dependencies to vendor-specific libraries in a web/ee container that will stop you from deploying it in another vendor's container. But then again, that's a programmer's error, not an indictment on the portability provided by the technology in question.
Actually, they want something better than they have now as fast as possible. Although I love and admire computationally efficient software, if the choice is a slow software application, or nothing at all, I'll take slow thanks and then complain until they fix it with a new version.
Science advances one funeral at a time- Max Planck
An important thing to remember is that those who are actually getting stuff done usually don't have a lot of time left over to be hyping their preferred technology online and in magazines. They're just too damn busy using C++ to implement the important native apps that are generating real wealth, for example.
The only reason we hear so much about Ruby, JavaScript, NoSQL and other crap like that is because its advocates are, well, often very, very unemployed. Being unemployed, they have lots of time to sit around and write articles about how great their technologies are, although nobody is willing to actually pay them to use these technologies!
Yep, I don't recall having memory management issues with C++ in the last ten years or so. Smart pointers take care of freeing RAM and the std::vector I use has bounds checking and extensive iterator checking turned on by default (even on operator[]).
Done properly C++ is as safe as Java, i.e. the only memory error is null pointer.
Java, OTOH has no stack unwinding for timely release of resources. Garbage collection is useless for anything other than RAM. Want a file or a network connection closed? You have to wrap it in a try...finally block and close it manually. Every single time, no way to automate it.
Then there's Java's brain-dead inheritance model. Get ready to do multiple inheritance manually by copying/pasting code from all the base classes. Cross your fingers that the interface never changes and you have to go and hunt down every last copy of it.
Want some "drudge"? Use Java.
Your point about the nuances of releasing resources other than memory (.ie. a network connection) are dead on. It is one of the main weaknesses of Java.
Your second point on multiple inheritance, however, makes no sense. You rarely come up with a valid need for multiple inheritance in C++. The majority of cases for modeling require single inheritance and that's it. And that's equally covered rather well in both C++ and Java. For the rare cases of using multiple inheritance (last time I ever saw it was for implementing multiple CORBA interfaces in Java 10 years ago) one simply uses a "tie", a delegation/composition mechanism using typical design patterns.
If you find yourself copy/pasting code for implementing multiple inheritance in a language that does not supports it, you are doing it wrong. Don't blame the language, blame yourself. In the general case, composition over inheritance, specially multiple inheritance. We have known this for quite some time.
incompetent and/or lazy programmers have increasingly turned away from native compilation in favor of managed-code environments such as Java and .Net
I've fallen off your lawn, and I can't get up.
Don't worry he'll write one.
"Ubuntu" -- an African word, meaning "Slackware is too hard for me". - stolen from Dan C alt.os.linux.slackware
It's a been a while since I've written much C++. What I miss most are destructors. I loved know that when scope is lost for a local variable I could depend on a dtor. I didn't have to worry about cleaning up in finally blocks and so many other cases. Predictably knowing that my dtor would be there to free up mutexes, close sockets and every other resource recovery task I needed was great.
Haskell or Scheme are both good choices. Also, Lisp. Go read a book called Structure and Interpretation of Computer Programs, which is free on the MIT site.
Is this the year of C++ on the desktop?
In that case write in Java and compile to native with gcj (which can go everywhere C goes for non-gui stuff). If your requirements include the word 'portability' then Java is usually the hammer you should reach for first.
Life in prison seems less harsh than forced to program in Javascript for eternity.
One of the sad facts of programming is that there should have been a replacement for C/C++ by now. But nothing ever overcame the legacy code base of the UNIX/Linux world.
I'd say that Javascript as still the sole programming language for client side web applications is worse than C/C++. If the programmer goes down to C/C++ level, they are presumably going up against complexity in pursuit of performance. Web applications are supposed to be easy to program, but resource consuming. Javascript should be an easy language, with built in limitations for the lower skilled programmer. Regrettably, the former is not true.
Yep, you read that right, there are native code apps that use the Java GUI for portability. These apps have names like things like "Matlab", "Maple", and "Mathematica."
Don't believe me? Why do you think Matlab has such a long launch time? It is because the GUI Command Windows is a JFrame that has to class load Swing on startup that makes the launch so pokey. It sometimes divulges its "secret identity" by showing the Java coffee cup icon on the Windows Taskbar when this is going on. Don't think Matlab is anything like a 100% Java app. My guess is the most of it is native code written in some semi-portable C/C++ -- they are just using Java for the GUI.
In that case write in Java and compile to native with gcj (which can go everywhere C goes
How easily does Java go to platforms that only run the CLR? Does J# use anything not supported on the Xbox 360?
for non-gui stuff)
And even for GUI stuff, as long as I write the front-end in each platform's preferred language, correct?
http://airex.tksc.jaxa.jp/pl/dr/19930073399
one example of many.
That's not actually true for learning. I find I learn by far the fastest if thrown in to a problem, and then have someone critique what I come up with. Climbing small mountains first has the effect of solidifying *wrong* information in my brain, which takes ages to get back out. In your metaphor, the reality simply is that mount Everest exist. Training on a molehill where oxygen masks don't matter will lead to forgetting them in basecamp, then dying, utterly convinced of how competent you are.
Throw students on mount everest, make sure to have evacuation options. That's how sherpa's do it (starting with 3-year-olds), and nobody beats them at rock climbing. There, metaphor taken too far ... check.
Besides, small-scale training just doesn't prepare you for the reality. You want to learn how to write every last imperative language there is ? Learn C++ ... then figure out which parts to drop so it becomes C/Java/Pascal/C#/F#/Python ... Learn functional programming (only const functions and objects) ... Monads (think about adding return this to every void member function) ... Learn dynamic typing (always lookup your functions in a map, don't directly call them) .... Learn java (autopointer everything, then look into more advanced garbage collection) ...
And if you want garbage collection to "just work" ... C++ can do that fine. A lot of programs are actually simpler in C++ than in java. They're certainly shorter, although that's hardly a contest when we're talking about java.
Good old C++ is still the best language for writing commercial applications. Here are some of the reasons:
* Vendor indpendent. It's the only widely used and supported modern language that doesn't belong to a single entity. There's always a choice of compilers on any platform. If one company decides C++ is not cool anymore and abandons it you are not going to be screwed - just switch to another compiler. That's a very nice way to protect your investment in technology. .NET can be easily reverse engineered even after obfuscation.
* Portable and platform independent. Although porting is not as simple as in Java, it's very much possible - take a look at modern browsers. Libraries such as Qt and Boost can make porting as easy as in Java.
* High quality optimizing compilers that can produce code that's faster than hand written assembly.
* Native code is much harder to reverse engineer or crack. It's an important consideration for commercial software to prevent stealing code and bogus patent claims. Java and
* C++ is fairly high level and is easy to code with good libraries. It's not as modern as C# for example but it's not ancient either.
However there's also the downside. I recently implemented a text parser for certain configuration file checking. Now granted we have huge configs, but :
Python parsing a 3.2 megabyte config file : 50 sec
C++ parsing that same file, same operations, same grammaer : 0.05 sec
(most of the code was parsing code anyway so there wasn't much to rewrite, also 90+% of dev time was spent getting that grammar to work)
This made the difference between the tool being used, and not used. Runtime matters. I participated in google code jam last year only with python, and the runtime is ... distracting. I don't deny the advantages of python : simply don't check for number overflows, simply don't care. But the disadvantages include a 20x slowdown for basic calculations. When problem runtimes for C++ code start exceeding 5-10 seconds, python is no longer an option. The time difference is actually so big that C++ O(n^2) algorithms would beat O(n log n) python algorithms on the large dataset in some cases.
Next year, I'll be using C++ in google code jam. Python is good for shell scripting and basic website operations.
For most of us, the framework is more important than the language.
.NET. Finally, a complete framework that handled everything, or nearly everything.
Once upon a time, Borland C++ was the best Windows development language out there. OWL made dealing with the complexities of Windows messages and common dialog boxes much easier than standard C++ (not that Microsoft even had a C++ compiler at the time). Microsoft came back with MFC, and then WTL. Both were big improvements over OWL.
But then came
Frankly, I don't really care which language I use most of the time. I just want a good framework to provide the gears and wheels, so I can spend my time doing what I really want to accomplish, instead of being forced to create my own widgets.
Unity, which uses C# and works greatly on all platforms.
Apparently (my experience as well) LLVM does a great optimizing compiling final step.
My book: Friendly F#, fun with game development and XNA; my game: Galaxy Wars by VSTeam; my gamedev language: Casanova.
and sometimes they dont: http://xamarin.com/ .
I hate C++ syntax. Unintuitive rubbish designed by retarded monkeys.
Object Pascal (Delphi) is a far superior dev environment than this obsolete crap that is a nightmare to code in and maintain.
Is the C++ crowd starting to sound a little like the Lispers? Maybe they've been feeling slighted these past 15 years when half their brethren jumped ship to Java and managed code. But at least it wasn't Smalltalk. Don't think they could have handled that insult.
What's your point?
HAND.
The most immature PL out there. No exception handling, everything done with (multiple) return values, a very immature API (without modules of any kind, just one big thing that Java is *trying* to get rid off). They've made sure it *compiles* really fast. Now that's nice for a PL that you really really really don't want to create a large system with. And did they really decide on a name that you cannot really google? Yes, they did :)
I see it as a hobby project of some programmers trying to get into language design, nothing more, nothing less.
I have used C++ with the Qt framework from Nokia ( formely Trolltech ) and it's a JOY to program in.
I find C++ together with Qt almost unbeatable :)
Its confusing enough that most people not up to it will leave once you cover the basics of pointers, yet not so difficult or complicated that it would take too long to learn.
The /vast/ majority of professional C++ programmers do not understanding everything about the language. It is a complex mess. Most people get used to a particular subset, and tear their hair out when they stumble across a gotta.
Well, if the "pointer bruising" bothers you, you could always use one of the myriad of other "native" compiler languages that doesn't rely on error-prone pointers for every damn little thing like C++ does. Ada, Delphi, and Eiffel spring to mind.
Damn the failure of my google-fu :-)
Awesome furniture, accessories and cabinetry in Santa Rosa, CA: http://humanity-home.com/
588 comments... like bjarne said: "There are only two kinds of languages: the ones people complain about and the ones nobody uses"
Which means that you have a choice which would be the best language for that situation, which would be different if your situation was different.
Divide by one, divide by zero. WRT your sig.
Writers imply. Readers infer.
This would be the most badass language ever. Just call it "Non-Diplomatic C"
The authority thinks it's brilliant and evolutionary to mix up EVERYTHING. I think it is FUCKING STUPID IDEA to mix all sorts of DECLARATION among C, C++, AND OBJECT-C and whatever they called... It mess up the beauty of codes / styles and gets people more troubles to encounter more syntax mistakes.