Lazarus

Miscellaneous => Other => Topic started by: ojn on August 22, 2012, 05:13:47 pm

Title: Book: FreePascal From Square One
Post by: ojn on August 22, 2012, 05:13:47 pm
Hello:

I came across a FPC/Lazarus book that is in progress. I haven't been able to find any information about it on this forum, so I thought that I would make this post.

You can read the blog about the book here:

http://www.contrapositivediary.com/?p=1072

And download a free PDF of the book as it stands now at:

http://www.copperwood.com/pub/FreePascalSquareOneVol1.pdf

The book seems to have had no additions made to it since 2.5 years ago. The author says that when the book is finished, he will publish it on Lulu.com.

Cheers,
Jerry
Title: Re: Book: FreePascal From Square One
Post by: BigChimp on August 22, 2012, 05:26:59 pm
Thanks, it looks good - shame about the lack of updates...
Title: Re: Book: FreePascal From Square One
Post by: Knipfty on August 22, 2012, 06:00:56 pm
Thanks ojn!

Perhaps if people started emailing him, his interest may be regained.

Knipfty
Title: Re: Book: FreePascal From Square One
Post by: TurboRascal on August 25, 2012, 12:12:22 am
Jeff Duntemann?! He definitely has a good name in computing literature. And we should definitely start pestering him to finish it :D

I find it quite encouraging that someone like him expressed interest in writing about Lazarus.
Title: Re: Book: FreePascal From Square One
Post by: Zoran on August 25, 2012, 12:41:46 am
Jeff Duntemann?! He definitely has a good name in computing literature. And we should definitely start pestering him to finish it :D

I find it quite encouraging that someone like him expressed interest in writing about Lazarus.

See: http://www.lazarus.freepascal.org/index.php/topic,8651.0.html
Title: Re: Book: FreePascal From Square One
Post by: Jeff Duntemann on September 12, 2012, 04:15:30 am
Hi guys--

I'm still out here, and the FreePascal From Square One project is not dead. The gist of it is to take the Pascal material from my 1992 book Borland Pascal 7 from Square One and adapt it for FreePascal using Lazarus as the tutorial IDE. My intent is to make it a free ebook (probably a PDF to keep source code from wrapping) and then make it available under Lulu for print copies.

I've tried a couple of other approaches. My first attempt was to use the text-mode IDE for FPC, but it gave me a lot of trouble. Lazarus was getting pretty close to 1.0 by that time, so I went back and began to rewrite what I had to focus on Lazarus. I've held back further work until the 1.0 release, so I may be running out of excuses, heh.

In all seriousness: I just installed Lazarus 1.0 for Windows and am very pleased with it. (I've had various odd problems with Lazarus in the past.) Installing it under Linux Mint is next on my list.

One problem is that there is an enormous amount of material to cover in any tutorial on FPC or Lazarus. I have a Delphi tutorial book from 1996 that I may pull material from: The Delphi 2 Programming Explorer. The challenge is to know what to cover and how to arrange it all.

In the meantime, here's a related question I have for Lazarus experts: Would it be possible to have an item in the File | New... dialog for a bare-bones minimum Pascal program? The current skeleton in Lazarus for a simple FreePascal program is this:

program Project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes
  { you can add units after this };

begin
end.
                         
In teaching an absolute beginner about Pascal, I'd like to avoid having to include (and therefore having to explain) the {$} switches. I've used the following skeleton for simple FPC programs under Lazarus and it works:

PROGRAM Project1;

BEGIN
END.

(The capitalization doesn't matter; this is just an ancient habit I'm in.)

I don't see how to create a File | New... skeleton item for Lazarus, but a completely simple and switch-free skeleton would be very handy for people writing tutorials. What do you think?

Many thanks!

--73--

--Jeff Duntemann
  Colorado Springs, Colorado, USA


Title: Re: Book: FreePascal From Square One
Post by: ojn on September 12, 2012, 05:54:09 am
My intent is to make it a free ebook (probably a PDF to keep source code from wrapping) and then make it available under Lulu for print copies.

Hi Jeff:

As a newbie to ObjectPascal, I can't help you with your question. However, I'd like to say that I would very much like to buy a print copy of your book when it's finished.

Thanks,
Jerry
Title: Re: Book: FreePascal From Square One
Post by: JuhaManninen on September 13, 2012, 08:52:26 am
In the meantime, here's a related question I have for Lazarus experts: Would it be possible to have an item in the File | New... dialog for a bare-bones minimum Pascal program? The current skeleton in Lazarus for a simple FreePascal program is this:

program Project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes
  { you can add units after this };

begin
end.
                         
In teaching an absolute beginner about Pascal, I'd like to avoid having to include (and therefore having to explain) the {$} switches. I've used the following skeleton for simple FPC programs under Lazarus and it works:

PROGRAM Project1;

BEGIN
END.

(The capitalization doesn't matter; this is just an ancient habit I'm in.)

I don't see how to create a File | New... skeleton item for Lazarus, but a completely simple and switch-free skeleton would be very handy for people writing tutorials. What do you think?

I added such Simple Program template in r38632. Please test with Lazarus trunk. Thanks for the idea.

As Phil mentioned in the other thread, in the future you can create feature requests in the issue tracker.
 http://bugs.freepascal.org
Then it will be noticed for sure.
Not all developers follow this forum intensively. Luckily I noticed this one.

I am also excited about your book.

Thanks and regards
Juha
Title: Re: Book: FreePascal From Square One
Post by: JD on September 13, 2012, 11:08:10 am
Hi guys--

I'm still out here, and the FreePascal From Square One project is not dead. The gist of it is to take the Pascal material from my 1992 book Borland Pascal 7 from Square One and adapt it for FreePascal using Lazarus as the tutorial IDE. My intent is to make it a free ebook (probably a PDF to keep source code from wrapping) and then make it available under Lulu for print copies.

--Jeff Duntemann
  Colorado Springs, Colorado, USA

Hi there Jeff. I must congratulate you for your work. It looks very professional and I sincerely hope you'll take it to its conclusion. I'm one of those that still refers to Delphi reference books when I use Lazarus and it would be a pleasure to see more and more reference works wholly devoted to FreePascal/Lazarus.

The only pure Pascal book left in my library is Learn Pascal by Sam Abolrous http://www.amazon.com/Learn-Pascal-Sam-Abolrous/dp/155622706X (http://www.amazon.com/Learn-Pascal-Sam-Abolrous/dp/155622706X)

Keep up the good work.  :D
Title: Re: Book: FreePascal From Square One
Post by: Ask on September 13, 2012, 11:29:39 am
I have similar requirements, so I am also interested in this change.
Tested -- this is going into the right direction.
Few notes:
1) What does "program source is maintained by Lazarus" mean in the description? The phrase seems awkward and not very meaningful, so perhaps it should be dropped (I do understand that it was copied from existing item, but still...)

2) This almost duplicates existing "Module/Custom Program" item. I suspect that one was added some time ago to satisfy similar feature request, but then mistakenly moved to "Module" category instead of "Project". It probably should be removed.

3) However, the "Custom Program" template contains additional lines:
3.1) {$mode objfpc}{$h+} -- I believe this is essential and should be included in "Simple Program" template, because it allows to compile the project from the command line (without complication of extra switches), which is both an important concept to teach the beginners and very useful for point (6) below.
3.2) uses SysUtils, Classes -- this is less important, but allows structured exception handling of standard run-time errors. Probably can be omitted...

4) "program project1" line is superfluous and should IMHO be dropped.

5) Since "Simple Program" probably means "Console application", "-WG" switch should be off by default.

6) Finally, I have closely related, but more complex, request -- introduce "Single-file mode" into Lazarus, where Lazarus does not create .lpi and .lps files, stores executable and object file in the same directory as source, and does not save desktop settings.
This mode can be triggered by either command line switch:
"lazarus.exe --single homework.lpr",
special directive in source:
{%singlefileproject},
or a heuristic:
enter single-file mode when passed a project name from command line,
and corresponding .lpi and .lps files do not exist.
"Project" menu item should be disabled/hidden in this mode.

The main use case, besides obvious beginner education, is competitive programming,
where in a typical contest participant may need to create 5-12 single-file projects in a time period of 3 to 5 hours.
Title: Re: Book: FreePascal From Square One
Post by: JuhaManninen on September 13, 2012, 08:17:34 pm
I have similar requirements, so I am also interested in this change.
Tested -- this is going into the right direction.
Few notes:
1) What does "program source is maintained by Lazarus" mean in the description? The phrase seems awkward and not very meaningful, so perhaps it should be dropped (I do understand that it was copied from existing item, but still...)

I had the same question in mind when I added the new project template. I removed the text now from all templates, and improved the remaining texts.

Quote
2) This almost duplicates existing "Module/Custom Program" item. I suspect that one was added some time ago to satisfy similar feature request, but then mistakenly moved to "Module" category instead of "Project". It probably should be removed.

Ok, I didn't even notice it earlier. It was clearly in a wrong place. Even its description said: "Better create a new project" which meant "I am in a wrong place".
Removed.

Quote
3) However, the "Custom Program" template contains additional lines:
3.1) {$mode objfpc}{$h+} -- I believe this is essential and should be included in "Simple Program" template, because it allows to compile the project from the command line (without complication of extra switches), which is both an important concept to teach the beginners and very useful for point (6) below.
3.2) uses SysUtils, Classes -- this is less important, but allows structured exception handling of standard run-time errors. Probably can be omitted...

4) "program project1" line is superfluous and should IMHO be dropped.

After your changes a simple program would look like this:
Code: [Select]
{$mode objfpc}{$h+}
begin
end.

which looks weird.
What does Jeff Duntemann say? He is the one writing a beginners' book after all.

Quote
5) Since "Simple Program" probably means "Console application", "-WG" switch should be off by default.

It is off by default! Or is it somehow on by default in your machine?

Quote
6) Finally, I have closely related, but more complex, request -- introduce "Single-file mode" into Lazarus, where Lazarus does not create .lpi and .lps files, stores executable and object file in the same directory as source, and does not save desktop settings.
This mode can be triggered by either command line switch:
"lazarus.exe --single homework.lpr",
special directive in source:
{%singlefileproject},
or a heuristic:
enter single-file mode when passed a project name from command line,
and corresponding .lpi and .lps files do not exist.
"Project" menu item should be disabled/hidden in this mode.

The main use case, besides obvious beginner education, is competitive programming,
where in a typical contest participant may need to create 5-12 single-file projects in a time period of 3 to 5 hours.

Good idea but I don't know how to implement it.
Could you please move this question to the Lazarus mailing list? Mattias reads it and he is the author of the project management stuff.


Regards,
Juha
Title: Re: Book: FreePascal From Square One
Post by: Jeff Duntemann on September 14, 2012, 01:21:27 am
I don't think the program keyword should be dropped.

Whether or not it's superfluous, it's present in the vast majority of Pascal tutorials out there (going back to the designer of Pascal itself, Niklaus Wirth) and especially in short programs intended to teach the language to beginners, I think it should be retained.

That said, I'm not a compiler writer and have not studied compiler internals in detail. Is there something about the program keyword that interferes with the operation of FPC?

--73--

--Jeff Duntemann
  Colorado Springs, Colorado, USA
Title: Re: Book: FreePascal From Square One
Post by: Ask on September 14, 2012, 03:38:28 am
It does not do anything bad, just an extra line.

If you remeber how Wirth designed it, you can even write
PROGRAM P(INPUT, OUTPUT);
and it will still be accepted by compiler :)
Title: Re: Book: FreePascal From Square One
Post by: Leledumbo on September 14, 2012, 06:32:25 am
In original Pascal, the program header is a requirement. Even the input,output declared like a parameter there is used. From Turbo Pascal days, it's no longer required (because input and output are system unit identifiers) and only gets parsed, but nothing is generated by the line. It's OK for documentation purpose IMO (what the program name is) and to say compatible with original Pascal.
Title: Re: Book: FreePascal From Square One
Post by: ojn on September 14, 2012, 10:08:35 am
The only pure Pascal book left in my library is Learn Pascal by Sam Abolrous http://www.amazon.com/Learn-Pascal-Sam-Abolrous/dp/155622706X (http://www.amazon.com/Learn-Pascal-Sam-Abolrous/dp/155622706X)

Thanks for the book recommendation! I was able to pick up a used copy in very good condition on Amazon for $0.09.

Jerry
Title: Re: Book: FreePascal From Square One
Post by: JD on September 14, 2012, 11:06:12 am
The only pure Pascal book left in my library is Learn Pascal by Sam Abolrous http://www.amazon.com/Learn-Pascal-Sam-Abolrous/dp/155622706X (http://www.amazon.com/Learn-Pascal-Sam-Abolrous/dp/155622706X)

Thanks for the book recommendation! I was able to pick up a used copy in very good condition on Amazon for $0.09.

Jerry

You're welcome. I hope you find it useful.
Title: Re: Book: FreePascal From Square One
Post by: miquelmatas on September 14, 2012, 12:16:19 pm
The only pure Pascal book left in my library is Learn Pascal by Sam Abolrous http://www.amazon.com/Learn-Pascal-Sam-Abolrous/dp/155622706X (http://www.amazon.com/Learn-Pascal-Sam-Abolrous/dp/155622706X)

Better than http://www.amazon.co.uk/Learn-Pascal-Three-Days-Abolrous/dp/1556228058/ref=lh_ni_t (http://www.amazon.co.uk/Learn-Pascal-Three-Days-Abolrous/dp/1556228058/ref=lh_ni_t) ?

Cheers,
Miquel.


Title: Re: Book: FreePascal From Square One
Post by: JD on September 14, 2012, 12:31:14 pm
The only pure Pascal book left in my library is Learn Pascal by Sam Abolrous http://www.amazon.com/Learn-Pascal-Sam-Abolrous/dp/155622706X (http://www.amazon.com/Learn-Pascal-Sam-Abolrous/dp/155622706X)

Better than http://www.amazon.co.uk/Learn-Pascal-Three-Days-Abolrous/dp/1556228058/ref=lh_ni_t (http://www.amazon.co.uk/Learn-Pascal-Three-Days-Abolrous/dp/1556228058/ref=lh_ni_t) ?

Cheers,
Miquel.

The two are very, very similar. Even the titles, order and contents of the chapters are comparable. However Learn Pascal in 3 days stops at Chapter 11 - Pointers and Linked Lists while Learn Pascal has that Chapter 11 and an additional Chapter 12 - Advanced Programming Algorithms which covers sorting algorithms, linear and binary searches, binary trees etc.
Title: Re: Book: FreePascal From Square One
Post by: miquelmatas on September 14, 2012, 12:39:06 pm
Thanks very much for clarification.
Title: Re: Book: FreePascal From Square One
Post by: JD on September 14, 2012, 01:03:00 pm
Thanks very much for clarification.

If you already have Learn Pascal in Three Days, don't bother getting Learn Pascal. You can just go on from there to Tomes of Delphi: Algorithms and Data Structures
http://www.amazon.co.uk/Tomes-Delphi-Algorithms-Structures-Developers/dp/1556227361/ref=sr_1_3?s=books&ie=UTF8&qid=1347620404&sr=1-3 (http://www.amazon.co.uk/Tomes-Delphi-Algorithms-Structures-Developers/dp/1556227361/ref=sr_1_3?s=books&ie=UTF8&qid=1347620404&sr=1-3)

Kindle version http://www.amazon.com/The-Tomes-Delphi-Algorithms-ebook/dp/B007FKB0EI (http://www.amazon.com/The-Tomes-Delphi-Algorithms-ebook/dp/B007FKB0EI)

In my opinion, the book is excellent for advanced pascal programming albeit with a Delphi mindset.
Title: Re: Book: FreePascal From Square One
Post by: TurboRascal on September 14, 2012, 01:33:49 pm
For algorithms I'd also recommend the legendary book "Algorithms" by R. Sedgewick. As I mentioned in another thread, the original editions were pascal-based, and considering the later ones switched to other languages, the pascal editions are available very cheaply.

For the program templates, I'd say perhaps the classic Pascal program structure would be the best for the purpose of the book:
Code: [Select]
program <name>;

begin

end.

It's fine to teach Pascal basics, including the ISO standard program directive. Objfpc is not required since compiler directives can be confusing to novices, and the limited default mode is just fine for teaching the basics. For switching to a higher level, objfpc could be used later, and the compiler directives could be taught along with other more advanced topics.
Title: Re: Book: FreePascal From Square One
Post by: Jeff Duntemann on September 19, 2012, 02:47:17 am
I added such Simple Program template in r38632. Please test with Lazarus trunk. Thanks for the idea.

As Phil mentioned in the other thread, in the future you can create feature requests in the issue tracker.
 http://bugs.freepascal.org
Then it will be noticed for sure.
Not all developers follow this forum intensively. Luckily I noticed this one.

I am also excited about your book.

Thanks and regards
Juha

Many thanks, Juha!

I've got a deadline on another project right now, but I will test this as soon as time allows.

It's not a really big deal, but I want to make Pascal as easy to pick up as possible, and also to retain "familiarity" with older works on the language.

Again, thanks and good luck!

--73--

--Jeff Duntemann
  Colorado Springs, Colorado USA
Title: Re: Book: FreePascal From Square One
Post by: miquelmatas on September 19, 2012, 09:47:38 am


I added such Simple Program template in r38632. Please test with Lazarus trunk. Thanks for the idea.


I do not find this template file...

Which name has it? Which folder path does it resides?

Thanks in advance.

Miquel.
Title: Re: Book: FreePascal From Square One
Post by: BigChimp on September 19, 2012, 10:24:19 am
@Miquel, if you have Lazarus trunk (development version): Project/New Project.../Simple Program which gives this:
Code: [Select]
program Project1;

begin
end.
Title: Re: Book: FreePascal From Square One
Post by: miquelmatas on September 19, 2012, 10:52:12 am
Got it!

Thanks very much!
Title: Re: Book: FreePascal From Square One
Post by: Nebula on September 19, 2012, 11:00:53 am
Well done Jeff, I hope you keep going with it.

I don't think it's as off-putting as you believe it is, for anyone motivated enough that they've already started reading the book.

If Lazarus already provides you with it, and the user doesn't have to type it in for themself - then the only issue is "What does it mean?". And that, IMHO, is easily dealt with by saying to ignore it, and if you really want to know, here's a quick explanation in a boxed paragraph that you can skip until later if you don't care yet.

A quick side by side introduction is all that is required at first -
 in column 1 the default template that does nothing;
 in column 2 almost exactly the same, but with a 'Hello World!' showmessage.

Anyone with any latent talent to understand programming will home in on the one different line that actually does something, and either won't worry about the extra cruft, or will read the optional explanation if they're curious.

Cheers
TinyPortal © 2005-2018