PHP vs Python

PHP is 24 years old while Python is 29 years old. Python and PHP have different syntax but very similar in paradigm, typing discipline as well as level of abstraction.

Both are high-level which means they are both easy to learn and easy to read since both have natural language English based syntax. All memory management are automated which helps to make the process of developing program simpler.

Example of simple For Loop in both Languages

PHP

PYTHON

We can see that Python is easier to read than PHP but both languages are equally popular with PHP at around 5 Million active programmers and Python at around 4.2 Million active users.

PHP were designed for web development so it provides better support for web development than Python.

Python was designed to be a fun & simple general purposed language so we can find it being used everywhere. Recent years, Python becomes the language of choice for data scientist and machine learning engineers because of its large ecosystem of data processing libraries like Numpy, Scipy, Tensorflow.

Probably because of its clean and simple design, Python ecosystem is exceptionally large and high quality. Python is being used by Python academics and practitioner

Data Types
Both Python and PHP are dynamic type languages.

PHP has following ten primitive types:
- 4 scalar types: boolean, integer, float, string.
- 4 compounded types: array, object, callable, iterable.
- 2 special types: resource, NULL

Python also support many similar types with few difference
- 6 scalar types: string, boolean, int, bytes, float and complex.
- 6 compounded types: list, range,  dictionary, tuple, sets, bytearray
- 3 special types: frozenset, ellipsis, none.  
(Ellipsis is used for multi-dimensional array and popular in Numpy)

Laravel vs Django

App Structure

Django App Structure

A Django project contains multiple smaller app/module with its own MVC architecture. The main app settings, routing and entry point are inside the project folder.

Laravel project have the same MVC architecture but instead of many module. Each component MODEL - VIEW - CONTROLLERS are broken down into smaller components.

Stock Tracker App in Laravel

Source-code: https://github.com/troydo42/polyglot/tree/master/Laravel

Part 1. Build The Landing Page

1.1 Project Scaffolding

We can run 2 following commands to scaffolding and start the development server

$ composer create-project laravel/laravel stock_tracker
$ php artisan serve --port=7070

1.2 Write View Template

Laravel View Template is insider 'resources/views'.It comes with
a default welcome.blade.php template. The syntax is pretty much
html with blade template tags.

We can create a new index.blade.php for our HighChart chart.

$ touch resources/views/index.blade.php

1.3 Serving View emplate via Route

Laravel route is inside routes/web.php. We will need to point the
root url to our index.blade.php

Last step is to add the static json data file inside the
'storage/app/public' folder and run the following command
to be able to access static content inside this folder

$ php artisan storage:link
$ php artisan serve

Now we should be able to view the app at http://127.0.0.1:7070


Stock Tracker App in Django

Source-code: https://github.com/troydo42/polyglot/tree/master/Django

Part 1. Build The Landing Page

1.1 Project Scaffolding

Installation and setup dev enviroment

$ python3.6 -m venv env
$ . env/bin/activate
$ pip install Django
$ django-admin startproject stocktracker

Scaffolding Our Project

$ cd stocktracker
$ python manage.py runserver 8080

Visit 127.0.0.1:8080

1.2 Write View Template

Django brakes a project down by apps. Each apps should have
one independent component that make up the whole project.

Lets create an app called 'landing' for our marketing
landing page.

$ python manage.py startapp landing

We can then write our view inside landing/views.py to return
a response string "This is your Django Landing".

1.3 Serving View templates via Route

First we need to add our 'landing' app inside 'settings.py'

We will then create an landing/urls.py file to route our views

We will then need to update the urls.py in the root folder
to register the landing/urls.py inside our main project

Add stock datafile 'aapl-ohlcv.json' in static folder inside our
landing app. We then have to set STATIC ROOT inside our
settings.py and run command to collect all static files

And then we can run this command to collect all static assets
into resource folder and restart server

$ python manage.py collectstatic
$ python manage.py runserver

Now our HighChart Apple Chart should be at 127.0.0.1:8080.

Both App should give us the same one-page chart like below.

In Part 2 and Part 3, we will add features that allow users to add different stock stickers as well as deploy the app on server of choices