Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@trickory just use the time command under Linux. The startup time for the Python interpreter will ruin everything for such a simple program.
-
@crapped thr core message was not about the speed. It was about the simplicity.
-
@LinusCDE compilation time is not included for C programs because C programs are typically used as resulting binary.
-
@Fast-Nop Yeah, but this aproach is about getting the line written 500 times as fast as possible if you start with nothing (not even the compiled binary).
In that case python wins. -
Now that we're talking about speed, i present this change to C version:
...
for(count = 500; count != 0; count--) {
... -
@FrodoSwaggins GCC will optimise printf with a static string just as well as puts.
-
Awlex177456y@hidingFromBoss since everything but 0 and NULL is "true" in C, you might es well drop the comparison. Unless it gives you some performance boost I'm not aware of.
-
@Awlex It's nice for clarity, and the performance is the same because the subtraction sets the ZERO flag in the CPU automatically.
-
@hidingFromBoss and talking of simplicity we could just write:
int count =500;
while (count - -)
...
PS: Just realized @Awlex already mentioned this. -
What is the estimated development time for Python vs C (including debugging/compiling/packaging)? How much is developer salary for either? How much more efficient is C code? Does the code need to change often? How often will the code be run (requests/executions)?
If you write code that needs to be continuously adjusted, and will be executed by a small amount of people (let's say, data analysis or machine learning) a higher level language like Python wins.
If you develop a product that needs to be optimized for execution and will be used by the whole world (let's say, a kernel module or a server daemon), a lower level language like C would win. -
@phreakyphoenix didn't know we could do that in C. Thanks.
@Awlex could you write your solution too, if it's different from phreakyphoenix's? -
Awlex177456y@hidingFromBoss it's actually the same as your but without the comparison. I just love (ab)using this whenever possible
-
Awlex177456y@undervalued0
Teacher: "Write this 500 times!"
Student: * Builds an embedded system *
Teacher:
C vs python
joke/meme