One of the biggest hangups I had when starting to program was deciding what technology to use. At the time I was only writing server side code and was working in shared hosting, so my options were limited to various versions of PHP.
Within the last year I started using cloud hosting and thus gained the ability to configure my servers to use any language I wanted. Shortly after realizing this a small amount of fear came over me. The choice of language wasn’t made for me anymore, I would have to pick from a giant pool of languages. I would also be spending at least three months learning all about this language I picked before I would feel secure in it. After that three months I might not like it and would have wasted three months of my life.
At the time I was doing a lot of freelance and was instructor at a college teaching web development. Because I was teaching I wanted to know the basics of all the languages I could use on the server, just in case my students asked me about them.
I knew the basics of most of these languages but I had never written anything substantial in them. So, over one long weekend I locked myself in a room and started writing hello world, testing frameworks, making CRUD, overall building projects in every language and every framework I could get my hands on.
Four days later here are the four things I learned.
1. At Their Core Every Language is The Same
At their core every modern language is the same. They may have different syntax and use different compilers, but the basic elements are the same. You have the following in every modern language.
Conditionals
The main types of these are if
, else if
, else
, and switch
.
Loops
Every modern language has while
and for
loops, but some also have foreach
loops.
Variables
Some have more datatypes some few datatypes but Booleans
, Numbers
, Strings
, Arrays
, Objects
in one form or another are the basics in every language.
Functions
Every language has functions. If you’re language doesn’t have functions then it seriously sucks.
If ever language is the same then why use one over the other?
2. Preference is the Biggest Consideration
The biggest thing to consider is what syntax you like.
Syntax and how the languages work behind the scenes are the major differences. Sometimes the syntax between two languages is the exact same. Sometimes it’s completely different. You may prefer one syntax over the others for various reasons.
Here are a some examples of things to consider.
Code Blocks
C++, Perl, Java, JavaScript, and PHP use curly braces to define code blocks.
function functionName{ // do something }
Python, use tabs or spaces.
def functionName(): #do something
And Ruby uses start and end tags to defined code blocks.
def functionName #do something end
Method Calls
C++, Perl, and PHP call instance methods like this…
myObject -> myMethod()
and static methods like this…
myClass::myMethod()
Python, Java, JavaScript, and Ruby call both instance methods and static methods like this…
myObject.myMethod() myClass.myMethod()
Naming Conventions
Most languages nowadays are using camelCase
naming but some use snake_case
. Some, like PHP, have only recently (PSR2) decided which naming convention should be used, while others, like Java, decided this when the language was formed.
These differences may seem petty but writing in a language that feels right is something that matters a lot.
David Heinemeier Hansson, the creator of Ruby on Rails, originally wrote in PHP and Java and said that he was “always looking for something else.” He was actually considering not being a programmer anymore until he discovered Ruby and created Rails.
However, some people, like me and many of my students, hate Ruby and prefer PHP and JavaScript. Some even like Java, or Python.
Try a language and figure out which one feels right.
3. Play to the Language’s Strengths
While your preference is the biggest consideration it isn’t the only consideration.
Some languages are better suited for certain tasks and applications than others.
For example: Node.js works with WebSockets and MongoDB much better than PHP because it’s a long running event driven language and uses the same datatypes as MongoDB. PHP works better with AJAX and MySQL than Node.js because it’s a short running request/response driven language with native SQL support through the PDO object.
Deciding what technology you will be using aside from your server side language often informs what server side language to use. When in doubt answer these questions.
4. Frameworks Are the Biggest Subject to Research
After writing a handful of web applications you’ll notice you’re writing a lot of the same code again and again. You might structure your application, check if a user is logged in, or push data into a database the same way each time. A framework makes these tasks easier by providing prebuilt functions for you to use.
But hold on. This is where the conversation of server side code gets complicated.
Because anyone can write a framework in any language which adds any kind of new features the difference between frameworks can be outrageous. Different patterns like MVC, HMVC, or MVVM are designed. Different validation techniques are used. And different database abstraction layers are created.
However, some frameworks can look nearly the same and in fact can be build on top of each other. In PHP, Laravel builds on top of Symfony and Lithium builds on what would have been CakePHP 3. In Node, Sails builds on top of Socket.IO and Express, which builds on top of Connect.
Understanding the difference between frameworks is key when picking a server side language.
Things to Consider
Conclusion
After all my research here is what I determined about myself.
So, I decided to stick with MySQL, PHP, and FuelPHP for most of my clients who want request/response drive AJAX based applications.
I also decided to use MongoDB, Node.js, and Express with Socket.IO for clients who want real time event driven WebSocket based applications. Most of my clients don’t need this but some do for chat rooms and various features.
I like having an old workhorse language like PHP in my toolbox and a new cutting edge language like Node.js ready to go in my tool belt.
Leave a Reply
You must be logged in to post a comment.