8 ms·
The nice thing about C is that it's so small that you can hold every corner, nook and cranny of the language in your head. There must be less than a dozen peopl
by f00zz 5y ago
The nice thing about C is that it's so small that you can hold every corner, nook and cranny of the language in your head. There must be less than a dozen people in the world that can say that about C++.
- tomcam 5y agoI count Stroustrup, Walter Bright... and 10 posers
- ssssssnakes 5y agoStroustrup once ranked himself a 6 on a scale of 1 to 10 as to how well he knows C++.
- bitwize 5y agoI've been known to rank myself as a 6 out of 10 "where 10 is Stroustrup".
- seibelj 5y agoI haven’t written C professionally or hobbily in 5+ years and I can fairly quickly get accommodated in open source projects. I know that it has many valid criticisms but C is such a pleasure.
- whatshisface 5y agoQuick, I need to parse a simple string; should I use scanf, fscanf, sscanf, scanf_s, fscanf_s, or sscanf_s?
- typon 5y agoI don't understand C programmers are their seemingly utter inability to understand that C is actually not perfect and has tons of flaws, including a lot of complexity. Just because you're used to something doesn't make that thing not complex. Try teaching C to first year undergrads.
- kevinmchugh 5y agoC the language is really neat and exciting. C the ecosystem, including standard libraries, is a lot less compelling.
- reasonabl_human 5y agoLearned C in a class as a first year undergrad, it was great!
- smabie 5y agoI feel like undergrads learn C in their first year? Or at least I did (well I already knew it, but had a class that was in C).
- pjmlp 5y agoOn my university we learned C++, already with proper strings, vectors, in-house collection library. About 30 years ago.
- colonCapitalDee 5y agoI don't think C is the standard anymore. I'm graduating class of 2022 and my college taught Java to freshmen. My friends at different colleges mostly had the same experience, with a few using Python or C++
- pta2002 5y agoThis definitely varies by university. I had haskell and C on my first year, only had Java on the second.
- kjs3 5y agoI don't understand non-C programmers and their seeming utter inability to understand that C programmers are very aware of C imperfections and how to effectively deal with it, while being equally blind to the flaws and complexity in their own environments. I learned C as a first year undergrad.
- deleted 5y ago
- spankyspangler 5y agoIs this supposed to be a trick question? All do virtually the same thing at their core, differing in where they take their input from and whether they are the C11 bounds checking variants. You can add all the v prefix variants too, doesn't really make things more difficult. You could have thrown in a bunch of functions from string(3), but even then... C string handling isn't great by any means, but it isn't vast or complicated either.
- whatshisface 5y agoYou can learn the C stdlib+system headers, but at that point you're doing something more or less equivalent to learning a high level language's features, and you're past the simplicity of K&R.
- spankyspangler 5y agoI'm not sure what you mean. C is a high level language. And yes it and standard library has obviously grown more complex than it was 50 years ago. It's small and easy to grasp the entire thing though, unlike most other more modern high level languages. That said, it's not entirely clear that matters too much. Almost any non-toy C project is going to be bringing in libraries outside libc, so you still need to go off and learn those if you want to work on a project. Doesn't really matter whether they're in the base language or not.
- pjmlp 5y agoReady for a random question out of the 200+ UB cases on the ISO C, or about a random feature from any C compiler?
- spankyspangler 5y agoI'm not sure if you replied to the wrong comment or not because it doesn't address what I wrote.
- 5y ago
- flukus 5y agoI type "man scanf" and check which one I need, I wish other languages had such accessible documentation.
- flohofwoe 5y agoHow often do you need to parse a string in an RTS game? If you need to do lots of string processing, C is simply not the right language. Thankfully one isn't forced to only learn a single programming language in life ;)
- krapp 5y ago>How often do you need to parse a string in an RTS game? Asset files, config files, shaders, obj files, CSV, XML, JSON, etc... it's not uncommon. Read the asset loading code in the posted game. For a language that doesn't even know what a "string" is, C applications tend to involve a lot of string parsing.
- GuB-42 5y agoYou write your own parser. Seriously, I don't use scanf that much in C. Most of the times, it doesn't do exactly what I want, or there is a more specialized alternative (ex: strtol). Also, generally, %s is bad, even the "safe" variant. For sscanf, it makes a copy, which is inefficient (if you are writing C, you want efficient code, right?) and you have to know the size in advance, and usually, you don't. Most of my string manipulation in C involves loops, pointers and a lot of in-place manipulation. It is tedious compared to other languages but it is very efficient, the reason I picked C in the first place.
- whatshisface 5y agoSo in the context of the larger debate, this answer falls in to the "C is simple, until you try to use it, at which point you start writing your own programming language in C to write your application in," category. In this perspective C is simple mainly because it's missing the already-written code that you have to benefit you in other languages.
- lal 5y agoI don't think any of this is close to fair. "C is simple" and "it takes some work to do stuff in C sometimes" aren't mutually exclusive, in fact the former necessarily implies the latter. C is simple, which means it doesn't have a pre-written obscure built-in or convoluted syntax to handle every possible thing you might want to do in the language. You're going to have to write some of the code in your project yourself. That doesn't mean C isn't simple. I don't think I have to get into why writing a string-parsing function isn't quite the same thing as writing your own programming language. And C has libraries too, to be fair. So if you prefer the "choose between 25 competing libraries that all provide the desired functionality but half of them are deprecated or don't work" workflow a lot of people are used to from C++ or whatever you can do that. Lots of people use libraries in C. In fact, as you might be aware, your OS's package manager doubles as the C language's third-party package manager. There has been plenty of "already-written C code," because it's a language that has been ubiquitous in computing for fifty years. I'm not sure where these same tired critiques bubble up from but I see them constantly and they don't make sense. There are a number of entirely valid and damning critiques to be made of the C ecosystem but "there aren't any libraries written in C" and "oh, so you say C is simple, huh? Have you tried using it?!" aren't among them. You're not going to be a 20 year veteran C developer and then suddenly just today learn about some obscure built-in, and that's what is meant by "simple" here, and that's a good thing.
- publicola1990 5y agoIn general though c++ has some level of feature orthogonality, that is features you don't use will not hurt you. But for large projects, C++ is the saner choice with its builtin library of data structures, templating, namespaces etc.. All these could perhaps be done in c, but why spent a lot of time making this infrastructure if one could spent more time on ones application domain solutions.
- CraigJPerry 5y agoYou gloss over the complexity cost of having too many overlapping tools in the bag though, a complexity cost that has drowned projects in the past. Arguably C++ as a language could be improved if someone was able to depreciate and remove the "legacy" parts. In practice though that's simply not possible. E.g. trivial example but you couldn't ever depreciate #include even though we have #import now. Instead of "fixing" the language, there's written (not enforced by the compiler) documentation https://github.com/isocpp/CppCoreGuidelines https://github.com/isocpp/CppCoreGuidelines - actually the first line is the perfect summary: "Within C++ is a smaller, simpler, safer language struggling to get out." -- Bjarne Stroustrup This is great documentation (and many parts are relevant to other languages) but many of its proscriptions cannot be enforced by the compiler so it will always be opt in, mis interpreted or ignored.