3 ms·
Of course you can, but this is implementation defined. So you need to create code that does different things based on the underlying implementation. Every reaso
by coliveira 3y ago
Of course you can, but this is implementation defined. So you need to create code that does different things based on the underlying implementation. Every reasonably large C code base checks the current implementation to define what type of integers, pointers, etc. they're dealing with.
This is by design, because C was created do deal with disparate processors and OSs. When it was crated it would be difficult and unwise to assume that an integer has size of 2 bytes, for example, since each machine would define its own preferred length.
- IshKebab 3y ago> When it was crated it would be difficult and unwise to assume that an integer has size of 2 bytes It was still a bad design. Of course this is in hindsight, but history has taught is it would have been much better if the default was for specific sized integers, with an option to use `uint_fast32_t` or whatever.
- gpderetta 3y agoThen we would be stuck with 16 bits integers. We are lucky to be in a point in time where integer types have been stable for a while, but it wasn't always so.
- IshKebab 3y agoWe wouldn't. People would update their code eventually or opt in to variable sized integers.
- coliveira 3y agoHistory says otherwise: C was so successful it is still widely used.
- xigoi 3y agoJust because something is popular doesn't mean it's good. Tobacco smoking is also popular.
- coliveira 3y agoSome of the best software we have to date was written in C. If you like it or not, it is a magnificent tool.
- xigoi 3y agoIt would still be good if it was written in a different language. Probably even better because the developers would have more time to improve the software instead of reinventing wheels, writing boilerplate code and chasing down segfaults.
- coliveira 3y ago> It would still be good if it was written in a different language. But it wasn't, C made all these software tools possible.
- IshKebab 3y agoNo it didn't. C happened to be the most popular language for a long time but that doesn't mean people couldn't have written software without it, or that if it hasn't been so popular a better language wouldn't have arisen. English is very popular but you wouldn't say "English is what made all those books possible" would you?