[Gambas-user] Gambas called by a Web Server

Tobias Boege taboege at gmail.com
Tue May 21 10:50:57 CEST 2019

On Mon, 20 May 2019, Cedron Dawg wrote:
> As I have mentioned before, I am planning on having a web front end on my FarmDB.
> My thinking was Apache/MySQL/PHP as I have that setup.  However, being able to do it in Gambas sounds very appealing.  So, I thought I would go to the Farm and see if there are any good examples.  Oh no, too tough to find anything in there, so I will ask instead.
> Are there any projects in the Farm, or some good example code for writing CGI equivalents in Gambas?
> Two alternatives, right?  Script or executable.
> What are the merits of either?

The merit of a script is that it's slightly easier to deploy I would say.
The great disadvantage of Gambas scripts is that you're effectively limited
to a single class in your project. If you look at the Gambas Wiki program,
it uses multiple classes and even Webpages [1] which clearly beat Print-
based CGI.

Concerning performance, you should know that the scripter is just a Gambas
program that takes your script, builds a proper project directory structure
around it, which gets compiled, *caches that* at least, and then has it run.
The overhead of looking the compiled executable up in the cache and having
to start the regular interpreter anyway makes it even slightly worse than
having a normal project.

For me, all signs point at writing a full project and running its executable.

But there's a third way: an application server. When I lived in the student
dorms, where my friends and I had a shared network, I used to run a bigger
Gambas program for us based on gb.web.form under gb.httpd which was reverse-
proxied by nginx. gb.httpd is sort of building a web server into your
Gambas program. On each new HTTP request, the server parses it, sets up
variables, then forks and longjmp's into the host Gambas program to handle
the request.

That was in the very early days of gb.web.form and it required some hacking
to get it all to work, but I don't remember where problems came up. Maybe
it's simply better these days and you want to try it out?


[1] http://gambaswiki.org/wiki/doc/webpage

"There's an old saying: Don't change anything... ever!" -- Mr. Monk

More information about the User mailing list