• Create Account

Banner advertising on our site currently available from just $5! # Finding joy in coding Using Pascal programming language Old topic! Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic. 44 replies to this topic ### #21_greyfox() Members - Reputation: 1134 Posted 30 June 2013 - 03:38 AM If your dealing with Windows API, wouldn't it be a lot easier to use one of the "Visual Studio" suites ? msgbox("Can't we all just get along?") Unfortunately not everyone uses Visual Studio (especially if they want to make game/software that is actually portable). Also in most cases people seem to want to reinvent the wheel, like here: http://thedailywtf.com/Articles/A-First-Date.aspx. Anyway from C-Like languages I particularly like Java and C#. First because of its clean, object-oriented syntax (though getters/setters gets to me and I don't use them in my own classes) and latter maybe because it was designed by guy who worked on Delphi (though I felt in love with C# thanks to Unity and learned about that same guy who worked on Delphi worked on C# also just recently). I kinda like Ruby too, but since it is only used in RPG Maker series and I rarely use RPG Maker, I don't have any occasions to practice it. Then what do you use instead of getters and setters? Public variables? “There are thousands and thousands of people out there leading lives of quiet, screaming desperation, where they work long, hard hours at jobs they hate to enable them to buy things they don't need to impress people they don't like.”― Nigel Marsh Sponsor: ### #22Darkhog Members - Reputation: 114 Posted 30 June 2013 - 03:39 AM Yes, they're more straightforward. Edited by Darkhog, 30 June 2013 - 03:40 AM. ### #23TheChubu Crossbones+ - Reputation: 6283 Posted 30 June 2013 - 03:59 AM Now, take those two codes to some friend who isn't programmer. First show it this: for (i=0;i<15;i++) { Car[i]->Ignite } I don't particulary care if the code can be understandable for non-programmers. Because hopefully, and if we do our jobs well, they'll never have to look at it. What I care is that its easier to type. There are a lot of curly braces around, typing {} is extremely easy, while the begin end; block isn't. The C-like for look is absolutely simple having in mind how versatile it is (no (for i=0, j=2; i < 15 && j < 20; i++, j+=4) in pascal for example). It would be better to compare it to a for each loop since it has closer functionality to the pascal for. Besides, you underestimate how well humans can read symbols (besides complete words I mean, or collection of symbols if you prefer), give the symbol a good enough meaning, and it will stuck in there forever. For example, it happened the first time I looked at a for each loop in Java, the teacher said "read the : as "in" ". Stuck in my mind forever. for Object obj : collection sounded totally sane since then. IMHO, C like languages hit a sweet spot between lone symbols and complete words (until you find C++ pointer arithmetic operators that is). Plenty of lone symbols so everything is fast to read and fast to type, but also a few words to mark the more complex ideas. Have in mind that I learned to code in Ada, and make no mistake, I really like some of its syntactic (sugarish) features (say, easy range manipulation, ordinal types, etc), but I found C-like syntax much easier to deal with and the lack of procedure/function distinction liberating. Specially the procedure/function distinction part, looks like its just a way to make compiler implementator's life easier rather than the language user's life easier, or maybe it derives from a time when programmers were more mathematicians than programmers (hence the name I guess). "I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ" My journals: dustArtemis ECS framework and Making a Terrain Generator ### #24_greyfox() Members - Reputation: 1134 Posted 30 June 2013 - 04:20 AM Yes, they're more straightforward. I agree “There are thousands and thousands of people out there leading lives of quiet, screaming desperation, where they work long, hard hours at jobs they hate to enable them to buy things they don't need to impress people they don't like.”― Nigel Marsh ### #25Hodgman Moderators - Reputation: 37945 Posted 30 June 2013 - 05:24 AM As above, getters and setters are often an anti-pattern. They usually indicate a failure of their parent class to actually represent some kind of useful abstraction. If you're making classes wih loads of paired setters/getters, then public members will probably suffice, as you're just describing a data format, not a true OO 'class'. First google result for me is: http://typicalprogrammer.com/?p=23 ### #26Darkhog Members - Reputation: 114 Posted 30 June 2013 - 06:17 AM Of course, but can we get back to the topic? IMO C/C++ is like cleaning your apartment after large party. Pascal is like party itself - you can get things done quickly while enjoying yourself without shooting yourself in the foot. Also great quote from David Keppel: C++ provides a remarkable facility for concealing the trivial details of a program - such as where its bugs are. Edited by Darkhog, 30 June 2013 - 06:17 AM. ### #27phantom Moderators - Reputation: 8516 Posted 30 June 2013 - 06:36 AM *shrugs* If I want to get something done quickly I'll go grab C# ### #28_greyfox() Members - Reputation: 1134 Posted 30 June 2013 - 08:02 AM *shrugs* If I want to get something done quickly I'll go grab C# Or python “There are thousands and thousands of people out there leading lives of quiet, screaming desperation, where they work long, hard hours at jobs they hate to enable them to buy things they don't need to impress people they don't like.”― Nigel Marsh ### #29Olof Hedman Crossbones+ - Reputation: 3561 Posted 30 June 2013 - 08:40 AM 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 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" ### #30kunos Crossbones+ - Reputation: 2224 Posted 30 June 2013 - 08:57 AM Of course, but can we get back to the topic? IMO C/C++ is like cleaning your apartment after large party. Pascal is like party itself - you can get things done quickly while enjoying yourself without shooting yourself in the foot. While I could agree with your conclusions.. the points you are making in this thread to prove your positions are just highlighting your total ignorance about C++ and C and absolute lack of understanding of programming in general. It would be interesting to see how you propose to pass a string to a C function then... that'll be really entertaining or how useful would be to pass a copy of a Widget that I want to set the text on.. amaze me. ### #31Code Fox Members - Reputation: 2165 Posted 30 June 2013 - 09:54 AM *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 The Internet is so big, so powerful and pointless that for some people it is a complete substitute for life . ~ Andrew Brown ### #32ChaosEngine Crossbones+ - Reputation: 2955 Posted 30 June 2013 - 08:26 PM 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 ### #33tstrimple Prime Members - Reputation: 1746 Posted 30 June 2013 - 10:25 PM *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? ### #34Code Fox Members - Reputation: 2165 Posted 01 July 2013 - 03:51 AM *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 The Internet is so big, so powerful and pointless that for some people it is a complete substitute for life . ~ Andrew Brown ### #35tstrimple Prime Members - Reputation: 1746 Posted 01 July 2013 - 10:37 AM Syntax of Python is shorter than most languages 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. ### #36Code Fox Members - Reputation: 2165 Posted 01 July 2013 - 04:46 PM Syntax of Python is shorter than most languages 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. The Internet is so big, so powerful and pointless that for some people it is a complete substitute for life . ~ Andrew Brown ### #37tstrimple Prime Members - Reputation: 1746 Posted 01 July 2013 - 05:03 PM 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. ### #38SimonForsman Crossbones+ - Reputation: 6665 Posted 01 July 2013 - 06:49 PM 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 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" 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) 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! ### #39BGB Crossbones+ - Reputation: 1554 Posted 02 July 2013 - 02:49 AM 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".

### #40Paradigm Shifter  Crossbones+   -  Reputation: 5555

Posted 02 July 2013 - 03:42 AM

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

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS