Python or C?
Python or C?
So I just started learning C, I've learned Python for about 3 weeks and I would like to compare and contrast them a bit and give them both pros and cons.
For this demo, I will be making a Pin Verification program in both Python and C. The objectives are:
- Ask for a Pin
- Save the Pin
- Print the Pin
- Ask for the Pin
- Say if their Pin is correct or not
So a pretty simple program.
In python, this took 7 lines.
In C, this took 16 lines.
Pros and Cons
- Python is Easy to Learn
- Python usually takes less time and fewer lines of code to write.
- Python can easily make variables and inputs
- You can not make "big" software with Python, for example, you can not make a full operating system with just Python.
- More people know python so there is a higher chance of someone already making/made what you want to make.
- You can make "big" software such as full operating systems and large programs.
- Fewer people know C as it is harder to learn which means you have a lesser chance that someone is already making what you are making.
- It is confusing to learn C at first because there are lots of squiggly brackets and parentheses.
- It takes more time and lines to write a program.
- Just to make an input you have to print the question then use scanf to save it to the variable.
So, you tell me, what do you think is better. I equally like both. But you can do more with C but Python is easier to learn. Let me know what you think in the comments!
@DynamicSquid On the LOC issue:
You seem to like the lines-of-code metric. There are many lines of GNU code in a typical Linux distribution.
You seem to suggest that (more LOC) == (more important).
However, I submit to you that raw LOC numbers do not directly correlate with importance.
I would suggest that clock cycles spent on code is a better metric.
For example, if my system spends 90% of its time executing XFree86 code, XFree86 is probably the single most important collection of code on my system.
Even if I loaded ten times as many lines of useless bloatware on my system and I never excuted that bloatware, it certainly isn't more important code than XFree86.
Obviously, this metric isn't perfect either, but LOC really, really sucks.
Please refrain from using it ever again in supporting any argument.