Feed aggregator
Amazon Pitches AI Tools as Co-Workers While Axing Jobs
Read more of this story at Slashdot.
Idaho Lab Produces World's First Molten Salt Fuel for Nuclear Reactors
Read more of this story at Slashdot.
Was the Airbus A320 Recall Caused By Cosmic Rays?
Read more of this story at Slashdot.
CodeSOD: The Magic Array
Betsy writes:
I found this snippet recently in a 20-year-old RPG program.
Ah, yes, twenty years ago, RPG, that means this was written in the 1970s. What? No. That can't be right? That's how long ago?
Joking about my mortality aside, in the early oughts, most of the work around RPG was in keeping old mainframe systems from falling over. That entirely new code was being written, that new projects were being started twenty years ago is not a surprise, but it's unusual enough to be remarkable. That said, the last release of RPG was in 2020, so it clearly keeps on keeping on.
In any case, this developer, we'll call them "Stephen", needed to create an array containing the numbers 12 through 16.
Let's take a peek at the code.
D RowFld S 3 0 DIM(5) D X S 3 0 D Y S 3 0 C EVAL X = 12 C FOR Y = 1 TO %Elem(RowFld) C EVAL RowFld(y) = X C EVAL X = X + 1 C ENDFORThe first three lines create some variables: RowFld, which is an array containing 5 elements, and will hold our offsets. X and Y are going to hold our numeric values.
We set X equal to 12, then we start a for loop from 1 to the length of our RowFld. We set the element at that index equal to X, then increment X.
The code is awkward, but is not exactly the WTF here. This particular program displays a file and a subfile, and these values are used to position the cursor inside that subfile. The array is never iterated over, the array is never modified, the array would 100% be better managed as a set of constants, if you didn't want to have magic numbers littering your code. More than that, the location of the subfile on the screen has never changed. And let's be fair, this didn't get rid of magic numbers, it just made them one through five, instead of 12 through 16, as the indexes in the array are just as arbitrary.
In other words, there's no point to this. Even if the specific version of RPG didn't have constants variables that you handle like constants would be fine (my checks on the documentation seem to imply that CONST first appeared in version RPG IV 7.2, which makes it look like circa 2016).
But there's one more bit of weirdness here. Stephen had several years of experience with RPG, and all of that experience was from the "free-format" era of RPG. You see, way back in 2001, RPG finally freed itself from its dependency on punchcards, and started allowing you to write code as just strings of text, without requiring certain things to exist in certain columns. This was a generally positive enhancement, and Betsy's team immediately adopted it, as did everyone running the latest versions of RPG. All new development was done using the "free-format" style, so they could write code like normal people. They even had a conversion tool which would do some simple string manipulation to convert legacy RPG programs into the modern style, and had basically abandoned the legacy style without looking back.
Except for Stephen, who insisted on the column oriented format. Who protested when anyone tried to modify their code to modernize it at all. "Oh, we used free-format at my last job," Stephen said when pressed, "but it's confusing and columns are just cleaner and more readable."
Eventually, someone else wrote a program that absorbed all the functionality in Stephen's program. Stephen kept plugging away at it for a few years afterwards, because a handful of users also refused to migrate to the new tool. But eventually they left the company for one reason or another, and Stephen found himself without users for his work, and left with them.
[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.All of Russia's Porsches Were Bricked By a Mysterious Satellite Outage
Read more of this story at Slashdot.
Can This Simple Invention Convert Waste Heat Into Electricity?
Read more of this story at Slashdot.
Why Meetings Can Harm Employee Well-Being
Read more of this story at Slashdot.
EU Urged to Soften 2035 Ban on Internal Combustion Engine Cars
Read more of this story at Slashdot.
College Students Flock To A New Major: AI
Read more of this story at Slashdot.
No Rise in Radiation Levels at Chernobyl, Despite Damage from February's Drone Strike
Read more of this story at Slashdot.
OpenAI Insists Target Links in ChatGPT Responses Weren't Ads But 'Suggestions' - But Turns Them Off
Read more of this story at Slashdot.
How Home Assistant Leads a 'Local-First Rebellion'
Read more of this story at Slashdot.
Why Gen Z is Using Retro Tech
Read more of this story at Slashdot.
Is Netflix Trying to Buy Warner Bros. or Kill It?
Read more of this story at Slashdot.
New FreeBSD 15 Retires 32-Bit Ports and Modernizes Builds
Read more of this story at Slashdot.
Homebrew Can Now Help You Install Flatpaks Too
Read more of this story at Slashdot.
Many Privileged Students at US Universities are Getting Extra Time on Tests After 'Disability' Diagnoses
Read more of this story at Slashdot.
Is Ruby Still a 'Serious' Programming Language?
Read more of this story at Slashdot.
New Jolla Phone Now Available for Pre-Order as an Independent Linux Phone
Read more of this story at Slashdot.
The Anxieties of Full-Body MRI Scans (Not Covered by Insurance)
Read more of this story at Slashdot.
