Live data from Hacker News

Deep C and C++ (2011)

slideshare.net

21–30 of 243 posts

Re: Deep C and C++ (2011)

#21
post #4

Heh, and they didn't even get into the aliasing rules. In embedded software, life would be a lot easier if I could hit every engineer who wants to type-pun without a union in the head with the ISO standard. For this reason, a lot of compilers have options to not strictly enforce the aliasing rules [edit] Also C and C++ are both permitted to reorder structs, it's just that they don't because that's the easiest way to…

No, in C struct members must be allocated in the order in which they are declared. C99 §6.2.5 says:

  A structure type describes a sequentially allocated
  nonempty set of member objects (and, in certain
  circumstances, an incomplete array), each of which 
  has an optionally specified name and possibly 
  distinct type.
and §6.5.8 says:

  If the objects pointed to are members of the same
  aggregate object, pointers to structure members 
  declared later compare greater than pointers to 
  members declared earlier in the structure,…

Re: Deep C and C++ (2011)

#23
post #9

I've been a C developer (among other things) for about 20 years or so, but I've always described my C++ skills as being "in the C with objects" range, I might have to change that to being "nearly in the C with objects" range.

Yep, with C and C++ , you can't really say you are an expert.

I wonder how's salary comparing to other programming languages?

Re: Deep C and C++ (2011)

#24
post #4

Heh, and they didn't even get into the aliasing rules. In embedded software, life would be a lot easier if I could hit every engineer who wants to type-pun without a union in the head with the ISO standard. For this reason, a lot of compilers have options to not strictly enforce the aliasing rules [edit] Also C and C++ are both permitted to reorder structs, it's just that they don't because that's the easiest way to…

C is not allowed to reorder structs. There's a section in the C standard, n1516 page 113 (section 6.7.2.1 paragraph 15)

> Within a structure object, the non-bit-field members and the units in which bit-fields reside have addresses that increase in the order which they are declared.

Re: Deep C and C++ (2011)

#25
post #4

Heh, and they didn't even get into the aliasing rules. In embedded software, life would be a lot easier if I could hit every engineer who wants to type-pun without a union in the head with the ISO standard. For this reason, a lot of compilers have options to not strictly enforce the aliasing rules [edit] Also C and C++ are both permitted to reorder structs, it's just that they don't because that's the easiest way to…

As mentioned by others, C does not allow reordering of members in structs. However, C++ does!

§9.2.12 says:

    Nonstatic data members of a (non-union) class declared without an
    intervening access-specifier are allocated so that later members
    have higher addresses within a class object. The order of allocation
    of nonstatic data members separated by an access-specifier is unspecified (11.1)
This means, that under a strict reading, even the following struct can have its members reordered:

    struct foo {
        int a;
    public:
        int b;
    }

Re: Deep C and C++ (2011)

#26

Earlier quoted context omitted.

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…

Exactly. Deeper you go, better you are. Better you are, better products you make. Just Simple mathematics.

I'm not sure if I would say that a deeper knowledge of a language would make "better products".

Re: Deep C and C++ (2011)

#27

It is interesting looking at the 'deep' issues of programming languages. This kind of ties in with the "Don't ask me maths questions..." post a few days ago. There really is a lot more to programming than just algorithms, UI design or syntax.

Yes, this worries me. Especially today some people think "great programmers" are the ones who knows all the "fashionable" tools and frameworks, wants to abstract everything (god help him if he install vim in his test environment without a fab file that configures chef) and maybe worships Uncle Bob Knowing how to use Redis is cool, do you know what's even cooler? Being able to write it (or at least knowing how it work…

I'll rather pay an artist to paint me a nice piece using store bought paint than making his/her own paint.

Each programmer is great in their own right.

Re: Deep C and C++ (2011)

#28
post #10

People complain loudly about gotchas in JS, but when you look at what C++ programmers have to contend with...

At least C++(11) is a (better) statically typed language :) Although, This isn't even half of it! thanks god the girl didn't know anything about templates.

Re: Deep C and C++ (2011)

#29

It is interesting looking at the 'deep' issues of programming languages. This kind of ties in with the "Don't ask me maths questions..." post a few days ago. There really is a lot more to programming than just algorithms, UI design or syntax.

I couldn't find that link, could you share it please? Thanks in advance.

Re: Deep C and C++ (2011)

#30
post #16

Earlier quoted context omitted.

In c and c++ understanding these things can save you 1 day a week on average.

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 sta…

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!
Post reply on HN