Which programming language should you learn? Python, PHP or Ruby?
Possibly the biggest question facing web development newbies is which language is best to learn for their future career and prospects. There are many programming languages to choose from and each has its own strengths and weaknesses. Possibly the most important concern is how long each language takes to learn and this varies for each language. So which should be learn for the best chance at a successful career in programming?
When I started to learn web development I searched a lot about it but it made me incredibly confused. I could not find a definitive answer on which language was the best because different authors gave different perspectives. Most authors were just comparing the languages without giving an overall conclusion.
Therefore, in this article I am going to compare three modern programming languages – PHP, Python and Ruby. First of all, I want to show some old data that I found when I started learning about web development. This old data is taken from here. Although this comparison is quite narrow and old, it does have some useful facts about the history of these languages.
- php vs python vs ruby
From this comparison of PHP, Python and Ruby it is clear that:
- The demand of PHP in the market is high.
- PHP programmers are also in high demand.
- Usability of PHP is low.
- Learning and understanding python is easiest
- Python is faster
- Learning Ruby is tough
- Ruby has highest usability
But as I said earlier it is brief comparison. From this comparison we cannot conclude that PHP is the best or that Ruby is the worst. The are also a number of further questions which have not yet been answered;
- Which language is the most secure?
- What are other limitations of these languages?
- What are the advantages and other supports for these languages?
- What is the job/developer ratio and average salaries for developers?
Which language is the most secure?
The security of the website/application depends primarily on the programmer not on the programming language. PHP is well known as an unsecured language. This is because the syntax of PHP is not as simple as the syntax of Python or Ruby. Due to complicated syntax (low readability) the chances of an error occurring is greater. If a programmer/developer does not make any errors then PHP is also not an unsecured language, and indeed PHP5 has a good reputation in comparison to older versions. As a result there is not really a solid conclusion to be drawn from the question of security.
What are the limitations of these languages?
- A more verbose syntax from C/C++ and Perl, with lots curly braces and dollar signs and "->"-s
- Confused tableau of function names. The builtin library has a wide variety of naming conventions. Functions often have prefixes to denote their source (but often not). Functions are often placed into classes to simulate namespaces.
- Not suitable for large applications: Hard to maintain since it is not very modular.
- Weak type: Implicit conversion may surprise unwary programmers and lead to unexpected bugs. For example, the strings “1000” and “1e3” compare equal because they are implicitly cast to floating point numbers.
- scripting language, not too object oriented.
- Python has no 'switch' statement and 'do ... while' construct
- increment and decrement and assignment operators (assignment is a statement only in Python)
- the ternary operator/statement (... ? ... : ...)
- an expedient (commonly installed) environment
- no private, protected and public modifiers for both properties and methods
- no abstract and final modifiers for both classes and methods
- Learning it can be difficult
- Lacks informational resources
- Slower processing time (CPU time) compared to other programming languages
- Development and updates are slower
What are the advantages and other supports for these languages?
- Easy for beginners to pick up. Easy to learn for developers who are from the similar syntax background like C, C++,C# , Java, Java Script etc.
- It supports all major web servers like Apache, Microsoft IIS, Netscape, personal webserver, iPlanet server, etc.
- PHP is highly accepted by many industries. It is more popular than other languages.
- During hosting, it is very easy to host PHP website directly without any server configuration. Hosting website may be a headache for newbies to web hosting.
- The zend framework in php is the most well known. The frameworks like Yii, Laravel, Codeigniter etc. have given a good strength to PHP.
- Easy to develop any type of CMS quickly.
- Easy syntax and very readable. Easy to learn for those who have little or no experience with programming.
- General purpose language.
- Very object oriented.
- Python is much better suited as a "glue".
- Huge standard library. Just to pick some random examples, Python ships with several XML parsers, csv & zip file readers & writers, libraries for using pretty much every internet protocol and data type, etc.
- High level data structures are list, directory are well suited in python.
- Great frameworks for web development like Django and Flask.
- Ruby is a more object oriented language compared to python and php.
- Ruby was developed to make developer's work easy.
- Mix-ins allow imported classes and modules to be extended and overridden by user code after it is imported. Classes are never closed on ruby. You can also modify later.
- Ruby code blocks are more powerful than Python's lambdas.
- Everything returns a value (including things like 'if' statements). Because of this, it is easier to write functional-like code than in python and much easier to chain commands.
- Gem libraries of Ruby. A lot of available gems make every task easy within a few efforts.
- The power of ruby in web development is rails framework. It is very magical. You need not to be worried about basic functionality of web development like simple edit or deletes. You can focus more on the other complex algorithms.
- Ruby believes in giving programmer the freedom and power.
What is the developers / jobs ratio and average salary?
This is a very subjective question and will not have a simple general answer. The number of both jobs and developers is greater in PHP, which results in a lower salary in general. However, this does not mean that the salaries of all developers / programmers are low and some developers also get paid very highly. There are also some solid job opportunities for python and ruby programmers as there are fewer developers, but the demand is generally lower.
Let's summarize all in short:
- PHP and PYTHON are easy to learn for beginners.
- PHP is currently the most secure for a job.
- PHP is good for small websites. ( Although there are big websites like facebook and wikipidia in php but they are diverting from it and embedding other languages also. Changing a website from one language to another is not a easy task.)
- Python is best as a general purpose language.
- Frameworks of python ( django ) and ruby ( rails) are preferred more than other frameworks for web developing.
Also read Django vs Laravel vs Ruby on rails
If you have any argument then comment to improve this post.