CodeSOD: Across the 4th Dimension
We're going to start with the code, and then talk about it. You've seen it before, you know the chorus: bad date handling:
C_DATE($1) C_STRING(7;$0) C_STRING(3;$currentMonth) C_STRING(2;$currentDay;$currentYear) C_INTEGER($month) $currentDay:=String(Day of($1)) $currentDay:=Change string("00";$currentDay;3-Length($currentDay)) $month:=Month of($1) Case of : ($month=1) $currentMonth:="JAN" : ($month=2) $currentMonth:="FEB" : ($month=3) $currentMonth:="MAR" : ($month=4) $currentMonth:="APR" : ($month=5) $currentMonth:="MAY" : ($month=6) $currentMonth:="JUN" : ($month=7) $currentMonth:="JUL" : ($month=8) $currentMonth:="AUG" : ($month=9) $currentMonth:="SEP" : ($month=10) $currentMonth:="OCT" : ($month=11) $currentMonth:="NOV" : ($month=12) $currentMonth:="DEC" End case $currentYear:=Substring(String(Year of($1));3;2) $0:=$currentDay+$currentMonth+$currentYearAt this point, most of you are asking "what the hell is that?" Well, that's Brewster's contribution to the site, and be ready to be shocked: the code you're looking at isn't the WTF in this story.
Let's rewind to 1984. Every public space was covered with a thin layer of tobacco tar. The Ground Round restaurant chain would sell children's meals based on the weight of the child and have magicians going from table to table during the meal. And nobody quite figured out exactly how relational databases were going to factor into the future, especially because in 1984, the future was on the desktop, not the big iron "server side".
Thus was born "Silver Surfer", which changed its name to "4th Dimension", or 4D. 4D was an RDBMS, an IDE, and a custom programming language. That language is what you see above. Originally, they developed on Apple hardware, and were almost published directly by Apple, but "other vendors" (like FileMaker) were concerned that Apple having a "brand" database would hurt their businesses, and pressured Apple- who at the time was very dependent on its software vendors to keep its ecosystem viable. In 1993, 4D added a server/client deployment. In 1995, it went cross platform and started working on Windows. By 1997 it supported building web applications.
All in all, 4D seems to always have been a step or two behind. It released a few years after FileMaker, which served a similar niche. It moved to Windows a few years after Access was released. It added web support a few years after tools like Cold Fusion (yes, I know) and PHP (I absolutely know) started to make building data-driven web apps more accessible. It started supporting Service Oriented Architectures in 2004, which is probably as close to "on time" as it ever got for shipping a feature based on market demands.
4D still sees infrequent releases. It supports SQL (as of 2008), and PHP (as of 2010). The company behind it still exists. It still ships, and people- like Brewster- still ship applications using it. Which brings us all the way back around to the terrible date handling code.
4D does have a "date display" function, which formats dates. But it only supports a handful of output formats, at least in the version Brewster is using. Which means if you want DD-MMM-YYYY (24-SEP-2025) you have to build it yourself.
Which is what we see above. The rare case where bad date handling isn't inherently the WTF; the absence of good date handling in the available tooling is.
I'm 65 with two young children: How can I provide for when I'm gone, but also make them good with money?
Forget revenge saving... use our mind-trick saving method to build a healthy pot of cash instead
Is Britain on the verge of stagflation? What the OECD warning over high inflation and low growth means
Labour taxes are blamed as private sector jobs are slashed... but the bloated public sector expands and grim survey lays bare broken Britain
Essex council planning to hand out £30k to local community groups
Woke-on-woke fury brings chaos to Greta Thunberg's Gaza flotilla: Pro-Palestine activists quit convoy after learning LGBTQ campaigners are on board... and Swedish eco-protester also leaves her role
Margot Robbie's post-baby body sparks frightening trend among women desperate to lose weight
Gigi Hadid makes rare comment about ex Zayn Malik as fans praise daughter Khai's 'normal' 5th birthday party
Heartbroken family reveal teen influencer who documented her 11-year cancer battle has tragically died
Plans to ban boy racers in Essex towns after 'significant antisocial behaviour'
Jennifer Aniston, 56, reveals what she indulges in on a 'cheat day' while still maintaining a size 2 figure
Trump threatens to sue 'Fake News' ABC as Jimmy Kimmel returns to host his late night show after Charlie Kirk comments
Trump's rallying cry for the defence of Western civilisation: NILE GARDINER on why the President's extraordinary wake-up call is a game-changer
Are certain people 'immune' to autism? Experts explain Trump's claims that some groups see no diagnoses
Micron close to selling all the high-bandwidth memory it will make in 2026
Memory-maker Micron says it is close to securing customers for all the high-bandwidth memory (HBM) it will make next year. Unsurprisingly, the company also predicts it will enjoy improved profit margins.…