Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Use languages that aren't stuck in the past, problem solved.
But seriously, I also don't get why this is still a thing in some languages. Even fucking Bash can call functions defined later. -
-
@deadlyRants I wouldn't say c++ is stuck in the past but to some extent you have a Point.
-
C/C++ have always had header files and forward declarations so that the function order in the source files doesn't matter.
-
Voxera113774yThat was a limitation of the compiler as it was a one pass compiler only going over the code once.
Due to this it had to know about the function definition before it was used.
Most other compilers do multiple passes so order is irrelevant. -
Root797014yCame here to say this @Voxera and this @Fast-Nop: Single vs multi pass compiler, and prototypes/headers in C/C++.
-
But why?!
For me anything/everything else is weird.. this way you can scan little bits of code befere you actually see how and where they're called..
Huh.. guess I'm weird that way.. -
@sladuled @iiii I think it's because I want to see the entry point at the beginning instead of looking for it specially if the file is huge (C devs love huge files). Also, it has to do with function scope. I always order my functions in the file from public to private. I don't want to read a private function before I can look at the main function.
Related Rants
-
xjose97x20Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
-
elgringo41Student - Teacher renaming .c to .exe make the program executable ? Teacher - Yes A group of people stand up...
-
Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ...
OK, here goes nothing: now, I absolutely hate putting the main function at the end of the file and everything else above it.
rant
go
cpp
c
c++