5 ms·
I don't think "most of the advantages of C no longer apply [if you use static analysis or bounds checking]" is fair. Even if your claims about losing libraries
by jjnoakes 11y ago
I don't think "most of the advantages of C no longer apply [if you use static analysis or bounds checking]" is fair.
Even if your claims about losing libraries, experienced developers, or automated tools was true (which think is false), you still get portability, close-to-the-metal code, full control of your processes, direct access to the native ABI, full access to the platform facilities, fast compilation, small executables, standalone libraries, memory layout control, ...
- lmm 11y agoC code is less portable than most of the alternatives. In the rare cases where the things you list are hard requirements there are still safer options e.g. Ada.
- jjnoakes 11y agoC code is less portable than which alternatives? As far as I know, most/all? alternatives are implemented in C or C++.
- lmm 11y agoPlenty of alternatives are self-hosting, but that's neither here nor there. Even if it's a major effort to port e.g. the Python interpreter to a new platform (particularly the first new platform - once you have a C codebase that enforces portability over many platforms it's much easier to add a new one). But that major effort has by and large been done for even relatively obscure languages and relatively obscure platforms. Whereas if you write in C you get to do that major effort for yourself for each program.
- jjnoakes 11y agoMore portable means "can be ported to new platforms more easily", not "has been ported to new platforms by someone else". A C program (in general) is more portable than anything written on top of C because to port, say, Python to a new platform, one has to have C there first. It has nothing to do with whether the work has been done by you or someone else. Of course, one can write code in either language which is not portable, but that is also beside the point.
- lmm 11y ago> A C program (in general) is more portable than anything written on top of C because to port, say, Python to a new platform, one has to have C there first. Port C compiler -> port your C program vs port C compiler -> port Python interpreter -> port your Python program. The latter can still end up a lot easier and cheaper, because the Python interpreter is already multi-platform and Python programs tend not to have much if any platform-specific code by the nature of the language. > It has nothing to do with whether the work has been done by you or someone else. It has everything to do with that. Ultimately via Turing equivalence it's possible to port anything to anywhere, so when we're talking about "portability" we must be talking about how much it costs to port a program to a new or existing architecture. > Of course, one can write code in either language which is not portable, but that is also beside the point. Again, it's very much the point, because it can't possibly be a yes-or-no thing. How costly is typical/idiomatic C code to port? How costly is typical/idiomatic Python code? Those are the questions that matter when we talk about language portability.
- jjnoakes 11y agoBy definition, the C language is more portable than the Python language, because in order to run Python on a system, C must run there first. Unless you are talking about a Python not implemented in C, or a C compiler that was created to only compile the Python interpreter (and not all of the C language), then there is no other way around this simple fact. A standard-conforming program should be part of the topic here, not "typical/idiomatic" non-objective software. Just because most people may not write portable C code doesn't make the language itself more or less portable. It just makes those particular programs less portable. Plenty of C code is highly portable. Plenty is not. Same can be said of Python. It is moot. The language is under discussion here, not any set of specific programs written in the language. Also, beside that simple logical conclusion, it is 2-3 orders of magnitude easier for me to port a C program I wrote to a new platform than it is for me to port the Python interpreter just to support my Python program on a new platform. Nevermind all of the features I would have to port (or neuter) inside Python which my program may not even use.
- 11y ago