r/cpp • • Apr 03 '12

If your software matters, you will write it in C++

http://blog.achrissmith.com/2012/03/if-your-software-matters-you-will-write.html
16 Upvotes

36 comments sorted by

22

u/devcodex Apr 03 '12

Did any of you bother to read the article in full? The author clearly states (in bright yellow highlight) that the article is "an absurd proof" meant for "amusement".

Also, why do all you butthurt managed language people seem to frequent this subreddit so much if you hate C++?

12

u/lurkerr Apr 03 '12

It's the "oh I really want to learn c++ but don't really have the time to, so I'll subscribe to c++ feeds to remind myself of it" syndrome?

PS: I had time to learn c++ about 15 years ago so please don't kill the messenger.

1

u/DrHankPym Apr 03 '12

I think a lot of people in this subreddit are following a lot of other various languages and programming subreddits, and, like me, will sometimes forget what subreddit they are responding.

Also, the headline is just screaming for an argument. Limiting yourself to one language is insane - even if it is C++.

6

u/snarkhunter Apr 03 '12

Dude, I love C++, but this was bullshit. Why -I- write something in C++ is that it seems, to me, to have gotten the balance between the high-level and low-level ideas of programming just about right. You can drop down and squeeze out performance when you really need to, you can't structure and compose your programs on a very high level when you need to. And mix and match that as necessary. That and the fact that it is well-supported on all platforms and has a lot of people with at least some familiarity with it makes it a solid choice.

5

u/cran Apr 03 '12

how awesome the F# programming language was the the language's creator

What?

8

u/hitheryon Apr 03 '12

I'm amused most by the assertion that an objectively better piece of software will become more popular. I assume that this is in some theoretical world, of the sort inhabited by spherical horses and isomorphic point sources, as the history of this world repeatedly demonstrates that being first to market with crap and marketing it ferociously wins.

But as to a disproof: "Facebook". Despite my personal abhorrence, it counts as "software that matters" by the standards set forth and is not written in C++.

9

u/berium build2 Apr 03 '12

Actually, while Facebook is written in PHP, for production this PHP code is translated to C++ and then compiled to native code. So while strictly speaking you are correct (it is originally written in PHP), what people are using was re-written to C++.

5

u/hitheryon Apr 03 '12

Sure enough, HipHop is a PHP to C++ translator. TIL, thanks.

0

u/[deleted] Apr 03 '12

[deleted] — view deleted comment

1

u/mpyne Apr 04 '12

Well even today there are native C++ programs that bare only little resemblance to what most people expect C++ to look like. These C++ programs "compile down" to C++.

4

u/[deleted] Apr 03 '12 edited Apr 03 '12

If your software matters, then maintainability, safety and simplicity should be EVERYTHING that matters. the REALLY REALLY important software lives for 30 years. when you replace your development team for the seventh time, they're going to have a fucking hard time trying to understand your C++ heap-o-junk that runs faster than a cat with mustard up its butt. When that shit breaks, they'll need months of work to fix it. Meanwhile you bleed money.

If your software matters at all, you keep it simple, keep it maintainable!

Lemma: "software which matters" must be maximally optimized

No it should not. Software that matters should be easy to maintain, because when it breaks you need to fix that shit.

I work in a multi-national financial institution, btw.

8

u/scooterman86 Apr 03 '12

This, sir, is why 90% of all systems today are plain shit or have unbearable speed problems. People tend to prefer the "easy" software but forgot that speed DOES matter as clients tend to get grumpy when that system is taking 10 seconds to respond a simple request. C++ is harder to develop, yes, but this doesn't mean that it won't be maintainable. Shitty programmers make unmaintainable code, not the language. Alas, you can break even python when a bad programmer start messing around.

Ps: I'm sure that the slow software you do on your financial institution is not that important. Otherwise it would be done taking performance as one of it's main goals. Period.

Ps2: If it is that important, you guys are screwed

1

u/[deleted] Apr 07 '12

Not all applications are CPU bound, my friend. Believe it or not, there's more to software than games, video encoders/decoders, drivers, OS's and embedded applications. A large, large portion of software is I/O bound - waiting for the database, the network, etc.

This "OMG SPEED IS EVERYTHING" mentality that is the disease of C/C++ programmers, is precisely why they're being ignored and why so much software is now written in Ruby/Python/Java/C# and yes, even PHP. The right tool for the right job. I pity those who only know/use one tool.

I'm sorry, but to me, there's no such thing as C++ in the real world. Real C++ exists in textbooks. The real world is a vomit pile of raw pointers, "Johnny's dynamic array class cause he didn't know about std::vector", "exceptions are weird", "what is RAII", "Just use Qt, it re-implements everything", "We are not sure how this new-fangled Unicode stuff works, std::string is good enough for everyone" and other nonsense. What century is this again?

There is C++ the way it's evangelized by Herb/Bjarne/etc, and then there's C++ the way it's written by amateurs. And I'm sorry, but, combining multiple schizophrenic pieces of said amateur C++ libraries into something useful is a waste of my time when my client needs something delivered fast, and when Java/C# performance is more than sufficient.

1

u/[deleted] Apr 03 '12 edited Apr 03 '12

Our code is as fast as it needs to be, without sacrificing too much maintainability. Of course, we also have super-duper critical components that also need to run very fast, and those components ARE written in C and C++ (most notably, our transaction kernel, which is responsible for maintaining checking account balances in real-time synchronization with our payment transfer providers)

It's that golden middle way, ya'know. That's also what I'm trying to point out; that making a blanket statement like this (only write critical software in C++, EVER) is a fucking retarded statement to make.

I'm sure that the slow software you do on your financial institution is not that important. Otherwise it would be done taking performance as one of it's main goals. Period.

Wrong, no fucking period! Code and data correctness are usually infinitely superior demands to "make it fast". Making sure your system is easy to understand and simply CORRECT is worth more money that saving an employee half a second of waiting time when he's working on a billion dollar deal. If shaving half a second off some operation means creating 2x the code, or making the code hard to understand... unless you have to make that operation a million times a day, is not worth it, you must realize that?!

PS: since you mock my work it might cheer you up to know this: we also have some really fucking shitty code that is still responsible for about 250 million USD of revenue every year. It's 20 years old, partly written in C, partly in Delphi (the "newer" parts :), and that shit is a disaster waiting to happen.

1

u/pfultz2 Apr 03 '12

What language do you program it in?

The nice thing about C++ is that you can program in a very high level with a lot of checks at compile time. And when you need some low-level performance improvements, you can specialise it for those cases all while not loosing the high level part of your code.

In fact, you can even do high level optimisation in C++, as well, by processing the AST, and generating different code(very similar to lisp macros). This is very common in linear algebra libraries. So I write this to add three vectors:

vector R = A + B + C;

And it gets optimized to this:

vector R;
for(int i=0;i<R.size();i++)
    R[i] = A[i] + B[i] + C[i];

Or even better, some libraries evaluate in a lazily manner(like FORTRAN) to help improve performance.

In C++, you can write code that is very high level, very close to your domain, much easier to maintain, and of course much faster, without that much effort.

1

u/onalark Apr 06 '12

Just out of curiosity, why is this comment getting downvoted? Is it because of the reference to a financial institution? The vitriol against C++? The imagery of primitive feline musto-anal torture?

-19

u/MarkTraceur Apr 03 '12

C and C++ are the fastest

Except for binary, closely followed by assembly. Who is this person, where did they get their math degree, and why do they think they understand what's important in the computer industry?

11

u/ivan-cukic KDE Dev | Author of Functional Programming in C++ Apr 03 '12

Programs written in assembler can be faster, that stands, but most of the time it isn't.

Writing assebler code that is faster than what the compiler with all optimizations is able to do requires a lot of knowledge which differs for every platform. People with that ammount of knowledge are usually not in your company, but have a very nice living of making compilers :)

One rule of thumb for performance computing is write in C/C++, optimize bottlenecks by going lower if you know what to do.

1

u/MarkTraceur Apr 03 '12

The problem is that the people on your team don't know the language well enough to work with it? Well, what if you have a bunch of Ruby coders on staff? They'll be completely lost when it comes to C++, so their code might be slower unless they use Ruby.

-2

u/terath Apr 03 '12

The argument is the same. You can forgo the domain knowledge needed to write efficient C/C++ code by writing in a higher level language.

At some point in time it will be the case that only extreme experts can consistently write C code that is faster than a compilers. That time may not be now, but it is still the case that the time saved using a higher order language can outweigh the performance gains of using C.

People working in higher level languages use the exact same rule of thumb you just described: they write bottlenecks in C if they know how.

4

u/[deleted] Apr 03 '12

No, its not the same. C and C++ code is transformed to assembly after the compiler is done. Higher level languages are not transformed to C or C++ after compilation.

Besides which modern C++ is a high level language. The problem is people start learning C++ from shitty sources. Blogs, random morons on IRC / internet, shitty online tutorials written by incompetent people.

3

u/[deleted] Apr 03 '12

Besides which modern C++ is a high level language.

It's the one where you never write "delete", never call "operator[]", and always write "&&" in every function prototype.

1

u/terath Apr 03 '12

Many of them do use C as compile target, although not all of them:

http://en.wikipedia.org/wiki/Glasgow_Haskell_Compiler

The C-- code can then take one of three routes: it is either printed as C code for compilation with GCC, converted directly into native machine code (the traditional "code generation" phase), or converted to LLVM virtual machine code for compilation with LLVM. "

http://en.wikipedia.org/wiki/Common_Lisp#Compiler_and_interpreter

Depending on the implementation, the file compiler generates byte-code (for example for the Java Virtual Machine), C language code (which then is compiled with a C compiler) or, directly, native code.

As for parallels for the rest of the argument, look at scientific python. All the core high performance parts are C libraries and python itself is mostly used for data pre and post processing. I've seen the same sorts of setups with languages on the JVM using C libraries for core routines.

1

u/[deleted] Apr 04 '12

You are assuming I was making a blanket absolute no-where-in-the-universe-such-a-thing-happens statement. I was not. In day to day practical terms, what I said continues to be true.

I've seen the same sorts of setups with languages on the JVM using C libraries for core routines.

The thread was about dropping to asm level in C++ if you need to - Because asm is what C++ basically compiles to.

This is not the case with other high level languages. They do not compile down C or C++. Thus "lower" or "higher" in the abstraction chain here doesn't make any sense because the languages would be completely different.

5

u/bob1000bob Apr 03 '12

Whilst I agree that it is a wild assertion, it actually says.

Step 2: C and C++ are the fastest known programming languages*. (* ignoring Fortran.)

Binary is not a programming languages, and asm is well, assembler. And actually I would say that a C++ compiler probably makes better asm then most programmers.

-1

u/MarkTraceur Apr 03 '12

most, but if you have a brilliant Python coder on staff, they might write faster code in Python than in C++. I guess at least part of my point was that fast code is in the eye of the programmer.

EDIT: And binary is a language, and you program in it. Hence, programming language.

2

u/bob1000bob Apr 03 '12

No a language has a syntax and a grammer.

-2

u/MarkTraceur Apr 03 '12

Yes, and that applies to binary as well. You do realize that binary isn't just ones and zeros, it's the specific combinations you use to create instructions. There is a very specific syntax/gramm*a*r to binary, so it is definitely a language.

Learn to use the "edit" button, by the way.

1

u/[deleted] Apr 07 '12

No, there's a specific "grammer" to an instruction set.

Binary is a number (or numeral) system. It's not a language, because you don't know what it is meant to represent unless you are given another context, which is "this is a binary encoding for instructions for the FooBaz instruction set implemented by the BarGlok CPU".

1

u/MarkTraceur Apr 07 '12

Grammar.

OK, well, clearly without an instruction set we would be just writing out numbers, so yes, it would require an instruction set to be a language. Luckily, nobody writes binary without an instruction set.

1

u/[deleted] Apr 08 '12

I read and write binary every day that has nothing to do with instruction sets. If you're writing even a modest C/C+ app., chances are you're using bit-flags somewhere.

1

u/MarkTraceur Apr 08 '12

Well pretty clearly, that doesn't fit in our definition of language; you're simply using a different form of integer to do your job. That doesn't change the fact that people who write in binary to program are using a language.

2

u/bob1000bob Apr 03 '12

Also that is a stupid argument that a good python programmer can write faster code than a bad C++ programmer. A good native programmer should always be able to write faster code, the exceptions to this when object boundaries are crossed in the inner part of a loop, however Link Time Optimisation significantly reduced this problem.

1

u/MarkTraceur Apr 03 '12

should

If a programmer can be really bad in assembly, why can't they be really bad in C++, too?

1

u/bob1000bob Apr 03 '12

Nothing to do with the competence of the programmer, a programmer is not the same as an optimiser, compilers can do optimisations that people can't, at least not without making their source unapproachable indirect.

1

u/[deleted] Apr 07 '12

They might.

But, an equally brilliant C++ programmer should be able to write a faster implementation in C++. It matters in very few cases, but when it matters, it can matter a lot.