Linked by MOS6510 on Thu 10th Jan 2013 23:25 UTC
General Development "For years I've tried my damnedest to get away from C. Too simple, too many details to manage, too old and crufty, too low level. I've had intense and torrid love affairs with Java, C++, and Erlang. I've built things I'm proud of with all of them, and yet each has broken my heart. They've made promises they couldn't keep, created cultures that focus on the wrong things, and made devastating tradeoffs that eventually make you suffer painfully. And I keep crawling back to C."
Permalink for comment 548450
To read all comments associated with this story, please click here.
C and Python
by FunkyELF on Fri 11th Jan 2013 21:48 UTC
Member since:

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.

Reply Score: 5