Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialOliver Bartoszek
2,273 PointsServer side programming?
hello. i was hoping that someone could elaborate on the term "server side programming". it has been coming up a lot but i've never really seen a good explanation..
i realize this is a broad question, and a quick wiki search does explain the basics, but i still don't understand what node.js is for example. i've even installed it, but i have no idea where the information is being stored or how it works.. or what makes it such a big improvement over other similar tools (like PHP i'm assuming)? etc. etc.
any insight would be greatly appreciated!
5 Answers
Michalis Efstathiou
11,180 PointsThe server is the computer our website files are hosted on, and that includes the database. The database is just some software on our server that stores all the information we need to keep a record of, like passwords and usernames, blog posts etc. So server and database are two separate things.
The developer decides what server side language he wants to use. You could choose a language because you know it better than others, or you can use it because it is more suitable to the application you are building. Also keep in mind that your server must support a specific language for you to be able to use it. For example you would not be able to use .NET with a unix server, you would need to go with a microsoft server
every time you type in a web address you, or your client is accessing files on the server, of coarse there are files on the server that clients dont have permission to access and you wouldnt be able to do so without authorisation. as for databases, the client cant directly access them, a client can request information from your web site, and your server side language will access the database, retrieve the information and send it to the client
Michalis Efstathiou
11,180 Pointswhen developing web pages/web applications, you use different languages for different tasks
you have:
html for the structure
css for the styling
javascript for the behaviour/interactivity
and then you need another language that will communicate with the server and the database and handle all the business logic of your application
an important difference is that front end languages such as html, css and javascript are client side languages, which means the visitor's browser gets the code and interprets it.
server side languages such as php, ruby and python are parsed by the server, and any data they produce is sent to the visitor's browser as text/html. this has performance as well as security implications, a visitor can see and manipulate front end code, but cannot do the same with server side code as that would be a security nightmare
simple, static websites dont need a server side language
In the past, javascript engines were not efficient enough to run javascript on the server, but as technology continued to improve, it not only became possible, but people using javascript serverside with nodejs are reporting improved performance for their apps
so basically nodejs allows your server to handle javascript serverside
an advantage besides performance is the luxury of using the same programming language for both front and back end functionality instead of two different ones
eck
43,038 PointsGreat explanation, Michalis!
Oliver Bartoszek
2,273 Pointsthanks for the super fast response Michalis! it definitely helps.. but i'm still trying to wrap my head around the concept. to expand a little on your answer:
- what is the relationship between the server and database, are they two separate things?
- what determines the language of the server/database?
- and finally, how are they accessed by the client?
i really appreciated your time and help, thank you!
Michalis Efstathiou
11,180 Pointsactually no, a server is nothing more than a computer that runs server software instead of a commercial operating system like windows. its job is to distribute data over the internet, like your website for example
most servers in the world run on apache or IIS(microsoft)
nodejs is not a framework, it is a runtime environment that acts kind of like a server, so you dont need software like apache, you can run nodejs on a normal operating system
and while javascript cannot be used server side with traditional server software, nodejs does just that, it allows javascript to be used in place of ruby, python, php etc
a database is completely separate, a database is a piece of software were you store all you information, and you use server side languages to retrieve and/or update that information, the most popular database is mysql which you can find tutorials for here on treehouse
for example, a visitor comes to your websites and completes a registration form, a server side language like php takes that info from the form and sends it to the database where it gets stored, when the visitor comes back and logs in, php will check the details he provided and see if they match what is stored in the database before letting the visitor log in, if the visitor then decides to change his password, then php again will take the new password the visitor gives and update the value stored in the database
Oliver Bartoszek
2,273 Pointsahhh now i get it.. once again thanks so much for your time Michalis!
Michalis Efstathiou
11,180 Pointsits my pleasure to help out Oliver!
Michalis Efstathiou
11,180 Pointscheers Eric!
Oliver Bartoszek
2,273 PointsOliver Bartoszek
2,273 Pointslet me see if i got this right..
so something like node.js (which i believe is described as a "framework") acts as the Database? and therefore, depending on the developers needs and preferences, it can effectively replace or be used instead of PHP, Ruby, Python etc..?
Shin And
8,924 PointsShin And
8,924 PointsHey Michelalis
Will you please explain the full capabilities of node.js?