Episode 007 – Handling EOF with std::getline

After coming across a coding challenge that required knowing how to properly read a file from stdin and print it back to stdout, I realized that I had to look up this seemingly basic task. And yet it’s one of those things that a developer usually takes for granted in a large project. You’re often building on thousands of lines of infrastructure with small details like handing input from stdin either already taken care of or made redundant by file I/O, RPC systems and networking.

Continue reading “Episode 007 – Handling EOF with std::getline”

An Asio HTTP client in 15 minutes

This episode completes our introduction to the Asio C++ networking library by coding up an HTTP client app capable of retrieving content from the web. Rather than create a toy example using a trivial protocol, I wanted to demonstrate how easy it can be to write a practical app in just a short amount of time. Of course don’t interpret this as a license to continue the work and try to roll your own HTTP client library.

Continue reading “An Asio HTTP client in 15 minutes”

Episode 003 – Intro to Asio

This episode will provide a quick introduction to the Asio library and a small amount of asynchronous programming in general. Future episodes will continue this work by introducing additional libraries and talking to actual web services. For now we’ll start by building a small app that resolves hostnames into IP addresses. The gflags and glog libraries will provide some helpful infrastructure to get things started. Take a look at Episode 002 to refresh your memory of how they work.

Continue reading “Episode 003 – Intro to Asio”

Episode 002 – An opinionated start to a C++ project

Thanks in part to fierce competition over the past decade, C++ has seen a huge ramp in language features and batteries included library support. Build tools have also improved so much that starting a new project could almost be described as user-friendly. Most projects are standardizing around CMake which, with a style ironically similar to C++, can be quite powerful when restricted to a pleasant subset of the overall language. This is a quick guide to starting your own C++ programming project. Use a few of these concepts and you’ll be off to a great start.

Continue reading “Episode 002 – An opinionated start to a C++ project”

Episode 001 – Handling Matlab interrupts in Java

Matlab is a great tool for prototyping new ideas, running experiments and visualizing the results. And its native support for Java libraries quickly takes those ideas from prototype to production. However with a large enough Matlab and Java code base, eventually one problem always rears its head. There is effectively no way to terminate a long running or blocked Java method call! Just try to Ctrl-C out of a Java method from Matlab and see for yourself.

Continue reading “Episode 001 – Handling Matlab interrupts in Java”