Learning freepascal

(SmaTheGreek) #1

I have downloaded free pascal & want to learn the basic things about programming in pascal.Can you suggest me some free internet books or tuts for programming in freepascal .Note that I am new at pascal .Please post links

(nico) #2

May I ask why you want to learn pascal?

(SmaTheGreek) #3

For school and also to learn one more language

(osxrules) #4

I learned Pascal at school too. I will tell you right now, it is a waste of time. I haven’t used it once outside of the classroom. If you know a language like C, Pascal is pretty easy to use.

Here are the basics:


Don’t go beyond what is necessary for the course because like I say, it’s a waste of time. Just learn C or C++.

(Duoas) #5

It’s not a waste of time. Modern versions of Pascal are very powerful, and friendlier than C/C++.

On a PC, Pascal and C/C++ are pretty much the same, so like osxrules said: if you know C/C++ you can pick up Pascal very easily.

Also check out http://www.pascal-central.com/

You have to be careful when talking to programmers. In the C/C++ community there is a lot of anti-Pascal elitism, which today exists only because of historical bigotries.

When programming Win32, I use Borland Object Pascal most of the time. After that I use C/C++. And occasionally PLT Scheme.
All that really matters in your choice is (1) applicability to the problem and (2) how much you like the language.

P.S. I’m pretty much a Pascal expert, so if you have any really weird questions feel free to ask.

(SmaTheGreek) #6

Thanks guys

(yfkar.) #7

Started programming with the good ol’ Turbo Pascal 5.5. Made a few small dos games with it (and had to write quite a bit of assembly to make them work not like slugs in tar). :smiley:

(SmaTheGreek) #8

Well until now I’ve been using visual basic 6 and sometimes python,but now I needed pascal for a project in the school and I think it is a good opportunity to learn the language…

(osxrules) #9

I meant from the standpoint that most other people use C/C++. I agree there are friendlier languages than both. I actually don’t like C++ that much at all. C on the other hand is my favourite programming language.

Yes, that’s true. I was judging it from my experience of using it but I admit some bigotry crept in and as I said above, just the fact that most other people use it gives it a big advantage. I don’t think you would be able to realistically do anything with Blender using Pascal for example - I’m not even sure you can use OpenGL with Pascal. System libraries, drivers, you name it, it’s all C or C++.

I didn’t realise you were a Pascal fan Duoas. I wouldn’t have been so harsh. You’re right that using a language you like helps a lot. I still wouldn’t use it for main projects personally but if it’s powerful enough, I suppose it’s OK.

(valarking) #10

Put me in that group.

I started programming on Object Pascal in Delphi and I thought it was great until I started using C++. Doing things with C++ is so much faster. They use brackets instead of english words for a reason!

(Duoas) #11

Don’t appologize, I wasn’t criticizing you, just making some general statements (seriously!).

Pascal has only recently become generally useful on non-PC systems. I learned to program starting with GW BASIC. Within the first two months I hit its limitations. So my dad introduced me to TP4 and there was no looking back --I love to program.

When I first started the university about 16 years ago, I quickly noticed that Pascal there was wimpy. (Someone(s) said: we want Pascal, so the C/C++ community said, OK, here’s the most primative form we can be bothered to make for you. It was barely ANSI compliant. And a waste of time.)

some history

Pascal was initially designed only as a teaching tool, and was both explicitly and implicitly limited: Nicklaus Wirth never really intended it to replace existing languages (like FORTRAN). It was just a kind of wish-list. Nevertheless it caught on quickly due to its inherent advantages over broken languages like ALGOL and its structure, strict data types, and readability. Universities worldwide adopted it in line with Wirth’s original purpose: to teach good programming.

When Borland first published Turbo Pascal in 1983, it took the world by storm. Here was a language that was powerful, flexible, and fast. Compilation speeds blew people’s minds. Borland’s take on Pascal (which were genuine improvements) made code optimizations, speed optimizations, and error checking the new standard. The addition of an integrated development environment put the icing on the cake: one program did it all. It was revolutionary.

In the Unix world, the C community, endeared to their favorite tool (as one is to their favorite editor), continued to look at Pascal as beneath their notice, and, pointing out some of its continued limitations, never endeavored to upgrade Pascal on their own systems. Pascal was a DOS/PC tool. Plus, what’s cooler than an OS and a language that were developed together? Don’t feel bad, they snubbed other languages too.

It is telling that Brian Kernighan’s “Why Pascal is Not My Favorite Programming Language” was written in 1981, when his statements were essentially correct (though dripping with condescension). He and Richie’s recently developed language, C, addressed issues that Wirth did not, giving it an advantage in power. And again, having your own OS bound to the language didn’t disadvantage it any. That document is still available for read even today, and as things go, it was the rallying cry against ever using Pascal, no matter how it improved through the years.

pascal today

Pascal still struggles to catch-up on historically antagonistic systems like Unix/Linux and the Mac which was traditionally a closed system (for which you only used proprietary tools to program it).

However, due to the efforts of Borland and, more recently, those who just love Pascal (such as the Free Pascal group and a few people working for the GNU foundation), Pascal has evolved into a very powerful language capable of doing anything C/C++ can do (and, might I add, with more style).

Now don’t get me wrong. I like C. And C++. A lot. But you should realize the reason why.

When you parse a C/C++ program into its lexical tree, and do the same for a[n Object] Pascal program, you get the same tree.

As to valarking’s comment. Your experience is, frankly, atypical. For a good touch-typist typing out begin and end instead of { and } takes no significant amount of difference in time; particularly, most of your time programming is not spent dinking with keywords. People like Pascal because of its clean, easy-to-read structure, and its straightforward, uncluttered syntax. It’s hard to lose a begin.

I’m proficient in Pascal, C, C++, assembly (intel and mips), scheme, haskell, basic, tcl/tk, … um, what else… i guess that’s it, and familiar with a host of scripting languages (like python and csh). I’ve been programming for more than 20 years on PC, SunSparc, and embedded systems.

My advice is: use the language (1) most suited to the job, and (2) that you like best.

P.S. Why would you want to mix Pascal into Blender sources? (Yes, you can use OpenGL and C/C++ libraries with Pascal.)
P.P.S. I can understand why non-native English speakers would dislike keywords in a language not their own.

(PassiveSmoking) #12

Good well-written post, that. :slight_smile: Might I also add, that one reason why early Pascals were unpopular was because they forced range-checking upon you, and would throw a runtime error if you tried to do such things as access beyond the end of an array. This didn’t happen in C, and allowed you to do some very powerful things.

However, this is also C’s downfall. Ever hear of the buffer overflow attack? This attack is possible almost entirely because C doesn’t range-check anything.

Modern pascals still have range-checking enabled by default but you can disable it if need be, this strikes me as a more sensible approach than the one C uses.

(Duoas) #13

Heh, thanks. It wasn’t just range-checking, it was type-checking forced down your throat in the most uncomfortable way. Pascal is very strongly typed -which is part of the reason it is so powerful, but like K said, “there [was] no escape.”

Something like
struct foo {
int a;
char c[];

is a very friendly thing in C. In Pascal, you’d have to be more careful.

type foo = record a: integer; c: char end;

then in code you would cast your structure type onto the data, and address the elements of c with

var c: pchar;
c = @(foo( my_object ).c);
write( c[ 12 ] );

(osxrules) #14

I heard about that. I didn’t notice it because I only made small pascal programs but C/C++ takes forever to compile. That really annoys me. Especially if I have to change a project setting in my IDE when compiling Blender because it starts from the beginning. 600+ source files. I’m guessing that’s why Maya has so many libraries. Blender is pretty big now so I would reckon it could use being split into subsections of code so we didn’t have to recompile the whole thing. That way updates would come faster because someone might finish a project in one library while another library is being worked on in CVS.

Are you a professional programmer or do it in your free time? If you earn a living from it, what language do you use most in your line of work?

Exactly, that was kind of my point. You wouldn’t. The same with most other projects people work on. When there are so many C/C++ projects around, it encourages you to stick to C-based languages. Check out the sourceforge stats:

Programming Language
ActionScript (74 projects)
Ada (105 projects)
APL (15 projects)
AppleScript (27 projects)
ASP (552 projects)
AspectJ (16 projects)
ASP.NET (120 projects)
Assembly (1594 projects)
AWK (11 projects)
BASIC (60 projects)
*C (15696 projects)
*C# (2786 projects)
*C++ (16458 projects)
COBOL (4 projects)
Cold Fusion (135 projects)
Common Lisp (18 projects)
D (25 projects)
Delphi/Kylix (1899 projects)
Dylan (3 projects)
Eiffel (69 projects)
Emacs-Lisp (11 projects)
Erlang (31 projects)
Euler (1 projects)
Euphoria (19 projects)
Forth (57 projects)
Fortran (163 projects)
Groovy (10 projects)
Haskell (40 projects)
IDL (12 projects)
Java (16359 projects)
JavaScript (2672 projects)
JSP (176 projects)
LabVIEW (8 projects)
Lisp (320 projects)
Logo (16 projects)
LPC (8 projects)
Lua (92 projects)
MATLAB (28 projects)
Modula (7 projects)
MUMPS (8 projects)
Oberon (0 projects)
*Objective C (728 projects)
*Object Pascal (277 projects)
OCaml (Objective Caml) (51 projects)
*Pascal (352 projects)
Perl (6139 projects)
PHP (11894 projects)
Pike (18 projects)
PL/SQL (1131 projects)
PROGRESS (26 projects)
Prolog (103 projects)
Python (4415 projects)
REALbasic (17 projects)
REBOL (15 projects)
Rexx (41 projects)
Ruby (387 projects)
Scheme (200 projects)
Simula (1 projects)
Simulink (2 projects)
Smalltalk (56 projects)
S/R (10 projects)
Standard ML (135 projects)
Tcl (904 projects)
Unix Shell (1812 projects)
VBScript (52 projects)
VHDL/Verilog (12 projects)
Visual Basic (2161 projects)
Visual Basic .NET (272 projects)
Visual FoxPro (4 projects)
XBasic (31 projects)
XSL (XSLT/XPath/XSL-FO) (202 projects)
Yacc (24 projects)
Zope (130 projects)

35000+ C-based projects.
629 Pascal-based.

I wish there was one or two langauges that people just settled on. I don’t like that there are so many. Can’t someone invent a language with the best syntax and features and scrap the rest? A language with fast compile times, fast performance, a purely objective language, truly cross-platform, and the ability to run interpreted. Python I guess comes close except on the performance side. In fact, I guess Object Pascal comes close too.

Mind you, I could say the same about spoken languages or even currency. It’s never going to happen though.

(Duoas) #15

Mostly in my spare time. I’ll have a BS in Mathematics and Computer Science in a year, so hopefully I’ll be more marketable (even though I’m not really learning much about programming in school. I did learn functional programming though, that was cool.)

On Windows I tend to stick with Delphi. But I’ll use C/C++ on occasion. It depends on the project and/or tools necessary for it. Hmm, I also seem to wind-up doing a lot of DOS BATCH programming… Maybe I’m just an old fart. (BTW, cmd.exe puts command.com to shame.)

Under Linux I tend to use C/C++, just because all the tools are already there. Also, I’ve not been too impressed (as yet) with Kylix. I like freepascal, but it’s graphical capabilities are still a little underdeveloped.

For cross-platform programming, I tend to use Tcl/Tk or Trolltech’s Qt (which uses C++).

Embedded systems usually have special tools: either an assembler or a simple Basic or C compiler. They work differently than normal desktop computers, so programming them isn’t really comparable.

Our points diverge somewhat on the Pascal in Blender. My point is this: don’t mix languages without a good reason. Blender is a C project with an embedded Python interpreter. There is no good reason to mix Pascal, or any other language, into the codebase. (It’s bad enough that C++, which is a distinct language, is getting mixed-in). It has nothing to do with the power or capability of any other language and everything to do with maintainability.

Thanks for the interest. :slight_smile:

One of the reasons C/C++ is so slow to compile is what is technically known as “dependancy hell.” Were Blender written in Pascal, y’all wouldn’t need them fancy-pants Makefiles. :stuck_out_tongue: Also, it has a lot to do with Pascal’s requirement that everything be forward-referenced. It’s not uncommon for Pascal compilers to work in one pass.