Sign In
Forgot Password?
Sign In | | Create Account

Quick and dirty code checking and execution

Colin Walls

Colin Walls

Posted Jul 28, 2014
0 Comments

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.

More Blog Posts

About Colin Walls Follow on Twitter

Colin WallsI have over twenty-five years experience in the electronics industry, largely dedicated to embedded software. A frequent presenter at conferences and seminars and author of numerous technical articles and two books on embedded software, I am a member of the marketing team of the Mentor Graphics Embedded Systems Division, and am based in the UK. Away from work, I have a wide range of interests including photography and trying to point my two daughters in the right direction in life. Learn more about Colin, including his go-to karaoke song and the best parts of being British: http://go.mentor.com/3_acv Visit The Colin Walls Blog

More Posts by Colin Walls

Comments

No one has commented yet on this post. Be the first to comment below.

Add Your Comment

Please complete the following information to comment or sign in.

(Your email will not be published)

Archives

 
Online Chat