OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 3:52 am

All times are UTC - 6 hours




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 27 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Pascal vs C
PostPosted: Wed Sep 02, 2015 8:53 am 
Offline
Member
Member
User avatar

Joined: Wed Aug 05, 2015 5:33 pm
Posts: 159
Location: Drenthe, Netherlands
I just couldn't help but react because I really don't know what onlyonemac's problem with Pascal is all about. But that topic wasn't the place to do it so lets "fight" about it here.
http://f.osdev.org/viewtopic.php?f=11&t=27692&start=105&sid=be6d1d56eac24bfa24f9c0846a70bcc6

onlyonemac wrote:
Kazinsal wrote:
Fairly large chunks of classic Macintosh system software were written in Pascal, IIRC.
Yeah that doesn't mean that it's a good language. Frankly it's antiquated and it sucks, and every time I've tried to use it I just can't THINK straight!!!
I know the feeling... when using C. That has nothing to do with the language but how hardwired we can get to our language of choice. Try thinking in another language like German or french if you rarely speak it. Same problem.

Pascal isn't antiquated in any way. Altho I wouldn't suggest using TP7 for a new project, just as I wouldn't suggest Visual C 1.0.

The free pascal compiler is up to date, compiles itself and is capable of everything C can do.

onlyonemac wrote:
there's no need to fuss with the incoherencies of a language like Pascal that was designed for a previous era.
Which incoherencies? When trying to write pascal while thinking in C?

onlyonemac wrote:
And once you've written everything in Pascal, you'll have to keep it that way or at least make a lot of changes to any code that you use that is written in other languages, as the calling style is significantly different from the ubiquitous C style.
Have you ever actually written anything in Pascal? It supports all calling conventions on a per procedure/function basis including cdecl, stdcall, fastcall etc.

Need an example on how to use them?
Procedure HelloWorld(); stdcall;
Procedure HelloWorld(); cdecl;

You can mix Pascal just fine with C, Go, Assembler and lots more. Fits like a glove, no problems what so ever.

_________________
"Always code as if the guy who ends up maintaining it will be a violent psychopath who knows where you live." - John F. Woods

Failed project: GoOS - https://github.com/nutterts/GoOS


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 11:38 am 
Offline
Member
Member
User avatar

Joined: Fri Aug 21, 2009 5:54 am
Posts: 178
Location: Moscow, Russia
Just wanted to add, Delphi-style "object oriented" pascal is braindead, especially past version 7.
If that's the "Pascal" you were thinking about, then i totally agree.
But Delphi to Pascal is what Hitler is to Charlie Chaplin's mustache style - a bad execution that gave a good thing a bad name.
Please keep that in mind.


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 1:34 pm 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
Nutterts wrote:
But that topic wasn't the place to do it so lets "fight" about it here.
Be warned... I don't lose fights!
Nutterts wrote:
Pascal isn't antiquated in any way.
Name one current, mainstream project that uses Pascal.
Nutterts wrote:
Which incoherencies? When trying to write pascal while thinking in C?
No, incoherencies in language structure and syntax. As in, in one context a particular thing should be written a particular way whereas in another context it should be written another way, whereas C as a unified structure and syntax - it doesn't matter what the context of a line or block of code is, it's still written the same way.
Nutterts wrote:
Have you ever actually written anything in Pascal? It supports all calling conventions on a per procedure/function basis including cdecl, stdcall, fastcall etc.
I have written stuff in Pascal before. And I mean as in, without bothering to add extra bits of code to every function just to make it compatible with the rest of the world. In other words, pure Pascal is not compatible in the manner that you describe - in order to ensure compatibility with the rest of the world, you have to add extra clutter to your code.

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 1:37 pm 
Offline
Member
Member
User avatar

Joined: Wed Aug 05, 2015 5:33 pm
Posts: 159
Location: Drenthe, Netherlands
Artlav wrote:
Just wanted to add, Delphi-style "object oriented" pascal is braindead, especially past version 7.
Auwtch... yeah, I probably was so traumatized from using Delphi 8 back then that I forgot how horrible it got after Delphi 7. If people got traumatized into hating pascal because of those implementations then I totally get it! It almost made me abandon the language myself.

_________________
"Always code as if the guy who ends up maintaining it will be a violent psychopath who knows where you live." - John F. Woods

Failed project: GoOS - https://github.com/nutterts/GoOS


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 1:50 pm 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
Just by the way, I have not used Delphi if that's what you're thinking. I'm talking about Pascal, as in the traditional Pascal that hasn't been updated for at least 15 years. And the various "modern" Pascals which are so full of bloated extensions that they might as well not exist.

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 1:53 pm 
Offline
Member
Member
User avatar

Joined: Fri Aug 21, 2009 5:54 am
Posts: 178
Location: Moscow, Russia
onlyonemac wrote:
Name one current, mainstream project that uses Pascal.
Total Commander.
http://www.ghisler.com/

"Windows-is-useless-without-it" kind of mainstream. :)

onlyonemac wrote:
No, incoherencies in language structure and syntax. As in, in one context a particular thing should be written a particular way whereas in another context it should be written another way
For example (including why is it bad)?

onlyonemac wrote:
without bothering to add extra bits of code to every function just to make it compatible with the rest of the world.
Hm?
A. What sort of code are you talking about? At worst you had to add stdcall or cdecl to the function declaration, AFAIK.
B. How does that matter for OS dev? Your OS, your rules (going back to the original *shudder*).

onlyonemac wrote:
Just by the way, I have not used Delphi if that's what you're thinking. I'm talking about Pascal, as in the traditional Pascal that hasn't been updated for at least 15 years. And the various "modern" Pascals which are so full of bloated extensions that they might as well not exist.
Ah. Classic "learned in school" pascal is also not a real programming language.
You need at least a few modern features to make it a useful high-level language.

Hm.
In my case it's a get-the-best-from-everywhere subset of a language, so we are quite likely talking about essentially different languages. :(


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 2:12 pm 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
Artlav wrote:
onlyonemac wrote:
Name one current, mainstream project that uses Pascal.
Total Commander.
http://www.ghisler.com/

"Windows-is-useless-without-it" kind of mainstream. :)
Good luck trying to satisfy me that something designed for Windows 3.1 and which has a webpage looking like it's from the 90s is really "current". Besides, that's just one against an almost infinite number of projects written in C, or another modern language such as Java. So you're going to have a hard time convincing anybody that Pascal is actually used in the field these days.
Artlav wrote:
onlyonemac wrote:
No, incoherencies in language structure and syntax. As in, in one context a particular thing should be written a particular way whereas in another context it should be written another way
For example (including why is it bad)?
I can't remember anything off the top of my head but I remember a good few examples in the Pascal programming book that I read, which I would post here if only my sight was still good enough for me to read said book.
Artlav wrote:
onlyonemac wrote:
without bothering to add extra bits of code to every function just to make it compatible with the rest of the world.
Hm?
A. What sort of code are you talking about? At worst you had to add stdcall or cdecl to the function declaration, AFAIK.
B. How does that matter for OS dev? Your OS, your rules (going back to the original *shudder*).
A. So? Having to add either "stdcall" or "cdecl" after EVERY function definition is a real pain in the @$$ and wouldn't be necessary if you used a more standard language, instead of trying to bend a non-conforming antiquated language to fit the modern world.
B. Your OS, your rules, but trying to do any low-level work in a language such as Pascal which has such a ridiculously high-level syntax that you can't really write decent system code in it (note that I said "DECENT system code") seems like a poor choice. And it is a major oversight in two ways: firstly if you later decide to write other parts of your OS in C, your existing codebase will be incompatible with it (unless you add "stdcall" or "cdecl" to every exported function, or "pascal" in front of every C function to specify Pascal calling style, neither of which is a very good idea) and secondly it will be impossible to port any standard libraries to your operating system, including such things as OpenGL, Cairo, etc. unless you add the correct calling directives to every function (see first part).
Artlav wrote:
You need at least a few modern features to make it a useful high-level language.
Exactly my point. And to add those "modern features" to an outdated language is going to require a significant amount of syntactical bloat which is what we get with e.g. specifying calling styles.

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 2:15 pm 
Offline
Member
Member
User avatar

Joined: Wed Aug 05, 2015 5:33 pm
Posts: 159
Location: Drenthe, Netherlands
onlyonemac wrote:
Nutterts wrote:
But that topic wasn't the place to do it so lets "fight" about it here.
Be warned... I don't lose fights!
We'll see about that ;)

onlyonemac wrote:
Nutterts wrote:
Pascal isn't antiquated in any way.
Name one current, mainstream project that uses Pascal.

Thats easy, the FPC compiler quite popular and well maintained. Oh and the language we're talking about, not Turbo Pascal from the 1980's.
http://www.freepascal.org/advantage.var

I'm not arguing that pascal is more popular or used more often. I'm just saying it can do anything that C can and that the language is easier to read.

onlyonemac wrote:
Nutterts wrote:
Which incoherencies? When trying to write pascal while thinking in C?
No, incoherencies in language structure and syntax. As in, in one context a particular thing should be written a particular way whereas in another context it should be written another way, whereas C as a unified structure and syntax - it doesn't matter what the context of a line or block of code is, it's still written the same way.

Can you give me an example because I clearly never noticed that before.

onlyonemac wrote:
Nutterts wrote:
Have you ever actually written anything in Pascal? It supports all calling conventions on a per procedure/function basis including cdecl, stdcall, fastcall etc.
I have written stuff in Pascal before. And I mean as in, without bothering to add extra bits of code to every function just to make it compatible with the rest of the world. In other words, pure Pascal is not compatible in the manner that you describe - in order to ensure compatibility with the rest of the world, you have to add extra clutter to your code.


Pure pascal is having the ability to select the calling convention. It's been so for as long as I can remember, even in de 80's. For unexported functions I leave it to the compiler to select the most efficient one. Not selecting the desired calling convention is just bad pascal programming when it comes to exported functions.

Do I really have to mention 'void' btw? There's enough clutter and unneeded stuff in both languages. Pascal imho still remains the most readable of the two when projects get big.

Ok, you can do nice things now like operator overloading and other modern language features. C has grown up in much the same way. There probably was a time when C could do something that you just couldn't do in Pascal. But I can't imagine anything today were that's still the case.

_________________
"Always code as if the guy who ends up maintaining it will be a violent psychopath who knows where you live." - John F. Woods

Failed project: GoOS - https://github.com/nutterts/GoOS


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 2:39 pm 
Offline
Member
Member
User avatar

Joined: Fri Aug 21, 2009 5:54 am
Posts: 178
Location: Moscow, Russia
onlyonemac wrote:
Good luck trying to satisfy me that something designed for Windows 3.1 and which has a webpage looking like it's from the 90s is really "current".
A. You asked for at least one.
B. "New (August 26, 2015): Total Commander 8.52 final (32+64 bit) for Windows released" It's as modern as today, pretty much. That's what matters, not what it's oldest version can do or the site looks like.

onlyonemac wrote:
A. So? Having to add either "stdcall" or "cdecl" after EVERY function definition is a real pain in the @$$ and wouldn't be necessary if you used a more standard language, instead of trying to bend a non-conforming antiquated language to fit the modern world.
B. Your OS, your rules, but trying to do any low-level work in a language such as Pascal which has such a ridiculously high-level syntax that you can't really write decent system code in it
A. Far from every program is a library that exports a ton of functions. Sure, there is a bit of discomfort for that, but you won't see it 99% of the time, no?

B. Having done it, i fail to see the problems. Can you elaborate?

onlyonemac wrote:
secondly it will be impossible to port any standard libraries to your operating system
It certainly would be *tricky*, i agree.

onlyonemac wrote:
Exactly my point. And to add those "modern features" to an outdated language is going to require a significant amount of syntactical bloat which is what we get with e.g. specifying calling styles.
Every language is outdated by that logic.
It's not like there is "The Pascal" and "Bloat" with nothing in between them.


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 2:42 pm 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
I'm really more on Pascal's side and would love to defend it (more precisely, the ObjFPC dialect) if there were any substantial arguments. The only thing I can see so far is the "cdecl;" thing. I just wonder why having to declare things extern "C" in C++ doesn't make people react in the same way when they see someone doing a C++ kernel.

Anyway, while we're waiting for arguments, I'll tell you two points why I think OSDev with FPC sucks. The first is simply syntactic sugar of various kinds that I'm used to from C: Macros are much less useful because units (which replace headers) can't make them available, arrays need to be declared with their size instead of deriving it from the initialiser list, initialisation syntax in general isn't as nice as C's designated initialisers. Small things like that, but they are annoying.

The other one is that the compiler isn't really meant for making changes to or even writing your own system unit. If a compilerproc is missing or has the wrong interface, you usually get a fatal internal error with a number and no useful message. Next thing is grepping the compiler source for the number and checking what was really missing. That's not quite how I'd like the error handling to be.

_________________
Developer of tyndur - community OS of Lowlevel (German)


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 3:09 pm 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
Nutterts wrote:
Thats easy, the FPC compiler quite popular and well maintained. Oh and the language we're talking about, not Turbo Pascal from the 1980's.
http://www.freepascal.org/advantage.var
I was actually going to say in the post where I originally asked that question that a Pascal compiler is not a valid answer, but I thought that that was obvious.
Artlav wrote:
B. "New (August 26, 2015): Total Commander 8.52 final (32+64 bit) for Windows released" It's as modern as today, pretty much. That's what matters, not what it's oldest version can do or the site looks like.
So it doesn't matter when the last release was, it's still an old program and it's most likely only written in Pascal today because that's how it's always been, and I bet the developer regrets that decision with all the other elegant C projects coming out these days.
Nutterts wrote:
the language is easier to read.
That is rather subjective. At least I've been keeping my arguments (mostly) objective.
Nutterts wrote:
Do I really have to mention 'void' btw? There's enough clutter and unneeded stuff in both languages.
At least C is consistent by making "functions" (which return a value) and "procedures" (which do not return a value) more or less the same thing, unlike Pascal which uses separate (and rather long) keywords to distinguish them (a good example of the kinds of inconsistencies which I am referring to) and which thus causes numerous issues such as requiring the programmer to change the keyword when adding a return value for a function and not permitting the programmer to discard the return value as is possible in C by simply not specifying a return location. So whereas in C we can have a list of e.g. file-handling functions, some of which return a file pointer or an error code and some of which return nothing, and we can call them all functions or call them all procedures because the terms are basically synonymous, in Pascal we now have to call some of them procedures and some of them functions (and they are also represented as such in the code) based on whether or not they return a value which is really irrelevant to their logical grouping in either the source code or the documentation.
Artlav wrote:
B. Having done it, i fail to see the problems. Can you elaborate?
I guess it's mainly just because I find Pascal incredibly unreadable and illogical in its structure, but if one analyses it I guess there's not really anything about the language itself that makes such a task difficult, just that it requires a fair deal of experience with the language and a significant mental detachment from C - neither of which are really bragging points these days.

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 3:12 pm 
Offline
Member
Member
User avatar

Joined: Fri Aug 21, 2009 5:54 am
Posts: 178
Location: Moscow, Russia
Kevin wrote:
Macros
Totally agree. I miss them quite often, and my own compiler is not up to speed yet...

Kevin wrote:
arrays need to be declared with their size instead of deriving it from the initialiser list
+1

Kevin wrote:
The other one is that the compiler isn't really meant for making changes to or even writing your own system unit. If a compilerproc is missing or has the wrong interface, you usually get a fatal internal error with a number and no useful message. Next thing is grepping the compiler source for the number and checking what was really missing. That's not quite how I'd like the error handling to be.
Hm? Never had that problem.
Won't it just fail to compile with "fpc_so_and_so not found" error?


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 3:13 pm 
Offline
Member
Member
User avatar

Joined: Wed Aug 05, 2015 5:33 pm
Posts: 159
Location: Drenthe, Netherlands
Kevin wrote:
The only thing I can see so far is the "cdecl;" thing. I just wonder why having to declare things extern "C" in C++ doesn't make people react in the same way when they see someone doing a C++ kernel.
The cdecl thing is imho just a childish way to point out that C won the race back then. Borland screwed it up. The winner became the standard. If pascal had become the standard they'd be specifying pascal as the convention in C all over the place. Just like stdcall for windows.

Your points are way more valid then the cdecl thing. Those things aren't impossible but it is pretty annoying. Chicken & egg thing I guess. There isn't a lot of interest to write a kernel in pascal so the tools are lacking. But Artlav is right that FPC atleast fails with a clear error message of whats missing. At least for me but it's only been about simple type declarations in system.pas up until now.

_________________
"Always code as if the guy who ends up maintaining it will be a violent psychopath who knows where you live." - John F. Woods

Failed project: GoOS - https://github.com/nutterts/GoOS


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 3:20 pm 
Offline
Member
Member
User avatar

Joined: Fri Aug 21, 2009 5:54 am
Posts: 178
Location: Moscow, Russia
onlyonemac wrote:
I guess it's mainly just because I find Pascal incredibly unreadable and illogical in its structure
I guess that's the core problem here.
People have different perceptions, and so different tools that fit them better.

Unreadable code is a very subjective thing.
I.e. i'm a very visual person, and see the code as a picture. That produces a coding style that is shocking to many other people.
I also prefer disambiguation over power, and so gravitate to languages a little more high-level than C.

Remove that, and the choice of language becomes a null question - whatever is used by everyone, that is C/C++.

Does that make sense?


Top
 Profile  
 
 Post subject: Re: Pascal vs C
PostPosted: Wed Sep 02, 2015 3:26 pm 
Offline
Member
Member
User avatar

Joined: Wed Aug 05, 2015 5:33 pm
Posts: 159
Location: Drenthe, Netherlands
onlyonemac wrote:
I find Pascal incredibly unreadable and illogical in its structure, but if one analyses it I guess there's not really anything about the language itself that makes such a task difficult, just that it requires a fair deal of experience with the language and a significant mental detachment from C - neither of which are really bragging points these days.


Exactly the point I made from the very beginning. I grew up with it. I tried C++ before I tried C and that was a mistake. Ignored C for 10 years because of a misunderstanding. Sure I regret it. But only because Borland messed up. It all didn't matter back then. I also didn't continue in it and make it my line of work. If I continued as a programmer things might have been different.

It takes a mental effort for me to switch to C, it's like crypto code to me if I haven't used it at least once a month.

_________________
"Always code as if the guy who ends up maintaining it will be a violent psychopath who knows where you live." - John F. Woods

Failed project: GoOS - https://github.com/nutterts/GoOS


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 27 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group