Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I know python is not suitable for things like microcontrolers, make drivers etc, but besides that, you can do everything using python, companys get stuck with speed optimizations for real hard time system but does forget other factors which one you can just upgrade your hardware for speed proposes in order to get your python program fit in it, if you think how much cust can the company have to maintain a system written in C, the comparison is like that: for example: 10 programmers to mantain a system written in c and just one programmer to mantain a system written in python, with python you can buy some better hardware to fit your python program, I think that low level languages tend to get more cost, since programmers aren't so cheaply than a hardware upgrade, then, this is my point, why should a system be written in c instead of python?

share

closed as not constructive by ChrisF Nov 24 '11 at 16:27

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

40  
Is that all one sentence? –  TheLQ Oct 19 '10 at 1:20
14  
@TheLQ: I would edit it, but it's a marvel, isn't it? –  Jon Purdy Oct 19 '10 at 2:02
2  
Do you have any actual evidence for a 10:1 maintenance cost ratio? –  David Thornley Oct 19 '10 at 15:28
7  
Why Python instead of something more powerful? –  user1249 Oct 23 '10 at 12:05
1  
Python does not do multi-threading well, and hence it sucks. The real question is why do we not use Clojure for everything? –  Job Dec 5 '10 at 16:03

6 Answers 6

The main reason is because the software was already written in C (or C++ or whatever) before Python became a legitimate choice.

If it's a question of rewriting your million lines of C code into Python or continuing with the C code, then the choice is clear. If you spend 12 month rewriting the code in Python, then that's 12 months where you're not adding new features and you'll basically spend 12 months getting back to exactly where you were.

Not to mention that fact that you'll probably have missed all those corner-case bugs that had been fixed over the years in the C version, but not really called out in the code so when your Python dev comes along to port it and says "why does the code do this? That seems wierd... I'll just do it this other way" he's actually forgetting about that customer from 6 years ago who lost 12 months worth of payroll because of this obscure bug in their RAID controller that was worked around with just that specific piece of code.

It's basically the same answer people get when they ask "Why doesn't Microsoft rewrite Windows or Office or (insert-product-here) in .NET? I thought .NET was the poster-child for all Microsoft development these days?"

Now, when it comes to developing new products, then Python (and all the other possible choices) become a more viable option. But you've still to weigh the benefit of going with Python (or whatever) over C or C++, particularly when your new product may be interfacing with lots of existing code that you've already got written in C or C++.

share
1  
in case of make a new software, what do you choice for? c or python? –  killown Oct 18 '10 at 23:40
3  
For new software, your choices are pretty much limitless (C, C++, C#, Java, Python, PHP, Ruby, etc etc) whatever makes the most sense for the particular project –  Dean Harding Oct 18 '10 at 23:42
1  
Obligatory Joel on Software link: joelonsoftware.com/articles/fog0000000069.html –  Tim Goodman Oct 19 '10 at 3:35
4  
"If it's a question of rewriting your million lines of C code into Python or continuing with the C code, then the choice is clear." Not really; if you can (for example) replace 1 000 000 lines of C with 5 000 lines of Python in a few months (and can afford the performance hit + few months), there's a good argument that doing so will increase your speed in the long run. 5ksloc is much easier to maintain, optimize, develop against and debug (and is less likely to be concealing bugs) than 1 million sloc. Now if the choice was 1 000 000 of C vs 900 000 of Python, that's certainly not worth it. –  Inaimathi Oct 23 '10 at 15:05
3  
It's not just a matter of writing a few thousand lines of Python. You first need to understand all 1M lines of C code before you can begin. You need to understand why each line does what it does (for example, does it fix some obscure bug that everybody's forgotten about? Or is it just some vestigial bit of code from some refactoring that was done 15 years ago?) Writing a few thousand lines of Python can be done relatively quickly. But understanding 1,000,000 lines of C code in order to be able to write those thousand lines of Python is much more work. –  Dean Harding Nov 26 '11 at 0:54

Because even when you're not writing "low-level applications" such as device drivers, the need for low-level code tends to show up in all sorts of places, especially for performance optimizations in computation-intensive parts of your app. This is common enough even in apps written in C and other static, fully-compiled languages, and it only gets worse when you start throwing inherently slow "high-level" language features such as dynamic typing and managed pointers into the equation.

When you have a language that abstracts away all the low-level details, such as Python, you are not able to get down to the level required to fix problems like this. That's why you tend to see the pattern of writing the core code in a compiled language, and then implementing lightweight business logic in a scripting language that runs on top of the core code, increasing in popularity quite a bit lately.

share
3  
Another solution for the same problem is writing your system quickly in a higher level language, then using a C FFI to replace those pieces that don't profile well. To be fair, I don't have experience doing this, but there doesn't seem to be an a priori argument that writing things in C first, then extending it in a more flexible language is the clear winner. –  Inaimathi Oct 23 '10 at 15:13

There are some systems that link in C directly. Sure you can proxy your function calls and embed an interpreter, but I can do that with nearly any language.

share

Well I understood your question as "Why continue to write things in C/C++ when better alternatives are present." Not let's rewrite everything just because we have a better hammer. And I agree with you in theory. Why write new things in C or ASM anymore because it turns out there are vastly more problems that work better for "high-level" languages than not.

I think about a story that James Gosling recalled about the Java team. They were looking at huge sections of code in the VM that was originally written in C because they thought it was faster. As time went on and they had to improve it, maintain it, and add new features. The team began to wonder why not move it to Java. They did and it turned out to be just as performant, simpler, and easier to modify. I do think new development should not be done in C/C++, except for those exceptions noted, but what makes our industry continue to grow is the platform change. We haven't really answered any new questions about computer science since the 70s, but we continue to grow in amazing directions. That's largely because every 10 years or so we create new platforms where we have to re-implement everything over there opening up opportunities to transition from previous languages to new ones. That's the secret to our industries success.

Here's a simple wrap up from 1980-2010: Unix C->Windows C++->Web Java/Javascript/Python/Ruby->mobile Objective C/Java).

share

Because if the "system" is a scientific library or a go playing program it might require top performances, that's why. If you buy hardware that's 10 times faster, the low level implementation will still perform better.

And then there's a quite philosophic reason, in my opinion: we have to keep in touch with the lowest level of our machines. Losing the knowledge of basic instruments like the C language would be like covering every inch of the earth with cement and build a perfectly working "system" upon it, forgetting about what was down there once that gave us birth and condemning the human race to eternal ignorance.

Kernighan and Ritchie would be very upset about it.

share

Some observations:

  • The huge trend in computing is mobile, which from several aspects is not far from microcontroller and embedded system development. Python is not yet the dedicated language for iOS, Android or Windows Phone 7.

  • In desktop computing, getting faster hardware is more and more difficult: CPU speed is stuck aroud 3GHz and getting all the power of multiple cores is far from easy. Low level languages have an advantage over Python here.

  • About maintainability, the 10:1 ratio may be true with just-graduated people who have never been exposed to C but know Python and Ruby and all other new languages. For the majority of senior developers, the ratio doesn't favour Python.

  • Some years ago, everything could be made in Java and be portable at the same time. Some years before, it was Perl. Clearly the actual winners these days are C, C++, C# and Objective-C.

share
2  
"CPU speed is stuck aroud 3GHz and getting all the power of multiple cores is far from easy." Isn't this pretty much the explicit goal of higher level languages like Erlang and Haskell? Erlang through a one-character "new process" operator, and Haskell with purely functional (and therefore theoretically fully parallelizable) programming? +1 for the mobile computing point, that seems to be the first well-reasoned argument I read here. –  Inaimathi Oct 23 '10 at 15:20
    
@Inaimathi: Why's it that fully-functional programming languages are easily parallelizable? –  Dark Templar Oct 9 '11 at 18:20
    
@mouviciel: How come you say that C, C++, C# and Objective-C are more portable these days than JAVA and Perl? O_O –  Dark Templar Oct 9 '11 at 18:23
1  
@Dark Templar - Because the components of a purely functional program have no dependency on external state and have no assumptions about what order they will run in. This makes it easier (though not easy) to reason about how to efficiently break such a program up across different processes. Have a Haskell-related link in which Simon Peyton Jones explains his approach in-depth. –  Inaimathi Oct 11 '11 at 0:26

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .