News for hackers. Stuff that matters.
Re:C++ in Coders at Work by Maro on Tuesday February 15, 2011 @07:46AM (#2220993)
All this C++ hatred is weird.

If you need to do systems level programming (eg. write a database), and you want to go beyond C's code organization capabilities, and you can select a sensible subset of C++, it's a great language, and you get to control all aspects of memory and CPU.

We're writing our database(s) in C++, and we're pretty much loving every minute of it, and would not switch to C, Java, Erlang or whatever.

Of course we're a startup, so we got to select our own subset, write our own containers, etc:

http://github.com/scalien/scaliendb

One downside is it's hard to find good C/C++ programmers on the market. The vast majority of applicants cannot complete our first interview filter (removing a characters from a C string and writing an instrusive stack in C++):

http://scalien.com/pdf/job.pdf

Re:C++ in Coders at Work by suraj on Tuesday February 15, 2011 @08:46AM (#2221127)
Looking at your code a bit, it seems you are not using templates, operator overloading, exceptions, STL or std::string. Your test framework also looks custom built (aside: IMO UnitTest++ would have fit you style). I think if you just changed class data to structure and member functions to accept structure pointer, you would get a nice C representation (almost every class I looked at had an Init method). In effect you are using C++ to avoid very small boilerplate code in equivalent C program.

No wonder you find C++ pleasurable, you are using it as C with classes! However, if you are working on an existing code base with mix of STL, boost and bunch of other libraries, you would start feeling pain of using C++. In my experience, every library author uses a different subset of C++ and as an application writer, you often have to grapple with the glaringly different idoms in your program. I find boost pleasurable to use; however looking at boost source is enough to melt my mind.

Almost everywhere C++ (language and libraries) try to satisfy every corner case and sacrifice usability of common case. e. g. STL iterators (at least I have BOOST_FOREACH to soften them). Ah well this is probably contributing very little to the discussion but I feel better now :) So let me redirect to [C++ FQA](http://yosefk.com/c++fqa/) and let yourself decide whether the points in FQA make sense to you.

Re:C++ in Coders at Work by dkersten on Tuesday February 15, 2011 @10:28AM (#2221519)
No wonder you find C++ pleasurable, you are using it as C with classes!

I also find C++ pleasurable (90% of the time) and in my code, I make heavy use of templates (including compile-time calculation/preparation of data, ie not only simple "templates as generics"), exceptions (well, not heavy use, I use them for handling exceptional circumstances, nothing more), STL (especially the containers), std::string (C strings and custom string classes are evil), Boost (not so much, but it has some great libraries), Qt (GUI mainly, but also the support libraries) and Intel Threading Building Blocks. I do not use multiple inheritance, but I certainly use classes and single inheritance, pointers, smart pointers and memory pools.

But I still like C++.

I agree that it has its problems and it certainly isn't a good language for beginners [1], but it is a very flexible and powerful language that is useful for a range of tasks from low-level to high-level code (though I guess it excells at mid-level: higher level that C, but low level enough for performance sensitive code, eg games). I certainly wouldn't recommend it for a lot of tasks, but I wouldn't avoid it either.

I'm not a big fan of the FQA, but the FAQ Lite is very good: http://www.parashift.com/c++-faq-lite/index.html also, Bjarne Stroustrups FAQ is excellent: http://www2.research.att.com/~bs/bs_faq2.html

[1] Even experts got this quiz wrong: https://scapecode.com/2009/10/a-simple-c-quiz/

Re:C++ in Coders at Work by dkarl on Tuesday February 15, 2011 @11:29AM (#2221824)
We use templates, exceptions, STL, and Boost and deploy to tens of thousands of devices in the field. We have the advantage of a uniform hardware and OS platform, so we don't have to worry about compiler issues.

We could reasonably replace C++ with a combination of C and a higher-level language. However, C++ is a much better language for our low-level code than C, and we have a lot of low-level code, so we have to take it seriously. If we took the route of using a high-level language to coordinate functionality implemented in C, we would end up using C++ to implement the "C" libraries, just for the benefits of RAII, exceptions, smart pointers, etc.

We could also succeed with a stable and efficient Common Lisp implementation. Other languages such as OCaml might work for us, but I'm not qualified to say.

We wouldn't bother changing at this point, though, unless we decided to create an entirely new product to compete with our current one. C++ is not a problem or a limitation for us. The shortcomings of C++ add a little bit of extra work, but they aren't a multiplier. Most other languages would aggravate our existing problems instead of just adding a constant factor of inconvenience.

And that's with templates, exceptions, STL, and Boost!

Re:C++ in Coders at Work by suraj on Tuesday February 15, 2011 @12:16PM (#2222111)
Our project uses ICE (http://www.zeroc.com) for some scalable computing and a large part of the system is indeed written in C++ (with bunch of other libraries). However, developing large scale application in C++ requires discipline even at smaller level (Should I use auto_ptr or shared_ptr? Should I pass by reference or by pointer? Macro or template? GCC does what?).

I have found C++ to be too complex to fit within my head. Even though I am programming almost exclusively in it for a while; I get a feeling that I am spending more time on placating the compiler than thinking about code.

For cross platform work that uses a lot of libraries I would not recommend C++. It is where my frustration stems from.

Re:C++ in Coders at Work by dkarl on Tuesday February 15, 2011 @12:32PM (#2222204)
I guess "discipline" is something we're lucky to have a lot of. 99% of usage questions are answered by looking at existing code -- just stay consistent unless there's a really good reason to depart. There are a bunch of things that would get you lynched in our group, but we rarely have to lynch anybody. There's a lot of mutual respect and a lot of respect for the existing coding style, especially among programmers who have done C++ programming elsewhere and suffered through unsafe and unscalable practices.

I think most good C++ programmers spend years coming up to speed. I know I spent many hours coding for fun in college and read through TC++PL a couple of times (also for fun) before I started programming in C++ professionally. It was a wise investment, no doubt about it. It's an open question whether it would be a wise investment today, though.

Re:C++ in Coders at Work by Maro on Tuesday February 15, 2011 @09:11AM (#2221216)
We do use templates in our containers:

https://github.com/scalien/scaliendb/tree/master/src/System/...

Yes, we try to avoid op.overloading, exceptions, and we explicitly don't use the STL, Boost, <any library>. All the code is ours, which is really nice if you're debugging, finding performance problems, etc. It was our experience on previous projects that pulling in outside libraries in a systems level project like a database ends up wasting time (spent in understanding, debugging and optimizing outside code) over just writing what you need. This has proven to be a good call, we fix all bugs, however deep or nasty very quickly.

Thanks for the UnitTest++ tip.

Re:C++ in Coders at Work by yannickt on Tuesday February 15, 2011 @10:43AM (#2221563)
The STL is not a third party library anymore and most of it has been part of the standard for several years now. I would be curious to know what problems did you have with the STL, and how long ago? In my experience most people who refused to use the STL did it for the wrong reasons. Even the EASTL (which makes a good case against the standard library implementations) implements the STL interface.
Re:C++ in Coders at Work by dkersten on Thursday February 17, 2011 @09:16AM (#2230955)
The STL is not a third party library anymore - its part of the langauge just as much as the C++ runtime is.
Re:C++ in Coders at Work by JoeAltmaier on Tuesday February 15, 2011 @09:15AM (#2221227)
Folks might accuse you of NIH, but the quality of outside libraries is variable, suitable for a prototype but for shipping code you need control of ALL of it.
Re:C++ in Coders at Work by dkersten on Tuesday February 15, 2011 @10:10AM (#2221440)
C++ Standard Library and Boost are of very high quality. It's quite tough to beat them.
Re:C++ in Coders at Work by dkarl on Tuesday February 15, 2011 @11:35AM (#2221869)
Plus they're open-source, so they're theoretically "yours" in the sense that you can compile and deploy your own. If you find a bug in Boost, you can fix it. We frequently deploy open-source libraries we've patched ourselves -- never Boost that I know of, but at least we know it wouldn't be a problem.
Re:C++ in Coders at Work by dkersten on Tuesday February 15, 2011 @12:17PM (#2222122)
Similarly, you can extend them (or at least make your own code compatible).
Re:C++ in Coders at Work by yannickt on Tuesday February 15, 2011 @10:57AM (#2221629)
Things like move semantics and r-value references in C++1x will make them much tougher to beat. And for the most part they're not particularly hard to understand either. The standard library in particular, despite being a generalized library, is highly customizable and can be optimized for special cases (e.g. with custom character traits or allocators). Because it's a standard, good C++ developers should be able to use it. But if everyone reinvents the wheel developers would have to learn a new container or string interface every time they change jobs.
Re:C++ in Coders at Work by JoeAltmaier on Tuesday February 15, 2011 @10:26AM (#2221510)
On major platforms. But on embedded etc its hard to use any library - there are unintended dependencies.

{ embedded programmer }

Re:C++ in Coders at Work by dkersten on Tuesday February 15, 2011 @12:18PM (#2222126)
Sure. You definitely have a point, but in context of the discussion here (ie Maro's code), I see no evidence that he is programming for an embedded system.
Re:C++ in Coders at Work by agazso on Tuesday February 15, 2011 @09:33AM (#2221294)
Also don't forget licensing issues. It becomes important when you make a living of selling software.
Re:C++ in Coders at Work by sausagefeet on Tuesday February 15, 2011 @11:30AM (#2221829)
Avoiding all other libraries seems an odd choice to me. Are you including std::string in "STL"? Almost all of the "STL" containers are part of the C++ standard now so not using them doesn't make a lot of sense.
Re:C++ in Coders at Work by zohebv on Tuesday February 15, 2011 @10:34PM (#2224831)
I have very little respect for the fqa. It is just a laundry list of complaints; absurd whining about every item in the C++ FAQ. For eg : http://yosefk.com/c++fqa/assign.html

If you are going to complain about a self assignment check in the assignment operator function, maybe you should stay away from any kind of programming at all.

And I don't understand this complaining about which subset of C++ needs to be used. I have written scala code and it most definitely does not use every feature of scala.

The scenarios in which any of the C++ features need to be used is fairly obvious.

1. STL - use it all the time, it is one of the core libraries of modern C++ 2. templates/overloading - You will use these features when you use STL. You typically won't create you own template classes. 3. exceptions - This is one of the C++ features used less often. Dealing with it is no different from dealing with exceptions in other languages like Java.

> I find boost pleasurable to use; however looking at boost source is enough to melt my mind.

The idea is that you use boost source and not look at it. boost libraries are a very specialized kind of template meta-programming code that only container writers have to deal with. I like being able to use a smart_ptr without having to worry about silly memory leaks, none of which would have been possible without templates or operator overloading in plain vanilla C.

There are several deficiencies with C++, that I experience on a day to day basis, none of which are discussed in any of these online C++ rants. I have never faced any software engineering issues because of the multitude of C++ features. That has never been the problem. If anything all these features reduce the amount of boiler plate that I need to write to get my job done.

You may not like STL iterators, but they are a 1000 times better than some of the gnarly C macros I have seen in C code to get STL like containers in C. Once you have seen that kind of C code, you will be glad about the existence of templates.

Re:C++ in Coders at Work by pmjordan on Tuesday February 15, 2011 @08:00AM (#2221030)
I think C++'s popularity comes from the fact that it is essentially a better C. Which parts of it are better than C happen to be a matter of taste and for what you need it. I don't think anyone loves all of C++. But I think there isn't a viable competitor in the "C, but better" space at the moment. Go is probably too high level to be a complete replacement. D is... a weird case. I don't think it stands much of a chance in the market because it's not sufficiently better than C++. Overcoming C++'s momentum is extremely difficult at this point.

EDIT: downvoters: if you think I'm trolling, please note that I've written more code in C++ than any other language. I would love a "better C" that's universally better than C++. If you disagree with my points, please elaborate.

Re:C++ in Coders at Work by T-hawk on Tuesday February 15, 2011 @12:11PM (#2222092)
> But I think there isn't a viable competitor in the "C, but better" space at the moment.

In the Microsoft ecosystem, C# is this. No, C# isn't OS-independent or hardware-independent or HTTP-server independent. It's not meant to be. C# isn't meant to be an abstractly beautiful language like Lisp or highly performant and portable like raw C. And it's not intended to be part of the LAMP free-software stack; it's intended for a business context that can spend a bit of money to make money. (The C# compiler is actually free, though the IDE isn't and of course the underlying Microsoft OS isn't.)

It's C and most of C++ without the foot-shootiness or Java verbosity. For what it is meant to be and for the problem domains that it serves, C# really does make for great productivity. My company and I have used it as our primary language for several years and I like it a lot. Most of the productivity comes from tight integration to external ecosystem elements that make for a useful application, notably MS SQL databases and ASP.NET web servers, all wrapped within a solid IDE. More productivity comes from getting to ignore things like memory allocation and header files which the language just handles for you. Perfect for simply getting things done in a business context when things like price and portability are not a concern. (When they ARE a concern, then by all means use the LAMP stack and C# is not for you.)

Re:C++ in Coders at Work by pmjordan on Tuesday February 15, 2011 @02:33PM (#2222817)
I think most of what can realistically move to high level languages already has (minus legacy code). Java and VB was the first mainstream wave, C# the second. They're sometimes still lumped in with "systems" programming, but I don't think that's a useful description. As such, when I talk about C++, you can assume I'm excluding situations where a managed, VM'd language would work fine.

Calling C# or Java a "better C" is therefore not terribly useful. C is not good at the things C# is good at and vice versa. I use about 6 or 7 different languages on a regular basis, and often the only choice is between C and C++.

I'm not sure where you're going with the second paragraph. C and C++ were never popular for general web app development.

Re:C++ in Coders at Work by sedachv on Tuesday February 15, 2011 @03:36PM (#2223167)
"Perfect for simply getting things done in a business context when things like price and portability are not a concern. (When they ARE a concern, then by all means use the LAMP stack and C# is not for you.)"

You've been brainwashed by Microsoft. No one using LAMP cares about price (that much) or portability ('L' is for Linux). Freedom from vendor lock-in (and in this case, a predatory, vengeful vendor) is the biggest practical advantage. Stability and the thing actually fucking working is another (I never enjoyed babysitting Windows servers; do you?). It's also easier to build robust applications with LAMP.

Enjoy paying your Microsoft tithe, peasant.

Re:C++ in Coders at Work by gaius on Tuesday February 15, 2011 @08:15AM (#2221058)
Curious; what makes ObjC not a viable competitor IYHO?

D is doomed by the Phobos/Tango schism, no-one would risk their business on it.

Re:C++ in Coders at Work by pmjordan on Tuesday February 15, 2011 @08:22AM (#2221062)
Curious; what makes ObjC not a viable competitor?

The Objective-C additions just aren't very low-level. They're basically an object runtime library with some syntactic sugar. This is fine for situations where you want something a bit more high level and dynamic[1], but gives you no advantage over C in something like device drivers or programming embedded devices, because you just aren't going to use those features. Minimalistic (optional!) vtable dynamic dispatch is great for these uses, though, and generic programming can be really nice (despite C++'s version in the shape of templates) even for low-level applications. RAII also is really nice.

D is doomed by the Phobos/Tango schism, no-one would risk their business on it.

If D was that much better, I think a sufficient open-source ecosystem would spring up around at least one of the two libraries that you could realistically use it. As it is, I doubt it would be popular even without the schism.

[1] Though in my opinion, most iOS apps would be easier to write in a managed language, especially if you could call out to C/C++. The Obj-C focus is understandable from Apple's point of view though.

Re:C++ in Coders at Work by jimbokun on Tuesday February 15, 2011 @09:05AM (#2221186)
"Though in my opinion, most iOS apps would be easier to write in a managed language"

Maybe, but just as you can not easily dismiss C++ because so many people have written so many successful programs in it, it is difficult to dismiss all of the great software from Apple, and arguably the largest library of software for mobile devices in the App Store, written in Objective C.

You point out the resource constraints that make C++ superior to Objective C and other languages for drivers and embedded systems. Similarly, I suspect Objective C gives Apple the right trade offs for writing sophisticated software for mobile devices that is responsive, uses memory effectively, and does not kill battery life.

Re:C++ in Coders at Work by pmjordan on Tuesday February 15, 2011 @10:38AM (#2221543)
FWIW, I agree that it's not a black & white issue, and I don't have an immediate suggestion for a replacement language that would be better than Objective-C in every aspect.
Re:C++ in Coders at Work by steveklabnik on Tuesday February 15, 2011 @09:25AM (#2221262)
I thought that one of them was going away with D2?
Re:C++ in Coders at Work by leon_ on Tuesday February 15, 2011 @08:23AM (#2221064)
> But I think there isn't a viable competitor in the "C, but better" space at the moment.

C99 is such a contender imho.

Re:C++ in Coders at Work by pmjordan on Tuesday February 15, 2011 @08:30AM (#2221073)
C99 is such a contender imho.

C99 is a pretty tiny (but welcome) incremental improvement on C. It's also almost entirely orthogonal to C++'s additions. Calling C99 a C++ replacement is pushing it, so you'll need to elaborate on why you think so. I'd be curious about an instance of something you can do better (let alone fundamentally better) in C99 than C++. I can think of plenty of examples of the opposite.

C++ sometimes makes me want to tear my hair out, sure[1], but when using pure C(99), I find myself thinking, "this code would be so much more compact in C++."

[1] This is usually because either I or someone else tried to be too clever. Otherwise it's because of something C++ does badly that neither C89 nor C99 do at all.

Re:C++ in Coders at Work by leon_ on Tuesday February 15, 2011 @09:11AM (#2221213)
> Calling C99 a C++ replacement is pushing it

I didn't call it a C++ replacement. Just a C89 replacement. "A better C" :)

> I'd be curious about an instance of something you can do better (let alone fundamentally better) in C99 than C++.

It depends. If you need C++'s syntactic sugar for OOP-style code then yes - C++ is better for that. But if you don't do OO-heavy stuff you can use plain C and get away with less complexity (and more control over the instruction cache, etc).

I'm in the lucky position of not needing OO so I get away with using C. And C99 makes my life, compared to the old C89 standard (and the C++ C subset), easier. I can declare variables in the middle of a function (or even within the if statement!). I can initialize structs by its member's names thanks to designated initializers. And the implicit "upcast" from void* to whatever is a blessing (though possible in C89 it isn't available in C++). Oh, and I almost forgot variable length arrays.

> but when using pure C(99), I find myself thinking, "this code would be so much more compact in C++."

Well, this can go the other way round, too. Just take the right tool for the job.

Re:C++ in Coders at Work by pmjordan on Tuesday February 15, 2011 @09:23AM (#2221254)
Okay, all of these points are fair enough. I guess I didn't make it clear enough, but:

There's no language currently out there that covers as much ground as C++ and is anywhere near as good at it. C99 falls into a similar bucket as Go or Objective-C in covering a subset of cases where C++ is useful.

Re:C++ in Coders at Work by SoftwareMaven on Tuesday February 15, 2011 @11:19AM (#2221765)
The point of the detractors, though, is that if only a subset of the language is good for any particular task, why not skip the subset operation and just choose a language better for the task?

I echo that sentiment. I'm using C++ in my current project (first time in many, many moons), and it dies what we want reasonably well, but it is bigger than any language needs to be.

Re:C++ in Coders at Work by lukeschlather on Tuesday February 15, 2011 @12:49PM (#2222289)
Because there's less cognitive overhead in learning 5 variations on one language to do 5 tasks than there is in learning 5 languages to do 5 tasks. You don't have to relearn what semicolons, parentheses, braces, colons and so on mean. You just have to learn how inheritance works. Or the STL. Or whatever.
Re:C++ in Coders at Work by eru on Thursday February 17, 2011 @05:58AM (#2230529)
> There's no language currently out there that covers as much ground as C++ and is anywhere near as good at it.

Have you tried OCaml? It's has it's problems, but it's nowhere near as bad as C++.

Re:C++ in Coders at Work by copper on Tuesday February 15, 2011 @09:30AM (#2221282)
Perhaps as a counterexample, when I'm write some linear algebra code that I expect to perform reasonably well, I greatly prefer using eigen to other BLAS implementations (well, except the MKL, but that's a different matter entirely.)
Re:C++ in Coders at Work by dkersten on Tuesday February 15, 2011 @10:05AM (#2221420)
I'm curious as to why you wrote your own containers instead of using the C++ Standard Library, Boost, EASTL or any of the other existing container libraries. Care to elaborate? Eg, if performance or fine-grained control over memory is an issue, take a look at EASTL, which EA use in their games (and is designed to be suitable for both PC's and consoles). They are also extremely stable and well tested.

I've never tried to find C++ programmers on the market, but I do seem to come accross fewer and fewer C++ programmers now. I use a lot of C++ myself (amongst other languages, including Clojure, Java, Python and recently SML). I think having learnt it long before becoming a professional programmer may have given me a kind of attachment to it, but I actually enjoy using it (most of the time, I do often wish it did things differently or supported features I see in languages like ML or Lisp derivitives).

As for your interview question, the first seems almost trivial. The second, an intrusive stack, isn't very hard either [1]. I'm surprised that most applicants have trouble with them!

[1] Heres one I slapped together in ~5 minutes (no comments, only tested by running that code, etc etc): https://gist.github.com/827619

Re:C++ in Coders at Work by plinkplonk on Tuesday February 15, 2011 @11:38AM (#2221885)
"I'm curious as to why you wrote your own containers instead of using the C++ Standard Library, Boost, EASTL or any of the other existing container libraries. Care to elaborate? "

A game developer disusses why he often writes his own data structures and steps out of STL and gives concrete examples at http://altdevblogaday.org/2011/02/15/data-structures-one-siz...

(fwiw I don't have a dog in this discussion. I don't use C++ and never will. The above is offered only because I had that page open in another tab when I read your question, and it seemed relevant)

Re:C++ in Coders at Work by dkersten on Tuesday February 15, 2011 @12:16PM (#2222113)
Thanks for the link, very informative.

Personally, I will write my own data structures, containers or memory allocators when I have a task that doesn't fit nicely into existing libraries. There is nothing wrong with that. I am curious though when people only use their own. For example, I believe that when writing custom containers, providing STL compatible interfaces (perhaps alongside a non-compatible extension if needed) is a good idea because then you can use the STL when it makes sense, but your own when it doesn't (and pass data between them easily).

Having said that, I did not spend long looking at the code in question (nd in the sibling comment a good reason was presented for at least some of the custom containers), so perhaps it isn't realistic or reasonable to mix and match in this case. Still, I like to understand peoples reasoning because it helps me improve my own coding practices.

Re:C++ in Coders at Work by agazso on Tuesday February 15, 2011 @11:17AM (#2221748)
(Another author here)

The basic issue is that we didn't want to include external libraries, because it's a pain to debug, pain to build on multiple platforms and there are licensing issues.

Also we don't use so many datastructures, so we rolled our own and we are happy with them. For example we have an intrusive treemap, that has a function for returning the middle of a sorted key which is useful when you want to split a keyspace into two. Not sure if any of STL/Boost supports that.

Your solutions looks good, you are hired! ;) Seriously, we know that it is not that hard, but still the applicants have problems with it.

Re:C++ in Coders at Work by dkersten on Tuesday February 15, 2011 @12:04PM (#2222044)
The C++ standard library shouldn't cause any problems on non-embedded platforms, including phones that support C++. Boost _may_ be a bit more tricky, though most of it is header-only, so it depends on the compiler more than the platforms (but if you use g++, there shouldn't be any issues). As for licensing, STL and Boost are both released under very unrestrictive licenses, similar to the C++ runtimes, so they won't cause you any licensing issues. Not too sure what license EASTL is released under. I know its an unrestricitve license, but don't know about the exact terms, so it may or may not be suitable.

Sure, obviously for niche tasks a general library may not perform as well as a container custom-made for the task at hand. That certainly is a legitimate reason to roll your own (though, if it were me, I would make my containers STL compatible, similarly to how Boost is STL compatible, that way you can mix and match between standard containers and custom ones and easily convert between them (eg, by using compatible iterators)).

Regarding applicants, I am just as surprised as you are. I guess I didn't notice how much C++ is diminishing in industry (outside of its niche areas, anyway).

PS: You're database does look interesting. May have to keep an eye on it.

Re:C++ in Coders at Work by js2 on Tuesday February 15, 2011 @08:51AM (#2221146)
select a sensible subset of C++,

The issue is picking the particular subset and then getting everyone to adhere to it. That works okay in mature engineering shops such as google:

http://google-styleguide.googlecode.com/svn/trunk/cppguide.x...

So I guess I'd say it requires more discipline than, say, Java. (One could similarly argue that writing good Perl requires more discipline that writing good Python.)

There's also John Carmack's quip:

IMO, good C++ code is better than good C code, but bad C++ can be much, much worse than bad C code.

-- http://twitter.com/ID_AA_Carmack/status/26560399301

Re:C++ in Coders at Work by JoeAltmaier on Tuesday February 15, 2011 @09:01AM (#2221177)
Hm the Google guide looks like yet another programmers personal expression of style. The "pretty print police" at work. There may be some defensible (i.e. related to actual good programming practice)comments in there, but much is the usual personal preference stuff about braces and capitalization.

Different folks internalize different features of C++, for good or bad. To take someone's comfort zone and institutionalize it is arrogant.

Re:C++ in Coders at Work by gjm11 on Tuesday February 15, 2011 @10:40AM (#2221545)
> much is the usual personal preference stuff about braces and capitalization.

There's nothing wrong with that; having that stuff in your style guide means that you get more consistent code, which is easier for everyone to read whatever their personal preferences.

(General point: Having a rule that says "Everyone must do X rather than Y" doesn't mean claiming, or thinking, that X is better than Y. There's not much to choose between driving on the left side of the road and driving on the right, but it sure is valuable to choose one or the other and stick with it.)

Re:C++ in Coders at Work by SoftwareMaven on Tuesday February 15, 2011 @11:27AM (#2221812)
Braces are such a stupid thing to be worried about (thank you, BDFL!), but things like variable naming are very valuable in helping people parse code quickly. If you look at my code, you know instantly which variables are global constants, which are class instance, which are method parameters, and which are locals. Those are the valuable additions; the rest is an expression of an anal, alpha engineer or a group that said "let's just start with this thing I found online".
Re:C++ in Coders at Work by yannickt on Tuesday February 15, 2011 @11:23AM (#2221785)
Actually most of the guide relate to good programming practices, and not just stylistic preferences. Also, I would argue that taking offense at style guidelines (which bring a lot of benefits, especially at a big software company like Google) is unprofessional.
Re:C++ in Coders at Work by cageface on Tuesday February 15, 2011 @07:57AM (#2221024)
One downside is it's hard to find good C/C++ programmers on the market.

It's interesting that C++ is increasingly becoming a niche skill. When I started programming you pretty much had a choice of C++ or VB if you wanted a job.

Suits me fine though. A lot of the most interesting work (DSP, kernels, graphics etc) is in C++.

Re:C++ in Coders at Work by rudiger on Tuesday February 15, 2011 @09:02AM (#2221179)
For those that don't know what it means for a data structure to be "intrusive", here's a link:

http://stackoverflow.com/questions/5004162/what-does-it-mean...

Re:C++ in Coders at Work by GrooveStomp on Tuesday February 15, 2011 @03:56PM (#2223241)
The remove_char function was fun to write, and I found a bug in my first implementation! The Intrusive Stack problem; however, is confusing to read. I searched for a description of what an intrusive stack is on DuckDuckGo, and the first result was for the Scalien job application. Further down on the page (through what appears to be several quasi-related links) I found a Boost article on intrusive containers which explained the idea much more clearly. After reading the Boost description, then re-reading the Scalien description another 3 or 4 times, I'm not comfortable to write an intrusive stack.

Are you sure applicants aren't failing because the application problem for the intrusive stack is written in a confusing manner?

Re:C++ in Coders at Work by GrooveStomp on Tuesday February 15, 2011 @06:04PM (#2223813)
Edit: "I'm now comfortable to write an intrusive stack." I mispelled it as "not" by accident.

I tried editing the post, but edit functionality doesn't appear to be working correctly.

Re:C++ in Coders at Work by dkersten on Thursday February 17, 2011 @09:27AM (#2230989)
"Are you sure applicants aren't failing because the application problem for the intrusive stack is written in a confusing manner?"

I don't know, its very possible. I found the application problem very easy to understand and writing an intrusive stack is really easy, so unless I'm very disconnected from the "average applicant", who apparently 1) isn't very good at C++ and 2) doesn't know how to implement common data structures, the problem must be with the application.

Re:C++ in Coders at Work by joe_the_user on Tuesday February 15, 2011 @05:02PM (#2223560)
"...you can select a sensible subset of C++"

I love programming in a sensible subset of C++ too.

The problem is that C++ has long history and when it began, many programmers had erroneous ideas about OO - some skipped it completely, some built absurdly deep inheritance trees, some engaged in ridiculous tricks to stay within "doctrine" (remember a fellow who had a pointer-member to the same object in a parent and a child class just avoid something about down-casting).

So from this history, there's a lot of really bad C++ code "out there".

And just much, when you take two code bases or two groups of programs, each happy with their different sensible subset of C++ and combine them, without being careful, you also wind-up with a hellish mess.

Re:C++ in Coders at Work by l0nwlf on Tuesday February 15, 2011 @08:45AM (#2221125)
Re:C++ in Coders at Work by chollida1 on Tuesday February 15, 2011 @10:36AM (#2221535)
> and writing an instrusive stack in C++)

What is an instrusive stack?

Re:C++ in Coders at Work by roel_v on Tuesday February 15, 2011 @10:51AM (#2221604)
It's explained in the link.
Re:C++ in Coders at Work by chollida1 on Tuesday February 15, 2011 @12:02PM (#2222030)
Thanks;)

I guess I was thrown off by the typo and was looking for something else.