Comment On The End of Hex as We Know It

The abstractions we build in computer science are meant to sweep away painful implementation details for any program, to make them someone else's problem. On real systems it's not always that simple. In the real world, it is sometimes necessary to get down in the muck and reinvent conventions in order to reinforce the foundations of a particular project. [expand full text]
« PrevPage 1 | Page 2Next »

Re: The End of Hex as We Know It

2007-02-26 09:11 • by Hit (unregistered)
Ahh..another classic case of a developer designing a Database with only his application in mind and having no regards to whether you can query it or not. Even asking simple questions about what "flags" are set with SQL would not be readable unless you heavily comment it.

As a developer that also designs databases myself, I have no problem with people who have that dual role, but it essential that they learn first what good database design is before they are allowed to create any sort of schema.

Otherwise, you end up with garbage like this.

Re: The End of Hex as We Know It

2007-02-26 09:11 • by Ged (unregistered)
To quote Homer Simpson, "oh ooo spaghetio!"

I mean holy crud, that code is just awful and unholy in so many ways...

Re: The End of Hex as We Know It

2007-02-26 09:12 • by Licky Lindsay
I've *joked* about using the ASCII characters that come after '9' as hex digits before.

I guess the moral of the story is, any hilariously implausible scenario you can imagine, has probably happened somewhere already.

Re: The End of Hex as We Know It

2007-02-26 09:17 • by seconddevil (unregistered)
I had a similar thing.... it converted ints (casted from strings) into binary, with the gotcha that every pair of binary was swapped for reasons that are beyon the scope of this post... so, say

input-> "XYZ" (imaginary values 'x', 'y' & 'z', btw)
to bin -> 01010101 01010101 00101011 (also imaginary, these don't correspond to anything (i think))
to code -> 10101010 10101010 00010111

magic

Re: The End of Hex as We Know It

2007-02-26 09:23 • by sir_flexalot
What in the world is the point of something like that? Wouldn't you have to custom-handle any operation with that value, i.e. math, etc?

Re: The End of Hex as We Know It

2007-02-26 09:28 • by seconddevil (unregistered)
122739 in reply to 122735
sir_flexalot:
What in the world is the point of something like that? Wouldn't you have to custom-handle any operation with that value, i.e. math, etc?
I am painfully aware of that

Re: The End of Hex as We Know It

2007-02-26 09:31 • by bstorer
Wow. The whole ASCII values for hex thing is laughable, but certainly workable. Switching the endianness is just frustrating. But the code! That takes it to another level.

Re: The End of Hex as We Know It

2007-02-26 09:41 • by Ron (unregistered)
122743 in reply to 122734
seconddevil:

to bin -> 01010101 01010101 00101011 (also imaginary, these don't correspond to anything (i think))


01010101 = 0x55 = U
01010101 = 0x55 = U
00101011 = 0x2b = +

"UU+" .... must be some kind of secret code....

Captcha: gotcha -- it's making fun of me for forgetting my password and the domain changing!

Re: The End of Hex as We Know It

2007-02-26 09:45 • by chooks
Ze goggles, zey do nothing.

Re: The End of Hex as We Know It

2007-02-26 09:49 • by snoofle
122747 in reply to 122743
Hmmm, I usually go straight for the article - I rarely look at the masthead. I didn't even notice the name change until I saw the previous article with 6 pages of posts.

New name is lame, if PC, but then again, the name only caught my attention the first day; I come for the content!

Re: The End of Hex as We Know It

2007-02-26 09:49 • by Luke Dawson (unregistered)
Do these "boolians" bare any resemblance to booleans by any chance, or is he reinventing those too?

Re: The End of Hex as We Know It

2007-02-26 10:18 • by [twisti] (unregistered)
This reminds me of another hex related WTF I've seen a friend do:

He's a horrible programmer that only knows PHP and SQL, and he was asking me for advise on how to store his ~10000 flags for his customers without wasting so much space. Obviously, I told him that storing them by using single bits was a good way - one byte could hold 8 of his flags, instead of wasting 8 bytes on it (he used some integer type to store 1's and -1's). Then I told him that because I know little about PHP and SQL, he should probably read up about bitflags and bitmasks.

I learned never to give out advise like that again when I saw him store a 10,000 character string (2-byte unicode, even): "0010101100101010010....". Testing for a flag would be done by something along the lines of byte.fromBinary(flagString.middle(400,408)); flagBoolean = byte && bitmask;

It still gives me nightmares.

Re: The End of Hex as We Know It

2007-02-26 10:19 • by [twisti] (unregistered)
122755 in reply to 122754
Now that I look at it again, I have no idea why it came to my mind as 'hex related'.

Re: The End of Hex as We Know It

2007-02-26 10:23 • by anonymous (unregistered)
122756 in reply to 122730
This is not a _Worse Than Failure_, this is another way to do ascii2binary. Here you have a binary you can read. Is binary because is the exact value (with a offset), and is text because you can open it with a text editor and change it. Is better to use 0..9-A..F, but that option can be nice to write simple code. Of course, if your code is complex, you better do the normal thing.

Re: The End of Hex as We Know It

2007-02-26 10:24 • by nobody (unregistered)
This code is hexed.

Re: The End of Hex as We Know It

2007-02-26 10:30 • by Dave (unregistered)
Most depressive.

captcha: pointer... but in MACHINEHEX!!!1! OMG!

Re: The End of Hex as We Know It

2007-02-26 10:37 • by ewan (unregistered)
122763 in reply to 122756
anonymous:
This is not a _Worse Than Failure_, this is another way to do ascii2binary.


I tend to agree, while it IS a WTF in that you look at it and go... WTF?! there is usualy some valid reason way back in time which has nescitated the method.

Often the danger of refactoring such code is that you won't notice the reason untill after you have made the change and things stop working!!

Re: The End of Hex as We Know It

2007-02-26 10:40 • by EmmanuelD (unregistered)
122765 in reply to 122756
anonymous:
This is not a _Worse Than Failure_, this is another way to do ascii2binary. Here you have a binary you can read. Is binary because is the exact value (with a offset), and is text because you can open it with a text editor and change it. Is better to use 0..9-A..F, but that option can be nice to write simple code. Of course, if your code is complex, you better do the normal thing.

Right, I prefer to write "4<1>": instead of this nasty 4a1b (or maybe something else). First, it's easier to understand, as the semantics are quite clear. Second, it doesn't mix numbers with letters - something that I haven't understood yet.

Frankly, all those damn conventions about hexadecimal or 'boolians' are just plain dangerous. Our job is kind of artistic, and that *conventionalism* is just another way to give up our freedom. I mean, what about the 1st amendment?

Free yourself! Reinvent!

For instance, my 'boolian' has two values, '+' and '-'. Makes it easier to read. bool(boolian('-')) has some chance to be false, and bool(bollian('+')) may be true in some cases.

(Captcha: riaa. Did I do something wrong?)

Re: The End of Hex as We Know It

2007-02-26 10:47 • by lmollea
I don't see where the "evil bit" as per RFC 3514 will be stored in that table...

Re: The End of Hex as We Know It

2007-02-26 11:08 • by seconddevil (unregistered)
it would be better to keep both, then change the title & image depending on what URL the luser types in. After a few months drop the one with the least usage....

gota love democracy

Re: The End of Hex as We Know It

2007-02-26 11:19 • by Reed H (unregistered)
BTW if people are upset about the name of the site, go post comments in that other article... some of us are trying to read and enjoy the actual content... thanks..

Re: The End of Hex as We Know It

2007-02-26 11:33 • by anonymous (unregistered)
122780 in reply to 122765
EmmanuelD:
anonymous:
This is not a _Worse Than Failure_, this is another way to do ascii2binary. Here you have a binary you can read. Is binary because is the exact value (with a offset), and is text because you can open it with a text editor and change it. Is better to use 0..9-A..F, but that option can be nice to write simple code. Of course, if your code is complex, you better do the normal thing.

Right, I prefer to write "4<1>": instead of this nasty 4a1b (or maybe something else).


WRONG!.. re-read please. I say, easy to READ by code.

Re: The End of Hex as We Know It

2007-02-26 11:47 • by AndrewB (unregistered)
122785 in reply to 122778
Reed H:
BTW if people are upset about the name of the site, go post comments in that other article... some of us are trying to read and enjoy the actual content... thanks..

I'm sorry. I should have thought about that before posting. It was slightly boneheaded of me to talk about how the new site name is lame in a thread like this when another much more appropriate thread is near. I promise to never fill these forums with such blatantly misplaced opinions on how the new site name is lame.

Starting NOW.

Re: The End of Hex as We Know It

2007-02-26 12:20 • by greywar (unregistered)
The flipped binary is something I have seen before while doing embedded systems. I just can't recall why now. I hate monday mornings.

Re: The End of Hex as We Know It

2007-02-26 12:34 • by beta
Oh I've been working on files which encodes date and time, and have specifications like that (after a bit of reverse engineering):


p45w_63A4gS0000.dat
|\/| ||||||`--'
| || |||||| part number of the file
| || ||||||
| || |||||Second \ Encoded from 0 on as
| || ||||Minute | 0123456789
| || |||Hour | ABCDEFGHIJ
| || ||Day | KLMNOPQRST
| || |Month | UVWXYZabcd
| || Year-2000 / efghijklmn
| || opqrstuvwx
| ||
| |Which part of data, "e" or "w"
| |
| Which part of data, as numbers
Always "p"

Re: The End of Hex as We Know It

2007-02-26 13:04 • by part-time language lawyer (unregistered)
122817 in reply to 122748
Naked (bare) booleans? Sounds like some geek's wet dream...

Re: The End of Hex as We Know It

2007-02-26 13:05 • by T.D. (unregistered)
122818 in reply to 122798
beta:
Oh I've been working on files which encodes date and time, and have specifications like that (after a bit of reverse engineering):


p45w_63A4gS0000.dat
|\/| ||||||`--'
| || |||||| part number of the file
| || ||||||
| || |||||Second \ Encoded from 0 on as
| || ||||Minute | 0123456789
| || |||Hour | ABCDEFGHIJ
| || ||Day | KLMNOPQRST
| || |Month | UVWXYZabcd
| || Year-2000 / efghijklmn
| || opqrstuvwx
| ||
| |Which part of data, "e" or "w"
| |
| Which part of data, as numbers
Always "p"



Er, you're generating a lot of these, right?

All the files from the same day have the same first 8 characters... that's gotta be hell to access and store. Do you stick them all into a single directory and just hope it works out, or what? I guess it's clever in that you can write out cute name searches based on whether you want the e[ast?] or w[est?] data.

My company does something similar but cleverly uses folder names for dates and then time chunks per day, so you can see at a glance what's going on from the shell, without even opening another interface. Hmm, 20060117 is missing, guess the MYSTERY DATA SOURCE was down that day...

Final thought: if the first character's always "p"-ing, do you really need it out there in the wind, so to speak?

--------------------------
capt = muhahaha... That's not funny.

Re: The End of Hex as We Know It

2007-02-26 13:22 • by Joseph Newton (unregistered)
122827 in reply to 122795
greywar:
The flipped binary is something I have seen before while doing embedded systems. I just can't recall why now. I hate monday mornings.


Big-endian/little-endian perhaps?

Whatever the reason on the machine level, such details should be taken care of at the lowest level possible, long before they arise to the level of source code.

Re: The End of Hex as We Know It

2007-02-26 13:26 • by iMalc (unregistered)
OMG, I have actually worked on a project in its maintenance phase, where the 6 characters after '9' were used instead of 'A'-'F' in its "HEX" output. It was written in ASM though.

We were going to fix it, but people who had already integrated with our system would suddenly have to change things too, so we just fixed the bugs and left well enough alone. The product is dead anyway now.

Re: The End of Hex as We Know It

2007-02-26 13:34 • by Jeff S
If you want comment on the new website name, that's fine, but please do so in an appropriate forum ... Thanks!

Re: The End of Hex as We Know It

2007-02-26 13:35 • by Antony Curtis (unregistered)
122837 in reply to 122732
Licky Lindsay:
I've *joked* about using the ASCII characters that come after '9' as hex digits before.

I guess the moral of the story is, any hilariously implausible scenario you can imagine, has probably happened somewhere already.


Perhaps someone should tell the guy that he is not programming on a Sinclair ZX-81... Those little machines did not use ASCII.... CHR(ORD('9')+1) = 'A'

Fun!

Re: The End of Hex as We Know It

2007-02-26 13:40 • by Antony Curtis (unregistered)
122851 in reply to 122837
Antony Curtis:
Licky Lindsay:
I've *joked* about using the ASCII characters that come after '9' as hex digits before.

I guess the moral of the story is, any hilariously implausible scenario you can imagine, has probably happened somewhere already.


Perhaps someone should tell the guy that he is not programming on a Sinclair ZX-81... Those little machines did not use ASCII.... CHR(ORD('9')+1) = 'A'

Fun!


Oops, I probably should use the correct ZX81 syntax.... so it would be CHR$(CODE('9') + 1) = 'A'

Re: The End of Hex as We Know It

2007-02-26 14:52 • by Expat (unregistered)
OMFG, That hex coding is painful to look at!
Maybe is because the boolians are used by booligans for configuation.
What if I take the array of bits and give a power of 2 value to each position on the array? I'm so clever! Maybe I should call them bite or bait, not decide yet...

Re: The End of Hex as We Know It

2007-02-26 14:52 • by Expat (unregistered)
OMFG, That hex coding is painful to look at!
Maybe is because the boolians are used by booligans for configuation.
What if I take the array of bits and give a power of 2 value to each position on the array? I'm so clever! Maybe I should call them bite or bait, not decided yet...

Re: The End of Hex as We Know It

2007-02-26 15:33 • by James (unregistered)
I actually used a "hex" like this for a personal program I wrote myself. It was actually used to write some simple "code" (pretty close to assembly in its simplicity of design, and a whole lot less readable) for a Scott Adams adventure-style game on a TI-99/4A written in TI Basic. (It worked, but not until I got it onto a different machine. The code was fine, but the slow machine, as well as the three layers of interpretation, made reading the <100 line file from disk take five minutes.)

For comparison, I came up with the scheme at the age of 14, and by the time I was 18, I had realized just how badly designed it was. And my implementation wasn't nearly as badly engineered as this monstrosity.

Re: The End of Hex as We Know It

2007-02-26 15:45 • by Rich (unregistered)
122949 in reply to 122837
CHR$ (CODE "9" +1)

I think you'll find.

Re: The End of Hex as We Know It

2007-02-26 16:20 • by totolamoto (unregistered)
122975 in reply to 122795
Flipped binaries are often necessary when working with bitmaps or else you end with strange pictures.

Re: The End of Hex as We Know It

2007-02-26 16:32 • by bstorer
122986 in reply to 122778
Reed H:
BTW if people are upset about the name of the site, go post comments in that other article... some of us are trying to read and enjoy the actual content... thanks..

The site had a name change? Huh, must've missed it.
On topic, though, people can't seem to see the bigger picture. Look at the pathetic way two booleans are stored as an int. That's way bigger Worse Than Failure material.

Re: The End of Hex as We Know It

2007-02-26 18:29 • by Johnny (unregistered)
I think nobody got it...
These are esoteric data types, they are not booleans but boolians. Geezzz you guys should get the WTF award

Re: The End of Hex as We Know It

2007-02-26 19:22 • by Excession (unregistered)
123057 in reply to 122748
Luke Dawson:
Do these "boolians" bare any resemblance to booleans by any chance, or is he reinventing those too?


Bare? You mean, of course, bear.

"Baring gifts" has all sorts of connotations :)

capcha: alarm

wtf: I have a username/account :)

Re: The End of Hex as We Know It

2007-02-26 19:45 • by Skipper (unregistered)
That was worse than pepper spray.

Re: The End of Hex as We Know It

2007-02-26 22:50 • by Joseph Newton (unregistered)
123071 in reply to 122851
Antony Curtis:
Antony Curtis:
Licky Lindsay:
I've *joked* about using the ASCII characters that come after '9' as hex digits before.

I guess the moral of the story is, any hilariously implausible scenario you can imagine, has probably happened somewhere already.


Perhaps someone should tell the guy that he is not programming on a Sinclair ZX-81... Those little machines did not use ASCII.... CHR(ORD('9')+1) = 'A'

Fun!


Oops, I probably should use the correct ZX81 syntax.... so it would be CHR$(CODE('9') + 1) = 'A'


Thanks, Anthony,

Boy, that does take me back, and I remember the thrill: "Fially, I have a machine I can actually write my programs on. Mine was a Timex, though, Timex 1000, to be precise. With the special supplementary RAM pack, I could boost it to a whopping 16K.

That was actually enough to implement a paystub generator that handled weekly, monthly, bi-weekly, semi-monthly pay periods, calculated OT on a 40hrs/week basis, and correctly handled federal, Oregon State, and Social Security deduction, taking earned income credit into account also. It worked quite well up until Sen. Bob "Long-Tongue" Packwood introduced his "Tax Simplification" in 1986. Somehow the dumbed-down tables were just not worth updating the program for.

Re: The End of Hex as We Know It

2007-02-27 00:21 • by Scottford (unregistered)
Best WTF in months, I says. Totally hideous.

Re: The End of Hex as We Know It

2007-02-27 03:41 • by Arancaytar
123096 in reply to 122740
bstorer:
Wow. The whole ASCII values for hex thing is laughable, but certainly workable. Switching the endianness is just frustrating. But the code! That takes it to another level.


What about the concept of storing a non-atomic value in a single field in the first place?

I can just hear the designer: "But 25 columns is just too BIG! How can we use such a WIDE table?"

Re: The End of Hex as We Know It

2007-02-27 14:17 • by whicker (unregistered)
123314 in reply to 122827
Joseph Newton:
greywar:
The flipped binary is something I have seen before while doing embedded systems. I just can't recall why now. I hate monday mornings.


Big-endian/little-endian perhaps?

Whatever the reason on the machine level, such details should be taken care of at the lowest level possible, long before they arise to the level of source code.

Wrong.

In the embedded world, you do not muck with the endianess. You let the program deal with it. It's easy enough to write a simple function to reverse the endian in a consistent fashion, rather than have hardware with just plain incorrect behavior if an un-alligned read or write is performed.

Stuff like, oh crap, what memory area was this read from? Oh no, that place... what were the first two LSB's of the address where this int32 was read?

Re: The End of Hex as We Know It

2007-02-27 14:38 • by Prosthetic Lips (unregistered)
123322 in reply to 122818
T.D.:
beta:
Oh I've been working on files which encodes date and time, and have specifications like that (after a bit of reverse engineering):


p45w_63A4gS0000.dat
|\/| ||||||`--'
| || |||||| part number of the file
| || ||||||
| || |||||Second \ Encoded from 0 on as
| || ||||Minute | 0123456789
| || |||Hour | ABCDEFGHIJ
| || ||Day | KLMNOPQRST
| || |Month | UVWXYZabcd
| || Year-2000 / efghijklmn
| || opqrstuvwx
| ||
| |Which part of data, "e" or "w"
| |
| Which part of data, as numbers
Always "p"



Er, you're generating a lot of these, right?

All the files from the same day have the same first 8 characters... that's gotta be hell to access and store. Do you stick them all into a single directory and just hope it works out, or what? I guess it's clever in that you can write out cute name searches based on whether you want the e[ast?] or w[est?] data.

My company does something similar but cleverly uses folder names for dates and then time chunks per day, so you can see at a glance what's going on from the shell, without even opening another interface. Hmm, 20060117 is missing, guess the MYSTERY DATA SOURCE was down that day...

Final thought: if the first character's always "p"-ing, do you really need it out there in the wind, so to speak?

--------------------------
capt = muhahaha... That's not funny.


Ooh, can we make the above a WTF? What happens when you get to year 2060? Sounds like a Y2K (which happens in another 17 years, according to us programmers) all over again.

Sweet!

-------------------------
capt = digdug (fun game)

Re: The End of Hex as We Know It

2007-02-27 21:37 • by Old Wolf
123404 in reply to 122732
Licky Lindsay:
I've *joked* about using the ASCII characters that come after '9' as hex digits before.

I guess the moral of the story is, any hilariously implausible scenario you can imagine, has probably happened somewhere already.


I had an IBM JX PC (1980 vintage) with a game called Tapper. After you finished four levels, level five was the same as level 1, and so on. Obviously the designers never anticipated anybody would bother to go past level 99, because the level indicator then went on to say ":0", ":1", etc. It went through ';', '<', '=', '>', '?' before I got bored of it.

Re: The End of Hex as We Know It

2007-02-28 12:09 • by beta
123528 in reply to 122818
T.D.:
beta:
Oh I've been working on files which encodes date and time, and have specifications like that (after a bit of reverse engineering):


p45w_63A4gS0000.dat
|\/| ||||||`--'
| || |||||| part number of the file
| || ||||||
| || |||||Second \ Encoded from 0 on as
| || ||||Minute | 0123456789
| || |||Hour | ABCDEFGHIJ
| || ||Day | KLMNOPQRST
| || |Month | UVWXYZabcd
| || Year-2000 / efghijklmn
| || opqrstuvwx
| ||
| |Which part of data, "e" or "w"
| |
| Which part of data, as numbers
Always "p"



Er, you're generating a lot of these, right?

All the files from the same day have the same first 8 characters... that's gotta be hell to access and store. Do you stick them all into a single directory and just hope it works out, or what? I guess it's clever in that you can write out cute name searches based on whether you want the e[ast?] or w[est?] data.

My company does something similar but cleverly uses folder names for dates and then time chunks per day, so you can see at a glance what's going on from the shell, without even opening another interface. Hmm, 20060117 is missing, guess the MYSTERY DATA SOURCE was down that day...

Final thought: if the first character's always "p"-ing, do you really need it out there in the wind, so to speak?


The WTF is that the file naming scheme is not created by me, but the previous programmer; thousands of files have been created already, and I can't ask for a more sensible file naming or directory structuring scheme. I'm just the one to use the files --- and you're right, all the files are placed in the same folder (don't ask how long it would take just to do an ls). What I need to do is to combine the "e" and "w" files with the same second and third character that are nearest in time, parse them, and do further processing.

In my student days, I once wrote a program that generated tens of thousands files in the same directory. It was a practical lesson to time how long the ls command can take. Maybe the programmer who designed such a scheme was just repeating my fault, but in a production environment.

Re: The End of Hex as We Know It

2007-03-01 19:41 • by AdT (unregistered)
F:<ABG> A>Q... ;KBEE:GM, CNLM ;KBEE:GM!

Re: The End of Hex as We Know It

2010-08-11 19:18 • by Anonymous (unregistered)
A WTF that wasn't noted here: He used Hungarian notation for bBit0 and bBit1. As if variables named Bit0 and Bit1 could be anything but Bools.

On second thought, that was actually well thought out. Sometimes, bits cannot be accurately represented by Booleans, such as when...I got nothing.
« PrevPage 1 | Page 2Next »

Add Comment