This may sound like a weird thing to do, but actually, I have craved for something like that every time I have to read C code. Converting C code to Python, can not only help us understand code more easily, but also turn non perfomance-critical code easier to maintain. C can be easy enough to read if well-written and formatted (indented) adequately, however having to move back and forth between .h and .c files drives me mad sometimes.
You can imagine my joy when I came across "ctopy", create by none other than Eric Raymond himself!
The first problem I ran into was the fact that ctopy was not available on my Ubuntu. No problem, a quick search through Eric's web site lead me to it:
http://www.catb.org/~esr/ctopy/
Naturally, ctopy is written in python and my immediate impulse was to download and test it.
For test code I decided to download a small C program from the "computer language shoutout" site:
http://shootout.alioth.debian.org/u64q/program.php?test=mandelbrot&lang=gcc&id=6
Unfortunately even for this simple program, ctopy didn't do a good job. I am not including the results here. but you can easily replicate them with the command:
cat mandelbrot.c | indent |./ctopy
The man page of ctopy recommends to pipe the C code through indent, because it relies on the indentation of the C code to do the translation.
Well as Raymond himself says in the beggining of ctopy's man page, its a quick and dirty translator, which requires a human to finish the job.
Anyway, that's how far my dream of a "Google Translate" for code went. I decided to post the links in case someone decides to continue where Raymond stopped.
Thursday, March 18, 2010
Friday, February 26, 2010
Utopia
Interesting post, But hoping to invert those proportions, i.e., making the smarter guys the 80% is harder that having a society where everyone earns more money than they can spend... Pretty next to impossible...;-)
in reference to: Coding Horror: The Two Types of Programmers (view on Google Sidewiki)Monday, December 14, 2009
LaTeX Tikz examples
I am currently working on a presentation where I have to include a lot of mathematical graphs, so instead of plotting using matplotlib and inserting the result as a figure, I am considering using specialized LaTeX packages to create the graphs. While searching for documentation, I found this great repository of examples for the Tikz package.
referente a: http://www.texample.net/tikz/examples/ (ver no Google Sidewiki)
Subscribe to:
Posts (Atom)
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=8bdfe72d-7ef4-4972-957a-38ebfa7af722)