Skip to main content

So, after writing my several thousand lines of Python....

After I have written and DEMO'd the code...

I finally finished writing the several thousand lines of Python code, interspersed with HTML and CSS .. and provided my bosses with a very nice DEMO of what the app does... needless to say, the app was running on our intranet - off my machine, which was partially converted into a Server Node on out intranet...

The bosses loved the app, they loved it so much, in fact, that they wanted it "out there" for the world to use!

Writing a web app in PHP is hard...

So, after writing all that awesome code in Python, it was time to start hunting for a new web provider which allowed Python 3 code ... none were forthcoming, and my bosses didn't like the idea of moving our website to a different provider ... so it was back to the drawing board ... to rewrite the entire thing in PHP ...

Well, PHP is not that hard ... when you know it...

In the defense of PHP, it's not really a hard language to master ... sure, there are a lot of functions, but nothing that is too insane to handle .. mostly, it's quite easy to learn and master ... but to write several thousand lines of code is another thing entirely.

I started by learning the basics - how to get it running on my Apache installation, how to "secure" the feature set... how to write the actual code, then it was time to slice the workload into pieces...

Understanding the concept of PHP is not too bad...

It took me a while to get my head into the concept of PHP - calling functions right inside the HTML code, functions which return more HTML ... with Python, you formatted the code as you went ... with PHP you formatted your page, and plugged in the function calls you needed at the end ... 

Once I got this distinction into my head, it was easy to implement the functionality needed to get my code running the way I wanted it to...

The most useful function in PHP

The most useful function I have come across in PHP is the "include" statement... not only does it give you the option of including HTML source, it allows you to use one "header", "footer" or source file all over your site ... this has by far saved me the most time. Of course, my Python was as modular as I could make it, but the idea of including a "header" file, or a "common html" file eluded me because it required me to write code to get it done ... in PHP this is already done for you so when you become aware of this feature, you start using it as second nature.

In conclusion...

In conclusion, I have to say that PHP is awesome, it simplifies several issues I have been having with Python, and it is blazingly fast ... Python is also pretty nifty when used right, but it costs you more complex code and several optimizations to make it as fast as possible ... in PHP one can write lazy code and still get away with a huge speed benefit. I must admit, that the learning curve is not as simple as I make it sound, but I can vouch for how much simpler it is to learn PHP than it is to learn Python ... probably because the syntax is so similar to Javascript and C++ ... 

All in all, I have already ported 90% of the project in about a month ... and the original App took me three months to write. And, this time I'm not dedicating nearly as much "zone time" to it as I should.

Comments

Popular posts from this blog

XBOX ONE Game Dev is supposed to be hard.

So I recently took the plunge and joined the Xbox One Creators Program with Microsoft. It turns out that it's supposed to be incredibly hard to build these little games we see all the time, and for the most part, it is. Not only do we have to deal with the fact that the XBOX One does not use the stripped down PowerPC architecture that the Xbox360's used to run on, we now have to contend with the fact that it's basically running Windows 10. I remember the good old days when win32 and GDI (Graphics Device Interface) were sufficient to get a decent game running on a Windows PC - especially if the game wasn't too resource intensive. Then came Direct(X/3D/2D/11/12) with all its COM (Component Object Model) Glory -> which, perhaps most asinine of all -> is still being used today. Getting into the creators program costs a little bit of money, and that's mostly to keep the chancers out and cover administration fees. After that you really only need to abide by th…

A few thoughts on Game Development

For those of you who follow my blog, you'll notice that I talk about building games, but I never really release anything useful or fully playable. I'm more interested in studying the individual parts of game development, without really caring about building a game as a whole. Well, for the most part this is perfectly acceptable, as I'm not a game developer by trade, and my bread and butter comes from being a utility developer. I've defined utility developer as someone who codes a variety of things without specializing in any specific discipline. As a self-taught developer, it's been hard for me to pivot into a role where I'm classed as a game developer by trade. This is all good and well, but I still want to talk about game development as a whole - specifically how to get a game off the ground. If you've been following any blog about game development, or any programming course which walks you through the process, you've most likely heard of all the ja…

So, python web apps are not that hard after all

So, I was saying earlier that writing web apps with Python is hard ...
I was sorely mistaken... Obviously, I am not using any frameworks to facilitate my project - which is a huge mistake, but a learning exercise for me (I'm  fairly new to python). When not using a framework, you are exposed to the internals of how CGI and Python all meld together, as well as how to use the FieldStorage object to respond to Ajax requests.
It's only hard if you do it the "wrong" way Writing a web app with Python 3 is only hard if you do it the wrong way. I come from a background of coding C++ code using the most bleeding edge coding techniques - OOP, TDD, Templates, Multiple inheritance, Polymorphism, insert bleeding edge coding technique here, etc.
Now, this is all good and well when using a language like C++ where you only face the OS endpoints (Windows API, stdlib etc) at certain points in your code. But these techniques do not work too well when using a high level scripting langu…