Problem statement

See the problem statement in the previous post.

This post is about using the C programming language to write a program that implements a shell (REPL) to JIRA’s servers.

Implement the REPL

The basic framework of the “shell” was brought in from this tutorial. The tutorial is well-written and made it easy to understand. This is important because my Tcl version just used “eval”, and that isn’t an option in C.


Available here.

This code implements less than the code in Tcl does, but takes more lines to do it. I didn’t want to implement and test any operations that wrote out to JIRA, like assigning issues or adding comments, since I shouldn’t be writing out to work issues at the moment. This code only gets issues and prints out the summary, description, and comments. It doesn’t even do search right now.

I didn’t want to implement an HTTP client for this, so I just used libcurl. I also didn’t want to deal with JSON-parsing myself, so I pulled in the Jansson library.

Thoughts and impressions

Amazing resource usage

The program used a max of ~12MB of RAM. This includes Curl and JSON-processing, unlike the number I had with Tcl. That’s brilliant. I like this a lot. CPU usage was 0%, just like the Tcl program. This is expected since most of the time the shell is just waiting for user input. There really isn’t a lot processing involved in this shell. 0% CPU usage is so nice.

Low programmer productivity (off the bat)

As one can see above in the “Code” section, the lines-of-code vs. user-features ratio is high. It’s even higher than what I did in Tcl, a language I’ve never coded in before.

But I don’t think it has to be this way. With the proper application of code reuse and factoring, I’m confident the programmer productivity of C can easily come up to over 70% of Tcl or Ruby or Python. As a program gets larger, it is incumbent upon the programmers to build up an application-specific “library” of reused functions. It’s important to ensure that code is refactored and reused appropriately. The advantage of higher-level languages is that someone else has already coded that functionality into the language, while a C programmer has to build it up themselves, or use a common library such as GLib.

This program was written with the intention of using as few non-standard libraries as possible. If I were to build this program in C while working toward higher programmer productivity, I’d just use GLib, or it’s equivalents. With those libraries, the programmer productivity metric for C jumps up a great deal.

I feel so l33t

I can’t lie about this; it felt pretty l33t coding directly in C. I thoroughly enjoyed browsing through the manpages of the various string-manipulation functions in the C standard library. Die.net is a great site.

Leave a Reply