Recent

Author Topic: Web programming: Python or Pascal?  (Read 13010 times)

thinking-in-pascal

  • Newbie
  • Posts: 5
Web programming: Python or Pascal?
« on: February 23, 2017, 09:58:05 pm »
Hi all

I'm trying to decide whether to use Python or Pascal for web programming. When I say web programming, I mean for generating dynamic websites on the server.

Both languages have a friendly, readable syntax but Pascal has the advantage of speed and low memory. Also, everything compiles neatly into one executable. Python deployment is messy in contrast. However, Python has a more active community around web development than Pascal and there are a lot more web development tutorials for Python than for Pascal.

If you use Pascal for web development, what has been your experience? What's worked well? (And equally what hasn't?)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Web programming: Python or Pascal?
« Reply #1 on: February 23, 2017, 10:04:34 pm »
If you use Pascal for web development, what has been your experience? What's worked well? (And equally what hasn't?)

I've used Pascal/Delphi in web development in two of my three jobs, but it was always more heavy duty work, with e.g. contractual penalties on when a stale item from a database was shown (it was an auction site)

The Python community seems vast at first glance, but I sometimes get the feeling 99% are targeted at total newbies and occasional users, which means that after you chew through the beginner stuff (a few months as professional, fulltime developer) you hit a wall.

Pascal/delphi is better in that regard, more advanced use, more pros etc.

As for generating dynamic websites, if PHP suffices, use PHP. It also starts with a PHP and is an industry standard. I honestly don't see why one would choose Python over PHP for generating basic dynamic webpages.
« Last Edit: February 23, 2017, 10:06:13 pm by marcov »

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Web programming: Python or Pascal?
« Reply #2 on: February 23, 2017, 10:07:36 pm »
If you use Pascal for web development, what has been your experience? What's worked well? (And equally what hasn't?)

Why not use both? For example, if you have some existing non-UI Pascal code, just put it in a dynamic library and call it from Python (or ASP.NET) on your server. Part 1 of the library article series shows how:

https://macpgmr.github.io

Part 3 includes a couple of Web apps that use Pascal on the server, either as a FCGI app or as a dynamic library.

And also maybe review the Web app overview articles, that also use Pascal on the server with the Javascript client frontend.

What you use for the public facing part of your Web server can vary depending on needs and how much work you want to do. For example, nothing is easier than an ASP.NET http handler (.ashx).

Edit: typo.
« Last Edit: February 23, 2017, 10:09:07 pm by Phil »

thinking-in-pascal

  • Newbie
  • Posts: 5
Re: Web programming: Python or Pascal?
« Reply #3 on: February 23, 2017, 10:53:41 pm »
As for generating dynamic websites, if PHP suffices, use PHP. It also starts with a PHP and is an industry standard. I honestly don't see why one would choose Python over PHP for generating basic dynamic webpages.

Yes you're right, PHP was made for the web and has all the features needed for dynamic webpages. The syntax is not very pretty though, which I know is a superficial reason to avoid it, but it's harder to move from something nice and readable like Pascal (which some people find too verbose anyway) to something like PHP :-)

jacmoe

  • Full Member
  • ***
  • Posts: 249
    • Jacmoe's Cyber SoapBox
Re: Web programming: Python or Pascal?
« Reply #4 on: February 23, 2017, 10:57:35 pm »
I like PHP - it is highly practical and you can write great code using it. ;)
It runs on anything, unlike Python.
And modern PHP is also extremely fast, and has batteries included (Composer), so that's my go to for web dev.

Pascal (Free Pascal) is more akin to Golang in terms of being a single, no-frills executable.
Python does not fall into that category due to runtime requirements.
more signal - less noise

thinking-in-pascal

  • Newbie
  • Posts: 5
Re: Web programming: Python or Pascal?
« Reply #5 on: February 23, 2017, 10:58:52 pm »
Why not use both?

Yes, that's definitely an option. There's something nice and neat in using just one language though. In fact, one aspect of Python that pops up frequently in the Python community (at least what I've observed) is to use external libraries written in C or another language. It always felt like a practical, but slightly messy approach. But that's probably more a reflection of my own bias :-)

thinking-in-pascal

  • Newbie
  • Posts: 5
Re: Web programming: Python or Pascal?
« Reply #6 on: February 23, 2017, 11:02:36 pm »
I like PHP - it is highly practical and you can write great code using it. ;)
It runs on anything, unlike Python.
And modern PHP is also extremely fast, and has batteries included (Composer), so that's my go to for web dev.

Yes, I've read that the latest version of PHP 7 is much faster than before (faster or equivalent Pascal in speed of execution?)

I think, maybe I'm just paralysed by all the choice available for web development and should just pick one language and make a start ;-)

jacmoe

  • Full Member
  • ***
  • Posts: 249
    • Jacmoe's Cyber SoapBox
Re: Web programming: Python or Pascal?
« Reply #7 on: February 23, 2017, 11:12:18 pm »
I plan to use FPC for things like comment server and other services, but PHP for applications.

Node.js and Ruby are just crazy! :o
Python is not too bad, but it is finicky to install/configure; especially on shared hosting..

Yes, I know; I also spend too much time deciding what tech I should use..  :-[

John O'Nolan from Ghost offers the following advice in the interview at https://www.indiehackers.com/businesses/ghost:
« Last Edit: February 23, 2017, 11:21:18 pm by jacmoe »
more signal - less noise

jacmoe

  • Full Member
  • ***
  • Posts: 249
    • Jacmoe's Cyber SoapBox
Re: Web programming: Python or Pascal?
« Reply #8 on: February 23, 2017, 11:17:25 pm »
But, honestly: build something using something that you love.

If you really like Python, chances are that you will succeed more using that instead of a language that rubs you the wrong way. ;D

Free Pascal might be harder to actually use for web programming - simply because the community is tiny compared to Python / PHP - but it is easy to deploy. As easy as Golang.

Pick a tech that you really like, because it is worth it.
There are people out there who use Lisp to create websites.. so what tech does not matter much.
« Last Edit: February 23, 2017, 11:41:35 pm by jacmoe »
more signal - less noise

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Web programming: Python or Pascal?
« Reply #9 on: February 24, 2017, 05:52:58 am »
If you use Pascal for web development, what has been your experience? What's worked well? (And equally what hasn't?)
No experience with Python, only Pascal. We use it for our microservices, which integrates to our main PHP product for plugin based features. I also have personal website (for my Tae Kwon Do unit) written fully in Pascal using Brook framework.
What's worked well?
  • Deployment is a breeze, I just need to send a single binary to update and restart the program through supervisor
  • Execution speed is fast, no need to use sophisticated caching framework, simply use what HTTP has provided, this leads to low server requirement as well
And equally what hasn't?
  • I ended up extending the ORM framework quite a lot, need a better solution but none of existing ones satisfying. EntityDAC looks good, but I don't think it supports FPC yet
  • The server is long running, while database connectivity can lose anytime. I need to create a setup-teardown mechanism for this, otherwise once connection is lost, further request will simply end up in ISE
But really, just use whatever you're comfortable with. My team leader always try to convince me to use node.js / Python, I always say no. When he insists, I tell him to take my chair as the project leader.

thinking-in-pascal

  • Newbie
  • Posts: 5
Re: Web programming: Python or Pascal?
« Reply #10 on: February 24, 2017, 04:09:59 pm »
  • Deployment is a breeze, I just need to send a single binary to update and restart the program through supervisor
  • Execution speed is fast, no need to use sophisticated caching framework, simply use what HTTP has provided, this leads to low server requirement as well

That's good to hear. Python is not simple when it comes to deployment, and there are too many additional steps for adding more speed: like caching, letting C libraries handle loads, using PyPy etc. I really like the simplicity of Pascal here.

But really, just use whatever you're comfortable with. My team leader always try to convince me to use node.js / Python, I always say no. When he insists, I tell him to take my chair as the project leader.

Good advice :-)

bee

  • Sr. Member
  • ****
  • Posts: 393
Re: Web programming: Python or Pascal?
« Reply #11 on: February 25, 2017, 04:14:50 am »
I've been making many web apps/services using Pascal (FPC) since years ago, long before fp-web even existed. I only use Linux though. So far so good. Practically, there's nothing you can not do with Pascal. :)
-Bee-

A long time pascal lover.

chebmaster

  • New member
  • *
  • Posts: 7
Re: Web programming: Python or Pascal?
« Reply #12 on: February 28, 2017, 10:05:03 pm »
When using php you don't need root access to restart something or other. You just upload .php files and that's all.

php below about 5.3 has atrocious memory efficiency (every single array takes 3 kilobytes and grows from there). I had so much fun with multi-dimensional arrays... Short story: don't.
php is fully OOP (all class methods are always virtual)

Learning php after Pascal lets you into the world of C-like syntax. Learning javascript is much easier afterwards.
In my opinion being able to at least read C code is essential (though I sometimes catch myself writing != instead of <> in my Pascal programs  :-[ )

Weak-typed languages with built-in associative arrays are *much* better at writing quick and dirty little things like web-pages than the woolly mammoths like Pascal. But for things like my game engine?  Free Pascal, nothing else!  8-)

You may also find that javascript is faster than Pascal at some things like string processing (and wasn't learning that a shock  :o). You can also offload building visual representation of server-generated data to client (and don't forget the unmatched power of Ajax aka dynamically loading parts of a web page). Javascript is sort of OOP but the logic behind it...  :o Make a fortitude check or lose sanity points.

 

TinyPortal © 2005-2018