4 ms·
Yes. That said, it was probably a mistake for C not to define standard fixed-width types such as int8, int16, int32, int64, uint8, uint16, uint32, and uint64.
by palish 18y ago
Yes. That said, it was probably a mistake for C not to define standard fixed-width types such as int8, int16, int32, int64, uint8, uint16, uint32, and uint64. (This limitation is worked around via the <stdint.h> header file; however, that header isn't present in Visual Studio, so anyone who wishes to use those fixed-width types needs to manually download <stdint.h> and include it in their projects. ( http://en.wikipedia.org/wiki/Stdint.h http://en.wikipedia.org/wiki/Stdint.h )
- scott_s 18y agoI agree. But, even if there was, say, a uint16 type in C, it wouldn't be the grammar that defines it as 16 bits.
- palish 18y agoWould the grammar define it as a reserved identifier / keyword?
- scott_s 18y agoCertainly. But the semantics of what "uint16" would mean is not in the grammar. There's nothing to prevent me from defining "uint16" to be a double precision floating point number. That would be stupid and unintuitive, but still possible. If you look at the specification for any language, the grammar is the smallest part. The C++ grammar takes up less than a dozen pages, but the entire standard is over 800.
- palish 18y agoCan I subscribe to your newsletter?
- scott_s 18y agoI honestly can't tell if you're complimenting me or calling me crazy.
- palish 18y agoCompliment... you seem to have a lot of experience with C++.
- scott_s 18y agoIn that case, thank you. I've done a lot of systems programming with C and C++. Understanding exactly what is defined by a language's grammar, though, originally comes from my undergrad courses in programming languages and compilers.
- palish 18y agoCool. Would you say formal education has made you a significantly better programmer? (The definition of 'significantly' in this context is up to you to decide.) I'm completely self-taught, but I've wondered if I missed out on something valuable by not going to college.
- scott_s 18y agoShort answer: yes. Long answer: it's hard to know for certain. I chose Computer Science as my major having done very little programming. I didn't do any serious programming until my intro to programming course my first semester. I did some programming in a high school course, but really, my start as a programmer coincided with the start of my formal education. But during my education, I was exposed to things I doubt I would have encountered on my own. In particular, what I learned from my programming languages, compilers and operating systems courses. In fact, if it had not been for my programming language course, I don't know if I would have realized how much I like thinking about how to express concepts in code. If it wasn't for my graduate studies, I doubt I would have become so comfortable with systems programming and performance in general. I'm also a biases person to ask because I'm close to getting my Ph.D. I have a Bachelor's and a Master's. So I've done a decent amount of schoolin'. The problem with being self-taught is sometimes you just don't know what you don't know. I know it sounds boring, predictable and constraining to learn a menu of concepts. But the benefit is that lots of people who came before you decided "these things are important to know to be in our field." (Hope you see this reply, I didn't realize you replied until just now.)
- ComputerGuru 18y agoVisual studio has __int8, __int16, __int32, and __int64. Any of these can be prefixed with "unsigned" to got their unsigned equivalents. They're compatible with their stdint equivalents.