Why Python is becoming a rock star

When i knew about Python, the IT language not the animal, some years ago it was for me, a pure PHP lover since beginning of PHP, the language of some math’s people that don’t really know what is love coding

By the way, at the beginning of the web, for the front and the back(office), we did not really need to make complex computation.

It was always the same song: get a data, do some simple operations with it, display it, ask for new data, and store the data in a simple DB and again get the data, etc..and PHP was good at it.

It was a simple cycle that a lot of people intend to make more complex adding stupid framework done only for people who wanted to be seen as clever by others but it was our life of programmers.

Then came the era of the API and web service switching to REST API or another communication channel with the third-parties application.

Javascript gained its true value with the rise of power of the computers and more stable browser, (thanks Google Chrome) and PHP became more and more complex and less direct losing grounds among communities.

Then Data came and the game between Python and PHP changed.

If you wish to make a different regression with PHP (linear, polynomial, log etc..), the basis of a lot of data stuff now, you need to search a lot in not supported classes and you won’t have exactly  find what you are searching: a good and usefull math libraries enough strong to compute fast with accuracy all the data you want. You will have some part of what you search but not a strong and used library.

In Python in 3 lines you have a swiss knife you can use without any real math knowledge.

linear_regressor = LinearRegression() # create object for the class
linear_regressor.fit(X, Y) # perform linear regression
Y_pred = linear_regressor.predict(X) # make predictions

You want a polynomial regression ? not a problem, just one line away (ok 2)

X = PolynomialFeatures(degree=5) # Ok just for fun i put a degree 5 in the regression..
X_poly = poly.fit_transform(X)
poly.fit(X_poly, Y)
lin2 = LinearRegression()
lin2.fit(X_poly, Y)

You want to plot it in a graph and save it to a PNG ?

2 lines more..or 3 lines more…ok 5 lines.

plt.scatter(X, Y)
plt.xlabel(‘X’)
plt.ylabel(‘Y’)
plt.plot(X, lin3.predict(poly.fit_transform(Y)), color=’yellow’)
plt.savefig(“mon-image.png”)

You want to show in desktop side the plot and have all the parameters in hand to change appearance, modifying constraints, let’s do a plt.show()

With integrated and support lib (matplotlib with seaborn and sklearn) installed with a simple “pip install”.

Pfff.Yeah

In 10 lines I have the basis to do powerful apps in the new era of the data and show them to my client(s).

PHP even the 7.x.x the last edition gives me that with much more efforts and a lot of customization and I am not really sure that it is working well at math level.

The framework data libs from Python is being used by the biggest companies in the field and a lot of new tech ones.

I tested the 2 approaches with data with PHP and Python. I can do finally more or less the same things with PHP but the time to build it and the instability to maintain it pushed me to begin to develop more and more in python and let the PHP for frontend and classic back-office operations.

Perhaps the rise of Python against PHP: it’s also easier in Python to manage streams for example and communications protocols, come with the data era.

PHP is not done for data and was not done for that, then all apps using data needs Python and not PHP. At least the best for us is to mix PHP and Python with a stack PHP/Python/Shell from frontend to backend. I will add also R as a good complement for Python when you need velocity.