Web Development lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Lord_ZealoN · 2009-05-28 21:07 I readed some old threads about webdevelopment under FreePascal. I see 4 options, and is like are outdated options. CGIs G-Framework: seems died, and not ported to freepascal. ExtPascal: Propietary. Pascal Server Pages I would like to know, if there are something like RoR, Django, and so on, or if some of this options, is viable for web development. There are somebody here developing web apps under FreePascal? Cheers. ---------------------------------------------------------------------- Phil · 2009-05-28 21:22 "ExtPascal: Propietary" Please explain what you mean by that. ExtPascal is licensed under BSD; Ext JS Core 3.0 is licensed under MIT. http://code.google.com/p/extpascal/ http://extjs.com/ Thanks. -Phil ---------------------------------------------------------------------- Lord_ZealoN · 2009-05-28 21:50 Well, I didn't explained very well. ExtJS is dual license. If your app is opensource no problem, if is commercial, needs a commercial license, like the old license of QT. ---------------------------------------------------------------------- Troodon · 2009-05-28 22:36 What's wrong with CGI? ---------------------------------------------------------------------- Phil · 2009-05-28 23:12 Quote from: Lord_ZealoN on May 28, 2009, 11:50:17 pmWell, I didn't explained very well. ExtJS is dual license. If your app is opensource no problem, if is commercial, needs a commercial license, like the old license of QT. Correct, for the full Ext JS. I'm not sure I would call a dual license "proprietary". Also, don't confuse Ext JS with the ExtPascal wrapper. You might want to take a look at the ExtP Toolkit that I'm developing. It adds visual "form" (TExtWindow) design capabilities to Lazarus: http://extpascal.googlegroups.com/web/ExtPToolkitStatus.html Thanks. -Phil ---------------------------------------------------------------------- Lord_ZealoN · 2009-05-29 08:33 Quote from: Phil on May 29, 2009, 01:12:57 amQuote from: Lord_ZealoN on May 28, 2009, 11:50:17 pmWell, I didn't explained very well. ExtJS is dual license. If your app is opensource no problem, if is commercial, needs a commercial license, like the old license of QT. Correct, for the full Ext JS. I'm not sure I would call a dual license "proprietary". Also, don't confuse Ext JS with the ExtPascal wrapper. Well, my fault. I didn't explaned fine. QuoteYou might want to take a look at the ExtP Toolkit that I'm developing. It adds visual "form" (TExtWindow) design capabilities to Lazarus: http://extpascal.googlegroups.com/web/ExtPToolkitStatus.html I don't understand very much about licenses, but, if I use ExtPascal, I'm using indirectly ExtJS (my app, would be a derivate work, I think), and I must respect his license. Is this correct? Quote from: Troodon on May 29, 2009, 12:36:15 amWhat's wrong with CGI? About web development, I only touched a little of PHP (reading wordpress or drupal code), because I don't like web development. But now, some companies, wants his applications connected with a web interface, or only working over web. The problem with CGI (as far as I readed, I never used it and could be wrong), is thath you have to parser all HTML, CSS and so on, and is more slow, and much sites talk about CGIs like "obsolet technology". As I said, I dont know. I only readed here and there to document me a little. Some help about this will be appreciated. ---------------------------------------------------------------------- bobo · 2009-05-30 02:32 Here are some examples about using CGI or Apache modules to create websites with Lazarus/Freepascal : http://bugs.freepascal.org/view.php?id=13706 This is not included in the Lazarus directory structure yet but you can download the zip from there and try them out. ---------------------------------------------------------------------- chrnobel · 2009-06-01 09:20 Quote from: Lord_ZealoN on May 29, 2009, 10:33:58 amThe problem with CGI (as far as I readed, I never used it and could be wrong), is thath you have to parser all HTML, CSS and so on, and is more slow, and much sites talk about CGIs like "obsolet technology". CGI is by no means "dead". I use Powtils (AKA Pascal Server Pages) for several portal solutions, and it is extremely fast, scalable, and as Powtils runs as binaries, it is also secure, not to to forget that ressorces are freed the very splitsecond the binary is finish executing - so no memory hogs. Combine that with Zeos, and it is possible to make some really powerfull webapplications with database access, but without the security flaws found in PHP. /Chris ---------------------------------------------------------------------- RudieD · 2009-06-04 20:51 QuoteWhat's wrong with CGI? Don't waste your time with Pascal and CGI. It's to fast ! I always have to check and check again to make sure that it did execute. And with the Powtils it's just to easy ! You will not feel as satisfied as you would be with some other languages. Pascal is just TOOOOOOOO productive. So once again, .... Don't use it !  Stay FAAAAAAAr away !  Regards   RudieD ---------------------------------------------------------------------- Troodon · 2009-06-05 05:05 I used to run a site with the Apache web server calling PHP scripts to generate the user interface, Perl scripts to parse text files, and a FreePascal console program to read GET parameters as command line arguments, solve a system of equations, and store the results in a MySQL database. It was extremely reliable and fast. ---------------------------------------------------------------------- bee · 2009-06-05 11:03 Quote from: Troodon on June 05, 2009, 07:05:21 amI used to run a site with the Apache web server calling PHP scripts to generate the user interface, Perl scripts to parse text files, and a FreePascal console program to read GET parameters as command line arguments, solve a system of equations, and store the results in a MySQL database. It was extremely reliable and fast. Congratulations! You had just created another code maintenance nightmare! If you are able to do all of them in a single language (whatever your favorite language is), I suggest you to use that language. Unless, you have a very strong technical reason to do otherwise. Have you consider how hard your server work by using many interpreted programs within a single application? It would be ignorable if your application is being accessed by only a few users. What's the problem if you write them all in single native language (pascal)? I believe all those tasks are very easy to be done in pascal. ---------------------------------------------------------------------- Phil · 2009-06-05 17:39 Let me say I'm sort of a convert to CGI done with Pascal, largely on the strength of Wanderlan's ExtPascal project (http://code.google.com/p/extpascal/). The only advantages I can see in working with a scripting language like PHP is that it's generally easier to deploy. Many ISP's, employers and "free" Web hosting services don't permit access to the cgi-bin folder on their servers. While this doesn't affect your development locally on your own computer, it might be a nuisance later to discover that your existing Web site won't do, meaning a change in URL and a small expense for a paid service could be necessary. The other advantage to PHP, etc. is that when deploying you don't have to worry about what OS the server is running, whereas with CGI you'll have to compile for a specific OS target, typically Linux. It might be useful if forum readers could post URL's of inexpensive Web hosting services that permit CGI apps which could be used for demo purpose and testing the deployment of CGI apps. With ExtPascal, I think we have a CGI approach that represents one of those watershed or breakthrough moments. At its heart is the commercial, dual licensed Ext JS, which is one of the most popular and most attractive looking JavaScript Web widgetsets available. What do I mean by a "JavaScript Web widgetset"? Generally this means a set of visual classes written in JavaScript that are sent as source code to your browser by the Web server. These classes implement the buttons and other controls that you program and that the user interacts with in the browser. Since JavaScript is sent as source code, the .js files are usually pretty unreadable since all white space has been stripped out to shrink the files. However, Ext JS includes "debug" versions that, while not documented, at least include whitespace and line breaks and can be read as normal source files. I'm glad Ext JS is commerical. This means it's not going to just disappear or fade into uselessness like to so many open source efforts. I also like the way that there isn't really much code supplied with ExtPascal. All the Pascal wrapper classes for the Ext JS widgets (TExtWindow, TExtButton, etc.) are auto-generated. This is really a great idea because it means that there's so much less source that has to be maintained. Wanderlan's code generator (that you run just once to create the wrapper class source files) is only a few thousand lines of code. The ExtPascal wrapper classes also emit almost all of the JavaScript, so you don't have to write much JavaScript yourself, although you can if you want. For example, when you instantiate a TExtButton class and set some of its properties, at runtime this results in a big JavaScript "new" constructor that actually creates the JS object. In addition to the base widgetset .js files that are sent when the page is first loaded, the browser will also receive this JavaScript that's created on the fly. Probably the only thing missing from ExtPascal is a visual designer. Right now, that's probably an advantage of a product like Delphi for PHP. Not only does it have a VCL for PHP class library (PHP classes that wrap the underlying qooxdoo JavaScript widgetset similar to the way ExtPascal wraps Ext JS), it also has a visual form designer that will be familiar to any Delphi or Lazarus user. However, that's where the similarities to Delphi and Lazarus end. Once you start coding in Delphi for PHP you realize quickly that you're in a different world. Not only are you writing both PHP and JavaScript code, but you're putting the code in the same file. The PHP code you write is only executed on the server and the JavaScript code you write is only executed in the browser, yet they're in the same file. And the order in which they're executed isn't obvious. Looking at the postings on the Delphi for PHP forum shows that this absolutely stumps most developers at first. Other issues with PHP, etc. that you only run into later include the fact that you can't use your normal debugger with these languages since they're scripting languages. With ExtPascal and Lazarus you just use your normal gdb. What I've been working on is a set of LCL/VCL-based "design" controls that can be used with Lazarus and Delphi to visually design ExtPascal forms. One of my goals is to write as little code as possible, so the design controls are just wrappers of TCustomForm, TCustomButton, etc. and the source for them is all auto-generated. One of the problems with so many open source projects is the sheer volume of code involved. Many developers seem to be as happy as pigs wallowing in all that code, but at some point, almost by definition, if the project doesn't magically attract other developers and grow and stabilize, it _will_ reach a crisis point when the original author is no longer able to maintain and advance the project. By writing less code, the seriousness of this crisis when it comes can be reduced. If you haven't tried out ExtPascal, you really should. If you have a Mac, Apache is already pre-installed and all you have to do is turn it on, so there shouldn't be any reason for not at least exploring CGI development with ExtPascal. And if you want to go the next step and install the Lazarus project package and design control package that I threw together, I think you'll be pleasantly surprised at what this adds to ExtPascal: - Once the project and design control packages have been installed in Lazarus, just choose File | New | ExtPascal Application to create a new ExtPascal project. This immediately gives a structure to your project that should be familiar - that is, it's almost exactly the same as an LCL application. If you look at Wanderlan's ExtPascalSamples.dpr you might be dismayed by its jumbled structure, but this file is really intended as a way to demo and exercise many of the Ext JS widgets, not as an example of how you should structure your projects. - Designing the ExtPascal forms visually and setting properties means you don't have to know very much about Ext JS. Although Ext JS is well documented (http://extjs.com/deploy/dev/docs/), this _is_ JavaScript documentation, not Pascal documentation. For example, to set a combo box's items, you'll find in the JS docs that you do this by setting the combo box's "store" array. In Pascal, this would be something like this (from Wanderlan's example): StoreArray := JSArray('"Shade", "Mostly Shady", "Sun or Shade", "Mostly Sunny", "Sunny"'); However, if you use the TExtFormCombo in Lazarus, you set the StoreArray property in Object Inspector using the familiar strings editor dialog just like you use with TComboBox. Thanks. -Phil ---------------------------------------------------------------------- bee · 2009-06-07 04:39 Quote from: Phil on June 05, 2009, 07:39:58 pmLet me say I'm sort of a convert to CGI done with Pascal, largely on the strength of Wanderlan's ExtPascal project (http://code.google.com/p/extpascal/). I used to be a user of Powtils. But since I found ExtPascal and it became quite stable, slowly but sure I moved to ExtPascal. Moreover since ExtPascal provided CGI gateway (which I requested for), I could combine Powtils (CGI) and ExtPascal (FCGI). Quote from: Phil on June 05, 2009, 07:39:58 pmThe only advantages I can see in working with a scripting language like PHP is that it's generally easier to deploy. The other advantage to PHP, etc. is that when deploying you don't have to worry about what OS the server is running, whereas with CGI you'll have to compile for a specific OS target, typically Linux. With a bit of extra efforts, through cross compilation and some shell scripting, deploying pascal web application could be as easy as PHP script. Quote from: Phil on June 05, 2009, 07:39:58 pmIt might be useful if forum readers could post URL's of inexpensive Web hosting services that permit CGI apps which could be used for demo purpose and testing the deployment of CGI apps. AFAIK, most web hosting providers provide CGI as standard/common feature, even on free ones, though every provider has different restrictions. However, I don't think we could deploy a FCGI application (ExtPascal) on common web hosting provider. Quote from: Phil on June 05, 2009, 07:39:58 pmHowever, Ext JS includes "debug" versions that, while not documented, at least include whitespace and line breaks and can be read as normal source files. I had contributed JS and CSS beautifier (new line, indentation, etc) for ExtPascal that would be run on $DEBUG_JS mode. It's very helpful and handy when we need to debug the generated JS codes (through Firebug). I've been waiting for it to be merged into official ExtPascal SVN repository. Quote from: Phil on June 05, 2009, 07:39:58 pmProbably the only thing missing from ExtPascal is a visual designer. We could also use ExtJS GUI designer after it's released on v.3.1. Yes, it's not as rich as Delphi or Lazarus but its designer feature is quite sophisticated. Quote from: Phil on June 05, 2009, 07:39:58 pmWith ExtPascal and Lazarus you just use your normal gdb. Being able to debug ExtPascal application as if it's a normal (desktop) application is a huge advantage to me. Plus, due to FCGI nature, I no longer need to manage cookies and sessions as they can be represented as normal variables. Quote from: Phil on June 05, 2009, 07:39:58 pmWhat I've been working on is a set of LCL/VCL-based "design" controls that can be used with Lazarus and Delphi to visually design ExtPascal forms. One of my goals is to write as little code as possible, so the design controls are just wrappers of TCustomForm, TCustomButton, etc. and the source for them is all auto-generated. Though I haven't use your tool but I do appreciate it and I believe it'd be very helpful to other people. I haven't yet use it because my web application isn't "window"-based. While by using your tool an approach, it obligates ExtPascal application to be "window"-based, as like desktop application build using Delphi or Lazarus. Quote from: Phil on June 05, 2009, 07:39:58 pmIn Pascal, this would be something like this (from Wanderlan's example): StoreArray := JSArray('"Shade", "Mostly Shady", "Sun or Shade", "Mostly Sunny", "Sunny"'); FPC also provides fpJSON that can be used with ExtPascal. ---------------------------------------------------------------------- Phil · 2009-06-07 15:47 Quote from: bee on June 07, 2009, 06:39:16 amWith a bit of extra efforts, through cross compilation and some shell scripting, deploying pascal web application could be as easy as PHP script. Yes, some additional documentation would be helpful. Quote from: bee on June 07, 2009, 06:39:16 amI had contributed JS and CSS beautifier (new line, indentation, etc) for ExtPascal that would be run on $DEBUG_JS mode. It's very helpful and handy when we need to debug the generated JS codes (through Firebug). I've been waiting for it to be merged into official ExtPascal SVN repository. That would be very useful! I compile with DebugJs defined. Currently I think all that does is switch to use the debug .js files of Ext JS, but if it could also make the page source more readable, that would be great. Quote from: bee on June 07, 2009, 06:39:16 amWe could also use ExtJS GUI designer after it's released on v.3.1. Yes, it's not as rich as Delphi or Lazarus but its designer feature is quite sophisticated. Although I assume that the Ext JS designer will generate JavaScript, not Pascal. Quote from: bee on June 07, 2009, 06:39:16 amThough I haven't use your tool but I do appreciate it and I believe it'd be very helpful to other people. I haven't yet use it because my web application isn't "window"-based. While by using your tool an approach, it obligates ExtPascal application to be "window"-based, as like desktop application build using Delphi or Lazarus. What layout do you use? I haven't worked through all the various layouts, but it would seem that they could be supported similar to the way Delphi for PHP supports different layouts in a pixel-based designer. Also, it's worth pointing out the obvious that another use for the IDE is not just visually laying out controls, but also making non-visual things easier - setting properties, creating controls properly, etc. It's not obvious how to use some of the ExtPascal controls and properties or what they correspond to in other frameworks (VCL/LCL). By capturing this knowledge and making it part of the IDE, users won't have to waste time working through examples trying to figure out how to simple things. Thanks for your comments. -Phil ---------------------------------------------------------------------- bee · 2009-06-08 01:32 Quote from: Phil on June 07, 2009, 05:47:04 pmThat would be very useful! I compile with DebugJs defined. Currently I think all that does is switch to use the debug .js files of Ext JS, but if it could also make the page source more readable, that would be great. I had given my modified ExtPascal source code to Wanderlan since a while ago. I gave it to the project author not to public (like you did) because I did also some modification to the base code. But, if you're interested I could send you the source code, especially the beautifier part. Quote from: Phil on June 07, 2009, 05:47:04 pmWhat layout do you use? I haven't worked through all the various layouts, but it would seem that they could be supported similar to the way Delphi for PHP supports different layouts in a pixel-based designer. Mostly fit layout and I avoid pixel based layout for common web application. Unless I made some kind of eyeOS-like environment for my application. Quote from: Phil on June 07, 2009, 05:47:04 pmAlso, it's worth pointing out the obvious that another use for the IDE is not just visually laying out controls, but also making non-visual things easier - setting properties, creating controls properly, etc. It's not obvious how to use some of the ExtPascal controls and properties or what they correspond to in other frameworks (VCL/LCL). By capturing this knowledge and making it part of the IDE, users won't have to waste time working through examples trying to figure out how to simple things. Agree. ---------------------------------------------------------------------- Troodon · 2009-07-10 00:34 Quote from: bee on June 05, 2009, 01:03:41 pmYou had just created another code maintenance nightmare! bee, I'm sorry but, here again, you don't pay attention to what you read. First, like I said, I used to run a website, that means I maintain(ed) my own software. Second, I used to, which means that website doesn't exist anymore. The point in my posting was simply that pieces of code written in several programming languages, each with its own strengths and weaknesses, can interact to create a seamless web site. I did that mostly as an exercise. ---------------------------------------------------------------------- matthius · 2021-11-29 01:06 ExtPascal is now UTF8 compatible : https://sourceforge.net/projects/extpascal/files/ExtPascal%20Ext%203.2 .1/ ---------------------------------------------------------------------- fpcoder · 2021-11-29 03:54 Thank you! However, there seems to be a name conflict for unit AddDirToPkgDlg. It prevented installation. Lazarus unit AddDirToPkgDlg used by ide.pas cannot be found. There is a unit with the same name in the ExtPascal/packager directory. Upon uninstalling ExtPascal, Lazarus compiled again. Quote from: matthius on November 29, 2021, 02:06:43 amExtPascal is now UTF8 compatible : https://sourceforge.net/projects/extpascal/files/ExtPascal%20Ext%203.2 .1/ ---------------------------------------------------------------------- cappe · 2021-11-29 05:52 The same error that gives me too, I was able to install it, but modifying it. Unfortunately in this period I have little time, as soon as I can I see if I can fix it. I make a premise, I'm learning about lcl components. ---------------------------------------------------------------------- cappe · 2021-11-30 09:01 Quote from: kapibara on November 29, 2021, 04:54:19 amThank you! However, there seems to be a name conflict for unit AddDirToPkgDlg. It prevented installation. Lazarus unit AddDirToPkgDlg used by ide.pas cannot be found. There is a unit with the same name in the ExtPascal/packager directory. Upon uninstalling ExtPascal, Lazarus compiled again. Quote from: matthius on November 29, 2021, 02:06:43 amExtPascal is now UTF8 compatible : https://sourceforge.net/projects/extpascal/files/ExtPascal%20Ext%203.2 .1/ How did you install it? If you try the old system it should only work that you have to modify extp_proj_intf.pas and it should install. For the functioning is another matter. ---------------------------------------------------------------------- egsuh · 2021-11-30 15:12 @Lord_ZealoN You said your client wants web-server based service. I think if you have program written in Free Pascal, it would be the best to use fpcweb --- CGI or FCGI. FCGI works fine on NGINX. I've developed a web server. Server part has to some computations like expression parsing and evaluation.  I use that code written in Free Pascal (originally written in Turbo Pascal). As the input form at the browser part has to be created dynamically, that part was written in javascript. Not sure whether PHP would be easier to do my job, but I'm not interested in PHP. ---------------------------------------------------------------------- fpcoder · 2021-11-30 17:03 I removed ExtPascal for now, so Lazarus could be compiled again. Reported the problem here so maybe it can be fixed and then I will make another attempt. Quote from: cappe on November 30, 2021, 10:01:44 amHow did you install it? If you try the old system it should only work that you have to modify extp_proj_intf.pas and it should install. For the functioning is another matter.