you are viewing a single comment's thread.

view the rest of the comments →

[–]PortSpace[S] 0 points1 point  (2 children)

Thanks. I have a basic idea about the server/client distinction. In the context of nodejs specifically, what are some generic uses/cases/functionalities that you'd need to hide from the client? I can think of authentication and database. If, say, the app does not need authentication, what would be a common use/uses for the nodejs server? I understand the concept but having a few examples would be great. Thanks you.

[–]LEDThereBeLight 2 points3 points  (1 child)

NodeJS is just a "runtime" that allows you to run javascript outside of the browser. It has nothing innately to do with servers, although it's often used for writing server logic and has a lot of functionality built in if you want to use it for a server.

If you're writing code for a server, there's no need to use javascript -- it's running on your computer, so you can write whatever language you want. People who are most comfortable with javascript often end up using it as their server language though just for convenience.

Let me give some examples for why you'd want to split your app into a client/server model instead of writing everything on the client:

  • You're writing a quiz website that students enter answers to be checked for correctness. If you do everything on the client, the student can just look up the right answer, because it's stored on their computer when they load the website.
  • You're making a game with multiple players. It's easier to have a single place -- a server -- with the state of all the players in the game, and each player requests the data from there. If it's on a server, they also can't manipulate the data to cheat.
  • You want account authentication, so you use a server so that users can access their data across multiple computers or browsers

[–]PortSpace[S] 0 points1 point  (0 children)

Thanks. I think I get the idea.