Rethinking the coding IDE : SourceKit App on Google Chrome

For the last couple of months I have tried to study up for coming job interviews. This typically means finding an area where I am rusty and make it shine. As I do this I find myself going through my old favorite IDEs and discarding them.

Instead I find myself using IDE combos that I never would have considered before and as a result I am starting to visualize the way I would like to work with my IDE.

Continue reading

Posted in C++, coding, Software Engineering | Tagged , | Leave a comment

Exploring C++11, part 2 (localtime and time again)

C++11 time, part II. Part I you can read here:
Several of the time functions in C++ are not thread-safe and using for example std::localtime or std::asctime can have unwanted side-effects. Other thread unsafe c-library functions that come to mind are std::ctime and std::gmtime. The compiler will likely point out any use of these unsafe functions by generating warnings.

It is nice to know that there is an easy way to make your time code thread-safe and as a bonus getting rid of the compiler warnings.

Depending on your platform the std::localtime can be replaced for platform dependent localtime_r or localtime_s.

std::asctime and std::ctime have _r and _s equivalents but a much better option is to use the std library functions std::strftime and std::put_time.

That is really all you need to avoid problems. Do you want to know details? If so, read on …
Continue reading

Posted in C++ | Leave a comment

C++ Debt Paid in Full? Wait-Free, Lock-Free Queue

In 2009 I wrote about a horrid lock-free Single Producer, Single Consumer Circular Fifo that I had seen in use in the industry. I tried to pick it apart and see what made it tick. Was it broken beyond reason or could it actually work? It was an attempt to understand without recommending the sketchy platform hack.

Of the C++ topics I have written that first article seemed to attract the biggest crowd at CodeProject.  A double-edged sword to say the least since I liked the feedback but did not like the thought of happy coders using something that was not at all kosher. Something that could break their shiny code when they least expected it.

Now with C++11 <atomic> it is a snap to write the wait-free, lock-free simple Single Producer, Single Consumer CircularFifo. Of all the lock-free structures out there, this got to be the easiest to grasp.

I just finished overwriting my old article. The old article is still saved with a nice revision tag but you have to dig to get to it.

For early reviewers here is my own snapshot of the revitalized article.  Its’ not yet spell corrected mirror but with nicer formatting can be found here CodeProject: Lock-Free Single Producer [...]

Enjoy
Kjell

Continue reading

Posted in C++ | 6 Comments

Java Battle Royal: LinkedList vs ArrayList vs DynamicIntArray

My obstinate anti-LinkedList blog entry which turned into a CodeProject article recently took some heat from a former college, David.

I think his objections were smart, to the point and important. Many of his objections came up earlier at CodeProject but instead of expecting the reader to read through all the comments there and here I decided to take a different approach. Instead of doing an easy-to-miss reply in the comments I decided to do a blog sort-of reply here. I am sure many has the same objections and questions as the ones earlier asked, and it is good to bring them into the light (questions + people ;) . This blog post will highlight some issues that were not clearly explained or could be misinterpreted.

Some cut and paste from the reply gives a nice picture of what we should all strive for:

David wrote:
What you should do is to look at your problem and create the most suitable solution for it
[...]
I would try to encourage them choose the correct one [kjell:  data structure choice]   for the specific problem! [...]

Well put. I could not agree more.
Some of the irate comments I have received I can sympathize with. My anti-LinkedList entry can be argued used somewhat contrived examples, even if I actually used real-life examples that I have encountered.

David was so kind as to suggest a few examples when LinkedList should shine. Let us look at them and compare. Let us also quickly do a recap of what the article showed.

Continue reading

Posted in C++, Java | Leave a comment

Not enough patience, Uncle Bob!

<Part II of my personal reflection series, that started back in February>
A while ago I set out to decide whether or not TDD is my cup of tea. Or rather, it is a cup I have just sniffed the aroma of and have yet to fully taste its flavor, would it be a Lapsang souchong experience or Oolong enjoyment?

I come from a background of safety critical, mission critical and tradition of heavily tested software development. Somehow this made me think that software quality was as natural as breathing air to me. My first years of coding followed the cycle of write, compile, test manually, refactor, code, compile, test manually, test of unit-ish suites when nearing completion, and so on.

TDD was an obscure, XP-derived sect that was fun to read about but quickly set aside in a dark corner in my mind. Placed together with other “this should be fun to experiment with in a distant future”. XP was summarily dismissed as I thought how much so called pair programming had set me back during my university years.

Now. Don’t get me wrong. I have grown into, and still am,  a firm believer that code should first be exercised against unit tests before set in place and run with the whole system. This experience came partly from failures of my own and mostly through failures of others that had me cleaning up their disgrace.  It was time consuming, annoying and I just kept wondering what possibly could have made this coder to not test her/his code? …Well hands-on, black-box testing in the lab is far from testing all the ins-and-outs of every class,. and just maybe my practice of the art was not that much different from those that failed? There were important lessons to be learned and they had a great impact on me.

Continue reading

Posted in rambling, Software Engineering | Leave a comment

g2log now with mainstream c++11 implementation

Now the thread part (and much more) of C++11 is available for free, for the mainstream C++ developer. Visual Studio 11 (beta and free) and g++-4.7 (free) are both stable and provides a lot of C++11 features. I really recommend all c++ developers out there to upgrade their toolbox.

Of course I will do my part. I have updated the CMake configuration and I had to fix some use of std::tr1 to std::, with some include correction as well, but now g2log [code | blog | CodeProject] should work out-of-the box both for Windows and Linux developers (VS11 and g++-4.7). The dependency to just::thread is no more.

A huge debt of gratitude to Anthony Williams and his great work with just::thread. I can’t wait to see what he is going to show us next. If you are interested in concurrency and threaded software knowledge I can recommend his book C++ Concurrency in Action. It was and still is a source of inspiration for me.

At the time of this writing there is only (non-recommended) test packages for g++-4.7 on ubuntu. For the Linux developers that would like to use g++-4.7 it is much better to compile it from scratch. I have written down a simple cookbook which in large is copied from http://solarianprogrammer.com/2012/04/13/building-gcc-4-7-on-ubuntu-12-04/ but I have removed the fortran stuff and simplified it a bit.

Enjoy

—- Building gcc-4.7 on Ubuntu 12.04 [read on ] —–

Continue reading

Posted in C++, Software Engineering | 11 Comments

Number crunching: Why you should never, ever, EVER use linked-list in your code again

21th August, 2012: A mirror of this blog-article but heavily debated can be found, with many reader comments, at  CodeProject

Mea Culpa – Please read before continuing

Let us look at the title again. It contains a very important prefix. The title says:

Number crunching: Why you should never, ever, EVER use linked-list in your code again.

Continue reading

Posted in C++, Software Engineering | 28 Comments