4 ms·
But the thing is so many things are mighty inconvenient to do in C. Every large program in C has to build up lots of fundamental infrastructure like a library o
by billfruit 5y ago
But the thing is so many things are mighty inconvenient to do in C. Every large program in C has to build up lots of fundamental infrastructure like a library of data structures, and mechanisms for error handling.
Why should one use C and spend a lot time on building a basic platform, rather than spending time, effort and creativity on the core concerns.
Not to mention the chances of so many things to go wrong, in writing C code. Its like climbing a mountain without a safety gear.
- dzaima 5y agoIf those utilities make up an excessively large portion of your program, C probably isn't the best choice. As long as you don't care about performance lost from the non-zero costs of "zero cost abstractions". If you're implementing custom data structures, you'll likely be able to make them optimal for your use-case, both from ease-of-use and performance. (except hashmaps. those do suck to write)
- wheelerof4te 5y agoHashmaps are often overrated. I can count on my fingers how many times I used dictionaries in Python. Pretty much anything you can do with dictionaries can be much more cleanly done with classes and other built-in features. Membership testing? Use sets. Data storage? Use classes with slots or tuples/namedtuples. Custom switch statement? Use the new match/case keywords or just fall back to plain if/elif towers. It's so much simpler.
- dzaima 5y agoIt definitely depends on the project. There are plenty of domains where hashmaps are useless, and some where half the things you do need one, and many in between. The in-between is the worst - if you need a hashset/hashmap just once, you'd still have to suffer through implementing one (O(n^2) is just not acceptable). But there is a bright side to this - hashmaps are pretty inefficient if a list could do, so the more you're pushed against using one, the more likely you are to have faster code :) (as long as you don't go the O(n^2) route, that is; also, hashsets are equally hard to implement manually as hashmaps)
- thechao 5y agoThe cost of removing an impedance mismatch between other peoples's code and your code base is inversely proportional to the scale of your code-base. If you have a 10 line program, use the standard libraries. If you have 10 billion lines of code, write your own language. Everything inbetween is a trade-off between comfort and effort.