Thought Leadership

Quick and dirty code checking and execution

By Colin Walls

I often need to do a bit of programming – normally C or C++. I am not generally writing a real software application, as that is not my job, but I often need to produce chunks of code to illustrate a point in an article, presentation or blog post. This code can be anything from a single line to a few dozen. Obviously, all I need to do is create a text file for the code and build it using a suitable toolchain for execution on my PC or for inspection of the resulting assembly language output.

Recently, I was introduced to an interesting alternative …

359f538e69461c8de26e816c3f981dd7Since I work for a company that supplies embedded software development tools, I have no shortage of compilers etc. And, of course, I will make use of these when the need arises. The problem is that I am intrinsically lazy and, if there are a just a few lines of code, I may not bother building/testing it. I just type the code into the article/slide/blog and hope that I have made no errors [or that, if there are, nobody will notice]. I am reasonably confident with C/C++ syntax, so I get away with this most of the time. However, I am not not totally immune to guilt and, particularly with electronic media, I would like to be 100% confident that I am providing my readers with [at least] syntactically correct code.

Just recently, my colleague Jon Roelofs drew my attention to a really interesting online tool: codepad

codepadJon gave me no instructions or introduction – he just threw it at me. But the tool is so simple and intuitive that I immediately saw the value of it [to me] and it was love at first sight.

Basically, codepad is a web app which enables you to compile/interpret/execute code in a quick, straightforward way. It supports C and C++, which are of most interest to me, but it can also handle Python, Lua and whole bunch of other languages. As such, the tool is ideal for syntax and basic functional checking on modest size pieces of code. But it has a few other tricks up its sleeve:

  • If you open a [free] account, you can save each code snippet [codepad calls them “pastes”] to come back to later.
  • You are given a short URL for the page, which makes sharing and collaboration easy.
  • Any paste can be used as the basis for another, so playing is easy.
  • The code can be saved to a text file on your desktop computer.

There may be more things that I have not found yet, but I am very happy with what is on offer. Give it a try.

Leave a Reply

This article first appeared on the Siemens Digital Industries Software blog at