Help a Hacker

December 5, 2019 Colin Walls

Nowadays, the word “hack” has bad connotations. The typical thought is that a hacker is gains unauthorized access to a website, server etc., with malevolent intentions. Historically, hacking meant something quite different; it referred to an undisciplined approach to writing code, when no consideration is given to design at all. The programmer just starts cranking code. While I am sure that a modern, well-qualified software engineer could never be accused of taking this approach to coding, I think there are circumstances when a bit of old-style hacking is justified and perfectly reasonable.

I do not generally have a need to write any serious code nowadays. However, I often need to write snippets to illustrate a point or a technique that I might be describing in an article, blog, or video. Although I can write C code with little effort, I have certain considerations when I do so in this context:

  1. I need to be sure that the syntax is correct.
  2. I want to verify that the code does do what I intended.
  3. I may be interested in the code generated by the compiler.

Obviously, I just need to compile, and maybe, run the code. I have various options:

  • I could build it natively on my computer and run the code – I use a Mac and Xcode is free. I have done this from time to time, but I find it a little awkward and do not get to see the compiled code.
  • I could build the code with a cross-compiler and maybe run it under simulation or on a real target; after all I work for a company that sells such tools. However, this requires some setting up that I might not be inclined to do for such small pieces of code.

My attention was drawn recently to a couple of free, online tools that address my needs rather well:

codepad (http://codepad.org) is an online tool that lets you enter some code and compile/run it. You can set up an account and save and share the saved code (termed “pastes”). Very simple and straightforward.

Compiler Explorer (https://godbolt.org) appears to be similar to codepad but has a focus on code generation. You can enter some code, then build it with a wide variety of compilers and view the assembly output.

Although my needs are rather specific, I would think that the capabilities of these tools are such that many engineers would find them handy from time to time.

Previous Article
AVX Releases New High-Temperature, Glass-Encapsulated Multilayer Varistors Rated for 150°C Operation
AVX Releases New High-Temperature, Glass-Encapsulated Multilayer Varistors Rated for 150°C Operation

Designed for use in high-temperature, high-energy, & harsh-environment automotive, industrial, & oil & gas ...

Next Article
Murata Manufacturing Co. Common Mode Choke Coil for Automotive Ethernet

Product has an operating temperature range of -55 to +150ºC, which compares to the -40 to +125ºC temperatur...