P a s F o r u m   F . A . Q

This is the section for questions about PasForum. The FAQ uses Q and A style as below:

Question (Q):

What is an FAQ?

Answer (A):

Frequently asked questions.

Where does one download PasForum to install on their own web host?
Get it from Powtils 1.5.X (download page). The PasForum source is in the examples folder in the zip file. You can also see our SVN repository which has development versions of PasForum. (latest 1.6.x-devel in examples folder).
What is PSP/PWU or Powtils?
A web development API or web framework for the freepascal/delphi/qompute compilers. It can even link to C++/C/D compilers if modified slightly. Powtils is the name of the web API project right now. Originally it was called PSP but many people were confused by the name and thought that it was some sort of JSP/ASP style development kit. In fact it is a powerful/fast/limitless way to build web programs rather than a limited scripting system.
The code that runs this forum, is good?
The Powtils API is awesome.. but PasForum doesn't make use of much of the API.. since it was written many years ago.

PasForum code is crap.. it needs improvement and is based on source code written back in the day when freepascal 0.9 and PSP 1.0 was being used. PasForum was written in one night when I decided to convert PSP4UM over to PasForum to get it working on FPC 2.0 and Powtils 1.5. PSP4UM was written in a rush by Trustmaster. It was a simple demo app for PSP many years ago: just a simple hello world style BBS.

I'm cleaning up PasForum when I have time. No promises though.

Consider too that the forums have been running for over 3-4 years without any serious problems, even if the code and text database is not a real one.

Really, no serious problems with PasForum so far?
Every 8 months or so I have had a 500 error with the forum because of a file locking issue with the SDS text files. This forum is on a shared server so when other people crash the server, the file locks can get stuck on. It takes only a few seconds to delete the file locks (lfw and lfr files) and the forum is up and running again. Not once has the forum ever been hacked.

The forums are also easy to backup. All the posts and content are stored in easy to access text files.

There was one time when all posts got chopped down to 255 characters since freepascal changed the way ansistring {$H+} directive acted... but this wasn't PasForum or SDS's fault - it was simply a backward compatibility issue with the compiler.

I don't consider any of the above issues serious, considering nothing has happened out of the ordinary. With file locking and a text file based database using a cheap shared hosting account (several users are packed on these servers who use buggy PHP code), these issues are expected. The 255 issue was a bit unexpected, but it really wasn't PasForum's fault and was extremely simple to fix.

What could be done with the code to make it better?
The code contains lots of HTML and logic mixed together, along with embedded SQL.

The point of PasForum is to be something someone can install without having MySQL, firebird, PostGre, etc. Everyone argues about the database to use and Powtils needs a demo forum with no external reliance. PasForum does not use a database, it uses Text files called SDS (simple data storage).

What can be improved in the PasForum code is:

Cleaning out the embedded SQL and embedded HTML. All the HTML needs to be moved out into templates. When PSP4UM was written years ago, there was no template ability (way back in the day: Personal Server Pages). Parameterized SQL queries or database calls that don't use embedded SQL would also clean up the code (but SDS doesn't support prepared queries since it is not a real database - a solution would be to use formatted SQL templates or $macrovar strings that are escaped just like a prepared query is).

PasForum also outputs little miniature html files piece by piece (fragments, since there was no template feature back in PSP4UM days). These also need to be merged into a single template.

Newer versions (that I haven't uploaded to SVN yet) are cleaned up with more features added and the above suggestions are addressed. Sometime I will release newer improved versions of PasForum. Newer versions now contain sections (old forum has only one section). Newer versions also contain space preserving for code inserts inside posts.. and clickable URL links.

Will there be another Forum?
I sure hope so. As stated, PasForum and PSP4UM code are crap, in my opinion.

There will be another forum written in addition to PasForum (Pasforum Version 2) which will use either

So to repeat: current PasForum code uses simple HTML snippets and outputs the snippets one by one, rather than using a template system or a Pascal based widget system. Not a lot of time was spent on PSP4UM or PasForum, but it works, and it is simple.

Personally I'd like to also write a forum for commercial use eventually, i.e. one like VBulletin but written in Pascal. Not sure when that will be though. Obviously that is a big task and there are other things to be done first, for Powtils.

Why do some versions of PasForum chop out the @ sign in email addresses?
It is a protection against spam - in later versions it is no longer chopped, but replaced with (@) (brackets protect spam) or AT in bold. For example john(@)website.com or johnwebsite.com or john website.com or john AT website.com are all methods of spam protection.
Isn't Pascal that language that died since it wasn't suitable for real world programming?
Actually, Powtils is written in Modern Pascal (fpc, Delphi, are all modern versions of Pascal). True, I would not use Standard Pascal to write web programs. Standard Pascal is not what Powtils is written in. I would not use Standard Pascal today. Modern Pascal is more like C++ or the D programming language, but cleaner and more like Python/Smalltalk for syntax. Read up on the D Programming Language by Digital Mars, and you will see that the D programming language is inventing a lot of stuff that Modern Pascal has had in it for years. Modern Pascal is NOT Standard Pascal.

Standard Pascal was the language invented by N. Wirth. Standard Pascal was a first attempt at Pascal - it was NOT the final Pascal or the final release of Pascal. The D programming language and the C++ programming language are not the FIRST attempt at C - and the B language is not C. So if B is not C, and D is not C, and C is not C++, then remember that modern Pascal is not Standard Pascal! Even C compilers today are NOTHING like standard C compilers were when C was invented - and there is no true 100% ANSI C compiler out there either.

What is the point of writing something in Pascal with all the other web scripting languages available?
I like to write desktop programs in Delphi/FPC/Pascal and writing web programs in Pascal allows me to reuse all my desktop code online. I'm also not a fan of PHP syntax, nor do I like perl syntax. I'm fond of declaring variables in a structured and organized manner and a lot of PHP/Perl code I see out there is really messy, fragmented, terse.

The good PHP code out there has lots of source comments beside each variable - but this seems like people are reinventing strong typing in PHP - it's just in the source comments instead of the language. Kind of hackish and messy.

Okay, so he likes organized and structured code. Java has that - so why not use Java?
Because I can't build native Java applications on the desktop and reuse my code on the web. And since Java is written in C, and not in Java, that turns me off. Pascal is written in Pascal - at least, freepascal is. I still write parsers and do byte twiddling, and I still write native apps - which Java isn't suited for. If Java was written in Java, and Java had a native compiler in ADDITION to its interpreter, I would seriously look into it.
And how about Python/Ruby if not Java or PHP, then?
I still can't build a native desktop application in Python/Ruby. Can't share code between Python/Ruby web programs and native desktop programs. Python and Ruby are not written in Python or Ruby, they are written in C. Any powerful language is written in itself - very few languages are powerful enough to do so. Yes, there are times for byte twiddling and writing true dynamic link libraries - which Python/Ruby really don't offer.
So why not use C or C++ if one wants to be such a low level dork?
Well, you don't have to be low level with Pascal. That's the point. It has all the low level stuff available, but for every day programming using Pascal is like using Python or Java. You can use strings, classes, dynamic arrays, etc. but you don't have to. In C or C++ the string type isn't even built in to the language! See the comments on the D Programming Language FAQ about built in string types. The D programming in my opinion looks a lot better than C and I see a lot of similarities between Pascal and the D language. The D language is not mature, though, and Modern Pascal is mature - and I still prefer Pascal syntax even if D were mature.

C and C++ still require lots of make files, cludgy syntax, and include files instead of modular units. There's just enough stuff about C/C++ that I don't like. It's not that C++ sucks with regards to power - it's just not as well fit for the job, that's all. No one is saying you couldn't build a web program in C++ and share code with a desktop program in C++.

Why use a compiled language, period?
I can reuse many of the static code snippets and the dynamic link library plug-ins I write for web programs in desktop software. For example a parser I wrote to highlight code into HTML can be reused in web program and a desktop program.

Take a real world example: you wish to syntax highlight code in a web forum dedicated to software developers. Say your web developer forum/bbs is called DevelForums.com. If your DevelForums.com website is powered by a PHPBB or VBULLETIN web forum, and you create a syntax highlighting system so members of your forum can insert code snippets into their post, can you reuse this syntax highlighting system in your desktop software too? You wish to make a CODE-TO-HTML native desktop software program that runs on Windows and/or Linux. The CODE-TO-HTML program is the exact same code that runs your web forum syntax highlighter! Code reuse alarm bells should be ringing off in your head right now.

Code reuse? You could still write a PHP/Python/Ruby script and ship it to people to run on their desktop. You can run scripts on a desktop. What's the problem?
Well your PHP/python/ruby desktop script is not easily shippable like a native app is. Who has the interpreter installed on a Windows box? How many interpreters does that linux box already have installed - Perl, Python, Ruby, SomeOtherLanguage, AnotherLanguage. And no matter which way you look at it, your python/PHP/ruby script is still just C code in the end - since the interpreter is written in C. So you'd probably just cut the middle man and write your desktop application in C or C++, while writing your web program in python/PHP/ruby. Most people do this! Admit it! That's twice the work.

If you ship the script to someone's desktop, they have to install an interpreter and they see all your source code and have to configure their PC's to get your CODE-TO-HTML program working. This is not convenient. Plus, since parsing is an intense CPU task, your desktop program may be slow. On the web app, the speed might not matter as much in some cases since network bandwidth is slow anyway, and it takes a while for the network bandwidth do catch up anyway. But you decide it's worth it to build a desktop program in a suitable desktop programming language like Delphi/C++.

So you see, you decided to write your web program in Python/Ruby/PHP, and then write your desktop program in C or C++. But you are back to square one again - how do you reuse your desktop program code with your web program? You can't insert C/C++ code directly into your PHP/PYTHON/RUBY scripts - but you can directly insert Pascal code into Pascal web programs, and you can directly link a DLL written in Pascal in a web program or a desktop program. Sure, you can write your web programs in C/C++ then, and skip ruby/python/PHP all together - good luck to you if you think that is viable.

Most people write web programs which are completely separate from their desktop applications. The syntax highlighter in a PHPBB forum cannot be reused in a C++/Delphi/FPC/Ada program. The syntax highlighter for Powtils can be reused in desktop software - it can be used to output highlighted code in a desktop application widget, it can be used in a CODE-TO-HTML native program. Ever seen those Pascal To HTML converters, C++ code to HTML converters? Or PHP code to HTML converters? Those are the same code that runs the syntax highlighter in a web forum! Makes sense to Reuse it in your desktop tools too, then. This is just one small example of where code reuse comes in to play. A syntax highlighter is not the only example, by far.

From a business perspective?
Not only does a compiled language allow you to reuse more code in your web programs and your desktop programs, but it allows you to choose between shareware/freeware/gnu style development. Do you want to ship customers a Shopping Cart which costs money? You choose whether you want to release the sources. Give them a binary demo first, but then only offer the sources when they purchase the commercial license. Or charge half price for the shopping cart with no sources, but full price with sources. Powtils development team are not GNU nazis, and we see no problem with people using Powtils for freeware/shareware purposes. i.e. we don't care if you make a web program freeware, gnu, or shareware. From a software business perspective, compiled web programs offer a lot more control for shipping your applications, and sharing code between desktop and web application, than scripting languages offer.
How about security?

A hacker/cracker can't see your source code if he gets into your Powtils web programs on your server, since they are binary.

However, if you use PHP/python/ruby, a hacker can get into your source files and find database passwords and other private data.

Also, most PHP websites I've visited do not filter many incoming URL variables or POST/GET variables. Powtils filters incoming variables automatically. For example, on the Borland website and several shopping carts written in ASP/PHP, I've been able to inject javascript into the search queries. Powtils protects you from this automatically. Not to mention session hijacking and other security issues prevalent in many scripting languages. No web program is perfectly secure, but there are stupid things you can protect a web program from - and a lot of PHP/ASP web programs are open to simple stupid attacks. I'm not sure about the security in Python/Ruby as I haven't visited many Python/Ruby based sites nor tried testing the security on them, so I won't comment there.