Welcome to a quick guide on the differences between server-side and client-side scripts. Just started with web development or interested to learn more?
- Scripts that run on the user’s device are called client-side scripts.
- They are generally less secure due to the fact that users have direct access to the scripts and can potentially mess with them.
- Good programmers usually restrict the use of client-side scripts to show data and collect input from the user.
- Scripts that run on the server are called server-side scripts.
- They are generally more secure because users don’t have direct access to the source code.
- Processing on the server is transparent to the user.
- Server-side scripts are mostly used to deal with transactions and processes.
Yep, the distinction between both is more than just “runs on the user’s device”, and “runs on the server”. There are various concerns behind each side, let us explore that a little deeper – Read on!
TABLE OF CONTENTS
|Server-Client Model||Server-Side Scripts||Client-Side Scripts|
|Useful Bits & Links||The End|
SERVER & CLIENT MODEL
Before we explain the differences, this is a small section for the total beginners who do not know what “server” and “client” mean… This is kind of super basic, so please feel free to skip this section if you are already a computer ninja.
SERVER AND CLIENTS
Once upon a time in the Stone Age of Computing, things were a lot simpler. Computers were standalone and not connected to one another. But with the invention of computer networking (and the Internet), things became a little more complicated.
- The server – Refers to a powerful computer that is set up to provide one or more types of services.
- The client – All other computers that connect to the server to use the service.
So in today’s context of the Internet, a few examples of services that servers can provide are:
- Video – Websites like YouTube and DailyMotion provide the platform to upload and watch videos.
- Audio – Websites like Soundcloud provides the platform to upload and listen to music/podcasts.
- Text – News websites, blogs, social media platforms, and much more.
But of course, the types of services can go beyond just websites. Another of such example is multiplayer gaming – Where someone set up their computer as the host/server, and other people join in as the guest/client. Also in today’s mobile applications, one can fire up a weather forecast app (the client), and it will connect to the server to fetch the current weather report.
Now that you have a basic understanding of the server-client model, you should be able to make a better sense of what server-side scripts do.
CHARACTERISTICS OF SERVER-SIDE SCRIPTS
Yes, we call them “server-side scripts” simply because the scripts run on the server. But here are a couple of “characteristics” of the server-side scripts to take note of:
- Transparent – They run on the server, and the actual code itself is obscured from the user. I.E. The user does not know how the code runs exactly, but only knows that something is being processed on the server.
- Secure – Since users do not know what goes on behind the server, server-side scripts become a “black box”, more suitable for secure transactions and processes.
- Backend – Generally used to do processing and transactions “behind the scenes”. I.E. Not deal with the user interface.
EXAMPLE PROCESSES OF SERVER-SIDE SCRIPTS
Yes, we can say that server-side scripts are used in general for “secure processing and transactions on the server”. But just what exactly? Here are a couple of quick examples:
- Database – Create, read, update, and delete entries.
- Monetary transactions – Payment and credit card processes.
- Fulfilling user queries – Search for information.
- Cross-server service requests – A good example will be fetching currency exchange rates from another server for an e-commerce website.
EXAMPLES OF SERVER-SIDE LANGUAGES
So what about the client-side scripts? Let us explore that a little more in this section.
CHARACTERISTICS OF CLIENT-SIDE SCRIPTS
Yep, you guys should be experts by now, and the characteristics of client-side scripts are kind of the mirror image of the server-side.
- Not really transparent – Client-side scripts are downloaded onto the user’s device, be it websites or installed apps. In one way or another, users who are better at being “super hackers” can reverse engineer and understand how the code works.
- Not as secure – Since users have access to the code, we want to avoid using client-side scripts for the direct processing of sensitive transactions and processes.
- Frontend – Generally used to work with the user interface, collect user input, and send data to the server for secure processing.
EXAMPLE PROCESSES OF CLIENT-SIDE SCRIPTS
Before the server-side can do any processing, we will need to first know what the user wants. That is pretty much what the client-side script does in general.
- User Interface – Forms, buttons, tables, graphics, whatever else.
- User Input Processing – Accepting user input, process what the user wants.
- Communications – Communicating with the server, sending data back-and-forth between server and client.
EXAMPLES OF CLIENT-SIDE LANGUAGES
USEFUL BITS & LINKS
That’s it for both of the server-side and client-side scripts, and here is the summary of the differences between the both of them.
|Client-side Scripting||Server-side scripting|
|Facing||Runs on the user’s computer.||Runs on the server.|
|General Purpose||Collection of user input, interfacing with the server.||Processes the user input, do transactions.|
|General Processes||Deals with user input and interface.||Deals with transactions and complex computations.|
|Code Transparency||Scripts are downloaded onto the client computer, which can be accessed by the users. Processes can be easily tampered with.||Scripts are not open to users. Processes are transparent or totally invisible to the users.|
|Security||Considered to be generally less secure as users can see and mess with the scripts.||Considered to be more secure as users cannot see the source code, and they usually cannot interrupt the process.|
IS THERE SUCH A THING AS “BOTH SERVER AND CLIENT-SIDE”?
Yes, and Java is a good example of a programming language that can be used to develop applications on both server and client-side – We can use it to develop server-side applications that do transactions, we can also use it to develop mobile applications.
Also, consider the “offline apps” these days, they will have to serve as both the front and backend. For example, a simple “to-do list” app has to deal with the user input, processes, and save the data onto the device itself; It is technically both server and client at the same time.
LINKS & REFERENCES
- Server-side scripting – Wikipedia
- Client-side – Wikipedia
- Difference Between Server-side Scripting and Client-side Scripting – TechDifferences
Thank you for reading, and we have come to the end of this guide. I hope that it has helped you to better understand, and if you want to share anything with this guide, please feel free to comment below. Good luck and happy coding!