Jan 252016
 

I ran into std::recursive_mutex while trying to debug something today. First let me illustrate. I found some class methods which looked like this:

Gasp! I’m thinking to myself, “Why the heck haven’t I seen a deadlock with this before?”. Clearly function_A() is getting a lock on the mutex, and calling function_B() which locks the mutex again.

“Brock, what is ‘lock_t’?……”

I’m glad you asked, because look what it’s hiding:

Ah ha! A type of mutex I haven’t used before. I wrote a previous post about how knowledge of the standard library is a good thing, and I stand by it, but it looks like there is a lot of push against using recursive locks and for good reason:

http://www.zaval.org/resources/library/butenhof1.html
http://www.codingstandard.com/rule/18-3-3-do-not-use-stdrecursive_mutex/
https://cppwisdom.quora.com/Recursive-mutexes-considered-harmful

In this case, everything worked fine, but until I checked the typedef I was questioning my whole universe! It lead me down a path that I didn’t need to for the bug I was trying to find.

My question is the following….

How do I write code that isn’t going to derail the next programmer that is debugging something? Well, clean coding always helps but in this case those functions above look incredibly clean… thankfully there is an effort from the modern C++ community on Cpp Core Guidelines.

And hey, look at this guideline in the works:

  • Prefer non-recursive locks (often used to work around bad reasoning, overhead)

 

Jan 162016
 

Although IDE’s will support git, and I’ll use them for things like history comparisons, I find it faster to do a lot of my git management from the command line (merge, rebase, push, pull etc). It’s invaluable to be able to tell which branch you are on when navigating through your workspace from the terminal. In a few easy steps using an OS X software management software package called Homebrew, we can change our git terminal environment on OS X from this:

Default bash
into this:

Git bash

Install brew:

Install git and bash-completion

If you don’t have one already, create .bash_profile in your user home directory and add the following

And that’s it! Since I found myself setting up my developer environment on OS X again, I also configured some global git settings while I’m at it:

Jan 032016
 

Well there it goes, my first year of blogging. It was certainly a bit on and off earlier in the year, I wasn’t entirely sure what I was getting into or what I was going to talk about. All I knew is that I wanted to have a public place to share my thoughts and interesting pieces of literature or code.

I didn’t really start to kick it into gear until I listened to a Ruby Rogues Podcast about marketing yourself as a software developer. I had never really thought about marketing myself to be honest, it’s something I think most scientists cringe about. “Leave it to the business majors.”, is what I’m sure most of my university colleagues would say. It’s an interesting discussion if you have an hour to burn:

 

The Ruby Rogue crew bring up a very interesting point throughout the discussion on if we choose “not to play the game”. The act of not participating is an action in itself. Though it was never my goal when I started posting, it’s been one portion of motivation to contribute more often rather than let it be something that collects dust.

In any case, for anyone who managed to find their way on here and found something useful. Woohoo! To cap it off, here is a graph of my server traffic over the last year.

 

bandwidth

 

So really only HTTP traffic. My webserver generated this image so I couldn’t remove the useless data. Anyway, I’m optimistic for a continued upward trend!