Linked by MOS6510 on Thu 10th Jan 2013 23:25 UTC
Thread beginning with comment 548450
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.
I sympathize. I have found that prototyping stuff quasi interactively in python and then porting it over to C/C++ can be a very productive way of programming.
Exactly.
Previous generations might have prototyped on paper or a chalk board before "finalizing" the C code.
Thats from a time where it made sense to plan ahead because you might be using punch cards or had to wait your turn for computer time.
Python makes a great prototyping language because it has been described as executable pseudo-code. Not too low or high level.
When I prototype in Python I'm doing the same thing, I'm just using a text editor rather than pad of paper.




Member since:
2006-07-26
I love C and Python.... and I love the fact that they're fairly simple to intermix.
Porting C to Python and Python to C is pretty straight forward (as long as you're not doing OO programming in Python obviously).
To me... I see Python as C but with a nicer syntax and just the right amount of built in data structures.
I love being able to create a throw-away list, dictionary, or other structure right inline a statement.
See if the first two letters of a string match one of several other strings?
In Python:
if foo[:2] in ['XX', 'YY', 'AB', '!!']:
print 'woo hoo'
In C:
if ( strncmp(foo, "XX", 2) == 0 ||
strncmp(foo, "YY", 2) == 0 ||
strncmp(foo, "AB", 2) == 0 ||
strncmp(foo, "!!", 2) == 0 ){
printf("woo hoo\n");
}
... its the little things.
Is the Python going to perform faster?... hell no, but I love the readability. And if it needs to be ported to C for performance, it is straight forward.