Category Archives: C language

Dependency injection demystified

At the moment, most of my actual coding work is in Java — which is a novelty for me, as it’s not a language that I am naturally inclined to like. But as I’m coming to grips with it, I’m finding that Java in 2015 is a rather more pleasant language than the one I wrote a CQL parser in back in 2002. The main problem with it is the culture, and in particular the huge vocabulary of patterns, which takes a long time to learn.

20120220_2

So here is today’s brief lesson, which is on dependency injection. Continue reading

A hard-to-find bug, and equivalent APIs in low- and high-level languages

I just wrote an entry about a hard-to-find bug on the blog of my employer, Index Data.  It turned out to hinge on the different API expectations of programmers in low- and high-level languages — specifically C and Ruby — and I think it’ll be of interest to most Reinvigorated Programmer readers.  Enjoy!

Programming Books, part 4: The C Programming Language

It’s 32 years old, and it remains the single greatest book ever written about a programming language.  Its crown is secure; even if you’d not already read the title of this article, you’d know what book I’m talking about.  It’s the only language-specific book in Top Five programming books of the Programming Reddit’s FAQ.  Co-written by Reinvigorated Programmer regular Brian W. Kernighan and Dennis M. Ritchie, it’s not just the definitive book about the language in question, it’s the book the rewrote the book on what it means to be definitive.  Step forward, please, The C Programming Language! [amazon.com, amazon.co.uk]

Continue reading

Why C Is Not My Favourite Programming Language

Ahem.

C is sometimes castigated for the syntax of its declarations, particularly ones that involve pointers to functions. The syntax is an attempt to make the declaration and the use agree; it works well for simple cases, but it can be confusing for the harder ones, because declarations cannot be read left to right, and because parentheses are over-used. The difference between int *f() and int (*pf) illustrates the problem

[…]

char (*(*x[3])())[5]

x: array[3] of pointer to function returning pointer to array[5] of char

— Kernighan & Ritchie, The C Programming Language, 2nd Edition, Chapter 5 (Pointers and Arrays), section 5.12 (Complicated Declarations).

Case closed.

.

.

.

(Sorry that the Category for this posting is “C language” rather than C; as far as I can make out, WordPress ignores !isalnum() characters when determining uniqueness, and won’t let me add a “C” category because I already have “C++”.)