Remy Porter

Computers were a mistake, which is why I'm trying to shoot them into space. Editor-in-Chief for TDWTF.

Sep 2016

Programming is Hard

by in Editor's Soapbox on

A bit ago, I popped into an “Explain Like I’m 5” thread to give my version of the differences between C, C++, Objective-C and C#. In true Reddit fashion, I had the requisite “no five year old could understand this” comments and similar noise. One thing that leapt out to me was that a few commenters objected to this statement: “Programming is hard.”

The most thorough objection read like this:


Properly Handled PHP

by in Coded Smorgasbord on

It’s tempting to pick on PHP, because PHP is a terribly designed language. At the same time, there’s an air of snobbery and elitism in our mockery of PHP. I mean, half the Web runs on PHP, so how bad can it be? These examples could easily have been written in nearly any other language, and they’d be just as bad in those languages too. Is it fair to single out PHP? Perhaps not, but each of these examples does nothing- or nearly nothing- which may very well be PHP’s greatest asset.

As a case in point, Ethan inherited some code. It needs to count how many sub-directories there are in a certain directory.


As The World Ternaries

by in CodeSOD on

Ah, the ternary operator. At their worst they’re a way to obfuscate your code. At their best, they’re a lovely short-hand.

For example, you might use the ternary operator to validate the inputs of a function or handle a flag.


Exceptional Condition

by in CodeSOD on

“This is part of a home-grown transpiler…”, Adam wrote. I could stop there, but this particular transpiler has a… unique way of deciding if it should handle module imports.

Given a file, this Groovy code will check each line of the file to see if it includes an import line, and then return true or false, as appropriate.


Sponsor Announcement: Atalasoft

by in Announcements on

Let’s take a moment to talk about documents. I once worked on an application that needed to generate some documents for Sarbanes-Oxley compliance, and without confessing to too much of a WTF, let’s just say it involved SQL Server Reporting Services, SharePoint, and some rather cryptic web service calls that I’m almost certain have stopped working in the years since I built it. The solution belongs here.

I bring this up, because I’m happy to announce a new sponsor here at TDWTF: Atalasoft, which would have kept me from writing that awkward solution.


unstd::toupper

by in CodeSOD on

C++ is a language with a… checkered past. It’s grown, matured and changed over the decades, and modern C++ looks very little like the C++ of yesteryear. Standard libraries have grown and improved- these days, std feels nearly as big and complicated as parts of Java’s class library.

One useful function is std::toupper. Given a char, it will turn that char into an upper-case version, in a locale-aware fashion. What if you want to turn an entire string to upper-case?


Pointless Revenge

by in Representative Line on

We write a lot about unhealthy workplaces. We, and many of our readers, have worked in such places. We know what it means to lose our gruntle (becoming disgruntled). Some of us, have even been tempted to do something vengeful or petty to “get back” at the hostile environment.

Milton from 'Office Space' does not receive any cake during the a birthday celebration. He looks on, forlornly, while everyone else in the office enjoys cake.


What You Don't See

by in Coded Smorgasbord on

Many times, when we get a submission of bad code, we’re left wondering, “what else is going on here?” Sometimes, you think, “if only I knew more, this would make sense.” More often, you think, “if I knew more, I’d be depressed,” because the code is so clearly bad.

For example, Devan inherited a report, built using SQL Server’s Reporting Services Report Builder tool. Now, this tool is not intended as much as a developer tool, as a “if you can use Excel, you can make a report!” It uses Excel-style functions for everything, which means if you want to have branching conditional logic, you need to use the IIF function.