1

I have implemented a python and c version of crack way back from problem set 2. Both of them work, and both use the same algorithms/processing just expressed in two different languages. Out of curiosity I wanted to see how fast python was over c, or vice versa.

I plugged in the same 5-letter hashed word for both, and crack.c was able to find the answer WAY BEFORE the python program. Is this normal? I would think that even if they are different languages, they would take at least the same amount of time, since they use the same algorithm... (if not python outperforming the more archaic c language, of what I had expected)

0

It's not the algorithms, it really is the language. C programs are compiled into machine code which executes quite fast. (If you think C is fast, try writing in assembler without all the overhead included in higher level languages!) Other languages depend on whether they are compiled or interpreted. Compiled languages would have similar speed. Interpreted languages take more time to execute because they have to be "interpreted" from the source code each time they are executed, similar to compiling line by line while executing.

Python is a language that isn't definitively identified as either compiled or interpreted. Rather, it seems to be dependent on the environment. In any case, I think the argument above applies here as python seems to behave more often like an interpreted language.

See the following link for more:

http://net-informations.com/python/iq/interpreted.htm

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

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