Recent

Author Topic: Book: FreePascal From Square One  (Read 24703 times)

ojn

  • New Member
  • *
  • Posts: 25
Book: FreePascal From Square One
« 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

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Book: FreePascal From Square One
« Reply #1 on: August 22, 2012, 05:26:59 pm »
Thanks, it looks good - shame about the lack of updates...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Knipfty

  • Full Member
  • ***
  • Posts: 232
Re: Book: FreePascal From Square One
« Reply #2 on: August 22, 2012, 06:00:56 pm »
Thanks ojn!

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

Knipfty
64-bit Lazarus 2.2.0 FPC 3.2.2, 64-bit Win 11

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: Book: FreePascal From Square One
« Reply #3 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.
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Book: FreePascal From Square One
« Reply #4 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

Jeff Duntemann

  • New member
  • *
  • Posts: 8
Re: Book: FreePascal From Square One
« Reply #5 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


« Last Edit: September 12, 2012, 04:19:31 am by Jeff Duntemann »

ojn

  • New Member
  • *
  • Posts: 25
Re: Book: FreePascal From Square One
« Reply #6 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

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4468
  • I like bugs.
Re: Book: FreePascal From Square One
« Reply #7 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
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: Book: FreePascal From Square One
« Reply #8 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

Keep up the good work.  :D
« Last Edit: September 13, 2012, 11:14:07 am by JD »
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Book: FreePascal From Square One
« Reply #9 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.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4468
  • I like bugs.
Re: Book: FreePascal From Square One
« Reply #10 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
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Jeff Duntemann

  • New member
  • *
  • Posts: 8
Re: Book: FreePascal From Square One
« Reply #11 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

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Book: FreePascal From Square One
« Reply #12 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 :)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Book: FreePascal From Square One
« Reply #13 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.

ojn

  • New Member
  • *
  • Posts: 25
Re: Book: FreePascal From Square One
« Reply #14 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

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

Jerry

 

TinyPortal © 2005-2018