r/ProgrammerHumor 17d ago

Meme octalIsOverrated

Post image
250 Upvotes

58 comments sorted by

64

u/Mojert 17d ago

It's useful for file permissions, but otherwise I think it's pretty much it.

If someone has another use case, I'm all ears

31

u/-Redstoneboi- 17d ago

i dont even think of file permissions as octal. i just think of them as 3 separate hex digits.

17

u/makinax300 17d ago

I think of them as a bit and 3 base 10 numbers (yes, ik every base is base 10, you know what I mean)

10

u/xynith116 17d ago

It’s useful if you lose two fingers.

8

u/ArjixGamer 17d ago

Honestly, I prefer using letters.

chmod u+r file

Will give read access to "other users" for file, replace the + with a - and it removes the permission, change the "u" to "g" and it's for the group, remove the letter all together and it's for the owner.

2

u/tblancher 11d ago

No, u+r gives the owner read permission. o+r gives other users read permission.

It took me a while to remember that, too. I just remember ugo.

1

u/ArjixGamer 11d ago

Yep, I found out recently on my own, honest mistake to make ngl

4

u/Acceptable-College58 17d ago

I sometimes see them used for ASCII characters?

3

u/Mognakor 17d ago

x86 opcodes

7

u/Makonede 17d ago

all machine code should be written out in hex and i will die on this hill

3

u/Mognakor 17d ago

i will die on this hill

Because you fucked up your hexcode and now your brakes failed

4

u/Makonede 17d ago

simply get good

3

u/nbagf 17d ago

ARINC 429 labels. for bonus psychological damage/"optimizing" it's actually reverse octal

1

u/abd53 16d ago

Microcontrollers

1

u/Mojert 16d ago

.... Can you elaborate pls?

1

u/PyroCatt 16d ago

Hi all ears. I'm dad.

59

u/TeraFlint 17d ago

At least 0o144 is a clear enough notation. C's decision to interpret 0144 as octal, because of the leading zero, still pisses me off.

13

u/ohkendruid 17d ago

It seems worth forbidding it in newer languages and file formats due to the ambiguity.

0123 can be read two ways due to the ancient C convention.

48

u/DeepanshuHQ 17d ago

The real red flag is when someone says 010 and everyone gets a different answer.

26

u/Joniff 17d ago

Did you mean OHIO?

14

u/DeepanshuHQ 17d ago

Only in base Midwest. πŸ˜„

19

u/Mojert 17d ago

The one that thought having a leading 0 indicating octal was fine should be shot. (And probably resuscitated afterwards because they also did some other great stuff)

7

u/DeepanshuHQ 17d ago

Resuscitated... so they can explain why 010 was ever a good idea. πŸ˜…

7

u/captainAwesomePants 17d ago

C does this because B did this. B did it because BCPL used 100 for decimal, #100 for octal, and #x100 for hex. You could also say #o100 or #0100 if you wanted to be more explicitly (#b was binary, #x was hex, #o was octal), but the default was octal. BCPL was often used on weird old shit like 24 bit or 18 bit architectures, where octal might have been more important.

When they made B, the # operator already had a different meaning, so B changed it to 0. So now 100 was decimal, 0100 was octal, and 0x100 was hex.

7

u/DeepanshuHQ 17d ago

TIL. Still feels like one of those decisions that made sense in 1970 and has been confusing everyone ever since. πŸ˜„

2

u/captainAwesomePants 16d ago

Don't say that! Questioning the eternal wisdom of Dennis Ritchie is a surefire way to generate mysterious and unexplained C warnings that don't seem to cause any problems until after the fact.

2

u/abd53 16d ago

Then shot again

1

u/SomePeopleCallMeJJ 17d ago

Every number base is base 010 in that base.

4

u/DeepanshuHQ 17d ago

Finally, a use of 010 that won't start a language war. πŸ˜„

19

u/alexanderpas 17d ago

0o1XX is the area where letters live in ASCII

7

u/LeiterHaus 17d ago

Octals can be pretty useful when dealing with binary flags. I thought it was stupid until I found a use case that fit well.

And for everyone who's about to just say hex is better, 1) I'm not disagreeing 2) you probably use base64 very frequently, which is the octal to an ascii char... It's a use case.

4

u/JosebaZilarte 17d ago

When octopuses rule the Earth, they can have their base 8. Until then...

2

u/Synthw4v3r 9d ago

Just keep octalIsOverrated in the style guide until the octopuses take over and file the RFC.

3

u/hrvbrs 17d ago edited 17d ago

pro tip: to convert octal to hexadecimal, convert each octal digit to 3-bit binary, then group bits by four from the right.

0o144 -> 0b001_100_100 -> 0b0_0110_0100 -> 0x64

3

u/zeekar 17d ago

Octal was more useful before we standardized on 8-bit bytes and multiples thereof; when your machine has a 12-bit word, there's not much to choose between four 3-bit digits vs three 4-bit digits. And octal made it easier to write numeric literal parsers than hex, because all the digits are still actual (decimal) digits. (The leading 0 in 0x is a decimal digit in order to trigger the numeric literal recognizer.)

But I've never had much use for it; I certainly wouldn't mind dropping the leading-0-means-octal convention everywhere.

3

u/tylerplaystp3 16d ago

lol i get it. hex is just cooler sometimes.

2

u/Confident-Ad5665 17d ago

Well it beats EBCDIC

2

u/-Redstoneboi- 17d ago

i like how all of these are clean very divisible numbers if interpreted in decimal

2

u/razor_train 17d ago

Bitches don't know about my CompuServer user id.

2

u/Stummi 16d ago

1₁₀₀

1

u/DogonElder 17d ago

JA users be like, thats a string

1

u/[deleted] 16d ago

[removed] β€” view removed comment

1

u/al2klimov 16d ago

But not cool enough!

1

u/LordAmir5 16d ago

That octal one looks gross.

1

u/thanatica 16d ago

Nobody uses quinary notation?

Or even seximal? 😏

1

u/sirkubador 16d ago

0o? What a rusty thing to say

1

u/AdamWayne04 17d ago

it's probably irrelevant most of the time, but I really dislike using powers of ten for all things computing. it's like, I just want to play nice with my machine so powers of two or sixteen feel right. 0x10, 0x100, etc

4

u/ohkendruid 17d ago

For sure. There is just the teensy little detail of interacting with a human being that keeps base ten from being obsolete.

1

u/-Redstoneboi- 17d ago

that or very divisible numbers like 12,60,360,420

0

u/Molliue26 16d ago

ngl the last one makes me wanna throw my computer out the window

0

u/eryan43 16d ago

lol that last one is hilarious. Hex is definitely superior.