- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
You've heard of unrolling loops, right? This is just an extension of that optimization technique - unrolled arrays. There's an ACM paper in this.
Admin
The question is "why?"
Admin
I like how they mixed up (and messed up!) the variables starting in PRICE and PIECE. For instance, there is no PIECE30 and no PIECE80 (and I think there are other missing).
Also, I never coded in BASIC, bu having stuffs named ADD27$ in the codebase looks also very nice to add confusion about whether it's a variable name or whether it's an operation that adds 27 dollars to something xD
I'm confused about those variables starting with MAT. Are those for used to do some math? Or do they represent the various materials sold by the company? (unless both cases actually exist in the codebase!)
Anyway... Good luck Argle!
Admin
A couple small-detail WTFs:
Why is there never a PIECE that's a multiple of 10?
Why is add140 the only one that's lower case?
Admin
That would be premature consistency.
Admin
I think I knew that version of BASIC once. The COMMON keyword declares those variables as global variables, so they never go away while the program is running. I say chuck all the variables, especially the Globals, and then see what missing variables the compiler complains about. Also, the naming conventions for variables is incompatibly different between various BASICs and C#.
Admin
Admin
Sorry, but I see no abstraction here. Premature abstraction would be something like a (badly implemented) map of variable names and values, preferably using RTTI, serialized into XML and persisted on distributed databases with multi-level caches and cloud backups, when all you need is a local integer variable. That's what I want to read about on this site!
Admin
Needz moar wooden table ...
Admin
Back when I was a kid I played around in QBasic. Variables were (mostly) not declared, but instead got a type by some sort of inverse hungarian notation. Ending the name with a dollar sign made it a string, a percent sign made it an integer. Not sure if that was just a convention or an actual requirement though.
Admin
As an old BASIC programmer, typically string-typed variables are those that ended with the dollar-sign and those without were either a FP type or an integer type. (Applesoft BASIC used trailing % to indicate integer types.)
Admin
The '%' sign was also used in the somewhat earlier BASIC-PLUS, developed by Digital Equipment Corporation for the PDP-11. I did a lot of work in that back in the early '70s. (Yes, I'm that old.)
Admin
And don't forget things like Microware's BASIC09, which was only just BASIC, having lots of similarities with more modern things like VB.
https://en.wikipedia.org/wiki/BASIC09
Admin
GW-BASIC had
$ String variable
% Integer variable
! Single-precision variable
# Double-precision variable
Admin
It's been decades... BUT... "COMMON" was for sharing, and changing the layout was a breaking change. Think of it as a record structure with implied members (each variable at a given offset). This was often binary persisted also as a "blob"... So pre-declaring spare variables was actually a common practice.
Admin
The important thing to keep in mind is that different specifiers denote different variables. So A$ isn't referring to A in some sort of string context, it is a completely separate and independent variable from A.
Admin
Congratulations, you caused me to spill my coffee. Though that laugh was urgently needed.
On a more serious note: This kind of issue is why I hate when languages require a separation of declaration and assignment. Technically present in C, but especially present in Fortran: Don't you love seeing 20 100-character-lines of declarations at the beginning of a function?
Plus, in Fortran declaration and assignment cannot be on the same line, unless you want a variable, that is persistent across function calls;
looks innocent, but it is implicitly the same as
which is very different from
The most insulting part? Fortran could be a good language, if it just filled out a few annoying omissions. And I count "variables must be declared in a separate declaration block" as one of the largest.
Less annoying but still annoying is the issue of compilation cascades, which are solved completely backwards... You can use submodules for that, but its hard for an existing code-base, and the language just hasn't cultivated a culture of cleanly separating "header" and "implementation" files. Especially, given that Fortran has compiler-generated
.mod
files, which are essentially header files, but are messed up for build systems by nonsense like Intel Fortran adding a timestamp into the file...Addendum 2022-12-02 03:47: I'm ranting I guess :/
Admin
I'm surprised no one has mentioned that declaring your inner loop variables first with short names was a real performance win on Microsoft Basic (e.g Commodore 64, and Apple II)
In that world all variables were stored as unsorted(?) tagged data in the variable space and the linear search time for the storage was important.
I don't remember a COMMON keyword in that BASIC though.
Admin
Most BASIC was interpreted not compiled. I don't know which one this was.
Admin
Commodore BASIC only supported 2 character variables (any other characters were ignored), so a variable called AA$ would be the same instance as AARDVARK$. With BASIC being interpreted the only (speed-) performance would be in the parsing of the BASIC code which was stored as text - although I as I remember keywords were tokenised. Using short (1 or 2 character) variable names was typically used to save memory rather than performance.
Admin
My solution depends on using the variable
MAT90$
........ oh noes!