Slashdot Mirror


Knowing C++ Beyond a Beginner Level

Nerval's Lobster writes: C++ is not an easy language to master, but many people are able to work in it just fine without being a 'guru' or anything along those lines. That being said, what separates C++ beginners from those with 'intermediate' skills, or even masters? According to this Dice article, it comes down to knowledge of several things, including copy constructors, virtual functions, how to handle memory leaks, the intricacies of casting, Lambda functions for C++11, (safe) exception handling and much more. All that being said, is there one particular thing or point that separates learners from masters?

49 of 345 comments (clear)

  1. Knowing when not to by perpenso · · Score: 5, Insightful

    What separates C++ beginners from those with 'intermediate' skills, or even masters?

    Knowing when not to use templates, virtualization, [insert favorite c++ function here], etc.

    Basically knowing enough about programming and problem solving with a particular language to tell a need from a want. Needing to use some language feature vs wanting to use some language feature. And being mature enough to stick to needs rather than indulge wants.

    Or to state things differently ... all the features have a time and place, and its probably not all the time and in every place.

    1. Re:Knowing when not to by Ihlosi · · Score: 2
      Knowing when not to use templates, virtualization, [insert favorite c++ function here], etc.

      Basically, only use a language feature if it provides a tangible benefit (making the code easier to understand and maintain almost always qualifies; making the code run faster qualifies if it's not running fast enough yet; "This is cool, let's try using it!" only ever qualifies in your own private projects).

    2. Re:Knowing when not to by PolygamousRanchKid+ · · Score: 4, Insightful

      I agree with your comment entirely. I would only like to add that a true C++ Master writes code that a C++ Novice can understand.

      Time to get philosophical. Tomorrow, you could get run over by a bus. Take a wander around your Cubical Town. Are there enough folks there who could take over ownership of your code?

      You can do some really cool things with C++. But if other folks cannot understand them, well it's best not to do it. Cool C++ features are like nuclear weapons: very powerful, but think about the consequences of using them . . .

      --
      Schroedinger's Brexit: The UK is both in and out of the EU at the same time!
    3. Re:Knowing when not to by AmiMoJo · · Score: 2, Insightful

      These days it's questionable if any large projects that use those kinds of features extensively should even be started in C++. There are better languages for such things.

      C has applications in OS, low level and embedded development. C#, Java, Objective-C and many other languages are better for applications. Somewhere in the middle you have C++, which is okay in moderation but wouldn't be your first choice for anything new.

      --
      const int one = 65536; (Silvermoon, Texture.cs)
      SJW, n: "Someone I don't like, and by the way I'm a fuckwit" - AC
    4. Re:Knowing when not to by eulernet · · Score: 4, Insightful

      You are thinking like a manager.
      As a programmer, I don't want to be replaced easily, and I don't care about my work when I'll die, or even when I quit my company.
      I have no problem to share my knowledge with my co-workers, but why should I write code for somebody who'll replace me ?

      Also, unless you write frameworks, I doubt very much that your code will be reused.
      It will probably be rewritten.

    5. Re: Knowing when not to by Anonymous Coward · · Score: 5, Insightful

      but why should I write code for somebody who'll replace me ?

      Because future you will replace present you. If you need to revisit code years later to fix a bug or add a feature, you want to be able to pick it up straight away, rather than try to figure out the mess you left behind.

    6. Re:Knowing when not to by TheRaven64 · · Score: 4, Insightful

      making the code run faster qualifies if it's not running fast enough yet

      And then only if backed up by realistic macrobenchmarks. There are a lot of things in C++ that have interesting performance characteristics (templates allow more inlining, so make microbenchmarks faster but can cause you to run out of i-cache and make the whole program slower, virtual functions prevent inlining unless the compiler can do devirtualisation, but are actually slightly faster to call than cross-library calls via a PLT if they're not inlined). Generally, algorithmic improvements will make a bigger difference than any language feature. The main reason for using templates should be to eliminate copy-and-paste coding, not to improve performance.

      --
      I am TheRaven on Soylent News
    7. Re:Knowing when not to by TheRaven64 · · Score: 4, Interesting

      If you can't be replaced, then you can't be promoted. Do you really want to be maintaining the same program for the rest of your life? And do you want to have a reference that says 'no one can understand this guy's code' when you leave for the next job?

      --
      I am TheRaven on Soylent News
    8. Re:Knowing when not to by 91degrees · · Score: 2

      As a programmer, I don't want to be replaced easily, and I don't care about my work when I'll die, or even when I quit my company.

      As a programmer, I make sure I remain employable by doing the best job I can do. Partly this is about basic ethics, but I know that even if I write ideal code, with perfect documentation, I'm still the best person to understand that. I don't want to work for any company I work for that doesn't realise this.

    9. Re:Knowing when not to by serviscope_minor · · Score: 4, Insightful

      This is complete and utter tosh.

      No one I know who does high performance code (such as numerics, real time computer vision, that sort of thing) uses anything but C++, especially for new projects. There is nothing out there that combines the speed and expressivity of C++, and when you know performance is going to be a factor at some point, C++ is the only choice.

      Frankly for a lot of scientific and numerics style coding, I often reach for C++ initially even when performance isn't required since it often maps on to those problem domains better than any other languages I've used.

      Oh and then there's the embedded world, where your choices are C and C++. Plenty of people use C++, since it like C scales all the way down to the 8 bitters like Atmel.

      --
      SJW n. One who posts facts.
    10. Re:Knowing when not to by serviscope_minor · · Score: 4, Insightful

      If you need really high performance you don't use most of the C++ features anyway, and end up basically writing straight C.

      Nope nope nope nope nope nope nope nope nope.

      That is far, far, far away from correct.

      Check out something like Eigen or TooN (a somewhat more obscure library which is used in the vision world for things like PTAM). They are very far from C++. The code written down in an editor reads more like maths. There's no explict loops, no explicit memory allocation. They're both high performance libraries used in challenging applications (seriously download and run PTAM, it's amazing).

      They're also fully templated so you can stick in an AD type instead of a normal number and get derivatives out automatically with no extra effort.

      Writing high performance C++ is nothing like writing high performance C. It's much better. All the messy C details of allocation and etc simply vanish, leaving clean, nice looking code which is straightforward to read, write and debug.

      Or another example from today for me. I need to find the best N (lowest cost) elements during some wort of complex search. It's easy. Just create a priority_queue<pair<double, int>> where the double is the cost and the int is the index of the object.

      Then about 3 lines of logic keeps the pqueue updated with the best N so far.

      All the irrelevant logic of how a queue works is witten and debugged by someone else and hidden from me without ever losing either performance or type safety. For bonus points, if I find I'm searching very small things and memory allocation becomes a penalty, I can switch the entire thing to stack allocation with almost no effort at all!

      --
      SJW n. One who posts facts.
    11. Re:Knowing when not to by eulernet · · Score: 4, Insightful

      If you can't be replaced, then you can't be promoted.

      It depends on the kind of promotion.
      Not everybody dreams to become a project manager.

      Do you really want to be maintaining the same program for the rest of your life?

      Not really, but if the pay is good and the job is nice, why not ?
      Personally, I have a life outside of my work, so I don't really mind.

      And do you want to have a reference that says 'no one can understand this guy's code' when you leave for the next job?

      That's the least of my worries !
      Do you think that the guy who will take your place won't hate you, even if your code is beautiful ?
      Do you believe that your company will not fire you if there are problems ?
      If the company doesn't care about me, why should I be faithful ?

      Finally, I have a personal question: why do you work ?
      Is it to receive aknowledgment, money, fame, self-esteem, or something else ?

    12. Re: Knowing when not to by eulernet · · Score: 3, Insightful

      I have 30 years of coding experience.
      Even though I believe I'm quite a good coder, when I read code from 5 years ago, I'm always surprised to realize that I can do better and simpler.

      Whatever the state of your code is today, it will be a mess in a few years.

    13. Re: Knowing when not to by evenmoreconfused · · Score: 3, Interesting

      Even though I believe I'm quite a good coder, when I read code from 5 years ago, I'm always surprised to realize that I can do better and simpler.

      Whatever the state of your code is today, it will be a mess in a few years.

      Yes. I find this to be the case too (I was a programmer in the seventies and eighties, and have been in programming management ever since).

      So it begs the question "can one write code that one won't think is sub-optimal five years from now?". I've begun to suspect that one can't -- so just learn to accept it and move on.

      What I try to get programmers to do is write code that is A) clear and simple and B) balanced in terms of development vs. maintenance time. I don't want programmers wasting time perfecting code that's not going even be looked at for years to come, nor do I want code that takes days to get into when attempting small fixes.

      It's like building a house: if you follow the building standards, it's quick, safe, and any plumber or other trade can walk in later and quickly fix or modify things. If you do a bodge job it all has to be torn out and redone properly, or, if you create custom installations, it gets very expensive to create and especially to maintain.

      --
      No. Well...maybe. Actually, yes. It really just depends.
    14. Re:Knowing when not to by Drethon · · Score: 2

      If you can't be replaced, then you can't be promoted. Do you really want to be maintaining the same program for the rest of your life? And do you want to have a reference that says 'no one can understand this guy's code' when you leave for the next job?

      Or for people who don't care about being promoted above coder level... If you don't write good code that other people can work with, you will never be moved to new projects. If you want to live in maintenance mode that is one thing but personally I want my code to reflect my skills so I can work on bigger and better projects.

    15. Re: Knowing when not to by Xenna · · Score: 2

      "Whatever the state of your code is today, it will be a mess in a few years."

      Funny, I just said that to a colleague tow hours ago. It's the fate of all software development.

    16. Re:Knowing when not to by Actually,+I+do+RTFA · · Score: 4, Insightful

      You are thinking like a manager...I don't care about my work when I'll die, or even when I quit my company.

      I'm both a programmer and a manager, so I can probably weigh in. I do care about what happens to your work when you leave the company. And part of my job is to make sure that your code is usable.

      why should I write code for somebody who'll replace me ?

      Because code is an asset that you are being paid to create. And if your code is not maintainable, it's not much of an asset; it's worth far less to me. So, if I notice our code is a fuck storm of uncommented overly complex verbiage, I'm not letting you work on anything important. So, maybe you get to work on small one-offs (really career enhancing), maybe I just fire you. But certainly I don't expect to allow you to keep extending your tentacles..

      The reason you say "most of your code will be rewritten" is because it sounds like your code is poor. Why would I pay asset-level prices for stuff with a shelf-life of a year?

      --
      Your ad here. Ask me how!
    17. Re: Knowing when not to by gfxguy · · Score: 2

      I'm like that. I actually wouldn't mind rewriting most of the stuff I've written, but it all works and I can understand what things I wrote 10 years ago are supposed to be doing. But like the GP, even while I'm writing I often feel like I could have done it a better way - not the nitty gritty coding, but the approach I took to begin with. I think the overall sentiment is there's always room for improvement, even if the code is good and works, but you can't keep changing or you won't finish (and I rarely get a chance at version 2 where I work).

      --
      Stupid sexy Flanders.
    18. Re: Knowing when not to by crgrace · · Score: 4, Funny

      Wow. You're right. It's only been four hours and your comment is already a mess.

  2. We're all learners... by vux984 · · Score: 2

    :eyerolls:

    We're all learners. But anyone with more than a passing familiarity with C++ already knows everything in that puff piece of a Dice article.

  3. Error Handling by oggiejnr · · Score: 4, Insightful

    I've always considered error handling to be the most important thing when it comes to knowing a language beyond the beginner level. Every language has it's own idiomatic ways from RAII in C++, finally/using in Java to the myriad of ways of handling return codes in C. It is also frequently undertaught in most programming language courses.

    It is for this reason I despise seeing C/C++ on CVs. It implies that you don't have a strong foundation in either language as idiomatic code is so different between the two. By all means list them as two separate languages, but be willing to demonstrate sound knowledge of both, not the bastardised, resource leaking hybrid I see so often when the term C/C++ is invoked.

    1. Re:Error Handling by Ambassador+Kosh · · Score: 3, Interesting

      I may hate seeing it written that way also but that is also the current most common way to write it and that is what HR systems and their computer screening systems except. You are writing a resume for an HR person usually and if you want it t be seen by someone more important it has to get past them first. That means doing stuff that HR people understand.

      There are many fights to take on in this world and others that are just not worth the effort to fight since the costs are so high compared to the benefits and this is one of those fights.

      --
      Computer modeling for biotech drug manufacturing is HARD! :)
  4. Given how C++ is taught. by serviscope_minor · · Score: 2

    You should certainly be familiar with the syntax.

    You should almost never see a new, and never a delete in normal code (rare exceptions for guru library writers only). If you do, you're almost certainly making life hard for yourself.

    Another thing is programming with concepts. These aren't part of the language yet, but are part of the culture, part of the design of the STL and hopefully will make it into the language. Things having the same "concept" are types where the operation of the semantics are the same.

    This is like a field in mathemetics: you have addition, multiplication, subtraction and division (well, really the additive and multiplicative inverses). If you get the proofs right, they'll work on any field. This is why you can muliply with a modular FFT.

    For example, ints, floats, std::complex all obey the same concept, that of a number. There are more, such as automatic differentiation types provided by expernal libraries.

    Another example is vectors in "metric spaces". A VP-tree is like binary search, but instead of working on an array of numbers, it works on a multidimensonal metric space of vectors. Normal 3D vectors in Euclidian space is a metric space (distances obey the triangle inequality), but interestingly so are bit vectors and hamming distance and even strings and edit distance. The underlying algorithm of a VP tree relies on several semantics. You need to be able to measure distances and update some lower and upper bounds. That is all.

    The art of concepts is writing the algorithm using the abstract interface of the concept upon which it operates. This has several nice properties. Firstly, you use nothing more than the concept. If you use an operation which isn't part of the concept, it's almost certainly a bug. Secondly the algorithms are much clearer because they don't mix in the implemtation of one specific instance of a concept (e.g. building edit distance right into your VP tree) with the underlying algorithm. And finally, once you've done that you get genericism for free. Stick a template around the class and you have a working, debugged algorithm which works on everything it could work on.

    This is how the STL works. For instance std::sort requires two concepts. The range spanned by the iterators passed to it must work with radom access and you must be able to compare the elements with <. Given that it can sort anything.

    A good stage to get to as a C++ programmer is to write code like that, not necessarily even because you need the genericism but it forces you to separate the underlying abstract algorithm from the concrete specific datatype it is operating on this time. Doing so has many benefits.

    --
    SJW n. One who posts facts.
    1. Re:Given how C++ is taught. by angel'o'sphere · · Score: 2

      Smart pointers live where ever you declare them.
      Either heap or stack or even with limited usability in static allocated memory.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    2. Re:Given how C++ is taught. by tp_xyzzy · · Score: 2

      > In a multi-threaded environment where objects may be shared, or not

      Isnt it bad sign, if you're forced to use unreliable multi-threaded abstractions... Good luck finding all race conditions...

    3. Re:Given how C++ is taught. by Rei · · Score: 4, Insightful

      "Smart pointers" are great -- if you don't care about performance (in which case, why are you not using Java?).

      Since when does Java's performance even come close to C++'s in benchmarks? C++ performance is generally very close to that of C's, and in some cases exceeds it (example: qsort vs. std::sort - C++'s use of templating allows for inlining of the sort function code)

      Smart pointers have very, very little overhead. The worst is std::shared_ptr, and it's still only adding a reference counter, and that's only used on pointer copy and deletion. And if you have a use case that requires std::shared pointer as your smart pointer of choice, then this is counting that you'd have to be doing anyway in some form or another.

        From the benchmarks I've seen, most people see about an additional 5%-ish overhead in debug mode with std::shared_ptr vs. raw pointers in pointer-heavy code. In a release build there's generally no measurable effect (the difference being, in debug mode it can't inline the dereferences).

      --
      What about the Ant People? They owe us money.
    4. Re:Given how C++ is taught. by TheRaven64 · · Score: 3, Insightful

      "Smart pointers" are great -- if you don't care about performance (in which case, why are you not using Java?). If the object is owned by one thread, it's just sloppy to put in the overhead of smart pointers to make your life easy.

      If an object has a single unique owner, then std::unique_ptr has no run-time overhead and will ensure that the object is correctly deleted even in the presence of exceptions. I agree with the grandparent: any object that isn't allocated on the stack should be created with std::make_shared or std::make_unique.

      --
      I am TheRaven on Soylent News
    5. Re:Given how C++ is taught. by rl117 · · Score: 2

      Well, rather than "not liking the sound of it", I would highly recommend you educate yourself about them. There's plenty of examples floating around. I've been using std::shared_ptr for well over a decade, first as boost::shared_ptr, later std::tr1::shared_ptr and today std::shared_ptr (they are all the same, just going to the final standard name with C++11). The number of memory leaks I've had in my released software over that period: zero, checked regularly with valgrind.

      Smart pointers aren't magic. They are just an instance of RAII to acquire a resource (memory) upon construction of an object and release it upon destruction. For std::unique_ptr, there's only ever one instance, though you can transfer it. For std::shared_ptr the object can be referenced multiple times, handled with reference counting, so destruction decrements the shared count by one, and deletes the memory once the reference count reaches zero. The smart pointer can be a variable in a function or class method, a class member, static member or global variable. It's the same in all cases.

      Think about how many bugs there are in C code due to malloc/free issues--double free, not freeing, and if using reference counting failure to increment or decrement where needed (just see how many times this crops up for GTK/GObject-based code). And no way to know who owns a pointer and who is responsible for freeing it--it's just a bare pointer. Smart pointers handle all of this for you, that is to say that the compiler does all the work automatically that you would have to do by hand *anyway*. And it's thread-safe and exception-safe. It makes it impossible to mess up memory management--if it's broken it won't compile. In terms of writing robust and reliable code, it's a world apart from plain C with malloc/free or old-style C++ with new/delete. It's vastly simpler for the programmer, too. There's little to dislike about this--IMO it's one of the most beneficial additions to best practices for C++ ever made.

    6. Re:Given how C++ is taught. by rl117 · · Score: 2

      I think you missed an important concept here: std::make_unique can never, ever ever leak. It returns a std::unique_ptr<T> which will free the allocation and/or transfer ownership to another unique_ptr instance (or to a shared_ptr). At no point can it lose track of the memory it is managing for you.

      Forget about "focussing on things have an equivalent delete/free". Understand that unique_ptr does this for you. So does shared_ptr. Their whole point is to manage allocations for their whole lifetime. No more need for manual make-work or tedious checking; this ensures it's correct under every circumstance. If it's not correct it won't compile, end of story. Ownership transfer is explicit. Doing it by hand the old way is error prone because it's possible to forget; we see time and time again that programmers aren't perfect and do forget, or introduce leaks when refactoring, or misunderstand who is the owner. These smart pointers eliminate that entire class of bugs at a stroke. And they are not "new" by any means; they have been around for over 15 years in boost, in C++03 TR1 and in C++11.

      I would highly recommend taking a read of Meyers' new Effective Modern C++ book, which covers all this in detail with really good examples.

      // old
      {
          Foo *f = new Foo(); // bare pointer with no clear ownership
          f->bar(); // leak on throw
          delete f; // leak if omitted
      }

      // new
      {
          std::unique_ptr<Foo> f(std::make_unique<Foo>()); // managed unique pointer with defined ownership
          f->bar(); // cleanup on throw
      } // cleanup at scope exit

      These are equivalent. Except: I didn't need to delete f in the second case; it happened automatically when f went out of scope. And if the bar() method threw an exception, it would automatically free the memory when the stack was unwound. There are other corner cases it also protects against. And this is about as trivial an example you can get; you can do much, much more with them.

  5. It's not about knowing, it's about understanding by rippeltippel · · Score: 5, Insightful

    Since C++ is the language of choice when you need performance (along with C and - sometimes - assembly), to write good code it's essential to understand what each line of code does to the machine (memory, registers, ...) and if/how instructions can be optimized by the compiler.

    This level of awareness is generally not required to be proficient in other languages, but in my experience it's what makes the difference between newbies and pros, at least in the areas where C++ is used for a good reason.

    Said that, it can be useful to understand as much as possible of any language and C++ can provide strong foundations in that sense, as this short article points out: http://www.forbes.com/sites/qu....

  6. Warnings by wienerschnizzel · · Score: 3, Insightful

    There is no single one thing to look for, because what you really want is EXPERIENCE with C++ programming and that encompasses a lot of things. But if you want an easy test to see if somebody has got enough experience, get some code sample that produces a lot of different warnings at compilation time and have them explain what the warnings mean and how one should get rid of them.

  7. I would suggest the stl by Ambassador+Kosh · · Score: 3, Interesting

    There are many things you can use to improve your c++ code like std::vector. With that you store data contiguously in memory but you also don't have any manual memory management. No new, no delete, no malloc, no free.

    For my high performance work I tend to use std::vector, BLAS and LAPACK and my programs usually have no manual memory management of any kind in them. Valgrind shows no memory leaks and the programs are very easy to read and work with.

    If you want to do high performance c++ then learn OpenMP and MPI. If you want to do threading just use OpenMP since that makes it VASTLY easier to get threading correct. Add tasks with OpenMP along with their dependencies and you end up with a nice cross platform and very high performance code base if you have done your job correctly. If you need to scale to multiple nodes then use MPI between nodes.

    --
    Computer modeling for biotech drug manufacturing is HARD! :)
  8. Re:Masters know their limitations. by jonwil · · Score: 3, Insightful

    I thought I was a guru level C++ programmer (I have been programming C++ for around 2 decades) but even I am constantly finding out about new things I didn't know existed.

  9. Non-master by gnasher719 · · Score: 3, Insightful

    I recommend this link: http://programmers.stackexchan...

    There is someone asking whether 8 lines of slightly clumsy looking code can be replaced with something better. The beginner wouldn't ask that question and wouldn't know an answer. The master would say "your code is just fine", because it is actually straightforward, easy to understand, easy to check for correctness. The first answer on stackexchange adds two arrays, one 20 line function, and a few lines of function calls resulting in code that is hard to understand and verify.

    Now where C++ is a bit unfortunate is the fact that once you leave beginner level and think you know it all, you have unlimited potential to create code that nobody can understand.

  10. Re:It's not about knowing, it's about understandin by rippeltippel · · Score: 3, Informative

    so, you claim you know:
    ...
    int a = 13;

    In which register a is residing, supposing we are on an ARM? Or suppose we are in an 68k? Or suppose we are on an x86?

    You are just an idiot!

    I don't claim i know, I claim that I understand: something that you're clearly neither willing nor capable of doing, as your question and offensive language suggest.

    Have a nice day!

  11. Masters don't play with Dice by MightyDrunken · · Score: 5, Insightful

    One of the defining feature of a non-beginner programmers is that they don't read Dice articles to find out anything about computer languages.

  12. Re:Experts... by Rei · · Score: 3, Funny

    Memory objects that clean themselves up after they go out of scope are the devil's work. The devil, I say!

    --
    What about the Ant People? They owe us money.
  13. Who else stopped reading at "this dice article"? by Qbertino · · Score: 4, Insightful

    Just asking. :-)

    --
    We suffer more in our imagination than in reality. - Seneca
  14. Re:Simple ... by serviscope_minor · · Score: 3, Interesting

    Wow the smug condesention is strong in this one.

    I for my part wrote an STL clone around 1993 when the STL was just a lab experiment at HP.

    The hard bit about the STL is the whole concept of, well, concepts that Stepanov finally hammered out. The STL, especially 1993 era is not all that complex.

    Well, iostreams and their interaction with locales is deeply fiddly and I'd steer clear of that. But the basic algorithms, you know, vector, list, set/ma/multiset/multimap, sort, heap, priority_queue and so on and so forth are not too bad.

    Not to say it's not an achievement, but it's not enough to convince me that you're an uber-guru. I've written STL compatible containers, and STL like algorithms for things that weren't in there. Apart from quantity the principle is the same.

    Perhaps you should read what I wrote: I have roughly 15 years consecutive C++ experience from 1989 till 2005, plus random 3 or 4 years over the last decade.

    15 years experience, or 1 year of experience repeated 15 different times?

    Given you've never seen code without new in it (as your other post claimed), I'm inclined to think the latter because you seem to be deeply ignorant of whole swathes of C++ style. In a lot of code, you never see new and delete. Everything is managed by containers. I work on computer vision systems, and you can get entire working, robust systems without a new anywhere in sight. The custom containers might have a new in, but that's---well, let me check the library I'm using---let's see there's 80 instances of new in 40k lines. Of those most are in old code from before TR1 gave us many standardised smart pointers, and others could easily be replaced with a std::vector (the code's not perfect, it's been hacked on for the last 15 years), some are strange, silly uses and the rest are to initialise now deprecated auto_ptr.

    There's about one legit one which uses placement new and posix_memalign.

    With spare time, I could make that one in 40k lines of code easily. In fact that's going to happen slowly as the library is being transitioned to C++14.

    I find it terrifying that someone who pust themselves forward as a super C++ guru is splattering new so much all over the place. But you won't believe me because without knowing anything about me you've convinced yourself that you're superior.

    Let's see what a real, certifiable C++ guru says:

    http://www.informit.com/articl...

    Bjarne doesn't like new/delete either. No offence, but I'll take his invention ans stewardship of the language over your 1 year of experience repeated 15 times.

    I doubt you regularly find one here on /. who has significantly more C++ experience.

    Out of interest, do you have any T-shirts with disparaging things written about n00bs on them? And are those slogans visible under the cheeto dust?

    --
    SJW n. One who posts facts.
  15. Re:It's not about knowing, it's about understandin by Rei · · Score: 2

    C++ lets you have just as much control over the code as C. The key difference is that it doesn't make you memory manage your objects every time, when 99.99% doing that is irrelevant toward performance and only serves as a common route to introduce bugs.

    --
    What about the Ant People? They owe us money.
  16. Re:which part by MiskatonicAcademic · · Score: 4, Interesting

    Scientific (matlab but faster): who cares, you just want the answer, not the software, right?

    Not always true. Sure, there is plenty of well-motivated ad-hoc coding in scientific research. However, we sometimes have supercomputers working for months to generate the answer. Even with well-written software this could mean many core-years of number crunching. Without good high-performing software we would not get the answer at all. Developing good scientific software takes time and effort too, but if the software can be used over and over to efficiently solve >1000 problems (for instance, the GROMACS papers have been cited by users ~15,000 times), then the time invested can be very good use of taxpayer money. C++ is not a bad choice for such software in that it enables very good performance and decent maintainability.

  17. Re:Simple ... by locofungus · · Score: 2

    I shouldn't rise to the bait but, oh well.

    There is no single job interview where I don't have to correct the interviewer about false assumptions of how certain stuff works in C++ ...

    Any competent professional will be aware that C++ is a language so vast and with so many obscure corners that there will be corners that they would need to check to be sure and may well get wrong in an interview situation. However...

    What is called in which order? Constructor? Assignment operator? A potential cast from bla to s? Or, the copy constructor?

    And why the funk am I supposed to know that?

    The reason this question would probably asked at interview is that there is a candidate who claims to be expert at C++ who is making statements about obscure corners of the language that are probably wrong but an interviewer doesn't want to get into an argument about it. So instead they'll ask something that any reasonably competent C++ programmer would be aware of (because this syntax is a legacy of C and doesn't do what a naive C++ programmer might assume)

    It's also interesting that the really smart C++ programmers are usually quite self-effacing. They probably won't comment or will say something like "Oh, I thought it was B but I'm not sure" if they think something the interviewer said is wrong. They certainly won't be aggressive about interviewer mistakes (although any sensible programmer won't take a job where the interviewers are making to many basic mistakes in the language)

    --
    God said, "div D = rho, div B = 0, curl E = -@B/@t, curl H = J + @D/@t," and there was light.
  18. Re:Masters know their limitations. by UnknownSoldier · · Score: 4, Informative

    This 100%. C++ has become a clusterfuck of over-engineering and I say that as someone who has worked on a C++ compiler.

    * /Oblg. Comedy: Hitler on C++

    When you have even committee members admit they only use a sub-set then you know the language is too big.

    The C++ committee recognizes there are many problems with C++ iostreams but nothing is being done towards performance and type safety.

    The committee would rather argue over the rare case of multi-dispatch / multi-methods then fix core issues.

    * http://www.stroustrup.com/mult...

    Crap like long long, "long double", etc. should have been deprecated in year X, and removed in year X+5. Are they going to add "long long long" someday?? Having types like "double" in 2015 is just retarded -- replace it with "float64_t", and the fore mentioned long double with the clear "float80_t". Bandaging the problem like int_fast32_t doesn't solve anything. How many fucking integers types does the compiler need to throw at us?? short, long, long long, int, long int, int_fast32_t, int_least32_t, etc. and I'm not even talking about MS's hacks of __int32, __int64, etc. Simplify the dam language already!!! Set year 2020 as the date when these barbaric types are deprecated, and year 2030 when they are removed.

    Modules have been in a constant state of on-again-off-again for over 10 years:

    * First mention N2073 (Sept.2006)
    * Revived N4047 (May 2014)
    * 2nd draft N4214 (Oct. 2014)
    * 3rd draft N4465 (April 2015)
    * Wording N4466 (April 2015)

    The pre-processor is STILL broken. One would expect #define token operation to work for ALL user-defined tokens. i.e. This isn't rocket science, just a basic Search-and-Replace:

    #define @(func) printf("%s\n",func)
     
    void foo()
    {
      @(__func__);
    }
     
    // Hell, even this should work
    #define @ printf("LOL. Your pre-processor is broken. HA-HA!\n" )

    There are no standard pre-processor macros for function names as a string. GCC has the excellent __func__ which Microsoft finally got around to implementing C99 N2340 in Visual Studio 2015!

    The C++ committee failed to learn the first lesson about design:

    * "Needlessly complexity is a symptom of bad design."

    Or paraphrased from Einstein:

    * "Things should be as simple as possible, but no simpler"

  19. Re:Masters know their limitations. by serviscope_minor · · Score: 3, Informative

    This 100%. C++ has become a clusterfuck of over-engineering

    Nope. It's mostly hampered by the need to be backwards compatible. The committee know full well if they make serious breaking changes, then the C++ world will split into two distinct languages. Many, many people won't adopt the new one and the vendors will continue to support them because there's money there.

    It's a blessing and a curse. The curse it it's hard to do anything but add features. The blessing is my code I debugged 13 years ago still works.

    The committee would rather argue over the rare case of multi-dispatch / multi-methods then fix core issues.

    You're basically being an arse. You're picking out one rather speculative paper designed to help C++ stay modern a ways in the future (and somehow labelling this as a bad thing) and yet knowingly ignoring the many papers on fixing core issues.

    Modules have been in a constant state of on-again-off-again for over 10 years:

    Yeah they should just slap in some module crap and if it's wrong, just rip it out and replace it. Who cares about getting things right and not breaking working code, eh? They learned their lesson very hard with export templates and are keen to not have to learn the same lesson again.

    There are no standard pre-processor macros for function names as a string. GCC has the excellent __func__ which Microsoft finally got around to implementing C99 N2340 in Visual Studio 2015!

    So you submitted a proposal, right? Or do you expect other people working for free to magically know your personal problems from your whining on slashdot?

    --
    SJW n. One who posts facts.
  20. Re:Experts... by superwiz · · Score: 4, Insightful

    Just think about it! (TM) A function gets automatically executed just because you leave scope. Doesn't matter how you leave it. Forget that it's a destructor. It's a function which gets called automatically without anyone writing any code to call it. Show me how to do that in C. And that's the fundamental difference between the 2 languages. The rest is syntactic sugar.

    --
    Any guest worker system is indistinguishable from indentured servitude.
  21. Re:Simple ... by serviscope_minor · · Score: 3, Funny

    Congrats, you clearly have the bigger C++ e-penis in this case.

    That's probably the most common type of logical phallusy.

    --
    SJW n. One who posts facts.
  22. Here we go again ... by gstoddart · · Score: 2

    And, once again, Nerval's Lobster gets a piece accepted which is little more than a thinly veiled reason to link to one of the endless stream of lame stories about "how much toilet paper do you really need" articles.

    Have you guys become so blatant with the click-whoring to Dice you have designated people who write pithy sounding summaries for repetitive and lame articles to drive to Dice.com?

    Because there are suspicious amount of lame "how much do you" articles submitted by this one poster, and all linking back to Dice.com. And never a mention that Dice.com is the parent company and is shamelessly shilling their own crap.

    Sorry guys, but you're becoming really obvious with this.

    --
    Lost at C:>. Found at C.
  23. Re:Experts... by Smerta · · Score: 5, Insightful

    I've made the exact same argument to co-workers at many firms... namespaces (e.g. Timer_Init()), virtual functions (tables of function pointers), etc. can be approximated / kludged together... but automatically invoking a function at the right place (destructor and, let's face it, the constructor is pretty handy too) is something that has to be baked into the language, and C++ has it. I work in safety-critical systems, and knowing that I can't leave a function with interrupts disabled, I can't forget to close this socket, etc. is incredibly comforting.

    I'll quote Bjarne Stroustrup here:

    "Just that closing brace. Here is where all the ‘magic’ happens in C++. Variables get destroyed, memory gets released, locks get freed, files get closed, names from outside the closed scope regain their meaning, etc. This is where C++ most significantly differs from other languages. It is interesting to see how destructors -- an invention (together with constructors) from the first week or so of C++ -- have increased in importance over the years. So many of the modern and most effective C++ techniques critically depend on them"

  24. Re:Experts... by Mike+McTernan · · Score: 2

    It's a function which gets called automatically without anyone writing any code to call it. Show me how to do that in C.

    Well, it's a compiler extension, but GCC supplies the __cleanup__ attribute which essentially allows arbitrary destructor functions in C.

    Mastery of the language is one thing, mastery of the tools another...

    --
    -- Mike