User:B9 hummingbird hovering/Blog/ComputerScience/Pascal

Journal entry
A number of years ago I half-considered half-entertained the future possibility of coding. I made the firm resolve to code in early May 2011 after giving the matter increasing consideration through the last twelve months. A few days prior to making this firm resolve I had borrowed Rossellini's 1971 telemovie of quality 'Blaise Pascal' in French with well-crafted English subtitles released in ... by .... Then in an epiphany of sorts I intuited that the computer language Pascal was given the nomenclature in honour of Blaise Pascal (1623 - 1662). Afterwhich, I viewed the film. I affirmed subsequent to my viewing that the mathematician, philosopher and scientist is eponymous to the programming language in question. I took this as a fortuitous and ever-so-subtle hint from Serendipity that this is to be the first non-web coding computer language I play, work and learn with in a path to code versatility, creativity and precision. Herewith is my learning weblog from which information may be extracted to inform a Wikiversity Pascal learning syllabus as well as progress a Pascal Wikibooks textbook.

Wallace Wang's Beginning Programming for Dummies (third edition, 2004: p.61) states that: "'The best way to learn anything is to start practicing it. If you want to learn computer programming, you should start writing programs on your computer as soon as possible. You can learn to program by starting out with one of hundreds of programming languages designed for novices, such as Pascal, LOGO, and SmallTalk. But the most popular beginner’s programming language is still BASIC.'"

Learning Tibetan and Sanskrit in my fashion on the Internet and my interest in Persian and Arabic all in an aid to foster deep understanding of nondual spiritual traditions which I have explored in another one of my Wikiversity weblogs I have resolved that to progress work and study on coding aesthetic algorithms and less an application and more an optimized environment for inspired translation from one language to another in a largely automated though interactive fashion that provides a number of possibilities and functionalities to support, inform and empower computer aided translation in the very near future as translation tools albeit problematic are already endemic throughout the Internet. This is what I want to focus my coding ability to do. This is another one of my mindstream gifts to my global Community and my World. This has really only recently become a possibility with the Unicode project to digitally encode all human scripts which has not yet been completed. I had already half-resolved to code a few years ago but had not seriously commenced research and study for I felt that my mathematical ability is or was not strong enough. But then I remembered how much I enjoyed calculus and I was good at mathematics in Year 12 and I enjoyed physics in year 12 even though I found it difficult. I am excellent at English and languages and I am a very exacting worker and these will feed in to uphold and support my coding ability. Besides, I will be able to write excellent support documentation and proposals for funding and for communicating ideas and conceptuality to non-technical persons and my interpersonal communication is powerful when I so choose to uncloak. I by intuitive offhanded happenstance borrowed the film Blaise Pascal and then made the connection with the Pascal programming language as I was in the process of investigating and acting on my resolve and have learnt to trust my intuition in guiding my activity and research.

I read the first four chapters of Wang's book which I found intelligible but then it was specifically coding for LibertyBASIC in a Windows Microsoft environment and though I may have possibly done this in a virtual box or in the Wine emulator within the Linux OS I felt or intuited that this was not the most appropriate path for my endeavour. I have researched and informed myself that Lazarus IDE, where IDE is an "integrated development environment" and Free Pascal are good for my preference for a Linux Operating System and I am currently running Natty Narwhal on my Netbook which I have recently installed. In Nutty I used the Ubuntu Software Centre to install Lazarus IDE and Version 0.9.28.2-12 beta was installed. I followed the Lazarus IDE development Twitter account LazarusDev and on the most recent tweet I noticed that a new version 0.9.30 of Lazarus IDE has been released and is available from Sourceforge http://sourceforge.net/projects/lazarus/files/ I am pleased to note that there is an IRC channel for Lazarus IDE users #lazarus-ide

Pascal is to foster my coding rigor and discipline as a point of entry. I am not engaging it as a language to do protracted work in, but then it may be handy in future in unknown ways. People in my lifepath are all talking Pascal down. I realise the 'interest' and 'fashion' to employ Pascal has waned but I trust in my intuition. My research affirms my choice and intuition in that I am interested in familiarizing myself with C and Pascal is an excellent stepping stone to C, refer: Comparison of Pascal and C I am also interested in Python and Perl but I am in no hurry to shortchange my Pascal experiential learning.

Pascal: overview
The strength or weakness of Pascal is that it requires a fixed structure and is a paradigm of Structured programming. At the beginning of a Pascal program the constants, types and variables require declaration, text in bold is defined in the appropriate line-item.

‎"'Pascal is an ordinary high-level language which is widely used as a starting or as a teaching language. However, nowadays Pascal is sometimes preferred to other languages, and could be useful to solve technical problems. It is not necessary to learn any other easier language to start learning Pascal, or any of that sort. It is a very easy programming language and helps you to understand the basics of the world of programming. Also, it greatly helps you in order to start learning the C programming language. I had different experiences, one of which I learned Pascal, and then moved to C programming very easily. The Pascal programming language has its structure and syntax very similar to that of the C programming language.'"

Internet resources

 * Saliba, Victor John (2006). Pascal Programming. Source: (accessed: Sunday May 15, 2011)

Print references

 * Abolrous, Sam A. (2002). Learn Pascal in three days. Third edition, illustrated. Plano, Texas, USA: Wordware Publishing, Inc.
 * Wang, Wallace (2004). Beginning Programming for Dummies. Third edition.

Communication channels

 * #lazarus-ide

The Structure of a Pascal Program
Program name; Const
 * (* Constants here *)

Type
 * (* Type definitions here *)

Var
 * (* Variable declarations here *)

Begin
 * (* Commands here *);

End.

Example of a Pascal program
A typical Pascal program might look like this:

Program TaxRefund: Const
 * TaxRate = 0.35;

Type
 * ClassLevel = (Upper, Middle, Lower);

Var
 * MyClass : ClassLevel;
 * TaxesOwed, Income : integer:

Begin
 * Income := 60000;
 * TaxesOwed := Income * TaxRate;
 * If MyClass = Upper then
 * Begin
 * WriteIn ('Bribe a corrupt politician.');
 * End;

End.

NB: i need to audit indent level...

Definitions

 * constants =
 * types =
 * variables =

Grammar, Syntax & Conventions
In no particular order and will need to be categorized and ordered:
 * every statement is closed with a semicolon, e.g.: ";"
 * a period or full-stop, e.g.: "." closes the entire program
 * comments and annotations may be enclosed in either curly brackets, e.g.: "{" & "}" or with a synergistic combination of parentheses and asterisks, e.g.: "(*" & "*)" which does not compromise compilation
 * not a case-sensitive language so the variable names: TaxRate, TAXRATE, taxrate and Taxrate; are all considered the same variable

Lazarus and Pascal Tutorials

 * Lazarus and Pascal Tutorials

Compiling a Pascal program within a Linux environment
Install the Free Pascal Compiler (FPC). This was automatically installed for me when I installed Lazarus IDE from the Ubuntu Software Centre in Natty Narwhal on Tuesday 17 May 2011. Therefore compilation through FPC can somehow be done within Lazarus IDE but it can also be done directly with FPC from the command line via Terminal.

These programs are fun from Terminal: fpc, fpc-depends, fpcmkcfg, fpcsubst, grab_vcsa, pc

The Free Pascal Compiler is an object pascal compiler supporting both Delphi and Turbo Pascal 7.0 dialects as well as Mac pascal dialects. It provides a completely portable RunTime Library (RTL) available on many platforms and compatible with Turbo Pascal, but also a platform independent class based Free Component Library (FCL) adding many Delphi extensions and interfacing many popular open source libraries.

Some extensions are added to the language, like function overloading. Shared libraries can be linked and created. Delphi language extensions like classes, exceptions, ansi strings and open arrays are also supported.


 * fpc runs the compiler framework in Terminal
 * I have located the fpc folder which is located @: /usr/lib/fpc
 * The fpc version installed is 2.4.0 @ /usr/lib/fpc/2.4.0 & this is what was retrieved from the Ubuntu Software Centre as a dependent source when I installed Lazarus IDE on Tuesday 17 May 2011 within Natty. I have sourced a FPC User Manual online for version 2.4.2 only so far. I know there is the new version on the respective SourceForge page which I have already downloaded and extracted from its zipped archive. I will read the installation instructions... but I don't know how this will impact Lazarus IDE. I should be able to compile with the Lazarus IDE as a frontend and GUI but I have been through all menus and have not yet had success. I intuit that I have to tweek the sources area where the Lazarus IDE saves and searches for files etc...to be continued.

I also found "How to Compile a Simple Pascal Program in Ubuntu" by Michelle Rogers:

 * How to Compile a Simple Pascal Program in Ubuntu" by Michelle Rogers I endeavoured to follow her instructions but it did not work for me how it had worked for her so I am reading a PDF I sourced from the Internet.