Cog in Matlab

Tuesday 12 April 2011This is over 13 years old. Be careful.

Cog, my templating and code generation tool, seems to be like the little engine that could. I wrote it years ago to bring a little Python power to a non-Python job. But then it was unexpectedly useful while preparing my slides for PyCon this year. I did a lightning talk explaining why (I start at about 8:00 minutes in).

One of the things I didn’t expect when I released Cog was that people would take the concept and port it to other languages. There are implementations for PHP, Ruby, and Perl. And now, Doug Harriman has written another, so you can Cog in Matlab. I don’t know anything about Matlab, I didn’t realize this was even a sensible idea, but now it’s real.

When I look at Cog now, I see things I’d like to change about it. Maybe there will be a more modern implementation some day. But it does its job well now. If you have text files that you want to do a little bit of processing on, look into Cog, people seem to like it.

» 3 reactions

Comments

[gravatar]
I love Cog, and couldn't have written all of those articles for PyMOTW without it.
[gravatar]
Ned,

I needed something similar a while back and I wrote a cmdline (j2.py) wrapper for Jinja2. Its now in heavy use in our build systems here as a text template compiler tool. I submitted it back to the jinja authors but it didnt go anywhere. I should just go put it up on bitbucket.

--
John Cavanaugh
[gravatar]
Ned:

For the sake of learning something about design, I would be interested in hearing some of the things you would change about Cog. It's small enough and simple enough to be a good case study in design.

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.