Recent

Author Topic: Use FreePascal for develop RESTFul services  (Read 777 times)

Fossy

  • New member
  • *
  • Posts: 20
Use FreePascal for develop RESTFul services
« on: March 26, 2019, 12:32:09 pm »
Hello:

I have much experience developing compiled CGI's with FreePascal, and now I want to develop an RESTFul service for mobiles apps.

Develop it is not problem, I want to know if is an good idea FreePascal instead PHP. I know that compiled CGI es much more fast than interpreted languages, but I know (by example) that PHP uses cache techniques and have integration with Apache. I think that CGI compiled load in memory one time and executes from there all times/app petitions, but I'm not sure.

What's your opinion?.

Thaks!!.

lucamar

  • Hero Member
  • *****
  • Posts: 1943
Re: Use FreePascal for develop RESTFul services
« Reply #1 on: March 26, 2019, 12:57:29 pm »
Develop it is not problem, I want to know if is an good idea FreePascal instead PHP. I know that compiled CGI es much more fast than interpreted languages, but I know (by example) that PHP uses cache techniques and have integration with Apache.

You can use cache techniques yourself and you can compile your program as an Apache modules instead of a CGI one. See the wikipage: FPC and Apache Modules

Quote from: Fossy
I think that CGI compiled load in memory one time and executes from there all times/app petitions, but I'm not sure.

No. A CGI program is normally run each time it's needed; FastCGI is what you're thinking about, and you can do those with FPC too.

For more info, start from the wiki Web Development Portal
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8089
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Use FreePascal for develop RESTFul services
« Reply #2 on: March 27, 2019, 06:23:48 pm »
I want to know if is an good idea FreePascal instead PHP
Largely a preference problem, i.e. not a problem.
I know that compiled CGI es much more fast than interpreted languages
Assuming the interpreted languages are executed in CGI way as well, largely yes. Otherwise, it might not (i.e. a long running interpreter service may be able to execute faster).
but I know (by example) that PHP uses cache techniques
Not activated by default.
and have integration with Apache.
As does FPC.
I think that CGI compiled load in memory one time and executes from there all times/app petitions, but I'm not sure.
OS dependent, but in general yes.
What's your opinion?.
Until you come up with a problem that matters a language selection, doing with any is just fine. For instance, if you want your app to easily take advantage of the number of processor cores, you're unlikely to do it by exploiting threads in PHP, but very likely with FPC. You will solve the scaling problem in PHP by spawning more worker service instead.

Fossy

  • New member
  • *
  • Posts: 20
Re: Use FreePascal for develop RESTFul services
« Reply #3 on: March 28, 2019, 01:21:48 pm »
Thanks Lucamar and Leledumbo!.

Very interesting your answers. I like the Lucamar option to compile source code as Apache module. Will give me speed, only one instance loaded in memory, and internal cache techniques implemented by Apache/Nginx by default.

At this point, I have read the link and I compiled the test .so hello world. I can load module in Apache, but I can't find how execute the code accessing to domain or parameter..., I'm lost here. How I can view the hello world test?.

I can convert an CGI application in to Apache module as an easy way?, or I need to write all code related to handle, hook...?.

Thanks!!

ASBzone

  • Full Member
  • ***
  • Posts: 239
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
Re: Use FreePascal for develop RESTFul services
« Reply #4 on: April 25, 2019, 07:38:38 pm »
At this point, I have read the link and I compiled the test .so hello world. I can load module in Apache, but I can't find how execute the code accessing to domain or parameter..., I'm lost here. How I can view the hello world test?.

I can convert an CGI application in to Apache module as an easy way?, or I need to write all code related to handle, hook...?.

Thanks!!


Have you seen this?  [size=78%]https://httpd.apache.org/docs/2.4/developer/modguide.html[/size]
-ASB: https://www.BrainWaveCC.com

Lazarus v2.0.5 r61666 / FPC v3.2.0-beta-r42593 (via FpcUpDeluxe) -- Windows 64-bit install w/32-bit cross-compile
Primary System: Windows 10 Pro x64, Version 1903 (Build 18362.295)
Other Systems: Windows 10 Pro x64, Version 1809 or greater