Hacker News new | past | comments | ask | show | jobs | submit login

Plenty 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.



More 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.


> 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.


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.


> 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.


Are 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).


> 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.


So? 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?


I 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.


That doesn't define the portability of the language though, that only discusses typical programs. They aren't the same thing at all.

The portability of a language is best understood as how difficult/expensive it is to port a conforming program written in the language in question.

It's easy to confuse the two. But a discussion based on that confusion is not very useful, as you are discovering.


> The portability of a language is best understood as how difficult/expensive it is to port a conforming program written in the language in question.

What proportion of the things that are referred to in ordinary, everyday language as "C programs" would you estimate are conforming? Maybe 0.01%? If I'd meant "conforming C code" I would've said "conforming C code".

Writing conforming C is not a realistic choice for most use cases. E.g. there are very few experienced conforming C developers available.


I don't think any of your assertions are true at all.

There are lots of conforming C programs (just look at the huge list of software which compiles on a huge list of platforms).

There are tons of experienced C developers. Who do you think writes all of that conforming software?

And none of this is related to the topic at all.

If you really can't get your head around the simple idea that the portability of the language is different than the portability of some arbitrary program written in the language, then just look at it this way: If you want to write a program in a language, and you pick C, your program will run on more platforms than if you pick Python.

This is true, regardless of any other argument you might raise, simply because Python won't run on a platform until C runs on that platform (since Python is written in C).

We've been over this. Ad nauseum. Please stop trolling.


> There are lots of conforming C programs (just look at the huge list of software which compiles on a huge list of platforms).

And look at how much of that list breaks when a new version of GCC introduces a minor improvement in optimization.

> just look at it this way: If you want to write a program in a language, and you pick C, your program will run on more platforms than if you pick Python.

That is the question to ask. And your answer simply isn't true. It will (in the overwhelmingly likely case) run on more platforms if you pick Python. Certainly if you hold costs constant, which is surely the only way to compare. If you're willing to spend unlimited time and effort on portability then your C program will run everywhere, but so will your Python program (since you can just port the Python interpreter).

> This is true, regardless of any other argument you might raise, simply because Python won't run on a platform until C runs on that platform (since Python is written in C).

Not actually true (Jython exists and could run on platforms that don't run C), but it doesn't matter. It is overwhelmingly likely that the Python interpreter will run on more platforms than your C program will.

> We've been over this. Ad nauseum. Please stop trolling.

I'm not trolling. Maybe you are?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: