Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-09

Project Idea: Mini-FPC

30 messages · 15 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Skybuck Flying

Hello,

Here is an idea to help new-comers to FPC understand how it works:

A new project could be created which would be called: "Mini-FPC".

The purpose of the project is to demonstrate how FPC compiles/builds itself and how it implements basic platform/cpu support.

So the very minimum goal of the Mini-FPC is to produce an executable which can run on the platform.

Optional components would be:

Returning a code from the executable, this would include the need for integers.
Outputting text to a console, this would include the need for strings.

Everything else can then be left out like:

floating point numbers,
sockets,
lists,
classes,
printers,
bitmaps,
perhaps even debugger or debugger support,
etc.

So it's trimmed down as much as possible to isolate it's core components.

Bye,
Skybuck.

Reply by email

Tomas Hajny
to Skybuck Flying

On Fri, September 9, 2011 03:48, Skybuck Flying wrote:

Hello,

Show quoted text 7 lines
Here is an idea to help new-comers to FPC understand how it works: A new project could be created which would be called: "Mini-FPC". The purpose of the project is to demonstrate how FPC compiles/builds itself and how it implements basic platform/cpu support.

.
.

Show quoted text 12 lines
Everything else can then be left out like: floating point numbers, sockets, lists, classes, printers, bitmaps, perhaps even debugger or debugger support, etc. So it's trimmed down as much as possible to isolate it's core components.

3 comments:

1) Floating point support is necessary for the compiler to compile/build itself, because floating point number support needs to be available in the compiler itself (otherwise source files containing floating point numbers cannot be processed by the compiler).

2) Needs of different users vary considerably. A user interested in compiling a simple console 'hello world' program using procedural Pascal needs only unit System and nothing else, a user creating 'hello world' in a GUI window using Object Pascal has much broader needs (broader than the compiler itself).

3) Everyone is free to create a special installation package for his own needs, but I can hardly imagine something like that becoming part of the general FPC distribution.

Tomas

Reply by email

Skybuck Flying
to Tomas Hajny

3 comments:

"
1) Floating point support is necessary for the compiler to compile/build itself, because floating point number support needs to be available in the compiler itself (otherwise source files containing floating point numbers cannot be processed by the compiler).
"

Why would a basic/core compiler which does not support floating point numbers need floating point numbers ?

Doesn't make much sense to me.

Surely free pascal can be reduced so far to integers only.

I can only imagine math.pas containing PI but math.pas should not be part of a basic/core compiler anyway.

So this argument of yours seems to make little sense unless you can give a very convincing example of "floats" being used inside the core of free pascal compiler.

"
2) Needs of different users vary considerably. A user interested in compiling a simple console 'hello world' program using procedural Pascal needs only unit System and nothing else, a user creating 'hello world' in a GUI window using Object Pascal has much broader needs (broader than the compiler itself).
"

No, calling the windows gui requires a windows api. It has nothing to do with compiler technology.

So again this argument of yours makes little sense.

"
3) Everyone is free to create a special installation package for his own needs, but I can hardly imagine something like that becoming part of the general FPC distribution.
"

The mini-fpc should be a "side-project" for those people interested in compiler technology only and not everything else.

Bye,
Skybuck.

Reply by email

John Clymer
to Tomas Hajny: . . 3 comments: 1) Floating point support is necessary for the compiler to compile/build…

Have you looked at target "embedded" ? For what specific platform are you contemplating this for ? (i.e. what specific need is driving this question ?) It implements a very minimal set of things, basically the minimum necessary to support the language core, and the minimum necessary to support a given processor and it's "system" unit.

John

________________________________

Earlier message 52 lines
From: Tomas Hajny To: FPC developers' list Sent: Fri, September 9, 2011 3:45:54 PM Subject: Re: [fpc-devel] Project Idea: Mini-FPC On Fri, September 9, 2011 03:48, Skybuck Flying wrote: Hello, > Here is an idea to help new-comers to FPC understand how it works: > > A new project could be created which would be called: "Mini-FPC". > > The purpose of the project is to demonstrate how FPC compiles/builds > itself > and how it implements basic platform/cpu support. . . > Everything else can then be left out like: > > floating point numbers, > sockets, > lists, > classes, > printers, > bitmaps, > perhaps even debugger or debugger support, > etc. > > So it's trimmed down as much as possible to isolate it's core components. 3 comments: 1) Floating point support is necessary for the compiler to compile/build itself, because floating point number support needs to be available in the compiler itself (otherwise source files containing floating point numbers cannot be processed by the compiler). 2) Needs of different users vary considerably. A user interested in compiling a simple console 'hello world' program using procedural Pascal needs only unit System and nothing else, a user creating 'hello world' in a GUI window using Object Pascal has much broader needs (broader than the compiler itself). 3) Everyone is free to create a special installation package for his own needs, but I can hardly imagine something like that becoming part of the general FPC distribution. Tomas

Reply by email

Skybuck Flying
to John Clymer

"
Have you looked at target "embedded" ?
"

Just took a look at it it's still quite big/huge and uses arm ?

"
For what specific platform are you contemplating this for ? "

None, redcode, cuda.

Mini-fpc could be reduced to show proportions that it becomes virtual, an exercise at seperating the processing of the pascal language and giving meaning/sense to the tokens so it becomes ready for assembling. It could be reduced to such a level that it becomes a question of plugging in the lower parts, so it could also become more moduler.

It's also important to reduce code size and code files as much as possible, just searching all files for a certain keyword already takes multiple seconds.

Mini-fpc would be ment to learn how free pascal works and also to be able to port it to other pascal languages for example Delphi, so further experimentation can be done.

"
(i.e. what specific need is driving this question ?) "

Understanding for example how free pascal compiles itself, which units it needs as a minimum, so far it seems to need system.pas, objpas.pas and sysinit.pas.

Something like that. sysinitpas.pas contains some routines in implementation section which must apperently be present, some functions are made public via special directives.

There is also another compiler directive for example "compilerproc" which remains undocumented, and then there are these things "aliases" and such.

Free Pascal seems to allow to compile a user supplied system.pas unlike Delphi where this is not allowed, so this could give some problems how to port Free Pascal to Delphi.

Mini-FPC would also be a helpfull tool to see if it's possible or not and which "self-compiling" features free pascal has which Delphi might be missing.

Perhaps there could be work arounds for Delphi how to still compile it.

"
It implements a very minimal set of things, basically the minimum necessary to support the language core, and the minimum necessary to support a given processor and it's "system" unit.
"

I wouldn't call that minimal in any sense.

Minimal would be: redcode support.

Also the free pascal/delphi language has become bloated with a lot of stuff... it could be further interesting to reduce it... just for a learning project, but perhaps that should be called: "Slim-FPC" or so ;) or "Nano-FPC" lol.

Nano would be:

One integer type, one string type, branch support, loop support, basic support, object orientation support, property support, array support, virtual methods support.

(Or maybe multiple integer types, just to make it a bit more usuable, and then also very maybe floating type or multiple floating types but this could again make it too complex, and keep it simple).

Only two platforms support to show how to support different assemblers, and how to swap rtl's or so.

A minimum ammount of files and code.

Bye,
Skybuck.

Reply by email

Tomas Hajny
to Skybuck Flying: 3 comments: " 1) Floating point support is necessary for the compiler to compile/build…
Skybuck Flying wrote 13 lines
" 1) Floating point support is necessary for the compiler to compile/build itself, because floating point number support needs to be available in the compiler itself (otherwise source files containing floating point numbers cannot be processed by the compiler). " Why would a basic/core compiler which does not support floating point numbers need floating point numbers ? Doesn't make much sense to me. Surely free pascal can be reduced so far to integers only.

OK, it's certainly possible to create a simple Pascal compiler without most of current features. Such compilers surely exist even now. What does it have to do with FPC then though? If you want to create a very simple compiler for the purpose of education about compiler techniques (my original understanding about your target was slightly different but apparently wrong judging from your response to my comments), it's probably better to start from scratch or e.g. use the old FPK 0.5 sources than trying to reduce the existing very wide features of FPC to a very small set.

I can only imagine math.pas containing PI but math.pas should not be part of a basic/core compiler anyway.

Indeed, math.pas is a bit more advanced stuff. Excluding floating points obviously means excluding much simpler stuff like standard division.

So this argument of yours seems to make little sense unless you can give a very convincing example of "floats" being used inside the core of free pascal compiler.

OK, sorry, I clearly misunderstood your intention (my original understanding was that you were suggesting reduction of the amount of units to avoid possible confusion with newcomers starting to program in Pascal, not for people interested in learning how compilers work or how they may be created).

.
.

Show quoted text 8 lines
" 3) Everyone is free to create a special installation package for his own needs, but I can hardly imagine something like that becoming part of the general FPC distribution. " The mini-fpc should be a "side-project" for those people interested in compiler technology only and not everything else.

OK, anyone can use FPC sources for such an activity, although I believe that there would be better options for achieving that as mentioned above. Personally, I don't think that floating point numbers are a major complexity driver from the compiler point of view but that doesn't really matter.

Tomas

Reply by email

Skybuck Flying
to Hans-Peter Diettrich: You'll have much trouble in *removing* existing features from FPC, affecting parser,…

-----Original Message-----

Earlier message 31 lines
From: Hans-Peter Diettrich Sent: Saturday, September 10, 2011 2:12 PM To: FPC developers' list Subject: Re: [fpc-devel] Project Idea: Mini-FPC Skybuck Flying schrieb: > Nano would be: > > One integer type, one string type, branch support, loop support, basic > support, object orientation support, property support, array support, > virtual methods support. " You'll have much trouble in *removing* existing features from FPC, affecting parser, error handling, intermediate representation, code generation and more at the same time. " Maybe mini-fpc is a bad idea ;) An alternative would be for developers to stop developing and start documenting what isn't documented yet ;) :) For example start right now until 31 december 2011. Or postpone and make a stable/release version of free pascal and then take a full year to describe all units ! ;) Bye, Skybuck =D

Reply by email

Hans-Peter Diettrich
to Skybuck Flying: " Have you looked at target "embedded" ? " Just took a look at it it's still quite…
Show quoted text 5 lines
Nano would be: One integer type, one string type, branch support, loop support, basic support, object orientation support, property support, array support, virtual methods support.

You'll have much trouble in *removing* existing features from FPC, affecting parser, error handling, intermediate representation, code generation and more at the same time.

DoDi

Reply by email

Martin Schreiber
to Jeff Duntemann: If a "mini-FPC" were to be created to help popularize the Pascal language and get…
Jeff Duntemann wrote 7 lines
If a "mini-FPC" were to be created to help popularize the Pascal language and get beginners interested and up to speed, it would be more useful to provide a simple IDE than a stripped-down compiler. The console FP IDE has never worked well for me (crashes a lot) and Lazarus is very large and intimidatingly complex. I'd rather see some effort put into an easy-to-install beginner's programming environment than in pulling features out of the compiler.

May I recommend MSEide?

http://developer.berlios.de/projects/mseide-msegui/

Martin

Reply by email

Jeff Duntemann
to Hans-Peter Diettrich: You'll have much trouble in *removing* existing features from FPC, affecting parser,…

If a "mini-FPC" were to be created to help popularize the Pascal language and get beginners interested and up to speed, it would be more useful to provide a simple IDE than a stripped-down compiler. The console FP IDE has never worked well for me (crashes a lot) and Lazarus is very large and intimidatingly complex. I'd rather see some effort put into an easy-to-install beginner's programming environment than in pulling features out of the compiler. I know this isn't the forum for that discussion, but I did want to make the suggestion.

--73--

--Jeff Duntemann
Colorado Springs, Colorado

Hans-Peter Diettrich wrote 18 lines
Skybuck Flying schrieb: > Nano would be: > > One integer type, one string type, branch support, loop support, > basic support, object orientation support, property support, array > support, virtual methods support. You'll have much trouble in *removing* existing features from FPC, affecting parser, error handling, intermediate representation, code generation and more at the same time. DoDi _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Michael Van Canneyt
to Jeff Duntemann
Jeff Duntemann wrote 8 lines
If a "mini-FPC" were to be created to help popularize the Pascal language and get beginners interested and up to speed, it would be more useful to provide a simple IDE than a stripped-down compiler. The console FP IDE has never worked well for me (crashes a lot) and Lazarus is very large and intimidatingly complex. I'd rather see some effort put into an easy-to-install beginner's programming environment than in pulling features out of the compiler. I know this isn't the forum for that discussion, but I did want to make the suggestion.

Maybe more effort should be put in the 'education' version of lazarus. Someone already started this.

Michael.

Reply by email

Mattias Gaertner
to Michael Van Canneyt
Show quoted text 15 lines
On Sat, 10 Sep 2011, Jeff Duntemann wrote: > If a "mini-FPC" were to be created to help popularize the Pascal language and > get beginners interested and up to speed, it would be more useful to provide > a simple IDE than a stripped-down compiler. The console FP IDE has never > worked well for me (crashes a lot) and Lazarus is very large and > intimidatingly complex. I'd rather see some effort put into an > easy-to-install beginner's programming environment than in pulling features > out of the compiler. I know this isn't the forum for that discussion, but I > did want to make the suggestion. Maybe more effort should be put in the 'education' version of lazarus. Someone already started this.

See here:

http://wiki.lazarus.freepascal.org/Lazarus_for_education

Any help and ideas are welcome.

Mattias

Reply by email

Ludo Brands
to Skybuck Flying: " Have you looked at target "embedded" ? " Just took a look at it it's still quite…
Show quoted text 22 lines
None, redcode, cuda. Mini-fpc could be reduced to show proportions that it becomes virtual, an exercise at seperating the processing of the pascal language and giving meaning/sense to the tokens so it becomes ready for assembling. It could be reduced to such a level that it becomes a question of plugging in the lower parts, so it could also become more moduler. It's also important to reduce code size and code files as much as possible, just searching all files for a certain keyword already takes multiple seconds. Mini-fpc would be ment to learn how free pascal works and also to be able to port it to other pascal languages for example Delphi, so further experimentation can be done.

Have a look at the P4 pascal compiler
http://homepages.cwi.nl/~steven/pascal/ . The whole compiler is written in pascal and is only 4000 lines in 1 file. It generates a high level pcode and comes with a pcode interpreter (1000 lines of pascal in a second file). Simpler you can't get. Cross platform. Only standard pascal though, no objects, etc.

Ludo

Reply by email

Mark Morgan Lloyd
to Michael Van Canneyt: Maybe more effort should be put in the 'education' version of lazarus. Someone already…
Michael Van Canneyt wrote 13 lines
On Sat, 10 Sep 2011, Jeff Duntemann wrote: > If a "mini-FPC" were to be created to help popularize the Pascal > language and get beginners interested and up to speed, it would be > more useful to provide a simple IDE than a stripped-down compiler. The > console FP IDE has never worked well for me (crashes a lot) and > Lazarus is very large and intimidatingly complex. I'd rather see some > effort put into an easy-to-install beginner's programming environment > than in pulling features out of the compiler. I know this isn't the > forum for that discussion, but I did want to make the suggestion. Maybe more effort should be put in the 'education' version of lazarus. Someone already started this.

I was hoping to put some time into the IDE, but in practice am using Lazarus now even for console apps.

One thing that does occur to me is that the sort of cut-down compiler that the OP has suggested is probably very similar to a minimal compiler+libraries combination that would be a useful timesaver when trying to get a new port or version to the "Hello, World!" stage. Is there a makefile target that will do this?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

John Lee
to Ludo Brands: Have a look at the P4 pascal compiler http://homepages.cwi.nl/~steven/pascal/ . The whole…
Show quoted text 11 lines
Have a look at the P4 pascal compiler http://homepages.cwi.nl/~steven/pascal/ . The whole compiler is written in pascal and is only 4000 lines in 1 file. It generates a high level pcode and comes with a pcode interpreter (1000 lines of pascal in a second file). Simpler you can't get. Cross platform. Only standard pascal though, no objects, etc. Maybe we could/should put a fpc compilable version of this into the fpc

docs, and into the fpc distribution? Can't imagine that one could do anything smaller or more portable?
John

_______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Marco van de Voort
to John Lee

In our previous episode, John Lee said:

> > Maybe we could/should put a fpc compilable version of this into the fpc docs, and into the fpc distribution? Can't imagine that one could do anything smaller or more portable?

P4 is not FPC compilable. It uses ISO style filehandling iirc.

Reply by email

Ludo Brands
to Marco van de Voort
Show quoted text 9 lines
> > Maybe we could/should put a fpc compilable version of this into the > > fpc > docs, and into the fpc distribution? Can't imagine that one could do > anything smaller or more portable? P4 is not FPC compilable. It uses ISO style filehandling iirc.

Correct.
And it uses also the ISO new(p, t,..., tn) syntax for dynamic allocation where tn are variant record tag types.

Ludo

Reply by email

Skybuck Flying
to Ludo Brands: Have a look at the P4 pascal compiler http://homepages.cwi.nl/~steven/pascal/ . The whole…

"
Have a look at the P4 pascal compiler
"

Ok, I had a look at it.

"
http://homepages.cwi.nl/~steven/pascal/ .
"

Nice site.

"
The whole compiler is written in pascal and is only 4000 lines in 1 file. "

Line-wise not to bad, the code itself also looks not to bad, but it does look:

1. Very old.
2. Written by a C programmer or so or a really old pascal programmer.
3. It doesn't use the case insensitivity future of pascal.
4. It has a huge ammount of q's, p's, kl's and lpt's as variable names just illustrate that this code and the variable names are not "self-documenting". The website/book tries to document these variables but I think I already spotted some variables which remained unexplained.

Therefore I do think this code needs a huge ammount of "refactoring" or simply put: "renaming of variables".

5. It was also not written in an object orientated way, this will probably mean that it's not very extendable and goes against the oo encapsulation philosophy and so forth...
So use just pascal only will need lead to name space conflicts within units/modules, this could be somewhat diverted by using multiple units/modules and perhaps prefixes but it is far from ideal.

6. Ultimately it would be beneficial if a mini-fpc or mini-pascal compiler would also include all modern oo features just so I can compile my own sources to whatever instruction set. So for this purpose this code does not really seem that suited ?!?

7. Why is it called an "interpreter" and not simply an "executor" ? Is there a technical reason for it ? The word "interpreter" has a bad association in my mind... I associate it with a "basic interpreter" which I think parses and executes at the same time.
This is not what the interpreter seems to be doing... it's actually executing instructions so it's not really an interpreter then is it ?

"It generates a high level pcode and comes with a pcode interpreter (1000 lines of pascal in a second file)."

This is nice, though the instruction set still seems a little bit large and a little bit weird here and there...

For example what is "SET - Set intersection" ???

"Simpler you can't get. Cross platform. Only standard pascal though, no objects, etc.
"

Hmm I don't know if that claim is true about being "simpelst" I doubt that actually... There is one more pascal compiler out there which might also be pretty good ;)

I find it kinda odd how all the documentation is seperated from the source code in an html file... at the same time I also find it somewhat interesting.

This allows the comments/explanations to be read seperatedly from the source... but it also requires some back and forth switching to see what it is referring to.

Perhaps a second version could be made where code and documentation is integrated into each other, this would probably/actually be a better way to keep the code usuable.

As it is right now it seems hard to maintain because of all the q's p's and so forth, but perhaps that is fixeable, but then it becomes a question of "is it worth it ?"

The answer to that question depends on many other things.

For now it is kinda interesting and I will probably play a little bit with it just to see if it will compile in Delphi ;) :)

I have my doubts thought ;) :) but so far I am willing to believe that it will compile and run ;) :)

The biggest adventage so far:

1. It's free.

2. It's relatively tiny.

3. It's pretty well documented.

4. It seems to produce "virtual" instructions which could be a big adventage, especially if it's possible to modify the instruction set, not sure about that though.

5. It seems to have an executor (which executes the instructions).

6. It seems to assume each instruction is the same size, which I kinda like too.

7. It has syntax checking/error reporting.

8. All source is freely available.

9. The book/documentation is freely available (a draft)

10. Because of the "virtual" instructions it could be possible to re-write the interpreter in a different language to make the instructions run on different platforms so in that sense
it's cross platform like java bytecode (virtual machines running on a "real" platform).

The biggest disadventages so far:

1. It's not object oriented, it's not modern, not known if it's possible to extend and would require further knowledge and time.

2. It's somewhat badly written, not self-documenting, though this could be fixed but this fixing would require some time, and I am not sure if it would make the code more readable but I would think so.

3. It's not object orientated which could cause problems, though it could be wrapped in objects but would also require more time.

4. Important comments/explanations are not embedded in the source itself, perhaps it should and would also require some further time to integrate it.

Conclusion so far:

1. It could be usefull to try and modify it to try and output redcode/corewar instructions, that would be cool, then warriors can be written in pascal code ! ;)

2. It could be usefull to try and write a php interpreter/executor so that the pascal p-code/virtual instructions can be run on webservers like linux/apache/php/mysql. Programs would be limited to just plain pascal though, but could still be somewhat usefull and more easy to debug on for example Delphi ;) :) (in an algorithmic way... hopefully the compiler/executor don't have any bugs itself ??? <- this is a good question and the answer is probably it has bugs, most software has bugs, bugs in it would suck, so this could be a hidden problem with it ;) :) but perhaps with some help from guys on this mailing list it might be fixeable ?!?)

3. It could be usefull to try and expand it so it can compile "cuda" kernels written in a pascal like language. (Or perhaps opencl kernels, personally I am interested in cuda only though for the time being ;) :)) Here there is also a possible adventage, the compiler could be made "cross platform" for cuda and opencl, write a "pascal kernel once" and compile to either cuda or opencl intermediate instructions, that in itself would be highly interesting, but if it can be done remains to be seen, I'd give it a 90% chance of succeeding, though cuda does have some features which opencl does not, but 90% compatibility would still be nice :)

4. It could also be used for further experimentation to add additional instructions or an "interleaved program" which executes between the other instructions to collect data/analysis data of how the other program executes, which is also interesting.

So this code does have some potential ;) :)

Lastly a comparision with free pascal to mini-fpc "trajectory":

1. The p4 compiler is already very minimal compared to fpc so this will require less work.

2. The p4 compiler is already producing "virtual instructions" and does not need an entire platform and complex rtl's which will also require less work.

3. I am not sure if the p4 compiler can compile itself, the text claims it does... which is kinda interesting... how it does that I don't know yet... it's probably not much of an issue because everything is in one file, unlike free pascal where a huge ammount of files
and a pretty large ammount of "fpc_" hooks have to be hooked up, perhaps the p4 compiler is also more clean and doesn't have "self-hosting language features" which free pascal does seem to need.

4. There is no assembler code in the p4 compiler which is good/nice.

5. There is no complex binary file format as far as I saw so far... but I could be wrong about that... but it's probably not as complex as PE windows format, for example...

6. There does not seem to be a complex debugger support, which could be a disadventage on the long run, but also an adventage on the short run, less complexity because of it.

7. The p4 compiler does seem to support some text, which is kinda nice, but ultimately not really required for my purpose I think, but still kinda nice, but so does free pascal but probably in a more complex way, and the unicode support seems also messy.

8. The free pascal compiler has an enormous mess of types, the types are all over the place, they are not located in a single location, but pretty much everything, many duplicates, many different names for the same thing.

So at first glance all-in-all it doesn't seem to be bad ;) :) and therefore I will have a more closer looksy in the coming days but in the end I would need object orientation, so on the long run P4 seems like a dead end ;)

So it depends a bit on if mini-fpc becomes a reality or not, if not then P4 seems to be a good alternative ;) :)

Bye,
Skybuck.

Reply by email

John Lee
to Ludo Brands: Correct. And it uses also the ISO new(p, t,..., tn) syntax for dynamic allocation where…
Show quoted text 15 lines
> > Maybe we could/should put a fpc compilable version of > this into the > > > fpc > > docs, and into the fpc distribution? Can't imagine that one > could do > > anything smaller or more portable? > > P4 is not FPC compilable. It uses ISO style filehandling > iirc. Correct. And it uses also the ISO new(p, t,..., tn) syntax for dynamic allocation where tn are variant record tag types. Of course, it isn't fpc! - but if folks want a really simple fpc, it could

be made compilable by some fpc'ite couldn't it? Don't we support some iso pascal stuff anyway? J

Show quoted text 7 lines
Ludo _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Jeff Duntemann
to Mattias Gaertner: On Sat, 10 Sep 2011 16:51:36 +0200 (CEST) See here:…

That just may do the job.

Three years ago I started rewriting my BP7 Pascal book for FPC, but the issue of which IDE would be better for beginners drove me nuts. I looked around for something simple and reliable and eventually set the project aside. Lazarus is really the way to go for an IDE, but it's a lot to grasp all at once for students and newcomers. Don't get me wrong; I love it--but it really wasn't designed for absolute beginners.

The book is an intro to Pascal and not to Lazarus, but I'd really like to use Lazarus as the example IDE, even though all the example code runs in a console. I'll take a look at Lazarus for Education this week and see whether it could work for the book.

Thanks for pointing it out to me.

--73--

--Jeff Duntemann
Colorado Springs, Colorado

Mattias Gaertner wrote 27 lines
On Sat, 10 Sep 2011 16:51:36 +0200 (CEST) Michael Van Canneyt wrote: > > On Sat, 10 Sep 2011, Jeff Duntemann wrote: > >> If a "mini-FPC" were to be created to help popularize the Pascal language and >> get beginners interested and up to speed, it would be more useful to provide >> a simple IDE than a stripped-down compiler. The console FP IDE has never >> worked well for me (crashes a lot) and Lazarus is very large and >> intimidatingly complex. I'd rather see some effort put into an >> easy-to-install beginner's programming environment than in pulling features >> out of the compiler. I know this isn't the forum for that discussion, but I >> did want to make the suggestion. > Maybe more effort should be put in the 'education' version of lazarus. > Someone already started this. See here: http://wiki.lazarus.freepascal.org/Lazarus_for_education Any help and ideas are welcome. Mattias _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Felipe Monteiro de Carvalho
to Jeff Duntemann
Jeff Duntemann wrote 6 lines
Three years ago I started rewriting my BP7 Pascal book for FPC, but the issue of which IDE would be better for beginners drove me nuts. I looked around for something simple and reliable and eventually set the project aside. Lazarus is really the way to go for an IDE, but it's a lot to grasp all at once for students and newcomers. Don't get me wrong; I love it--but it really wasn't designed for absolute beginners.

I have already worked with 13 students from my university, all of which had never worked with Pascal before and using Lazarus was never an issue. I just explained how to install it correctly (because my projects requires Lazarus from svn) and that's all. I didn't need to say a word about how to use the form designer and people could use it. I didn't need to say a word about how to add files to a project, everyone could do it. When using the stable version I didn't even need to explain them how to install it.... so did you really have a problematic experience involving Lazarus and newbies?

Felipe Monteiro de Carvalho

Reply by email

John Clymer
to Skybuck Flying: " Have a look at the P4 pascal compiler " Ok, I had a look at it. "…

There is a slightly more "modern" P5 based off of P4, with source code that can be compiled using Borland Pascal (and presumably, FPC's Turbo mode should be close to compiling it as well.)

http://www.standardpascal.org/p5.html

________________________________

Earlier message 213 lines
From: Skybuck Flying To: FPC developers' list Sent: Sun, September 11, 2011 12:01:50 AM Subject: Re: RE : [fpc-devel] Project Idea: Mini-FPC " Have a look at the P4 pascal compiler " Ok, I had a look at it. " http://homepages.cwi.nl/~steven/pascal/ . " Nice site. " The whole compiler is written in pascal and is only 4000 lines in 1 file. " Line-wise not to bad, the code itself also looks not to bad, but it does look: 1. Very old. 2. Written by a C programmer or so or a really old pascal programmer. 3. It doesn't use the case insensitivity future of pascal. 4. It has a huge ammount of q's, p's, kl's and lpt's as variable names just illustrate that this code and the variable names are not "self-documenting". The website/book tries to document these variables but I think I already spotted some variables which remained unexplained. Therefore I do think this code needs a huge ammount of "refactoring" or simply put: "renaming of variables". 5. It was also not written in an object orientated way, this will probably mean that it's not very extendable and goes against the oo encapsulation philosophy and so forth... So use just pascal only will need lead to name space conflicts within units/modules, this could be somewhat diverted by using multiple units/modules and perhaps prefixes but it is far from ideal. 6. Ultimately it would be beneficial if a mini-fpc or mini-pascal compiler would also include all modern oo features just so I can compile my own sources to whatever instruction set. So for this purpose this code does not really seem that suited ?!? 7. Why is it called an "interpreter" and not simply an "executor" ? Is there a technical reason for it ? The word "interpreter" has a bad association in my mind... I associate it with a "basic interpreter" which I think parses and executes at the same time. This is not what the interpreter seems to be doing... it's actually executing instructions so it's not really an interpreter then is it ? "It generates a high level pcode and comes with a pcode interpreter (1000 lines of pascal in a second file)." This is nice, though the instruction set still seems a little bit large and a little bit weird here and there... For example what is "SET - Set intersection" ??? "Simpler you can't get. Cross platform. Only standard pascal though, no objects, etc. " Hmm I don't know if that claim is true about being "simpelst" I doubt that actually... There is one more pascal compiler out there which might also be pretty good ;) I find it kinda odd how all the documentation is seperated from the source code in an html file... at the same time I also find it somewhat interesting. This allows the comments/explanations to be read seperatedly from the source... but it also requires some back and forth switching to see what it is referring to. Perhaps a second version could be made where code and documentation is integrated into each other, this would probably/actually be a better way to keep the code usuable. As it is right now it seems hard to maintain because of all the q's p's and so forth, but perhaps that is fixeable, but then it becomes a question of "is it worth it ?" The answer to that question depends on many other things. For now it is kinda interesting and I will probably play a little bit with it just to see if it will compile in Delphi ;) :) I have my doubts thought ;) :) but so far I am willing to believe that it will compile and run ;) :) The biggest adventage so far: 1. It's free. 2. It's relatively tiny. 3. It's pretty well documented. 4. It seems to produce "virtual" instructions which could be a big adventage, especially if it's possible to modify the instruction set, not sure about that though. 5. It seems to have an executor (which executes the instructions). 6. It seems to assume each instruction is the same size, which I kinda like too. 7. It has syntax checking/error reporting. 8. All source is freely available. 9. The book/documentation is freely available (a draft) 10. Because of the "virtual" instructions it could be possible to re-write the interpreter in a different language to make the instructions run on different platforms so in that sense it's cross platform like java bytecode (virtual machines running on a "real" platform). The biggest disadventages so far: 1. It's not object oriented, it's not modern, not known if it's possible to extend and would require further knowledge and time. 2. It's somewhat badly written, not self-documenting, though this could be fixed but this fixing would require some time, and I am not sure if it would make the code more readable but I would think so. 3. It's not object orientated which could cause problems, though it could be wrapped in objects but would also require more time. 4. Important comments/explanations are not embedded in the source itself, perhaps it should and would also require some further time to integrate it. Conclusion so far: 1. It could be usefull to try and modify it to try and output redcode/corewar instructions, that would be cool, then warriors can be written in pascal code ! ;) 2. It could be usefull to try and write a php interpreter/executor so that the pascal p-code/virtual instructions can be run on webservers like linux/apache/php/mysql. Programs would be limited to just plain pascal though, but could still be somewhat usefull and more easy to debug on for example Delphi ;) :) (in an algorithmic way... hopefully the compiler/executor don't have any bugs itself ??? <- this is a good question and the answer is probably it has bugs, most software has bugs, bugs in it would suck, so this could be a hidden problem with it ;) :) but perhaps with some help from guys on this mailing list it might be fixeable ?!?) 3. It could be usefull to try and expand it so it can compile "cuda" kernels written in a pascal like language. (Or perhaps opencl kernels, personally I am interested in cuda only though for the time being ;) :)) Here there is also a possible adventage, the compiler could be made "cross platform" for cuda and opencl, write a "pascal kernel once" and compile to either cuda or opencl intermediate instructions, that in itself would be highly interesting, but if it can be done remains to be seen, I'd give it a 90% chance of succeeding, though cuda does have some features which opencl does not, but 90% compatibility would still be nice :) 4. It could also be used for further experimentation to add additional instructions or an "interleaved program" which executes between the other instructions to collect data/analysis data of how the other program executes, which is also interesting. So this code does have some potential ;) :) Lastly a comparision with free pascal to mini-fpc "trajectory": 1. The p4 compiler is already very minimal compared to fpc so this will require less work. 2. The p4 compiler is already producing "virtual instructions" and does not need an entire platform and complex rtl's which will also require less work. 3. I am not sure if the p4 compiler can compile itself, the text claims it does... which is kinda interesting... how it does that I don't know yet... it's probably not much of an issue because everything is in one file, unlike free pascal where a huge ammount of files and a pretty large ammount of "fpc_" hooks have to be hooked up, perhaps the p4 compiler is also more clean and doesn't have "self-hosting language features" which free pascal does seem to need. 4. There is no assembler code in the p4 compiler which is good/nice. 5. There is no complex binary file format as far as I saw so far... but I could be wrong about that... but it's probably not as complex as PE windows format, for example... 6. There does not seem to be a complex debugger support, which could be a disadventage on the long run, but also an adventage on the short run, less complexity because of it. 7. The p4 compiler does seem to support some text, which is kinda nice, but ultimately not really required for my purpose I think, but still kinda nice, but so does free pascal but probably in a more complex way, and the unicode support seems also messy. 8. The free pascal compiler has an enormous mess of types, the types are all over the place, they are not located in a single location, but pretty much everything, many duplicates, many different names for the same thing. So at first glance all-in-all it doesn't seem to be bad ;) :) and therefore I will have a more closer looksy in the coming days but in the end I would need object orientation, so on the long run P4 seems like a dead end ;) So it depends a bit on if mini-fpc becomes a reality or not, if not then P4 seems to be a good alternative ;) :) Bye, Skybuck.

Reply by email

Skybuck Flying
to John Clymer: There is a slightly more "modern" P5 based off of P4, with source code that can be…

P5 is also in an unusuable state.

It should not be allowed to write code as follows:

repeat
if a < b then
begin
end
until a < b;
^ This code should produce an error becomes end is not ended with a semicolon –> ;

This confuses Delphi’s source beautifier, which could be seen as a short coming in Delphi’s source beautifier.

I take indentation very seriously.

Code with spaces is high risk of indentation mistakes.

The P5 code is not properly indented.

The risk of a indentation mistake (editing the wrong begin/end) is huge so I am not going to spent any further time on it.

Until perhaps a source beautifier can correct the situation.

But since the code is now probably undocumented

The code does silly things like:

end (* some comment *) ;

^ semi colon at the back ?!?!?!?!?!?!?!?!?!?!?!?!?!?!

One little missing semi colon like that and all hell breaks loose, very unwise to write code like that.

Better is to write:

end; (* some comment *)

This coding style is probably what causes some kind of indentation problem for the source beautifier.

I fail to see how I could make sense of “proper identation” of an automated tool cannot ?!?

Bye,
Skybuck.

Reply by email

Felipe Monteiro de Carvalho
to Skybuck Flying: P5 is also in an unusuable state. It should not be allowed to write code as follows:…
Skybuck Flying wrote
^ This code should produce an error becomes end is not ended with a semicolon –> ;

Looks like you are not aware that Pascal uses semicolon as separators, not statement enders. AFAIK the code you posted is valid, and so it is to write for example:

procedure something;
begin
  if X then
  begin
  end // <- no semi-colon
end;

If the identation program has issues with that then you found a bug.

See: http://en.wikipedia.org/wiki/Comparison_of_Object_Pascal_and_C#Semicolon_use

Felipe Monteiro de Carvalho

Reply by email

Skybuck Flying
to Felipe Monteiro de Carvalho: Looks like you are not aware that Pascal uses semicolon as separators, not statement…

Well I hope the pascal language is updated so semicolons become required for end's.

Take a long hard look at the P4 or P5 code and you will find a lot of if then else statements with wrong identation as well, this makes it somewhat hard to understand which else belongs to which if, it also makes it somewhat more hard to fix the situation by adding begin end blocks and it makes the code less suited for editing which is a bit drawback.

But always writing end; the code is more easily editable because it will become more robust.

In the example you posted if an else is pasted right after the end it would be valid while that was perhaps not it's intention... and it would confuse the rest as well.

I think P4 and P5 code is a perfect example of confusion and such ;)

Now one could claim that it's my lack of understanding of the pascal language.

But then ask yourself on question: Why does Delphi's source beautifier have problems with it ? Why does Jedi Code Formatter have problems with it ?

Apperently I am not the only pascal/delphi programmer in the world which gets confused by the P4 and P5 code ! ;)

Definelty warrents further investigation into all this matter ;) not only the source beautifiers by free pascal and delphi compiler itself as well.

Here is an very nice experiment for you pascal compiler writes.

Do as I say and make end without a semicolon an error if it's not followed by an else.

This will probably immediatly make apperent where there are all kinds of sloppy programming sections in P4 and P5.

Also code like:

if a < b then SomeStatement
else
SomeStatement

if b > a then SomeOtherStatement
else AnotherStatement

^ Notice not a single semicolon

Apperently it's completely legal to write code like this... but I consider it quite bad.

Bye,
Skybuck.

Reply by email

Felipe Monteiro de Carvalho
to Skybuck Flying
Skybuck Flying wrote
Well I hope the pascal language is updated so semicolons become required for end's.

lol!

Show quoted text 5 lines
Take a long hard look at the P4 or P5 code and you will find a lot of if then else statements with wrong identation as well, this makes it somewhat hard to understand which else belongs to which if, it also makes it somewhat more hard to fix the situation by adding begin end blocks and it makes the code less suited for editing which is a bit drawback.

Then re-ident it to the way you want. I don't think it was suggested that you use P4 or P5 out-of-the-box but instead that you improve them?

Felipe Monteiro de Carvalho

Reply by email

waldo kitty
to Skybuck Flying: Well I hope the pascal language is updated so semicolons become required for end's. Take…
Skybuck Flying wrote
Well I hope the pascal language is updated so semicolons become required for end's.

semicolons terminate statements... end does not...

Take a long hard look at the P4 or P5 code and you will find a lot of if then else statements with *wrong identation* as well, this makes it somewhat hard to

above *hilite* by me...

yeah, about that... there is no such thing as "wrong indention"... you can indent and format your code any way you like as long as the compiler can make sense of it... even if you write everything out in long lines instead of breaking them down into indented sections...

Reply by email