Page 5 of 10

Posted: Fri Jan 11, 2008 11:48 am
by ucosty
You don't really nead headers. They just make it easier to share prototypes around without having to retype them in every source file.

Im sure the only reason that you need prototypes is because C/C++ compilers only consider programs file at a time. The compiler needs hints showing it how to arrange things so they come together at the linker stage.

Posted: Fri Jan 11, 2008 12:55 pm
by Craze Frog
Laksen wrote:Things I enjoy about Object Pascal that I seem to lack in C:
-case insensitivity. Really... Is there a need for something like case sensitivity? To me it is a complete annoyance
-The header/source thing. I just don't like it. The UCSD pascal unit convention goes much better to my taste of code/interface seperation
(The following is probably more of a compiler problem)
-basic error checking(overflow, bounds, range, etc). I understand why some people, me included, would like to have them disabled sometimes, but I can disable them easily. Having this feature allows me to code alot faster without having to worry about small problems that might result in bugs later on

I could keep complaining but those were the major points, that didn't have very much with syntax to do :wink:
Troll! :roll:

Posted: Fri Jan 11, 2008 1:39 pm
by ucosty
I should add that I don't use C.

I use C++ because I wanted to use namespaces, streams, and templates.

Posted: Fri Jan 11, 2008 2:06 pm
by Tyler
ucosty wrote:You don't really nead headers. They just make it easier to share prototypes around without having to retype them in every source file.

Im sure the only reason that you need prototypes is because C/C++ compilers only consider programs file at a time. The compiler needs hints showing it how to arrange things so they come together at the linker stage.
That's ignores the main advantages of header files. The seperation of Decleration and Implementation as well as the ability to store typedefs, defines and constants in uncompiled files which can be kept in a central store makes sharing basic constructs and interfacing with compiled libraries possible without having to write any interop code and often without having to memorize documentation.

In a situation where you want to share your code, you do, basically, need the header files, and they aren't there just for ease of use.

EDIT: I do use C, but i mostly write my Operating System in Assembly because i am very obsessive about knowing exactly what every byte in my Operating System is and does. However, i wrote my own assembler in order to get all the above advantages and be able to use a single set of headers for both C and Assembly code. I know GAS does this, but i prefer Intel Syntax and most of NASM's constructs, so i was forced to write my own.

Posted: Fri Jan 11, 2008 2:29 pm
by Candy
Laksen wrote:Things I enjoy about Object Pascal that I seem to lack in C:
-case insensitivity. Really... Is there a need for something like case sensitivity? To me it is a complete annoyance
I dOn'T sEe WhY eNfOrCiNg A cErTaIn CaPiTaLiZaTiOn CoUlD bE hElPfUl FoR cOnSiStEnCy Or ReAdAbIlItY, nO.
-The header/source thing. I just don't like it. The UCSD pascal unit convention goes much better to my taste of code/interface seperation
Make a *big* program for your compiler and tell it to compile it - there's NO way to. Now make a properly written C program of equal or bigger size. It compiles.

The point with headers is that they describe what the C file will contain, without actually writing it (so you get a huge boost in speed on compiling, less mess, more of an "interface" to the file) and you don't auto-include all other files as a header which means that when your filesystem routines compile they don't interfere with your mouse routines. Another point - you can parallel and distributed compile it without a change.

Perhaps it's a good idea to reflect on what Pascal and C were made for. Pascal was intently developed to annoy me (and yes, it's had it's good share), C was developed for huge programs compared to the computers on which they would run. Compared to modern computers, the program size has become extremely diminutive compared to the memory size. At the time C was new, the program would be 100000's to millions of lines of code, with a computer with only a meg of ram or so. Nowadays, the average program is like 5000 lines of code with a computer that can trivially keep 1GB in memory.
-basic error checking(overflow, bounds, range, etc). I understand why some people, me included, would like to have them disabled sometimes, but I can disable them easily. Having this feature allows me to code alot faster without having to worry about small problems that might result in bugs later on
Is intentional in C, in C++ you can make arbitrary types with all kinds of bounds checking that Pascal can't do (but then again, Delphi might be able to).

Posted: Fri Jan 11, 2008 3:48 pm
by crazygray1
Tyler wrote:
ucosty wrote:You don't really nead headers. They just make it easier to share prototypes around without having to retype them in every source file.

Im sure the only reason that you need prototypes is because C/C++ compilers only consider programs file at a time. The compiler needs hints showing it how to arrange things so they come together at the linker stage.
That's ignores the main advantages of header files. The seperation of Decleration and Implementation as well as the ability to store typedefs, defines and constants in uncompiled files which can be kept in a central store makes sharing basic constructs and interfacing with compiled libraries possible without having to write any interop code and often without having to memorize documentation.

In a situation where you want to share your code, you do, basically, need the header files, and they aren't there just for ease of use.

EDIT: I do use C, but i mostly write my Operating System in Assembly because i am very obsessive about knowing exactly what every byte in my Operating System is and does. However, i wrote my own assembler in order to get all the above advantages and be able to use a single set of headers for both C and Assembly code. I know GAS does this, but i prefer Intel Syntax and most of NASM's constructs, so i was forced to write my own.
I find that interesting, do you have it on linux? If so, could I try it out?

Posted: Fri Jan 11, 2008 3:59 pm
by AndrewAPrice
Laksen wrote:Things I enjoy about Object Pascal that I seem to lack in C:
-case insensitivity. Really... Is there a need for something like case sensitivity? To me it is a complete annoyance
Then always type variable names in the same case?

It's useful anyway, because (I know it's bad programming habit) but I have a few variables labeled thing like "Device" and "device". I really only use this in 2 situations:

If "Device" is a class, and "device" is an instance of the class, or
"Device" is a global or member variable (except I usually use m_device) and "device" is a parameter passed as a function parameter, e.g. "ChangeColour(Colour colour);" uses both situations.

Posted: Fri Jan 11, 2008 6:08 pm
by Laksen
Candy wrote:
Laksen wrote:Things I enjoy about Object Pascal that I seem to lack in C:
-case insensitivity. Really... Is there a need for something like case sensitivity? To me it is a complete annoyance
I dOn'T sEe WhY eNfOrCiNg A cErTaIn CaPiTaLiZaTiOn CoUlD bE hElPfUl FoR cOnSiStEnCy Or ReAdAbIlItY, nO.
Hah, I seem to have heard that one before. Even in a more childish tone. I wasn't talking about proper capitalization. Any sane programmer capitalises their identifiers properly.
But, I don't really care what way any other programmer capitalizes their local variables or keywords, as long as it doesn't hamper my efficiency.
Candy wrote:
-The header/source thing. I just don't like it. The UCSD pascal unit convention goes much better to my taste of code/interface seperation
Make a *big* program for your compiler and tell it to compile it - there's NO way to. Now make a properly written C program of equal or bigger size. It compiles.
Wtf, man :lol: Are you drunk or something?
I recompile the fpc rtl and my os every time I build my os and it takes less than a second.

I understand your points about distributed/parallel compiling and that jazz. But, in my opinion, I would rather trust my compiler, than my linker, to check if functions exist in another file.
-basic error checking(overflow, bounds, range, etc). I understand why some people, me included, would like to have them disabled sometimes, but I can disable them easily. Having this feature allows me to code alot faster without having to worry about small problems that might result in bugs later on
Is intentional in C, in C++ you can make arbitrary types with all kinds of bounds checking that Pascal can't do (but then again, Delphi might be able to).
Delphi is getting enterprise-ish, too much .Net and databases. At that point Freepascal is getting ahead. It recently got beta support for generic types

Posted: Fri Jan 11, 2008 6:23 pm
by Tyler
crazygray1 wrote:
I find that interesting, do you have it on linux? If so, could I try it out?
Nope, sorry, Windows at the moment, and it isn't open source, because it's embarrassing code :-P.

Posted: Fri Jan 11, 2008 7:04 pm
by binutils
ucosty wrote:I should add that I don't use C.

I use C++ because I wanted to use namespaces, streams, and templates.
FYI, for namespace.

In plan 9, which is written in their own c.
it support private namespaces without any syntactic sugar.
protocol instead of language structure.
http://www.ddj.com/mobile/184404878

Posted: Fri Jan 11, 2008 7:16 pm
by ucosty
thats not code level namespacing.

Posted: Fri Jan 11, 2008 7:21 pm
by binutils
ucosty wrote:thats not code level namespacing.
Yes, that is their intention exactly.

Posted: Fri Jan 11, 2008 8:45 pm
by Colonel Kernel
Smalltalk FTW!

Posted: Fri Jan 11, 2008 8:52 pm
by Alboin
Colonel Kernel wrote:Smalltalk FTW!
How so very appropriate.

Posted: Fri Jan 11, 2008 9:38 pm
by crazygray1
I've got wine I can still test it.