News for hackers. Stuff that matters.
Re:Popular Myths about C++, Part 3 by jayvanguard on Monday December 22, 2014 @09:17PM (#8786496)
In 1995 C++ it wasn't a good choice. In 2000 it was a poor decision in most cases. In 2005 it was a bad decision in almost every case. In 2010 it was completely indefensible. It is almost 2015, why are we even talking about it? C++ was a mistake. A bad detour on the highway of computing.
Re:Popular Myths about C++, Part 3 by pmelendez on Monday December 22, 2014 @09:50PM (#8786573)
>"In 1995 C++ it wasn't a good choice. In 2000 it was a poor decision in most cases. In 2005 it was a bad decision in almost every case. "

Was it? Most console games are written in C++ in that period of time. A very popular desktop office suite is built on C++. The most popular design and photograph edition tool for Windows is written using C++.

So you are suggesting that all those guys who picked C++ for those popular piece of software are a sort of lucky morons?

It is a strong and risky assertion don't you think?

Re:Popular Myths about C++, Part 3 by imanaccount247 on Tuesday December 23, 2014 @12:42AM (#8786937)
In 1995 most games were in C or asm, not C++. Even will into 2000+ as asm faded out, C was still big and the C++ usage was largely as C with classes.
Re:Popular Myths about C++, Part 3 by kragen on Tuesday December 23, 2014 @10:21AM (#8788450)
I wasn't writing games in 1995 but I suspect you are mistaken. Fortunately https://en.wikipedia.org/wiki/1995_in_video_gaming tells us about the major games that year; unfortunately there are 33 of them. Descent and Mortal Kombat 3 are the ones I remember. https://github.com/drguildo/Descent/blob/master/MAIN/AUTOMAP... Descent is written in C++ (note the "//" comments) but it's a very C-styled C++, not even with classes. MK3 I don't have any idea, but it was eventually released for a lot of platforms with different CPUs, so I doubt it was written in assembly.
Re:Popular Myths about C++, Part 3 by imanaccount247 on Tuesday December 23, 2014 @10:41AM (#8788548)
>Descent is written in C++ (note the "//" comments) but it's a very C-styled C++, not even with classes

That is C. Lots of C compilers supported // comments, like watcom which they used. Notice the file extension says it is C. Notice it uses absolutely no C++ features at all.

http://en.wikipedia.org/wiki/RollerCoaster_Tycoon Still using ASM in 1999. Go look at quake 3 which was when id started into C++. Notice how it is barely C++. It seems odd to "suspect I am mistaken" rather than look at the evidence which lines up exactly with what I said.

Re:Popular Myths about C++, Part 3 by kragen on Tuesday December 23, 2014 @12:33PM (#8789073)
Thanks for helping me look at the evidence! Maybe you're right. Do you want to pick another two or three random games from that list and figure out what language they're written in? Or figure out what MK3 was written in? I was trying but then I ran out of time while writing my comment.

I don't think RollerCoaster Tycoon is a good piece of evidence because it's famous largely for being written in assembly at a time when most games had already abandoned it.

(Sadly, I don't think it would be odd at all to ignore the evidence, but I aspire to better than that.)

Re:Popular Myths about C++, Part 3 by Torgo on Tuesday December 23, 2014 @12:45PM (#8789135)
It's unfortunate that you were downvoted when you're right, at least for the console space. You couldn't use many of the advanced features of C++ on the consoles of 1995 (rtti, exceptions, STL was garbage in 1995); C++ compilers were all non-conforming and so cross-platform was horrible; code optimization was bad and space/cpu was at a premium. I don't think either the Saturn or the PS1 devkits even had a C++ compiler in 1995 though it would have been possible, and the other consoles definitely didn't. I think people get used to how well things work and how ubiquitous tech is now and they don't remember how it used to be.
Re:Popular Myths about C++, Part 3 by pmelendez on Tuesday December 23, 2014 @11:40AM (#8788827)
I am not sure about 1995. But at least since 1998 exists Unreal engine and the amount of games using it is humongous. And Unreal's source code is more involved that just C with Classes. (Which by the way is still C++)
Re:Popular Myths about C++, Part 3 by imanaccount247 on Tuesday December 23, 2014 @04:02PM (#8790209)
The original unreal in 1998 was C with classes. And a significant amount of asm. And note that was in 1998, and part of the sales pitch was that it was OO, which was essentially unheard of at the time. C++ compilers were still really bad at the time, and if you wanted to be portable you really couldn't use much besides C with classes. The unreal engine has been rewritten from scratch several times over the years. What we have now is not indicative of what we had 15 years ago.
Re:Popular Myths about C++, Part 3 by sbmassey on Monday December 22, 2014 @10:27PM (#8786647)
Because the alternatives to C++ are even worse.

There are still a lot of problem areas where GC is unacceptable, or you need precise control over memory, or access to things like Cuda, along with the high order programming constructs you get in C++.

Maybe Rust will take over some day ...

Re:Popular Myths about C++, Part 3 by btmorex on Tuesday December 23, 2014 @01:22AM (#8787017)
You're wrong, but I think you just don't have the right kind of experience to understand why.
Re:Popular Myths about C++, Part 3 by adamnemecek on Monday December 22, 2014 @09:30PM (#8786529)
So what's an alternative?
Re:Popular Myths about C++, Part 3 by cheepin on Monday December 22, 2014 @09:35PM (#8786546)
"C++ sucks" has become a bit of a meme around here. The upsides outweigh the downsides for a surprising number of cases. Every alternative is either immature, doesn't solve the use case that needs C++ or doesn't have the required libraries/tools.
Re:Popular Myths about C++, Part 3 by cageface on Monday December 22, 2014 @11:29PM (#8786762)
There are people that sit back and bash C++ and then there are people that just roll up their sleeves and build really cool things with it. I'd certainly rather be in the second camp. I wouldn't mind having a simpler, more elegant language with the same design tradeoffs but that language doesn't yet exist.
Re:Popular Myths about C++, Part 3 by fsloth on Tuesday December 23, 2014 @02:05AM (#8787138)
My experience with legacy C++: Main problem with C++ is that it has lots of accidental complexity and a relatively weak standard feature set. The lava layer pattern is apparently very hard avoid in old applications. Due to the aforementioned weaknesses the lava layering now applies also to the modules that would be standard static modules in other languages. So it's a bit wastefull.

But since lava layering is caused by cultural and architectural issues I cannot claim that the system would be in any better shape just if some other language had been used.

Re:Popular Myths about C++, Part 3 by lomnakkus on Tuesday December 23, 2014 @12:45AM (#8786946)
False dichotomy. Plenty of people who "build really cool things with it" also bash C++, and rightfully so.
Re:Popular Myths about C++, Part 3 by cageface on Tuesday December 23, 2014 @01:58AM (#8787122)
Nobody I know. People I know that use C++ every day will admit it has issues but are also realistic enough to understand that any language with the same design constraints and long history as C++ will be complex.

It's the catbirds in the gallery that don't actually have to write the kind of apps that require a language like C++ that "bash" it.

Re:Popular Myths about C++, Part 3 by jbergens on Tuesday December 23, 2014 @06:47AM (#8787773)
But for projects that don't view those design constraints as very important and projects created when there were other languages that don't have the same history those compromises/explanations won't help. If/when there is a better language you don't have to suffer the history of C++ anymore, just use a newer language without the history. And if the constraints for example were to make it C compatible and very fast, for many projects those may not be of much importance anymore. Other language may be fast enough and easier to write in. I think it is probable that most of todays applications has lower speed requirements than C++ were aiming for. Those who needs speed can probably still use C.
Re:Popular Myths about C++, Part 3 by jevgeni on Tuesday December 23, 2014 @02:52AM (#8787235)
Catbirds like Linus Torvalds, for example?
Re:Popular Myths about C++, Part 3 by rgbrenner on Tuesday December 23, 2014 @03:26AM (#8787294)
Does Torvalds write anything in C++?

The kernel and git are in C

Re:Popular Myths about C++, Part 3 by jevgeni on Tuesday December 23, 2014 @03:56AM (#8787361)
This is my point exactly. I'd consider both git and the Linux kernel tough projects, so the choice of the programming language is interesting. More so, given his stance on C++.
Re:Popular Myths about C++, Part 3 by inDigiNeous on Tuesday December 23, 2014 @04:33AM (#8787455)
How come it's interesting ? Linus has always been a C -programmer, and kernel space is something where you want to keep things simple and access tha raw bits of things, so C is a natural choice.

And if you've been programming C for 20 years or more, writing git with C feels like a natural solution.

It's not always about writing stuff with the most high definition solution, it's more about expressing ideas with the tools you know also.

Re:Popular Myths about C++, Part 3 by jevgeni on Tuesday December 23, 2014 @09:04AM (#8788119)
In the case of git, C++ was actually evaluated (in a manner very natural to Linus) and not discarded due to some habit:

http://harmful.cat-v.org/software/c++/linus

Re:Popular Myths about C++, Part 3 by yongjik on Tuesday December 23, 2014 @01:51PM (#8789528)
> I've come to the conclusion that any programmer that would prefer the project to be in C++ over C is likely a programmer that I really would prefer to piss off, so that he doesn't come and screw up any project I'm involved with.

Quintessential Linus, but I wouldn't call this an "evaluation"... :)

Re:Popular Myths about C++, Part 3 by jevgeni on Tuesday December 30, 2014 @11:06AM (#8815110)
Fair enough.

As a side note: I think we as a community should promote the catchphrase "You've Been Torvalds'd".

Re:Popular Myths about C++, Part 3 by nadams on Monday December 22, 2014 @10:53PM (#8786694)
I want to point out that Tiobe ranks C++ as the #4 most popular language - http://www.tiobe.com/index.php/content/paperinfo/tpci/index....

I'll just say I'm not a fan of C++ and would rather write my own language similar to the source-to-source compiler idea of HaXe ( http://haxe.org/ ).

Re:Popular Myths about C++, Part 3 by _RPM on Tuesday December 23, 2014 @01:31AM (#8787047)
Another meme / idiom seems to be "Why use C/C++ when you can use Rust?"
Re:Popular Myths about C++, Part 3 by Retra on Tuesday December 23, 2014 @02:46AM (#8787220)
Sounds better than labelling anything you've seen twice as a meme/idiom/myth/design pattern, etc.
Re:Popular Myths about C++, Part 3 by adamnemecek on Monday December 22, 2014 @10:26PM (#8786644)
I know. I was hoping he would respond with some misguided suggestion further revealing his ignorance.
Re:Popular Myths about C++, Part 3 by imanaccount247 on Tuesday December 23, 2014 @12:43AM (#8786939)
C?
Re:Popular Myths about C++, Part 3 by pmelendez on Tuesday December 23, 2014 @12:14PM (#8788989)
Do you really think C is any easier to understand that C++?

Let's do something simple, a function that returns a reference to an array of a known size.

Some of C alternatives would be:

    int (*foo())[2] {
    }
or maybe if you have the length somewhere else:

    int** foo ()
    {
    }
or you could try to implement or use an existing implementation of a dynamic array (nothing in the standard as far as I know)

vs.

    std::vector<int>& foo() {
    }
Re:Popular Myths about C++, Part 3 by imanaccount247 on Tuesday December 23, 2014 @03:55PM (#8790161)
>Do you really think C is any easier to understand that C++?

Yes. C is very small and simple. You can learn all of C in a very short time. C++ is the most complex programming language in existence. It is unlikely that there is any person in the world who actually knows it all, including the creators.

>or you could try to implement or use an existing implementation of a dynamic array

Imagine that. You could use libraries that implement things you want. What a concept.

Re:Popular Myths about C++, Part 3 by pmelendez on Tuesday December 23, 2014 @04:38PM (#8790367)
> "Imagine that. You could use libraries that implement things you want. What a concept."

I think I didn't explain myself, but something that basic in these days should be on the standard library in my opinion.

>"Yes. C is very small and simple. You can learn all of C in a very short time."

I don't think C is simple at all. Its syntax can be really cumbersome at times (see my first example). Also it is very annoying to debug, and C code is very prone to contain memory corruption bugs and leaks.

C has great advantages but being simple is not one of them.

Re:Popular Myths about C++, Part 3 by imanaccount247 on Tuesday December 23, 2014 @07:00PM (#8790895)
>I think I didn't explain myself, but something that basic in these days should be on the standard library in my opinion.

Ok well you hop in your delorian and go back to 1970 and let them know. In the mean time, how does that in any way make C not capable for the same tasks as C++?

>I don't think C is simple at all

Then you don't know C. The entire point of C is that it is simple.

>Its syntax can be really cumbersome at times

That has nothing to do with simplicity, and C++ has far more complex syntax.

>Also it is very annoying to debug

C is very simple and straight forward to debug. C++ is much more difficult to debug. Have you ever used either language?

>and C code is very prone to contain memory corruption bugs and leaks.

Because it is so simple.

>C has great advantages but being simple is not one of them.

Well your opinion is in the vast minority, and does not seem to have any basis in reality. The C spec is a tiny fraction of the size of the C++ spec.

Re:Popular Myths about C++, Part 3 by pmelendez on Tuesday December 23, 2014 @07:52PM (#8791022)
>Ok well you hop in your delorian and go back to 1970 and let them know.

Well they could have added in C99 or more recently in C11. What's wrong about updating a language?

> In the mean time, how does that in any way make C not capable for the same tasks as C++?

I would rather prefer not reinventing the wheel and a language that actually ship with it.

> Then you don't know C. The entire point of C is that it is simple.

I know C fairly well to recognize it quirks (just like all languages have). I think your definition of simple is very different of mine. Scheme is simple, InteractiveC is simple, C it is not.

> That has nothing to do with simplicity, and C++ has far more complex syntax.

cumbersome(adj): difficult because of extent or complexity

simple(adj): 1.easily understood or done; presenting no difficulty. antonyms: complex

How come something cumbersome has nothing to do with simplicity?

Also I am not saying that C++ is simple. But it has a subset that it is well defined, type safe and easy to understand.

> C is very simple and straight forward to debug. C++ is much more difficult to debug. Have you ever used either language?

Yes, I have used both in my formal job, and I can avoid memory leaks and memory corruption easily on C++. Not the case on C, specially when working in medium size teams where always people forget what they should cast a void* into and why they should not.

>>and C code is very prone to contain memory corruption bugs and leaks.

>Because it is so simple.

Seriously? It is a feature now? Well Scheme is a good example of language that is order of magnitudes simpler than C and it is not prone to memory leaks nor memory corruptions

>"Well your opinion is in the vast minority, and does not seem to have any basis in reality. The C spec is a tiny fraction of the size of the C++ spec."

If by simple you mean simpler than C++, yeah. You could say the same of Perl. Does is it make Perl a simple language?

Re:Popular Myths about C++, Part 3 by imanaccount247 on Tuesday December 23, 2014 @11:15PM (#8791513)
>What's wrong about updating a language?

Nothing, they do update the language. But fundamentally changing the language to be completely different is not the same as adding some small thing. C is simple on purpose. Adding complexity is not just an update, it is making it no longer suitable for its intended goal. So they choose not to.

>I would rather prefer not reinventing the wheel and a language that actually ship with it.

You don't have to reinvent the wheel, use a library like you already said.

>I think your definition of simple is very different of mine

Clearly. But mine is the same as 90% of the people who have commented on the subject. People overwhelmingly describe C as simple.

>Scheme is simple

Yes it is. As is C.

>How come something cumbersome has nothing to do with simplicity?

You just quoted how. Are you joking?

>Also I am not saying that C++ is simple

But you are arguing that C is complex and thus not appropriate, while C++ is appropriate. You can't have it both ways.

>Yes, I have used both in my formal job, and I can avoid memory leaks and memory corruption easily on C++

Which has what to do with debugging? And why are you incapable of avoiding those problems easily with C when everyone else does it just fine?

>Not the case on C, specially when working in medium size teams where always people forget what they should cast a void* into and why they should not.

Yes, clearly there's no way groups of people could work together on large complex software in C. I'll go tell linux, apache, X, all 4 BSDs, nginx, postgresql, postfix, etc, etc, etc that they don't exist. I'm sure they'll be glad to know.

>Well Scheme is a good example of language that is order of magnitudes simpler than C and it is not prone to memory leaks nor memory corruptions

Scheme is not even one order of magnitude simpler than C. Go read the specs. And scheme is not prone to memory leaks and "corruption" because it is higher level. This also makes it much slower. Even more importantly, it makes it a ridiculous comparison.

>If by simple you mean simpler than C++, yeah.

You are the one advocating C++ over C while claiming C is too complex. What are you blaming me for?

Re:Popular Myths about C++, Part 3 by Symmetry on Tuesday December 23, 2014 @09:32AM (#8788211)
C++ is currently really the only choice if you're making an application that is both large and performance critical. If you're building a AAA video game or a web browser or a robot's navigation system then it probably is the best choice even if it's a painful one.
Re:Popular Myths about C++, Part 3 by geofft on Tuesday December 23, 2014 @02:04AM (#8787136)
C++11 is a very different language, in much the same way Java 8 isn't Java 1, or Visual Basic .NET isn't BASICA.

(It's entirely possible that all six of these languages are terrible, but that would be six separate claims.)

Re:Popular Myths about C++, Part 3 by GFK_of_xmaspast on Monday December 22, 2014 @09:32PM (#8786538)
Because C++11.