TheaterFire

What is the most useless but interesting thing you learned while learning programming?

Posted by F_F_G_@reddit | learnprogramming | View on Reddit | 69 comments

The most useless thing I've heard is the advice that you need to write websites in C++

Reply to Post

69 Comments

Heartic97@reddit

I mean, I used to think that learning out-dated methods was useless, but understanding how a language started and how it evolved was actually very useful. The classic example is how to center a div without the use of modern CSS methods such as flex/grid.
View on Reddit #50731758

ahavemeyer@reddit

Swapping two variables by using math.
View on Reddit #50593703

MathiasBartl@reddit

How to write assembly programs without conditionals.
View on Reddit #50703213

bashomania@reddit

XOR FTW?
View on Reddit #50595174

Brahvim@reddit

XOR is used in assembly to clear registers, too!
View on Reddit #50702529

ahavemeyer@reddit

Yessir. Still love that trick.
View on Reddit #50602013

backfire10z@reddit

And for the curious here is a great explanation on why it works: https://stackoverflow.com/a/249431
View on Reddit #50602406

bashomania@reddit

And some great discussion on why it may not be a great idea on pipelining architectures. Cool topic.
View on Reddit #50672766

nooone2021@reddit

In C, if you have an array for instance: `int array[100], index = 10;` `array[index] = 42;` `index[array] = 42;` The last two lines are identical in C, because `array[index] == *(array + index) == *(index + array) == index[array]`. Sum is a commutative operation, so you can swap operands.
View on Reddit #50699597

dragonore@reddit

I can't think of anything useless I learned in programming. Closest think I can think of is maybe learning something out of order, that is about it I guess.
View on Reddit #50692385

According_Smoke_479@reddit

I wouldn’t call it useless but in C# you can put underscores in integers in place of commas to make it easier to tell what the number is. So you can have a million as “1_000_000” and it’s no different than “1000000”. I’m not sure what other languages allow for that but it’s kind of nice as a quality of life feature. The only reason I say it’s “useless” is that it doesn’t do anything but make it more readable for you. Learned that one recently
View on Reddit #50598607

MrsMiterSaw@reddit

Works in python... Sadly not in c++
View on Reddit #50657232

QuantumDiogenes@reddit

````1'000'000````
View on Reddit #50674433

MasterDrake97@reddit

you can use 1'000'000 in c++
View on Reddit #50638605

Weasel_Town@reddit

Java does too. Not useless. It can spare you some debugging constants set to 100M when you meant 10M.
View on Reddit #50601111

gregmcph@reddit

I've got to get to a javac and try it out now.
View on Reddit #50627782

ez4Pasha@reddit

Go and PHP does too :)
View on Reddit #50621783

backfire10z@reddit

Python also has this! Nice for readability.
View on Reddit #50602156

microcozmchris@reddit

Too bad there isn't a convenient reverse of it.
View on Reddit #50610846

backfire10z@reddit

I’m not entirely sure what a reverse means?
View on Reddit #50611015

MammothEmergency8581@reddit

Same you think l things. People are posting examples but I don't get it.
View on Reddit #50615728

backfire10z@reddit

I see. I believe they meant something that can output (print) long numbers with underscores for readability. That functionality also exists in Python with f-strings.
View on Reddit #50618363

zenware@reddit

Could you give an example of what you mean by reverse in this context?
View on Reddit #50610959

microcozmchris@reddit

>>> n = 1_000_000 >>> n.readableoutput() 1_000_000
View on Reddit #50611058

zenware@reddit

>>> x = 1_000_000 >>> print(f”{x:_}”) 1_000_000
View on Reddit #50611373

microcozmchris@reddit

Nifty. f-string magic is deep magic. I need to read more of that documentation. I use them all the time, but the more esoteric incantations don't stick.
View on Reddit #50611495

P4RZiV0L@reddit

JavaScript silliness. Scheduling a setTimeout function to 2147483648 executes immediately, and scheduling one just 1ms less (2147483647) executes in 596.5 hours.
View on Reddit #50607603

PureTruther@reddit

I do not know JS but it does not sound like silliness but your lack of knowledge. 2147483647 is the limit for 32 bit signed integer. You can try it with 2³² as 2's complement. So when you give 2147483648 to any 32 bit operator, it will return -2147483648 (due to overflow) which is min value for 32 bit unsigned int type. And I assume that in the function you mentioned, this value is treated as 0.
View on Reddit #50649027

P4RZiV0L@reddit

That is exactly correct, and no, no lack of knowledge but thanks for the attempt at an insult lol
View on Reddit #50649574

hSverrisson@reddit

How did you test this?
View on Reddit #50637154

IamImposter@reddit

By mocking
View on Reddit #50642049

PureTruther@reddit

I checked most of comments. And I'll leave an advice for all: Learn low-level programming, if you want to be a programmer.
View on Reddit #50649237

Aglet_Green@reddit

While learning to program in the 20th century, I learned how to format a floppy disc. Be it 5 1/4 or 3 1/2, I could format all of them I always found it very interesting. But it's kind of useless now as most new programmers have no idea what a floppy disc, or whatever happened to the A: and B: drives. I guess most think the 'C' in C: drive stands for computer. . .
View on Reddit #50593323

mysticreddit@reddit

Drive letters in Windows comes from MS-DOS which was copied from the shitty CP/M OS.
View on Reddit #50647982

ValentineBlacker@reddit

I never did have a computer with a B drive... I wonder if B drives and B batteries went to the same place 🤔
View on Reddit #50601003

Veggies-are-okay@reddit

This! This is now my most useless fact. I had never really given much thought about that C: drive take…
View on Reddit #50598712

BodeMan5280@reddit

How much I don't care about being "technically correct". Is it a method or a function? IDGAF
View on Reddit #50593191

MatthewMob@reddit

I'd say that's closer to pragmatism than apathy.
View on Reddit #50607515

BodeMan5280@reddit

I'd like to believe that, but my imposter syndrome gets in the way...
View on Reddit #50647222

Kqyxzoj@reddit

Meh.
View on Reddit #50630497

markochaplin@reddit

Frameworks
View on Reddit #50642457

TheCatsMeow1022@reddit

The criteria to validate a credit card number is real from the beginning of CS50 lol. Interesting but not particularly useful
View on Reddit #50637568

tamil_random_rant@reddit

I think memorizing the algorithms is useless. Though we can simply import and use it.
View on Reddit #50634665

Affectionate_Market2@reddit

In high school I was going through CISCO courses. It's not useless thing per se, there are many jobs based around this knowledge. But I ended up doing something different and not using this knowledge at all. However it's very cool knowing how computer A can communicate with computer B over the globe in a matter of milliseconds. I was always wondering how the routers know where to forward each piece of information.
View on Reddit #50634554

tamil_random_rant@reddit

"match case" statement in python. I don't know why I am every time using 'elif'.
View on Reddit #50634473

gomsim@reddit

It's not useless knowledge for the world, but it's certainly been useless for my career (so far at least). I learned how projection, ray tracing, ray casting and 3D transformations work and wrote a simple 3D engine. In my jobs I've just written servers, business logic and infrastructure.
View on Reddit #50634257

SpottyJaggy@reddit

I am still learning. Everything is useful.
View on Reddit #50609894

pugal002@reddit

I am also
View on Reddit #50632805

Afraid-Locksmith6566@reddit

Ieee754-1985
View on Reddit #50593230

TheBigBananaMan@reddit

Are you saying you just know the name and not what it means? In any case, knowing how the IEEE 754 standard works can be quite useful in a few cases. An interesting little project I did was an algorithm for adding (I think it was adding anyway) floating point numbers in the IEEE 754 standard in assembly. It’s actually a lot trickier than you’d think.
View on Reddit #50604930

Afraid-Locksmith6566@reddit

I say i know the standard and the name and name is something i could not now and would be happier man
View on Reddit #50614658

ShangBrol@reddit

Speaking of standards... seeing 927 and knowing what it is.
View on Reddit #50625065

Ki1103@reddit

I don't quite get this? Aren't IEEE754-2008 and IEEE754-2019 _basically_ the same, with only minor revisions? Or is it that you think floating point numbers are useless?
View on Reddit #50603786

Joewoof@reddit

OpenGLES programming in Objective-C. The tech isn’t dead, but for what I do nowadays (teaching Lua, Python and TypeScript in highschool), it’s pretty much useless. Even manual memory management in Objective-C is useless now since ARC became a thing. And even if it isn’t Swift has pretty much replaced Obj-C now.
View on Reddit #50617905

wizzardx3@reddit

Fork bombs https://en.m.wikipedia.org/wiki/Fork_bomb
View on Reddit #50611127

nousernamesleft199@reddit

`a[6] == 6[a]` in c/c++ anyway
View on Reddit #50610400

bdc41@reddit

3-i where i is 1 or 2. Faster than an if statement, but basically never used.
View on Reddit #50598599

backfire10z@reddit

Can you give an example? What do you mean?
View on Reddit #50602200

Ki1103@reddit

I think what he's referring to is called branchless programming. Essentially, branching is difficult for the CPU so if you really care about performance you want to avoid branches (if statements) wherever possible. This is now (mostly) useless as often the compiler will be smart enough to eliminate branches unless they are totally necessary
View on Reddit #50604158

Supersaiyans2022@reddit

Erlang. I was dabbling in functional programming for a minute.
View on Reddit #50603176

Individual-Praline20@reddit

Void can be an object
View on Reddit #50602463

ValentineBlacker@reddit

I learned a lot about the history of typography. Whitespace, ligatures, etc etc. There's a lot of history in things like line break characters too. It's useless because they don't even let you write your own CSS these days :/.
View on Reddit #50601215

vMbraY@reddit

Finally grasped math (somehow lol) after picking up programming
View on Reddit #50599046

Psychoscattman@reddit

I dont think i have ever learned something useless in relation to programming. Sure some things are less usefull in a normal day but i dont think its every useless. A few years ago i saw this talk by Nicholas Ormrod about the string implementation at facebook. In that talk i learned about something called "short string optimization". It was an interesting talk but i was not doing any C++ programming and i certainly wasnt using the Facebook string implementation so i found it of limited use. Fast forward some time i was reverse engineering a program and i found this really strange pattern that i kept seeing all over the place. I took some time to analyse it but couldnt make sense of it. Then i suddenly rememberd that talk about the short string optimization and realized that i was looking at the microsoft implementation of the short string optimzation. I was really pround of myself in that moment that i remembered this seamingly useless talk i saw a few year earlier. So i really dont think that there is anything useless i have learned. You dont even have to remember it perfectly. Even knowing that there is something to be learned about a certain subject is good enought for you to start learning that subject.
View on Reddit #50597015

Veggies-are-okay@reddit

Only useless… for now!
View on Reddit #50598794

iOSCaleb@reddit

Even people taking advanced math classes have a hard time counting.
View on Reddit #50594087

Ki1103@reddit

I don't think of anything I've learnt as _useless_. Knowledge is useful. Knowing how not to do something is useful. Knowing how things used to be done, and why they aren't done that way anymore, is useful. But to answer your question: NaN packing. F64s have many, many ways to represent NaN, so why not use them to represent error codes? This is "useless" nowadays because computers have too much RAM, but it used to be important knowledge.
View on Reddit #50592967

Strict-Koala-5863@reddit

alert(“hello world!”);
View on Reddit #50592742

dwe_jsy@reddit

Nothing is useless
View on Reddit #50592519