Finding joy in coding Using Pascal programming language

Started by
43 comments, last by jms bc 10 years, 9 months ago

*shrugs* If I want to get something done quickly I'll go grab C#

If all I care about, is how fast I can bang out code, I use Python 2.7
- It's so much faster to type than C# or Ruby

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson

Advertisement

Correct me if I'm wrong, but I'm sure I remember pascal having something to do with the Win32 API?

Or am I just mad?

if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight

*shrugs* If I want to get something done quickly I'll go grab C#

If all I care about, is how fast I can bang out code, I use Python 2.7
- It's so much faster to type than C# or Ruby

How exactly is it faster to type?

*shrugs* If I want to get something done quickly I'll go grab C#

If all I care about, is how fast I can bang out code, I use Python 2.7
- It's so much faster to type than C# or Ruby

How exactly is it faster to type?

Syntax of Python is shorter than most languages tongue.png

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson

Syntax of Python is shorter than most languages tongue.png

CodeGolf would disagree. Python usually ranks about the same as PHP, significantly behind Ruby, which is behind perl. It's hard to compare C# in those scenarios due to the boilerplate that gets generated for you (so you don't have to type it) but with ScriptCS getting more popular, I wonder how it would fare.

Syntax of Python is shorter than most languages tongue.png

CodeGolf would disagree. Python usually ranks about the same as PHP, significantly behind Ruby, which is behind perl. It's hard to compare C# in those scenarios due to the boilerplate that gets generated for you (so you don't have to type it) but with ScriptCS getting more popular, I wonder how it would fare.

Since when is Ruby fast to type out ?

I always end up getting a little confused with it's mix-and-match syntax style.

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson

Since when is Ruby fast to type out ?

I always end up getting a little confused with it's mix-and-match syntax style.

Whatever you're most familiar with is going to be what you're fastest with. But with the codegolf example, the measurement is based on number of characters typed to provide a solution.

Pascal was actually the first programming language I used. It was before internet, and a friend had lots of patience for my endless questions by phone smile.png

I remember my first program, a small "piano" in text-mode "graphics", with lots of copy-paste, because I hadn't grasped the concept of "functions" yet.

Then I moved on to assembler, z80 and 68000 for TI calculators.

After a few years of that, transitioning into C and C++ felt very natural, "to get things done quickly" smile.png

It was pretty much the same for me, allthough i dabbled with basic first and started my assembly journey with the inline assembler in pascal, my jump to "C++" wasn't all that smooth though (that damn rule of three caused me some major headaches tracking down memory leaks and wierd bugs due to shallow copies since i didn't write any copy constructors for my classes) (My C++ has gotten alot better though, mainly because i've picked up other languages SML and Java are probably the ones that have had the biggest impact on how i write code, allthough python is starting to leave a mark aswell now)

[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

Correct me if I'm wrong, but I'm sure I remember pascal having something to do with the Win32 API?

Or am I just mad?

IIRC, some compilers used the "pascal" modifier for Win16 API functions.

in this case, AFAICT, it was pretty similar to "stdcall" used in the Win32 API.

both use callee stack clean-up, but the pascal pushed arguments from left-to-right, whereas stdcall pushes them from right to left (like cdecl).

beyond this? AFAIK, most of the core parts of early Windows were written in assembler, but later on (generally by Win9x and WinNT), most things were generally written in C and C++.

as for the Pascal vs C and C++ thing:

I mostly prefer C and C++ style syntax.

"var x:type;" and similar are passable IMO, partly as they are a bit more convenient from a parsing perspective (*1), and after exposure to a few languages which do things this way, one gets used to it. "type x;" is a little more convenient and cleaner looking though.

people often hate on the C-style "for()" loop for some reason, but it works.

it doesn't seem entirely unreasonably though that a language could support something like:

"for(i in 1 to 15) { ... }"

but this seems like a minor issue once a person understands what a "for()" loop in C is actually doing.

*1: a few common syntax elements in C-family syntax do tend to be a little troublesome to parse unambiguously, namely:

declarations; casts; templates / generics; ...

explicit keywords in these cases can make parsing these things a little easier, along with avoiding both possibly syntactic ambiguity as well as the problem of placing restrictions on various constructs.

as for "." vs "->", almost may as well make "." the default and otherwise treat them as analogous (with the compiler sorting out the rest).

as for ":=", "=", and "==".

I prefer "=" for assignment and "==" for comparison.

FWIW, the mathematical concept of "=" doesn't really exist in programming anyways, so really it can go either way.

it just so happens that variable assignment is a very common operation.

one frequent annoyance from a syntax design POV is the lack of more brace characters, hence the sometimes needed use of trickery to get more types of braces (sometimes context, sometimes ugly hacks).

granted, sometimes it may make sense to just use a few rarely used characters to stretch it out:

#(...), #[...], #{...}, $(...), $[...], ${...}, ...

along with some other options being double-braces and mismatched braces.

...

of course, potentially, many people might balk at something like:

"somegeneric#(T)" rather than the more usual and expected "somegeneric<T>" even if the latter makes more of a mess out of the parser.

then again, if the language has already gone as far as using "x:type" declarations, the designer may well be justified in being like "just deal with it".

The reason for the pascal calling convention for most functions of the Win32 API is to save memory (when Windows 3.1 was out memory was limited in PCs). The called function cleans up the stack (since it knows how many arguments and how much stack space they require), this is done at the end of the function just before the RET.

With the C calling convention the stack is cleaned up by the caller after the function returns (the caller knows how many arguments were passed to the function). This means there are extra instructions following a return from a function, rather than the extra instructions being at the end of each function with the pascal calling convention, so more memory is used for the program with the C calling convention.

Since the caller knows how many arguments are passed to a function (and the function does not have to know), C calling convention supports variable length argument lists (like printf), whereas pascal calling convention does not. You will notice that Win32 functions which take a variable number of arguments do not use the pascal calling convention.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

This topic is closed to new replies.

Advertisement