4 ms·
By 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 tal
by jjnoakes 11y ago
By 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.
- lmm 11y ago> By 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. What definition are you using, and what practical use is your definition? You seem to be defining "portable" in some absurd, irrelevant way so that your preferred language "wins", regardless of what that actually means. > 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. The standard is just some words on a page. The programs and tools are what give it meaning. If 90%+ of the things we call "C programs" don't conform to the standard, it's not reasonable to treat the standard as the definition of a "C program". And for any practical, real-world decision like "should I write my program in C or Python", the typical/idiomatic is the question that matters. > 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. How often do you port things to a platform on which the Python interpreter doesn't already build? And how large are these programs for the 2-3 orders of magnitude? (I guess small in any case if you're talking about writing a program yourself rather than in a team). The Python interpreter is actually pretty small.
- jjnoakes 11y agoAre you being obtuse on purpose? There are C compilers for N platforms. There are Python interpreters for M platforms. Since the Python interpreter is written in C, N >= M. The programs I have ported are more than a million lines. Not the largest, sure, but not trivial. And they run on platforms where Python does not. The size of the C code or the Python interpreter code does not matter. What does matter is what subsystems are required. Python is general purpose and has a wide set of requirements (networking, file systems, process manipulation, dynamic loading, the list is quite long). Oh, and the Python list includes compiling C programs (for extensions). A second reason backing my absurd definition. The C programming language requirements placed on the hosting environment are much smaller. So the language is more portable for that reason as well. It is beneficial to only port what you use, instead of having to port a monolithic interpreter, including the parts you don't need (which may not even run on the target platform easily or at all).
- lmm 11y ago> There are C compilers for N platforms. There are Python interpreters for M platforms. Since the Python interpreter is written in C, N >= M. Sure, but existence of a compiler is only a small piece of portability. As a FreeBSD user I'm very used to downloading a random program and finding it won't run on my platform. Happens a lot more often when the program's written in C than when it's written in Python.
- jjnoakes 11y agoSo? The existence of a conforming C compiler is all it takes for the C language to have been ported to that platform. Or do you think C isn't ported to a platform unless every random C program you download from the internet compiles and runs?
- lmm 11y agoI think portability is best understood as a measure of how difficult/expensive it is to port a typical program in that language to a new platform, because that's the question which is likely to be relevant in practice.