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?
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.
... all the features have a time and place, and its probably not all the time and in every place.
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
Well, that really tells you all you really need to know.
: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.
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.
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.
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....
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.
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!
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.
The "masters" figured after 10 to 20 years of C++ that being a master is just mental masturbation, so they moved on to .Net and JVM based languages like C# or managed C++ and Java/Scala.
It's ironic how you accuse people of mental masturbation in a sentance that sounds likeso much wankery. I was going to correct you and point out where C++ is the superior alternative to almost everything else. I came to realise that you're not actually interested in learning. You seem more keen on letting the world know about your supposed mental superiority.
It also sound like you're intervierwing for C++ jobs you don't want purely so you can lord it over the interviewers. Get over yourself.
SJW n. One who posts facts.
If he was coding instead of making stuff from wood and metal, he would be using C++.
Why is Snark Required?
C++ gives a nice balance between high performance and relatively good safety.
Experience writing, debugging and maintaining code.
The bucket list of having to know this and that means nothing when the programmer doesn't know how to apply it. Claiming things like the latest C++11 features (lambdas) as separating beginners from masters is just BS trying to artificially simplify the issue into something quantifiable. HR and managers love that, because it is easy to test.
I write C++ code for over 15 years now and I can't claim that I am conversant with all those new C++11 features, like lambdas or even move semantics. I didn't need or encounter them so far in production code. The first lambda I have found was only very recently in some brand new code that is explicitly written as C++11 - and had to look up what that weird syntax was about. However, I am pretty sure I will be running circles around anyone who has just drilled themselves on the C++11 specs, but never wrote anything serious in it - I have simply seen and written so much code already that I am fluent in the language, even without knowing all the obscure features. It is the same as with learning foreign languages - you can be excellent at grammar but you still won't be able to communicate until you have to speak it for a while ...
The ability to write code that compiles and runs correctly the first time, without memory leaks, pointer errors, and other bugs.
How do you get that? That's easy too: write a few hundred thousand lines of complex code and debug and test it.
I have a friend who is retired and he makes stuff in his shop. Instead of buying hinges, he makes them himself out of raw metal stock. He enjoys the challenge.
If he was coding instead of making stuff from wood and metal, he would be using C++.
Except the STL provides a lot of those widgets off the shelf.
Has little to no experience, learns the first tasks. Every step he takes has to be supervised and controlled.
Knows how to do things, you can give him a list of task, and he will work on them until they are finished. Can supervise an apprentice.
Knows his trade. Knows how to organise task. Is able to split a project into several tasks he can either work on himself or give to a journeyman or even to an apprentice. Knows how to teach an apprentice. Knows how to differentiate between a well finished task and one you have to do over again.
What we have here is the question what you have to know in C++ to be on journeyman level.
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.
At this stage 'a' isn't in a register. It's a symbol that will probably be replaced by a constant 13 in a later operation, or pushed onto the stack if used as a parameter (assuming stack based calling)
The C++ master knows C, too and never forgets that he is still programming as close to the "bare metal" as with C. The only thing between him and the processor is the compiler, and no virtual machine, bytecode, or CLR runtime. C++ is a tool to write good (readable, reusable, "object oriented") C code.
bickerdyke
I would rather say that about Ada.
No... That is more like the arrogant closed minded jerk.
A master will strive to learn more about such features and when they suffencly understand them they will implement when approproprate.
I myself have been out of practice in C++ for about 15 years. I recently began working on a project where I needed better systems control and huger performance. So I choose to use C++. I know most of the concepts however I needed to research how to to do some things over again.
My experience made it easy for me to search for the topic and relearn the language again.
What else I found is the C++ comes with a new set of extra standard libraries that made many of the obnoxious aspect of C++ much less tedious to use.
If something is so important that you feel the need to post it on the internet... It probably isn't that important.
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!
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.
No.
C++ abstracts away too much for that to be useful.
With C that kind of knowledge can be useful.
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.
The most dangerous drug
And lots of it
The HR process will grill you on C++ at a master level and yet somehow their entire production system is some Ruby abomination that has never seen the touch of a person with more than 5 years of experience in programming. They may need performance, but they're unwilling to commit to the changes required to get it. They may need a master C++ programmer, but they'll never use you to the full extent of your capabilities. And that doesn't really matter as long as they're willing to pay you like they are.
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
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 know it doesn't matter, which apparently is alot more than you do.
Btw, it might not be in any register, or even anywhere in memory.
-true masters have their own style of writing c++ code. They don't listen to the newest silver bullets, but instead can decide themselves, which techniques to use in each situation. Masters can dodge the pressure of bleeding edge features, and focus on the requirements. They implement the simplest possible code, without any advanced tricks or newest fads, never coding themselves to a corner. They don't listen when the world screams that the code is shitty, when they know better than everyone else. Masters develop their own coding standards and conventions, distinguishing his code from the gray mass that everyone else is doing. Going against the tide is important part of being a master.
Ada is a nice language. Too bad it's not used much.
C++ abstracts away too much for that to be useful.
Does it? :-)
I agree that C takes you very close to the bare metal. Yet C code is perfectly valid C++ code, and C++ allows you to achieve the same* level of control that you get in C, plus (as you pointed out) many useful abstractions that could hide what happens underneath.
However my point is that using some of those abstractions without understanding them could have nasty effects. Just a few examples:
Of course there are similar abstractions in other languages, but their implementation is often mediated by some framework/VM/etc that takes care of the shit for you to some extent. In C++ there's no garbage collector (although you can write your own) and you have full responsibility of what your code does. You can write your own tools for the job, your custom allocators, your libraries and abstractions, but you are responsible for most of it (new compilers help, thankfully).
To write good C++ you always have to see through the code, or you'll likely end up having sub-optimal stuff (which I concede can be enough in some cases).
* if you think that's not the case, please provide some examples.
C++ is a decent language to choose for many types of projects, and which pieces of the language depends on which type of project that is.
Embedded applications: There are several sets of best practice for embedded or hard real time c++, no exceptions (unbounded latency), no dynamic memory allocation (fragmentation), no dynamic casting (unbounded latency), no recursion and on and on. There actually seems to be a bit of consensus on this best practice, but it varies with the constraint of your particular system and if it needs some safety committee's approval.
Systems programming (OS or driver): I have never read any best practice documents for this, but the code I have read all looks like C with classes. few or no templates show up I've noticed.
Large scale performance critical stuff (games among other things): Widely varying best practice statements and all sorts of different coding, I have no idea.
Scientific (matlab but faster): who cares, you just want the answer, not the software, right? Don't read this stuff, it hurts. but it usually works.
I always look forward to /. c++ posts. I know I'm being clickbaited by Nerval's but its sooo fun!
refactor the law, its bloated, confusing and unmaintainable.
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.
Just asking. :-)
We suffer more in our imagination than in reality. - Seneca
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.
It's not 13bout knowing ex13ctly which register 13 is stored in, r13ther underst13nding how the compiler optimizes 13n 13lgorithm...
Ugh, d13mmit R13ndall...
What about the Ant People? They owe us money.
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.
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.
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:
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"
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.
Albert Einstein once said: 'Everything should be made as simple as possible, but no simpler'. I think that sums up the most important quality a good developer must have. It is very tempting to try to use every known feature of a programming language, and even in a simple language, the result is not pretty - C++ is far from simple, so you can imagine how ugly it can become.
That said, to master a technology means that you are able to use the difficult features with reasonable ease, when the need arises. That includes all the reviled features in C++, such as templates and meta-programming; there is probably nothing in the language that is simply superfluous, and learning how these features are used is a good idea (and an important part of that is knowing when not to use them).
Converting C program into C++ makes you realize how much boilerplate code C++ can remove.
constructors/destructors and replacing code using reallocs often with std::vector.
At the end of the day, know enough C++ so that you can simplify a 500 lines, error-prime C program into an equivalent, simple to understand, 250 lines C++ and you are my C++ hero!
I used to be a big fan of C++ until I realised how this language has so many hairy corners. When you start spending hours figuring out which feature is best to express a certain thing and have to consider all the implications of your choices, this is called mental masturbation. I prefer to focus my mental energy into actually solving problems than figuring out the intricacies of the language. The beast has become way too much complex for my taste! for that reason, I have returned back to C for the most part
Memory objects that clean themselves up after they go out of scope are the devil's work. The devil, I say!
Exactly. The devil creates work for idle hands, does he not? And what does not having to do vast amounts of error prone grunt work do if not leave hands idle?
SJW n. One who posts facts.
Being able to write readable code. It's a very rare skill.
Did you know 80 to 90% of the moderators on slashdot wouldn't recognize a troll even if one dragged them under a bridge.
C++ is a multi paradigm language, which allows to use low-level and high-level features. The art of coding in general is writing readble code, which uses the offered features wisely.
Which is in line with my comment: when the programmer uses proper highly-abstracted C++ mechanisms, micro-managing knowledge is not useful.
Good points. You convinced me that it actually might be beneficial to know what happens under the hood even with C++, to write professional code.
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.
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.
The learner is stuck in an infinite loop to learn C++. the master aborts and retries with D.
I started playing with C++ when I when into college in 1991. At one point I probably would have qualified as more or less a C++ expert. Then, as the language grew more and more insanely complex with each revision, I stopped trying to keep up on the whole language.
Nowadays I'm content to just make sure I understand the subset I normally use, read up when I come across a part I don't use, and ignore the rest. For my own programming, at least, the language has simply become too complex to be worth mastering.
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.
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"
Well, for starters '@' isn't a valid character in a token. Are you sure you worked on a compiler?
If you don't know about copy constructors, when & why to use them, you're not even a beginner.
And that in a nutshell is what's wrong with C++. It has bloated and bloated over the years, never deprecated anything of note and now its this behemoth that few compilers implement in its entirety and few programmers now how to use including all the gotchas, weird semantics and vast complexity.
Much like the English language, which is also quite useful and therefore widely used. Being useful over a wide variety of scenarios and being bloated-and-complex are often two sides of the same coin.
I don't care if it's 90,000 hectares. That lake was not my doing.
is there one particular thing or point that separates learners from masters?
I think you mean "what separates those who are still early in their learning from those who have pretty much mastered the topic."
As anyone who has "mastered" any topic of significant depth will tell you, there is always more to learn.
Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
All that being said, is there one particular thing or point that separates learners from masters? Knowledge of public well known libs, how to overscope and underscope legacy code without touching it keeping it manageable.
And that explains why $ is accepted but not @ how again?
#define $ printf("Works!\n")
#define @ printf("Nope\n")
If you can debug a generic memory leak or bounds overrun (which might not cause a crash until long after the breach), then you are no longer a beginner.
If you don't understand memory management then you are not yet a C++ programmer, let alone an intermediate one.
In my experience of interviewing, I have spoken to many alleged C++ programmers who can give a textbook definition for the terms 'copy constructor' and 'assignment operator', but who have no idea of their purpose, and their role in resource management. Unfortunately, I do not need to imagine the sort of code they write, because I have seen it.
You're comparing Apple and Oranges.
The PDP had 36-bit address space. Are there any modern CPU's that don't use powers-of-2 for registers and address space?
Instead of fixing the language and compiler, is a hack. We only need a few basic types built into the language.
Deprecate and Remove this "short" and "long" stupidity. It isn't 1972 anymore.
Yeah... C++ is great that way. It's my favorite language :)
"False hope is why we'll never run out of natural resources!" - Lewis Black
> You also forgot the BYTE, WORD, LONG, etc. types all over the Windows API. Sure, they're older than stdint.h, but they're yet another buttload of type aliases to keep track of.
I didn't mention it because that is a separate issue. Microsoft's stupidity is not part of C++, though they seem to have inherited some of it.
I guess someone at Microsoft liked C's "double", and hated the inconsistency with "float" so they added an alias System.Single in C# !
In contradistinction to System.Double
Much of the modern C++ dialects seem to be a winner. Certainly smart pointers and templates can be good, and are an improvement over the older C++ concepts. C++11/14/17 add features that make writing broken code harder.
Like anything, with much power comes much responsibility.
Lambdas and templates when overused make debugging next to impossible. I was working on some code that was so far nested in a bunch of templates, I couldn't use GDB to make any sense of it. Eventually I tore apart the templates to find a small bug in one of them.
Also the G++ compiler errors don't often point to anything meaningful. Missing a semicolon can result in a paragraph of errors, one may point at the actual error.
Don't get me wrong, I really appreciate C++, but you earn your pay using it.
The explanation is that the Standard doesn't allow either of them. If your favorite compiler allows the former, it's as an extension. If you really want to know the reasons behind compiler-specific behavior, ask whoever wrote your compiler.
"When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
In either case, once you turn the optimizer to high you don't know what's going on under the hood.
"When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
1) Read all of Scott Meyer's books. Not all of the rules in the old books apply anymore, but a lot still do, and they are not covered in his new books. 2) Go to https://www.youtube.com/result... pick out the videos you like and especially focus on Bjarne Stroustrup, Scott Meye, Herb Sutter, Nico Jousittis. Watch them. Look for other videos ( believe me there are more then you can watch in a lifetime unless you're a C++ superwaonk ) from other conferences. 3) Be familar with the newer concepts: variadic templates, perfect forwarding, move semantics, and concepts (lite). 4) Of course you have to have done some programming touching these things, but Scott Meyer's IIRC has never written programs. Finally, if there is something that needs to be done: for example, writing a specialized template library; and you balk because you do not have the basic knowledge needed to write that, then you are not a master.
Yes writing in C++ ( or even C ) is more expensive, but programmer cost is no longer the biggest factor in cost. Every cycle more needed by a program needs so many more milliwatts. Every cycle more generates so many calories which require so many milliwatts of airconditioning. Add enough and it really costs a lot. If you are writing for Android, it may mean that the Galaxy Tab 3 is not good enough to run your code, which means so many customers lost. Etc. It really has always been this, Moore's law just did a good job of obscuring the fact.
IMHO the best C++ programmer is the one that stays away from C++. When performance is a concern, C is the obvious tool of choice. If OO and speed of development are important, I'd opt for Java or Python any day over C++.... As a kernel engineer I may be a bit biased, however...
I remember reading slashdot the day that there was news that the C++ grammar had officially been proven to NOT have a bad left recursion in it. That was around 12 or 13 years ago, if I remember right. Up until then, nobody was actually sure, and every compiler writer had to take a slightly different approach to the things they were going to leave out of the compiler.
When you start with that as a foundation—20 years of having a language grammar that nobody is sure can be completely implemented—you're starting from a pretty bad place. The language was badly designed to begin with.
Then you've got the issue of Templates. Powerful? Yeah, for sure. But that's because the template language is turing complete on its own, and nobody realized THAT at the time either. I'd reckon (wildly, I admit) that 95% of the functionality of templates and template meta-programming is discovered functionality. ANY language becomes hyper powerful when you bolt another entire language to the side of it. They were just supposed to solve a problem with generics, and instead created a couple new ropes to hang yourself with.
C++ is a language that isn't so much as designed by committee as designed by falling down rabbit holes. What new, bizarre, unconfronted thing will we see next? Who knows?
It's really hard to master the entirety of C++, so you're better off knowing just a meaningful subset of it. Go and pick up Effective C++ and the sequel—they're basically just filled with the pitfalls of C++ to avoid and some decent things worth knowing. That's the stuff that tends to show up on C++ interviews. There's basic stuff in there and less basic stuff, but all of it is useful.
My company has a course on advanced C++ and C++ pitfalls, and even after 15 years, some of them caught me. Lots of them did, really. It was interesting because the room had a dozen or so programmers, and we all fell for completely different things.
C++ gives you a lot of rope to hang yourself with. The trick to using it well is to limit how much rope is around your neck at any given time—never do something cleverly that can be done simply, even if the simple way takes up a few more lines.
Oh, and comment your damn code. I don't care what language you're in, you're not a master of it until you know how to leave a trail of comments that even a new programmer can follow. When you're on your third 18-hour day, you have an imminent deadline and you're starting to go crosseyed, you'll either love or hate yourself based solely on the amount of good comments you left in your code. Things that are obvious when you're awake and well rested become muddy when you're tired and hungry and want to go to bed.
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
I had to look at the code for dbus. I found some "interesting" things. The first is DBusString and DBusRealString. One is effectively a String class. The other is a wrapper for the first class, that for some reason hides it's content. The second thing is something called something like DBusList, a linked list of generic pointers.
I can't say for sure, but I suspect that I could have replaced large chunks with C++ been slightly more efficoent. Just by a few simple tweaks which were obscured by all the extra verbiage and need to make sure such "localized" libraries were correct.
Hell, as I started to write this, I realized one major inefficiency. In C++ it would have been written using "vectors" contiguous array that are resizable instead of linked lists. This would make a big difference. Advancing the iterator to a linked list involves dereferencing a pointer. Advancing the vector iterator involves incrementing a pointer. A major difference as the majority of the time the link list increment will involve a cache hit.
So it seems a C++ version of dbus would be much faster then the C version.
As for readability. If you insist on readablity for all "programmers" then you wind up with the piece of shit that is the Google C++ coding standard. An intermediate C++ programmer will be able to understand, a highly intelligent beginner would. Someone who indulges in stupidity would not. If you see something like MyClass(MyClass &&my_class_in) and change it without knowing what it does, assuming it is wrong ( nevermind that it does compile ) you will get into trouble.trouble. I have a simple philosophy, I use any tool in C++ to organize the software as well as possible. Everuthing else follows from that.
Bzzt. Dollar sign is a gcc extension.
And MSVC as well.
or manage to proceed without collapsing the workshop, cause your iron ore was located under your workshop, so you started digging at the side...
And that is why I call sticking to C++ "mental masturbation".
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
Of those most are in old code from before TR1 gave us many standardised smart pointers, and
And
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.
Wow, you want to argue about the amount of "new"s per kLOC? Do you really believe that makes any sense?
At some point you have to instantiate your business objects. Regardless what they are.
The only way around real need for new is to have all memory statically allocated.
So the argument how many news and deletes are around makes not much sense.
Every Smart Pointer is initially initialized via a new.
Given you've never seen code without new in it (as your other post claimed),
I did not claim that. I have plenty of source files that have no new, nevertheless the whole program has a lot of news. Well, actually as I mostly use prototype based factories the news are centralized and they are bottom line few.
convince me that you're an uber-guru You pulled this out. I'm just an ex guru who is stuck with 10 year old C++ standards and thus my knowledge is declining and regarding C++11 outdated ;D
But that is half what I want ... when I do C++ in our days I stick to Qt and occasionally embedded programming. Real business logic should be done in a safer easier to use language, and I'm tired about the "who knows more about C++" pub talks :D
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
Erm, perhaps you should learn to read.
The parent claimed a good C++ developer can tell from every line of code, which registers are affected.
Which is clearly nonsense.
However: show me the trick how such a variable may not be "anywhere in memory" ... nice try.
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
You did claim that.
And there is not much to understand about those lines.
Obviously you have a mental problem, or why do you offend me by calling my language offensive?
Is that a new fractal approach to discussion or simply a misplaced double recursion?
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
On a SPARC processor it would most definitely be in a register ... read about register windows and such.
The first 8 local variables in a function are in registers, so are the first 8 parameters to the function.
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
OK? The point is that it's not standard. Macro names must follow the same rules as variable names, ie, letters, numbers, and underscores only; and can only start with underscore or letter.
I'm not sure why you're want a macro named '@' anyway. C++ already has punctuation strewn everywhere. The last thing we need is more funny characters. :-b
That question is actually rarely asked.
It was more an example for the "complexity" of C++ that might occur in a single line of code.
The funniest supposedly difficult question was about the size of byte, char, short, int etc. in Java and char, short, int etc. in C.
I found that question retardedly silly and when I worked for that company in the end I met the interviewer and asked why he asked something so simple.
The answer was: I was the only one out of ~ten interviewed persons who answered this simple question instantly and correct.
When I point out an error of the interviewer (usually it is in his papers and not an error by himself) I'm obviously polite. But I'm also resolute. I take crafting software serious and being certain about facts and avoiding mistakes/defects is very important to me.
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
Why would you say this? This is not an attempt to argue but an attempt to see your point and to listen to it objectively. What would you recommend besides C++? I, personally, was a programmer for part of my job and wrote a lot of software specifically to do the tasks we needed to do to be successful. A lot of that was written in C++ and the vast majority of the rest was in C. Well, except for web-facing things...
Seriously, why would you say that and what would you recommend besides this? I still like to play around, if I build something interesting then I just give it away, so I am very receptive to learning something new or spending some time with a language I have not used in a while.
"So long and thanks for all the fish."
Master C++? What an oxymoron. It is quite difficult to master C, even though it is 1/10 (1/100th) the complexity of C++.
People that are smart enough to master C++ are probably too smart to get sucked into doing lowly programming for a living.
And yes, I have 30+ years of C coding experience, so I guess that makes me a moron.
The English language isn't defined by a committee which has the opportunity to fix longstanding issues with the language or deprecate redundant, arcane or dangerous functions and code. C++ does have this opportunity but never takes it. Instead it just heaps another layer of features on top of the old, we all sit around for years waiting for the compilers to implement this mess properly and by then another standard has come out.
No no no, you wrote a C++ compiler and you don't even understand why C++ is successful? It's because it still compiles all the old code. You DO NOT deprecate types that are in use in working code. I'm not sure "long double" is in fact used in any working code, but "long long" is THE 64-BIT TYPE so you don't fucking deprecate it.
This is a stupid justification. Gcc already has switches for different standards, -std=c++98, -std=c++11 etc. There is absolutely no reason whatsoever to stop certain functions, and language features from being deprecated or removed in new standards. If people still want to compile old code they can throw the switch in there and they get that functionality. If they don't, the compiler defaults to the latest version of the standard.
So that it immediately sticks out instead of using an alphabetical character which would probably be lost as "noise."
> The point is that it's not standard.
That's not the entire picture.
GCC Tokenization says this:
C++ does have this opportunity but never takes it. Instead it just heaps another layer of features on top of the old,
Correct, and that's an excellent example of why C++ is both popular and messy. If the C++ committee started "cleaning up the language" by removing backwards compatibility with old features, the language would split into two languages ("old C++" and "new C++"), neither of which would have the compatibility or the marketshare of the current C++.
I don't care if it's 90,000 hectares. That lake was not my doing.
Excuse the lack of quoting, on phone.
First, business what now? There is so much more to C++ than that. I doubt I've encountered one this year. But when I do, they can either be shoved into a container, or instantiated with make share or make unique.
There's no need for new anywhere.
But it seems like you're massively misinterpreting what I say as no news happen under the hood. Certainly they do, but they're all safely hidden away, so lifetime is managed cleanly and safely for you. Not sure how you came to that conclusion, but whatever.
And dude, if you call yourself an ex guru, you're implying that you think you were a guru. It's rather tacky to describe oneself as such, not to mention lacking in credibility. Stroustrup and etc never call themselves gurus.
SJW n. One who posts facts.
BLAS and LAPACK are libraries.
You need to differentiate between the dynamics of a language (ie: FORTRAN vs. C/C++) and the libraries available.
FORTRAN 77 vs. FORTRAN 90/95 and up are completely different species.
So we start talking about eigen systems programming in one language vs. another. Well, when was that library written? In what version of what language? Just because it is a widely available library, does that mean it is any good internally?
Theoretically, if there were a fully C++ written linear algebra (or any other library) that isn't linked with some gawd aweful old FORTRAN code or (asm{ ... }) down in the bowels of the machine, then you could make an honest comparison. But since everyone seems to start off with poor examples from free programming cook books and someones opinion from the web, without seriously (re)designing or understanding the patterns used to accomplish the task, you then get what you get (ie: crap).
After long time programming in FORTRAN 77/90/95/etc. and C, and C++, and many other languages I would have to say that most programming comes down to energy expenditure. If a grad student comes out of school after programming mainly in Matlab the first thing that person is going to suggest for a programming project is going to be Matlab. This same phemomenon is what has kept FORTRAN alive. In the case of FORTRAN , the legacy dependency code of many scientific applications ultimately led to the refactoring of FORTRAN as a language rather than discarding all that code. It amounts to loss aversion and an unwillingness to learn new languages in entrenched users.
Why not create an open scientific co-processor card spec that has hardware advanced functions instead of farting around with GPU discretes that were originally designed for video games. Then we could just have linear algebra calls in the standard math library that are driven by math hardware instead of 50 years of accumulated CPU work-arounds for 8088 code (that was sarcasm).
Progamming always seems be 'VHS instead of BETA' because most programmers doing applied programming for science arrive in industry with only single language skills and programming was only a sideline from whatever thier degree was in.
I also continue run into 'C' programmers who refuse to learn C++ . it's some kind of religion thing. Deities will apparently smite them if they crack a manual.
C++ gives a nice balance between high performance and relatively good safety.
Huh? Relative to what?
C++ was my primary language for quite a few years. I was very good at using it effectively while introducing far fewer bugs than most coders I encountered, but I would never call that language anything near safe.
Maybe you're talking about a subset of C++ that does not include things like pointers and arrays?
Relative to C# or Java, for example.
Raw pointers and arrays can be avoided when writing C++. Smart pointers and vector are the alternatives.
Yes, so? If I was using a SPARC I'd be assuming register based passing.
If it was to be used in a calculation, and the architecture doesn't have operations on constants then I'd know it would go into a register. I wouldn't know which register, but that wasn't the point. The point is knowing it will be stored in a register. In the case of a SPARC, and if we're using it as a function parameter, and if there are fewer than 8 parameters, and if the parameters are all simple types, then it will be stored in one of the upper 8 registers in the window, and a competent programmer with low level SPARC experience will be able to tell you exactly which.
No, you miss the point completely.
The GP claimed a good C programmer can tell from every line of code (C code!) which registers of the processor are affected.
Which clearly wrong. No one knows that. Not even on a SPARC or Power PC where C code to register mapping is pretty straight forward.
And you are now running of into the wild arguing for the arguments sake.
and a competent programmer with low level SPARC experience will be able to tell you exactly which. ... they are simply stuck behind on portable assembler and often have no clue about any higher level architecture or language concept ... regardless what language or architecture.
Wrong! Every programmer who gets an introduction how SPARC register windows work, will grasp that immediately. No special "I'm a super competent programmer" skill is needed. That is exactly my point. People should simply stop to claim that a C programmer is by definition more competent than any "non C programmer".
They are not
Then they come and claim: "look at that! I know in what register that variable goes, you don't!" And how relevant is that exactly for 'what'?
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
I did not call my self an ex guru, some idiot called me an "uber guru" and I told him, I was perhaps once a guru. Long ago.
It does not matter how you call yourself, the question is what you are :D
I never call myself a master in martial arts, however I am ...
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
I never call myself a master in martial arts, however I am ...
you just did.
SJW n. One who posts facts.
If you think so :D
I don't think that pointing out a fact to another person falls into "calling yourself something" .
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
I don't think that pointing out a fact to another person falls into "calling yourself something" .
Ah, so it's a fact that you are/were a C++ guru, eh? So my man, what precisely defines guru that makes such thing a fact? Calling yourself a guru is akin to insisting your nickname is Mr Awesome.
SJW n. One who posts facts.
Er, you seem to lack reading skills.
I did not use the word guru about my C++ skills before someone called me mockingly an "Uber Guru" and I made perfectly clear that I once "perhaps was a Guru" but don't feel like that anymore ... after all I stopped using C++ hard core around 2000 and afterwards only used it it from time to time.
But seems you are obsessed with that word :D
As long as I can still show the youngsters how stuff works I definitely don't feel "underquallified" regarding C++. though.
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
I see. You were indeed talking about a subset of C++. Thanks for clearing that up.
Yep, technically you are correct.