News for hackers. Stuff that matters.
Re:Deep C and C++ (2011) by hacknat on Wednesday October 23, 2013 @02:48AM (#6597293)
I'm not so jaded as to think that deep language understanding isn't a useful or good thing, and I'd like to think I have some myself. However, deep language understanding is not what separates the great engineers from the good ones.

In an interview, I would much rather hear a person say something about a statically declared variable with no initialization being poor code to leave behind for the next person than some arcana about the standard.

Re:Deep C and C++ (2011) by ksk on Wednesday October 23, 2013 @04:28AM (#6597586)
>In an interview, I would much rather hear a person say something about a statically declared variable with no initialization being poor code to leave behind for the next person than some arcana about the standard.

Why are you forcing those two choices? One could be well-versed with the arcana AS WELL AS point out that bit about statically declared variable ..

The problem IMO is most programmers cargo-cult/copy-paste/stackoverflow their way into programming jobs. No, that does not mean you never ask for help. No, that does not mean you never copy-paste. (Phew!)

Its sort of like when you're learning math. Great mathematicians can understand the theory and just apply it to whatever problem they come across. Its because they have a very solid foundation underneath them. They wield their knowledge like tools and can just build anything with those tools because they understand those tools very well. Most students however just learn the patterns of the problems. And once they know enough patterns they can solve problems which fit into one of those pre-understood patterns.

The people who are deeply knowledgeable about the language are good at knowing the boundaries of the language, knowing when you're using constructs that are not valid-syntax (which still compile), etc. The social aspect of 'good comments' , 'readable code' or 'maintainable code' is also important. You can have programmers that do both. Ofcource those programmers will never work for 'you' (not you, personally..) because most programming jobs are shitty and do not require programmers of that skill. You'll find them toiling away in anonymity, working in research labs, working on compiler optimizers or operating systems or some other domain with challenging technical problems.

Re:Deep C and C++ (2011) by cousin_it on Wednesday October 23, 2013 @07:52AM (#6598162)
> Great mathematicians can understand the theory and just apply it to whatever problem they come across.

As someone who's both a mathematician and a programmer, I think that analogy glosses over an important difference, which is also relevant to why many people refuse to memorize certain things.

Good mathematical theories are internally consistent in a very strong sense. When you're learning them, you feel like you're learning something eternal that could not possibly turn out any other way. If you forget half of calculus, you can reconstruct it from the other half, and the reconstruction will be unique.

The details of programming languages, like C and especially C++, are not like that. For many mathematicians who would otherwise make excellent programmers, the details of C will feel like something not worth memorizing, because they don't make sense - they are not an inevitable, provably unique solution to any problem.

To a mathematically inclined mind, programming concepts form a hierarchy depending on how "inevitable" and worth memorizing they are. Concepts like computability, lambda calculus or big-O complexity are near the top, syntaxes of specific languages are lower down, and API details are at the bottom. That also reflects the rates of change: math doesn't change, languages change every decade, and APIs change every year.

If I want to hire a programmer for the long term, as opposed to getting quick help on my current project, I will be mostly asking them about concepts from the top of the hierarchy, not what static means in C. Of course some people will disagree with me and demand detailed knowledge about static or templates or whatnot, while dismissing mathematical questions as "puzzles". Maybe that's also a valid style of programming, I'm not sure...

Re:Deep C and C++ (2011) by tel on Wednesday October 23, 2013 @08:12AM (#6598222)
A thousand times this. Mathematicians are spoilt by maths riches of eternal problems. CS ought to be too, but so many are instead fascinated by the 10 year, 2 year, 1 week problems around the fashion of a programming tool.

No wonder everyone is always talking about the rapid pace of learning in high technology.

Re:Deep C and C++ (2011) by ksk on Wednesday October 23, 2013 @08:57AM (#6598379)
No, I too am talking about a hierarchy of internally consistent knowledge.

Have you implemented a compiler or a interpreter for a popular language? I could be wrong but I strongly suspect you haven't. If you have ever implemented a compiler you understand the language at a fundamental level and when stumped with a bug or a highly technical puzzle or what have you - you get that "aha" moment where its like "Ofcource ! How else could it be. This language feature must be using this construct because of X or Y reason and the compiler has to work this way because this part here doesnt allow for it to work any other way, etc ,etc and the optimizer has xyz amount of scratch registers so abc condition could never happen, and on and on."

Re:Deep C and C++ (2011) by cousin_it on Wednesday October 23, 2013 @09:11AM (#6598455)
My comment was talking about a stronger kind of consistency, maybe "inevitability" would be a better word for it. You could make many different tiny changes to the rules of C and still end up with a workable programming language. (Many people have done that, there are tons of languages derived from C.) You could say that the rules of C are "random" - after learning the first n rules, you cannot use logic to predict the n+1st. So learning the rules of C is more about memorization than logic. Math is different: when you learn a piece of math, you know exactly how it follows logically from the pieces you learned before, and you know it couldn't be any other way. That's why it feels more reasonable to me to inquire about math, rather than the details of C.

Lawrence Kesteloot said it well at http://www.teamten.com/lawrence/writings/what_interests_me.h...:

On a planet far away they have universities. In those universities they have many of the same subjects we teach here, such as math, biology, philosophy, history, computer science, psychology, and literature. But although the subjects of the classes are the same, the contents are different. They teach a history class, but their history is different from ours. So are their biology and literature. I’m not interested in subjects where their content is different from ours.

In some classes, though, the content is the same. They’re teaching the same physics class (assuming they’re at the same level of understanding we’re at) and the same math classes (with a different base). In computer science most of what they teach is different, but their theory of computation is surely the same. Their biology is different, but their teaching of evolution is the same. Their philosophy is vastly different (think how different Eastern and Western philosophies are on earth), but their philosophy of science is probably very similar.

Even if this point of view doesn't make sense to some people, I subscribe to it because it's very inspiring to me. YMMV.

Re:Deep C and C++ (2011) by ksk on Wednesday October 23, 2013 @09:38AM (#6598607)
>You could say that the rules of C are "random" - after learning the first n rules, you cannot use logic to predict the n+1st.

You're mis-applying things here. The language is not something to be theorized by itself. Like any (edit:spell) other body of knowledge, it has its own set of initial axioms and the 'C standard' which defines the language is simply a collection of rules other meta-knowledge which are based on those. In that sense it is internally consistent. Thats what I meant.

Re:Deep C and C++ (2011) by cousin_it on Wednesday October 23, 2013 @10:07AM (#6598792)
Yes, you could say that the C standard is a formal theory. It won't be a very interesting one to a mathematician though, because it's huge and describes only one thing, C. There are no special considerations to single out that theory from a huge pool of similar ones. It's like devoting your life to the study of one particular differential equation with a thousand terms, which was written by a committee. Why not the other equation which has a minus instead of a plus over there? Why not study differential equations in general?

Compare with a formal theory like PA, which fits on a page and describes the natural numbers. Proving a theorem about PA has implications everywhere, because natural numbers are everywhere. Or if we want to talk about computation, there are many formal theories with short descriptions that have much more to say about computation in general.

Re:Deep C and C++ (2011) by ksk on Wednesday October 23, 2013 @10:38AM (#6598980)
I am not against your POV ! I think we largely agree on most things here. I wanted to correct what I perceived to be a mischaracterization of my 'off the cuff' analogy.
Re:Deep C and C++ (2011) by cousin_it on Wednesday October 23, 2013 @11:19AM (#6599238)
Yeah, from your reply to patrickmclaren I understood the point you were trying to make, and I agree with you. Sorry for misunderstanding you so persistently.
Re:Deep C and C++ (2011) by patrickmclaren on Wednesday October 23, 2013 @09:56AM (#6598733)
Can you deduce the majority of the C language from these initial axioms?

You misunderstand the usage of consistency regarding mathematics. It is not the same. These rules which compose C are design decisions, and whether they are entirely artificial. Mathematical consistency arises from imposing axioms, following which there are no decisions to be made.

Re:Deep C and C++ (2011) by ksk on Wednesday October 23, 2013 @10:16AM (#6598847)
>Can you deduce the majority of the C language from these initial axioms?

Well, no. You can deduce A language but it might not be C.

I sense we're going down a fruitless path here. In my first post I was only giving an analogy of someone understanding math at a fundamental level to someone understanding a programming language at a fundamental level and how they could inform similar abilities/prowess in people when it comes to dealing with complex problems/etc.

Re:Deep C and C++ (2011) by pandaman on Wednesday October 23, 2013 @10:36AM (#6598970)
My guess you apply your experience with some bizarre language (PHP?) to C, which you never learned. C and C++ are internally consistent in the same way a math theory is. Many programming languages are not, indeed.

> You could make many different tiny changes to the rules of C and still end up with a workable programming language. (Many people have done that, there are tons of languages derived from C.)

Coincidentally, same is Math. I give you Euclid's Fifth postulate as an example.

>You could say that the rules of C are "random" - after learning the first n rules, you cannot use logic to predict the n+1st.

This depends on how do you enumerate these rules. If you learn that auto variables are allocated on the stack it's easy to predict that you cannot return their addresses and there are not going to be default initializes for them.

Re:Deep C and C++ (2011) by pkolaczk on Wednesday October 23, 2013 @03:07PM (#6600909)
Saying that C++ is internally consistent at all is a huge exaggeration. Actually I'd be very careful with stating it is more consistent than PHP. Both have many sharp-edges and in both there are plenty of features that feel "tacked on" and are non-orthogonal to each other. E.g. why I can't make a generic (template) function virtual or why I cannot overload some overloadable operators to have exactly same semantics as the builtin ones.
Re:Deep C and C++ (2011) by nly on Wednesday October 23, 2013 @08:15PM (#6602656)
You can't make a member function template virtual because it's just a template, the function doesn't exist until it's statically instantiated. Instantiation can happen across units of compilation, making it impossible for the compiler to generate a vtable with all the instantiations within it. It's not a "tacked on" feature/limitation at all, and I don't see how any statically typed language that allowed function overloading could really work around that issue.

I'm not sure what you mean about the operator overloading thing.

Re:Deep C and C++ (2011) by pkolaczk on Thursday October 24, 2013 @04:02AM (#6603904)
This was a rhetoric question. I perfectly know why I can't do that in C++. C++ does not allow this because of particular generics implementation (done by static compile-time macro expansion), not because those two features are inherently contradictory. In fact, they are completely orthogonal and Java/Scala/C# have no problems with that, despite being statically typed.
Re:Deep C and C++ (2011) by pandaman on Wednesday October 23, 2013 @11:31PM (#6603270)
As nly pointed out - the virtual template function just does not make sense if you understand what it is. As for the operators I'd guess you mean && and ||? You cannot make them shortcut because the user defined operators are just functions and functions in C++ do always evaluate their arguments.
Re:Deep C and C++ (2011) by pkolaczk on Thursday October 24, 2013 @04:08AM (#6603927)
Virtual generic functions do make sense and many languages allow them. The problem is C++ implements them by compile-time macro expansion (called templates), which renders them impossible.

Template types are also not really first-class members of the type system. The compiler can't really reason about them, it only type-checks them after expansion, when all the genericity disappears. This is completely different than the fail-fast approach in Haskell or even Java, where the code is type-checked at the generic level.

Don't get me wrong - templates is an awesome, extremely powerful feature of C++, but it doesn't play well with the rest of the language, and really feels tacked-on.

Re:Deep C and C++ (2011) by pandaman on Thursday October 24, 2013 @10:32AM (#6605451)
Sure, generic functions are awesome when you don't care about performance. This is why C++ does not have them. If you knew nothing about C++ and somebody told you "here, we have a language with zero run-time overhead, can you guess if we managed to implement generic functions?" what would you say?

Function templates are not generic functions. Same as template classes are not types. They play really well with the rest of C++ but I agree, not so well with the rest of Java or Haskell :)

This is the major problem people nowadays have with C++ - they learn some "practical" high-level language in school (usually riddled with random stuff, judging by how much people here are pissed with my mentioning of PHP) and try to think about C++ in concepts of such a language. Then blame C++ for not being their favorite language.

Don't get me wrong. I am quite happy with this making my skills very rare and expensive, giving me both job security and decent compensation. I also want to thank all the people spreading the "C++ is complex hodgepodge of completely random things so it's impossible to learn" idea :)

Re:Deep C and C++ (2011) by pkolaczk on Thursday October 24, 2013 @12:01PM (#6605987)
Generic functions like in Java/C# can be implemented efficiently and with zero overhead. There is nothing that prevents a JIT compiler to generate several versions of the code optimised for different types at runtime, exactly like C++ does at compile-time. Some VMs already do that to some extent in order e.g. to better inline calls for the generic argument. Still, those optimisations are in their infancy, but the situation improves with every year.

"Don't get me wrong. I am quite happy with this making my skills very rare and expensive, giving me both job security and decent compensation."

Eh? C++ skills are not any more expensive than decent Java/C#/Python/(put whatever mainstream language here) skills. Who told you that? This is supply-demand. There is lower supply of C++ coders, so some may think the prices should be higher, but in fact it is compensated by lower demand. C++ is also still being taught at schools, so those skills are not that rare as, say, Haskell, Erlang or Go.

Re:Deep C and C++ (2011) by pandaman on Thursday October 24, 2013 @12:49PM (#6606313)
How do you figure out the types at run time with zero overhead? I guess we have different concept of "zero".

As for the price of my skills - my paycheck told me that. And sure, it could be low demand (there are vacancies in my field, that had been open for years, but I don't really know what kind of demand there is for Python, could be decades for all I care). I am just happy for my compensation and if others have more expensive skills - I am happy for them too :)

Re:Deep C and C++ (2011) by pkolaczk on Thursday October 24, 2013 @01:04PM (#6606434)
Nothing is truly zero overhead. C++ templates are neither, because they create some overhead in code size which is obviously non-free (both space-wise and time-wise). Zero-overhead for me = optimized to the point that noone can notice. There is no problem for a VM to generate 10 versions of a tight loop, every one optimised for particular type, with a switch for the type right before entering the loop, or the whole method, or even a whole call-tree.
Re:Deep C and C++ (2011) by pandaman on Thursday October 24, 2013 @01:40PM (#6606657)
We also mean different things by overhead. For me (and the C++ committee) it means something that is done in addition. So for me templates create zero overhead as the do not produce more code than the same, non-template code. In practice, templates produce less code as there is a higher chance to fold common code from the instantiations of the same template than from many handwritten functions.
Re:Deep C and C++ (2011) by pkolaczk on Friday October 25, 2013 @04:07AM (#6610350)
Comparing to other generics implementations - they do add a lot of code, much more than is really needed to achieve good performance. Sure, some of this code can be reduced at linking stage, but for this to work you need to statically link everything which has its own set of problems (overhead of repeated code in every binary).

IMHO the approach is a great example of premature optimisation: generate 2^N versions then try to fold some similar ones to save space. Much better approach is: generate 1 version and specialize small parts when really needed. Technically, assuming sufficiently smart compiler, both would end up with exactly the same code, performing exactly the same, but the latter solution is preferable for other non-performance wise reasons (like better type checking, ability to distribute binary libraries, faster compile times, etc.).

BTW: I still often find Scala containers to be often much faster than C++ STL. But this is probably for much different reasons than template/generics implementation.

Re:Deep C and C++ (2011) by pandaman on Friday October 25, 2013 @10:25AM (#6611773)
I have lost you. Are you still arguing that C++ is internally inconsistent because it's not doing stuff that Java does? Are you arguing that templates add a lot more code than a VM and JIT compiler and languages with generic functions are as efficient as C++?

In the first case - I fail to see how it follows. In the second case - our levels of expertise is too far apart to discuss anything. I am not saying you are not qualified, I might be just too out of the loop and missing some dramatic advances in Java, Scala etc.

Re:Deep C and C++ (2011) by cousin_it on Thursday October 24, 2013 @11:48AM (#6605909)
I guess it's a matter of taste. Almost every time I get puzzled by some design decision in C++, it makes sense at first but then falls apart on closer inspection. The most recent example amused me so much that I wrote a blog post about it: http://slepnev.blogspot.ch/2013/07/printing-int-in-c.html. My experience with Haskell so far has been the opposite, design decisions make no sense at first but then turn out to be really smart.
Re:Deep C and C++ (2011) by pkolaczk on Thursday October 24, 2013 @01:33PM (#6606608)
@cousin_it: I have exactly the same feeling about C++ and Haskell. Another feature of this kind is inability to do virtual calls from constructors / destructors. Sure, the explanation makes perfect sense and leaves you with a feeling that C++ got it right and the rest of the world got it wrong. C++ protects you from accessing not-fully initialized object, awesome isn't it? Unfortunately it gets in the way when using factory methods (which are perfrctly ok to be called from the constructor in other languages) and is a source of subtle bugs.
Re:Deep C and C++ (2011) by pandaman on Thursday October 24, 2013 @12:41PM (#6606238)
C++ library is not something that is supposed to be very useful, it's something that is supposed to be available. I, for one, never used that library in my 15 years of professional programming.

Even though the library is covered by the same standard as the language it's not a part of the language and, in practice, is not even available all the time.

Re:Deep C and C++ (2011) by pkolaczk on Thursday October 24, 2013 @12:52PM (#6606329)
@pandaman: Just a minor nitpick about the statement that C++ library is not a part of the language: How come 'new' (builtin language operator, and reserverd keyword) can throw 'std::bad_alloc' (library construct) then? ;)
Re:Deep C and C++ (2011) by pandaman on Thursday October 24, 2013 @01:28PM (#6606574)
New itself does not throw, the allocation function does. Nobody makes you use the library allocation functions.

A better nitpick would be dynamic_cast throwing under some conditions. But then, how does it make iostreams the part of the language? There is just a typedef in the std namespace that aliases the type for some optional, compiler specific, data.

Re:Deep C and C++ (2011) by pjmlp on Wednesday October 23, 2013 @04:06PM (#6601315)
In C++'s case "The Design and evolution of C++" is a good read to understand how the language turnout that way and why certain compromises were done.
Re:Deep C and C++ (2011) by pkolaczk on Thursday October 24, 2013 @04:10AM (#6603929)
Sure, all the inconsistencies have a nice explanation, I never questioned that. PHPs === operator has a nice explanation, too.
Re:Deep C and C++ (2011) by mden on Wednesday October 23, 2013 @10:57AM (#6599101)
I think the point was that mathematics relies on a small set of postulates from which you can derive everything else. Changing a postulate results in a separate system. The same is true in programming languages, but the number of postulates is very large compared to mathematics to the point that their utility is greatly reduced. And also there are so many languages each with its own postulate set that it's really inelegant when compared to mathematics.

Another way to put it is, learning the postulates for langx doesn't provide enough value for many to be worth doing.

Re:Deep C and C++ (2011) by pandaman on Wednesday October 23, 2013 @11:21AM (#6599251)
>I think the point was that mathematics relies on a small set of postulates from which you can derive everything else.

And I agree, this is one of the assertions my opponent has made. I did not go to refute it because, if not outright false, it's disingenuous.

>Another way to put it is, learning the postulates for langx doesn't provide enough value for many to be worth doing.

This is also true, same goes for everything else. I make money using C - I learn C's postulates. If somebody paid me to use topology - I'd learned topology postulates. What would be stupid if I were paid to use topology but said: "it's hard to learn and it makes no sense for me because I don't like mathematics and don't know any other math discipline so why would I all of sudden learn topology's postulate when I can copy formulas from the net and ask questions on manifoldoverflow.com?"

Re:Deep C and C++ (2011) by pessimizer on Wednesday October 23, 2013 @12:23PM (#6599689)
Trying to derive C from its postulates is like trying to derive 70s television from its postulates. Most of C is an accident of history.
Re:Deep C and C++ (2011) by pandaman on Wednesday October 23, 2013 @01:08PM (#6600069)
I am not sure what is your point now. Are you aware that most of the math is way older than C?
Re:Deep C and C++ (2011) by kazagistar on Wednesday October 23, 2013 @11:37AM (#6599366)
Mathematicians tend to miss one important ideal; a major consumer of your code needs to be other programmers who read it. Hence why mathematicians often end up writing code that, while more terse, is a jumbled mess of single letter variables and layered abstractions.
Re:Deep C and C++ (2011) by alexk7 on Wednesday October 23, 2013 @11:11AM (#6599192)
Standard mathematical notation is not inevitable and is not unique. It is on par with most programming languages for being quite random. Both programmers and mathematicians use an imperfect tool (programming language, mathematical notation) to achieve goals that may, or may not, be eternal.
Re:Deep C and C++ (2011) by cousin_it on Wednesday October 23, 2013 @01:01PM (#6600023)
That's a fair point, and math notation is famously more ambiguous than programming languages. But it seems to me that the concepts denoted by math notation (e.g. numbers, arithmetical operations, functions...) are inevitable and unique, while the concepts denoted by strings in a programming language are much fuzzier and more arbitrary (except for languages that have a denotational semantics, which are few and far between).
Re:Deep C and C++ (2011) by agentultra on Wednesday October 23, 2013 @01:52PM (#6600409)
People often speak of the axioms in maths when they describe how, "elegant," and, "consistent," it is. I'm not a mathematician but I've read Gödel's "proof" and know enough that there are no guarantees. It matters what system of axioms you use and requires the reader to recognize the limits of those axioms in defining the system of logic they they imply. Or some such.

Point being that there is no system that is complete. There are large bodies of mathematics these days that have specialized their notations and axioms to their domains. It is incredibly difficult to maintain a masterful knowledge of all of their idiosyncrasies and notations.

Re:Deep C and C++ (2011) by blt on Wednesday October 23, 2013 @05:30PM (#6601847)
Scheme has a bit of flavor of the "inevitable" to me...
Re:Deep C and C++ (2011) by epsylon on Wednesday October 23, 2013 @09:35AM (#6598584)
> Why are you forcing those two choices? One could be well-versed with the arcana AS WELL AS point out that bit about statically declared variable ..

You're the one forcing the choices.

He's just saying that one should consider another metric to gauge developers, that is knowledge of good software practices over deep language arcana wisdom. And he's saying that whatever the knowledge depth (or lack of) of a candidate on the C or C++ language, he'll choose the one with better software practices. (Of course, the two metrics are slightly correlated, but being an expert on C trivia doesn't necessarily makes you a good developer)

Life is too short to become an expert on C's dark corners, and I'm not even talking about C++'s.

Re:Deep C and C++ (2011) by ksk on Wednesday October 23, 2013 @10:35AM (#6598963)
>You're the one forcing the choices.

"I would much rather [a person do X] than [a person do Y]"

I parse this kind of statement as a person doing X is more important than a person doing Y. I stated that I thought both were achievable. How have you parsed it?

Also trivia implies some memorized factoids. The entire point of the article is having an understanding of the underlying implementation of the compiler, maybe the implementation of the standard library, or the OS or the hardware ADDS to your knowledge about C making you a much more complete/well-rounded developer. Calling it C trivia is baffling to me.

>Life is too short to become an expert on C's dark corners, and I'm not even talking about C++'s.

Agreed !

Re:Deep C and C++ (2011) by sanderjd on Wednesday October 23, 2013 @12:06PM (#6599568)
> Also trivia implies some memorized factoids. The entire point of the article is having an understanding of the underlying implementation of the compiler, ...

That's some of the point of the article, but some of it is also about memorized factoids. There is a lot of focus on what different versions of the C standard say about different things, which is just factoids. There is a lot of focus on how different declaration syntax behaves (statics, linker visible, etc.), which is just factoids.

Re:Deep C and C++ (2011) by ksk on Wednesday October 23, 2013 @01:54PM (#6600424)
If you had to write code for a platform and the only compiler available was C89 compatible, you better know what syntax the C89 standard says is legal and not legal. Its simply called knowing the language. By your implied definition I see every single thing that anyone reads/learns as a 'factoid'. In my mind factoids imply some useless disconnected fact like the number of restricted keywords or the number of pages in the standard or the preferred wine of the standardization committee(its called beer I think :P). I guess we have a difference of opinion on that.

Also the difference in syntax and translation unit/linker behavior is not a random fact. Its the culmination of the thought process that goes into designing the language and also knowing a bit of the theory behind classical compilers/linkers.

Re:Deep C and C++ (2011) by sanderjd on Wednesday October 23, 2013 @03:12PM (#6600954)
It is probable that we have a disagreement about what counts as a "factoid", and maybe it's not a great word to be using ( I took it from the parent), but I do think there are real differences between some things you're conflating. Working within the framework of your example, I think understanding how compilation units and the linker work is far more fundamental than knowing when the the "static" keyword impacts linking and when it doesn't. If I know that I need some way to make my variable visible outside my compilation unit, I can look up the syntax to do it ("factoid"), but if I don't understand how linking works at all, I'm missing a more fundamental mental model. Of course, I absolutely think that a C programmer should know the syntax, it's just less important to remember such things than to understand the model.
Re:Deep C and C++ (2011) by pjmlp on Wednesday October 23, 2013 @04:38AM (#6597624)
> You'll find them toiling away in anonymity, working in research labs, working on compiler optimizers or operating systems or some other domain with challenging technical problems.

Sadly you are required to move for such jobs, which is not always an option.

Re:Deep C and C++ (2011) by kamaal on Wednesday October 23, 2013 @07:34AM (#6598096)
And best of all is such things are not fashionable. Take a round of HN or any other place where programmers hang around. Take a note of how many articles, blogs posts, essays, tiny libraries, frameworks etc are written for languages like Javascript, or Python, or Ruby, or Java.

Compare this with C. There is a degree of serious technical focus that languages like these demand for big projects. Embedded systems, Operating systems, Databases, compilers etc. A big part of software world uses these languages on a daily basis. But there is no where the kind of hipster crowd, these languages have the web frameworks or languages have.

Even if you spend some time searching for resources on the net, there are few that teach deep C skills. There might be one or two books out there which haven't been updated in 2 decades.

By and large, these are unfashionable fields to work in. The barrier to entry is really high, Success comes only with seriousness and application of well focused effort, mistakes are expensive and they warrant serious RTFM'ing the hard way- to write to some real serious code.

Re:Deep C and C++ (2011) by ksk on Wednesday October 23, 2013 @09:30AM (#6598548)
I don't know why you have C up on some pedestal. Its not really a 'hard' language to learn or grasp.

Sure some languages take less time to learn than others. But every single language makes tradeoffs. For e.g performance vs productivity/usability OR static typing vs dynamic typing is a common theme when discussing C vs {Java, Python, blah}.

Also, your comments falsely compare the difficulty of the TASK with the difficulty of the IMPLEMENTATION/LANGUAGE. They are not the same! Take any advanced applied math algorithm and implement it in Python. Its not 'easy' by any means.

The domains you mentioned have a higher barrier to entry because the tasks themselves are difficult. The languages and technology used are simply variables in a much larger optmization problem that also includes monetary/human/computing/time resources as variables.

Re:Deep C and C++ (2011) by pjmlp on Wednesday October 23, 2013 @03:11PM (#6600946)
Small rant, so take it with a grain of salt.

Personally I don't care about C, due to its unsafe by default design and my background in safer languages for systems programming.

I got my first computer, a Timex 2068, at the age of 10. Spent two years mainly playing games and eventually started looking into programming.

When I learned C, at the age of 16, I already knew BASIC (Spectrum, GW, Quick, Turbo), Assembly (Z80, x86, 68000), Turbo Pascal.

So C was for me a bit "meh" language, given that Turbo Pascal gave me much more, granted except for portability. So I quickly jumped to C++, which allowed me some strong typing comfort and higher abstractions in a forced C land.

Regardless of the language, when I was 18, I had already coded compilers, graphics applications, GUI prototypes, MS-DOS drivers.

Nowadays kids seem just to do JavaScript/Python/Ruby frameworks for generating web pages.

Re:Deep C and C++ (2011) by kyllo on Wednesday October 23, 2013 @04:07PM (#6601318)
Nowadays kids seem just to do JavaScript/Python/Ruby frameworks for generating web pages.

That's progress, IMHO.

Instead of distributing application binaries carefully targeted to each type of user machine, we only have to run the application on one server machine (or a cluster of them) in a central location and can serve the application over the network. We now have code-generating frameworks that help automate away much of the tedious, repetitive parts of implementing an application.

It's not a good thing that software development is hard. It does mean that you're a very smart and hard-working person if you're able to do it effectively. But it's not a good thing for society that you need to be so smart and hard-working in order to do it.

It is, however, a good thing that it's not as hard as it used to be. The fact that a software developer has to do and know less today than they did 20-30 years ago, just to build an application and distribute it to a large number of users, is a sign of progress.

Re:Deep C and C++ (2011) by blibble on Wednesday October 23, 2013 @04:22PM (#6601405)
turbo pascal is as unsafe as C is, just with more verbose syntax.

it has pointers, pointer arithmetic, manual memory allocation, function pointers, casts, unions, you name it.

I bet you could write could write 30 odd rules for cpp and then compile your "pascal" with cc, e.g.:

#define begin {

#define end }

#define := =

#define ^ *

#define @ &

and so on

Re:Deep C and C++ (2011) by pjmlp on Wednesday October 23, 2013 @04:49PM (#6601607)
No it is not, because:

- It has real strings

- Arrays don't decay to pointers

- It has reference arguments, which avoid pointer usage for records and out arguments

- Requires explicit casts for type conversions, instead of implicit type casts

- Provides region allocators, which allow to release a full block of memory in one go

- Has real enumerations that don't decay into ints

- Allows writing generic code over arrays without requiring the developer to manage a separate length variable

- Has proper memory allocation constructs instead of requiring the developer to know the size of memory to allocate

Finally, there are other languages in the Pascal family, that provide safety, while allowing for C dirty tricks done explicitly via a system/unsafe package which provides much fine control over the use of said features.

Re:Deep C and C++ (2011) by blibble on Wednesday October 23, 2013 @06:42PM (#6602253)
so C doesn't have proper type safe enums (though you could hack those up with typedef + cpp), but does require casts for most type conversions (except those for void*).

pascal style strings can be done with the preprocessor, as can generic iterators, allocation for idiots, and "out" function arguments.

memory pools are a library feature.

and the arrays are the same too, a pointer in pascal can be treated as an infinitely sized array, but the reverse isn't true, just like in C.

and, believe it or not, there are other languages in the C family, that provide safety in the same way there are for pascal.

tl;dr: pascal and C are more alike than different.

Re:Deep C and C++ (2011) by pjmlp on Thursday October 24, 2013 @01:46AM (#6603584)
> so C doesn't have proper type safe enums (though you could hack those up with typedef + cpp), but does require casts for most type conversions (except those for void*).

That still does not make them safe, implicit conversion to int will still happen.

> pascal style strings can be done with the preprocessor, as can generic iterators, allocation for idiots, and "out" function arguments.

No type safety.

> memory pools are a library feature.

That aren't part of any C compiler. So you can't count them being available.

> and the arrays are the same too, a pointer in pascal can be treated as an infinitely sized array, but the reverse isn't true, just like in C.

You lost me there.

> and, believe it or not, there are other languages in the C family, that provide safety in the same way there are for pascal.

Yes, that is why I use Modern C++, C#, Java, D and will only use C at gunpoint.

> tl;dr: pascal and C are more alike than different.

True, except in Pascal when bad things happen is because the developer explicitly wanted them to happen.

In C everything goes and to have Pascal's safety back, all modern C compilers provide static analyzers. Thus proving a point about the languages design's.

Re:Deep C and C++ (2011) by yngccc on Wednesday October 23, 2013 @01:30PM (#6600240)
they are unfashionable not because they are written in C/C++. Programming at the end of the day is just not that hard, what is hard is domain knowledge, you can write a compiler in any language.
Re:Deep C and C++ (2011) by ksk on Wednesday October 23, 2013 @09:02AM (#6598402)
>Sadly you are required to move for such jobs, which is not always an option.

True. Talent going to waste is sadly nothing new. Has happened, will continue to happen. :(

Re:Deep C and C++ (2011) by kazagistar on Wednesday October 23, 2013 @09:28AM (#6598536)
The other day we were discussing interview questions at work. The idea came up to ask people to solve a simple programming task in an ugly, arcane, and generally incorrect way; something like "Implement X as a python one liner, using at least three methods from itertools". The good candidates would point out that it really should not be done that way.

But puzzle questions like that are silly anyways, so whatever.

Re:Deep C and C++ (2011) by Someone on Wednesday October 23, 2013 @08:16AM (#6598229)
"Great mathematicians can understand the theory and just apply it to whatever problem they come across."

I don't think you know how great mathematicians think. http://en.wikipedia.org/wiki/57_(number)#In_mathematics "Although 57 is not prime, it is jokingly known as the "Grothendieck prime" after a story in which Grothendieck supposedly gave it as an example of a particular prime number."

Re:Deep C and C++ (2011) by ksk on Wednesday October 23, 2013 @09:01AM (#6598396)
>I don't think you know how great mathematicians think.

I'm confused. What is your basis for that statement? If you you know how they think why don't you just express it? :-S I am sorry, I have no clue what your point is, or even if you have one.

Re:Deep C and C++ (2011) by Someone on Wednesday October 23, 2013 @02:53PM (#6600820)
Grothendieck is/was (according to Wikipedia, he is still alive, but he retired from mathematics years ago (http://en.wikipedia.org/wiki/Alexander_Grothendieck#Politics...) a great mathematician who knows/knew a lot about prime numbers, but he could not apply that 'to every problem he came across'. In fact, when pressed to give a concrete prime number, he came up with 57.

That makes him a counterexample of the claim that all great mathematicians can apply heir knowledge.

If he were a computer scientist, he would have written several brilliant papers about the pros and cons of various properties of programming languages, but he would not be able to write a compiler for any language or even to write a program.

Re:Deep C and C++ (2011) by ryandrake on Wednesday October 23, 2013 @11:23AM (#6599270)
I cant even remember how many times I've had to ask co-workers,

  "So, that's what you think your code will do... what does the standard say?"
or,

  "Why did you use int there when the API spec defines the parameter as taking size_t?"
or,

  "You think that code in your inner loop will compile to one machine instruction. Have you actually looked at the compiler's output?"
and the looks/responses that I got. There seem to be very few programmers who understand the language & their compilers deeply enough, or even care to learn. These programmers are far more productive because they're not constantly guessing or assuming how their code might work.
Re:Deep C and C++ (2011) by kerkeslager on Wednesday October 23, 2013 @01:30PM (#6600238)
There's a deeper problem here, though. If you're asking, "So, that's what you think your code will do... what does the standard say?" the problem isn't really that they don't know the standard, it's that they've written the code in a way where it's ambiguous what it does.

If I see

    static int i;
in code, I'm going to change it to

    static int i = 0;
even if I know that static integers are initialized to 0 in the standard, because I know that eventually someone will have to maintain the code who doesn't know that. I don't particularly care what the standard says there: the code shouldn't assume detailed understanding of the standard, which isn't realistically a valid assumption.
Re:Deep C and C++ (2011) by daenz on Wednesday October 23, 2013 @02:19PM (#6600588)
You nailed it. Standards are nice and all, when they're perfectly unambiguous, and when everyone follows them exactly. That is not the real world. Writing code clearly and explicitly has far more reward for the effort put into it than learning all the standards pedantically.
Re:Deep C and C++ (2011) by devcjohnson on Wednesday October 23, 2013 @01:58PM (#6600460)
Me too reply...

Don't get cute and always prefer to explicitly state in code what you get for free implicitly. The maintenance guy that follows behind you will be the one to espouse how clever you actually are. That's how I mentor junior engineers as a general rule.

Re:Deep C and C++ (2011) by FLUX-YOU on Wednesday October 23, 2013 @04:29PM (#6601447)
The field has to accept some knowledge deficits if it's going to pretend to meet business demands. I thought the original post heavily implied that the 'dumber' programmer shouldn't be hired or have a job; are we going to turn away all potential C programmers until they've mastered everything that the 'smarter' programmer knew? I'd say that would heavily discourage new C programmers if they had to commit to mastering all of that before they could think about getting a position. That would lead to shortages, of course.
Re:Deep C and C++ (2011) by thepicard on Wednesday October 23, 2013 @02:56AM (#6597322)
Arguably if people have such strong understanding of things they will be better programmers too. I would prefer the person who knew what they were doing, because they also know _why_ weird things are weird, and have a better real understanding of what to do and not do.

A person who just knows it's "bad code"--but not why--is almost certainly going to leave other bad code from lack of understanding. To pull an example from the slides, the virtual destructor: making that class virtual when it shouldn't is a waste of CPU cycles _and_ bad documentation for future developers.

Re:Deep C and C++ (2011) by jamornh on Wednesday October 23, 2013 @03:17AM (#6597377)
However, I'd be concerned that the person with strong understanding of things will simply leave uninitialized static variables lying around in the code simply because they _knew_ it was always initialized to 0. It might work if your entire coding team has that innate understanding, but that is unlikely.

Sometimes I think that having deep and expert understanding of a language may cause you to create code that other team members cannot understand... not on purpose, but due to your assumption that these are common knowledge (whether they should be or not isn't the issue.)

Re:Deep C and C++ (2011) by mansr on Wednesday October 23, 2013 @04:47AM (#6597649)
Static initialisers are a horrible example of "deep" knowledge. Not knowing how they work reveals not only ignorance of syntax but a fundamental lack of understanding of the entire programming and execution environment. Failure to understand your environment inevitably leads to confusion and bad decisions.
Re:Deep C and C++ (2011) by Jare on Wednesday October 23, 2013 @08:22AM (#6598259)
A more common example is operator precedence, especially booleans. The precedence rules are easy and set in stone for decades, but always use parentheses to clarify, and I do not trust programmers that don't.
Re:Deep C and C++ (2011) by thepicard on Wednesday October 23, 2013 @12:14PM (#6599623)
Again, I think one with deep understanding would know that leaving it unset would result in zero, but also know that initializing it declares intent of the original author, and is thus useful.
Re:Deep C and C++ (2011) by lttlrck on Wednesday October 23, 2013 @08:00AM (#6598182)
I disagree that static initialization is deep understanding nor is it innate.
Re:Deep C and C++ (2011) by easytiger on Wednesday October 23, 2013 @03:01AM (#6597332)
In c and c++ understanding these things can save you 1 day a week on average.
Re:Deep C and C++ (2011) by pjmlp on Wednesday October 23, 2013 @03:20AM (#6597385)
I would say even more than that.

C and C++ can make someone loose days to track down issues, in this day and age, where teams are distributed with lots of offshoring and various skill levels across development sites.

My last C++ project was in 2006, since then I have only used C++ outside work. At work our focus has been in JVM and .NET languages.

I don't miss playing the C++ fireman expert role that has to fix a stability problem created by someone in the other side of the planet.

Re:Deep C and C++ (2011) by easytiger on Wednesday October 23, 2013 @03:55AM (#6597481)
Yea actually even last week I have spent and entire day trying to bend a c++ library to my will due to errant assumptions and such. All part of the long and painful learning process!
Re:Deep C and C++ (2011) by dman on Wednesday October 23, 2013 @01:30PM (#6600231)
Lets abandon quantum mechanics because most people dont understand it.
Re:Deep C and C++ (2011) by ateevchopra on Wednesday October 23, 2013 @03:17AM (#6597373)
Exactly. Deeper you go, better you are. Better you are, better products you make. Just Simple mathematics.
Re:Deep C and C++ (2011) by acron0 on Wednesday October 23, 2013 @04:27AM (#6597583)
Totally disagree with this. I've worked with plenty of fantastic programmers who are basically worthless without the guidance of a good lead/producer/designer.

Nonobligatory image to support statement: http://codinghorror.typepad.com/.a/6a0120a85dcdae970b0128776...

Re:Deep C and C++ (2011) by Dylan16807 on Wednesday October 23, 2013 @08:48AM (#6598360)
That gui seems fine to me. It's ugly as sin, sure, but it has everything easy to find and clearly labeled. Ignore the parts you aren't using and you're good to go.
Re:Deep C and C++ (2011) by aspensmonster on Wednesday October 23, 2013 @10:38AM (#6598984)
Ehhh. I'm not so sure about setting the depth for recursive retrieval to zero. That's basically telling wget to download the internet IIRC :D
Re:Deep C and C++ (2011) by Dylan16807 on Wednesday October 23, 2013 @12:46PM (#6599878)
The entire domain. Reasonable use case.
Re:Deep C and C++ (2011) by xixi77 on Wednesday October 23, 2013 @12:48PM (#6599901)
I love this GUI. Gives a clear view of what can be changed, and so much more user friendly than having to remember where each of the nested (often so many times!!) options goes. "Advanced..." buttons everywhere are the worst, and don't get me started about wizards.
Re:Deep C and C++ (2011) by ateevchopra on Wednesday October 23, 2013 @07:45AM (#6598141)
A programmer is not a designer. Both are completely different fields. What you are saying is that a shark(programmer) cannot fly like an eagle(designer). But it sure can swim. And vice-a-verse.
Re:Deep C and C++ (2011) by acron0 on Thursday October 24, 2013 @09:01AM (#6604974)
Hmmm, no, to mimic the analogy I am saying that just because something has teeth doesn't mean it can bite like a shark. Just because something has wings doesn't mean it can fly like an eagle. A budgie with a jetpack, however, can probably fly better than an eagle. Or something.
Re:Deep C and C++ (2011) by dmak on Wednesday October 23, 2013 @03:45AM (#6597445)
I'm not sure if I would say that a deeper knowledge of a language would make "better products".