r/ProgrammerHumor • • Oct 07 '26

Meme wasteOfPreciousSpace

Post image
7.3k Upvotes

244 comments sorted by

View all comments

Show parent comment

62

u/camander321 Oct 07 '26

The moment your code compiles, theres no such thing as "type". "type" is just idiot-proofing for the programmer

9

u/Lord_Lorden Oct 07 '26

That's completely dependent on the language :)

3

u/camander321 Oct 07 '26

Do you have an example?

7

u/SelfDistinction Oct 07 '26

Lisp usually puts a few magical bits into every value to tell you whether it's an integer, a nil, a tag or a cons cell.

2

u/Demiu Oct 09 '26

Yea... because types get erased. That's still no types, but now with an extra value used to denote what it used to be

1

u/SelfDistinction Oct 09 '26

Yeah but that extra value does get used to figure out what function to call on certain values, in the same vein C++ uses vtables to track the type of a class, so in a sense the type still exists and causes either extra hardware on lisp machines or extra instructions in interpreters.

10

u/Prawn1908 Oct 07 '26

Languages that don't compile directly to machine instructions or don't compile at all.

21

u/camander321 Oct 07 '26

At some point, regardless of whether its a "compiled" language or not, there is a point where its reduced to simple machine instructions. Doesnt matter when that happens. Doesnt matter if you call it compilation or interpretation. By the time the code is in program memory, the concept of type has fallen away.

2

u/Prawn1908 Oct 07 '26

Ok sure, but when talking about data structures those higher level languages are still storing a lot of type data alongside all your variables.

-2

u/Lord_Lorden Oct 07 '26

That's just semantics though. Runtimes with strong reflection support like .NET make typing a big part of the language. Hell, in C# you can even add new types and generate code at runtime.

11

u/camander321 Oct 07 '26

Of course its semantics. Thats all type is. And C# uses JIT compliation. Meaning preliminary "compilation" just converts it to an intermediary language. Thats what reflection is looking at amd manipulating. That intermediary language is then interpreted as machine code on the fly (at which point type is no longer represented) and processed.

-3

u/Lord_Lorden Oct 07 '26

By that logic, the moment Windows loads your code into memory, it ceases to be relevant. Operating systems are just idiot-proofing for the programmer.

7

u/camander321 Oct 07 '26

Um...yeah. i think we're getting a bit of track here, but yes. Whenever and however the machine code was generated, its already formatted appropriately for the target architecture, so you are correct. The machine code is entirely agnostic to the operating system that is running it.

0

u/Lord_Lorden Oct 08 '26

That is completely ignoring the libraries and utilities even the most basic program must access in order to do anything. Put some text on the screen without using a system library or BIOS utility, why don't you.

The world of programming is built on layers of abstraction, and they don't stop existing just because you zoom in.

2

u/7734128 Oct 08 '26

"don't compile at all" - That's all languages for me :/

1

u/Ecstatic_Doughnut216 Oct 07 '26

Famously, everything in Python is an object.

8

u/camander321 Oct 07 '26

Python doesnt compile directly into machine code. My point is that by the time you have machine code, type no longer exists.

2

u/carnoworky Oct 07 '26

Including the classes 😭

1

u/Ecstatic_Doughnut216 Oct 08 '26

Especially the classes.

1

u/SpandexWizard Oct 08 '26

Real question.. when is a class NOT an object? You are making something you can instance and reference. I've always struggled with oop but it's always felt like classes are what makes objects objects...

1

u/MattieShoes Oct 07 '26

pretty sure Python libraries do things in other ways. I mean sure, numpy isn't WRITTEN in python but you USE it in Python.

2

u/ZachAttack6089 Oct 07 '26

You could argue that any language that has reflection or dynamic type casting still has a concept of "type" after compiling

2

u/ClaymoresInTheCloset Oct 08 '26

bah. Thats just in the runtime, they're talk lower level than that.

1

u/mrheosuper Oct 08 '26

Kind of, they still care about 2s complement number, or x87 and ieee754 number.