how many languages are neccesary for browser mmorpg?

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
uh oh
Posts: 17
Joined: Sun Jul 27, 2014 7:28 pm

how many languages are neccesary for browser mmorpg?

Post by uh oh »

Hi, got another silly question,
I was wondering whether a browser mmorpg could be made just with node and a database like mongoDB completely without php and mysql? Is there a way for javascript to deal with session cookies? What are the possible disadvantages, advantages, challenges?
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: how many languages are neccesary for browser mmorpg?

Post by Jackolantern »

Node.js is a replacement for PHP, and MongoDB is a replacement for MySQL. So you won't need PHP or MySQL for a node game. As for things like sessions, cookies and the such, you will get that stuff with ExpressJS, the go-to web framework for node. Unlike PHP, node doesn't come ready for web development out-of-the-box. That is why things like Connect were created. Connect is "middleware" for node, meaning that it builds up common things like sessions and cookies, but without implementing it into a ready-to-use framework. That was left to framework developers. Connect is powering pretty much every major node web framework.

Advantages include the fact that with node and MongoDB, you have a "full stack" of Javascript, so you will be using JS for the server-side, browser-side and for data access. This is a pretty huge advantage compared to having to use Javascript for the client, PHP for the server-side and SQL for data access. Another advantage are web sockets. Node works in a way that works very well with very little complexity for networking/sockets. Websockets are not really possible in traditional PHP because of the way that PHP works. PHP is set up to handle the HTTP request/response cycle, and very little else. There are a couple of native PHP solutions for web sockets, but they are not built on traditional PHP nor widely adopted so there is very little help if you have any issues.

Disadvantages are pretty scarce with node. I would just say the tools aren't as good as for some other platforms, such as .NET. But considering node's young age, they are quite impressive. Also, you have to be more mindful of code structure with node or you can end up with a mess. JS is not a traditional object oriented language. But node does implement a module system, which is your best bet for keeping your project tidy.

Challenges? Starting out the biggest issue is wrapping your head around asynchronous programming. But if you come to it with an open mind, it will likely just take a couple of days to get the hang of that aspect. Scaling can be a challenge with node once you reach the maximum you can handle with a standard installation. However, a standard installation can handle a lot (the power of asynchronous programming), so it will likely be a while before you will need to scale out.
The indelible lord of tl;dr
User avatar
Verahta
Posts: 441
Joined: Wed Aug 24, 2011 1:50 am

Re: how many languages are neccesary for browser mmorpg?

Post by Verahta »

Where does HTML5 and Jquery fit in with node, express, mongo, connect?
"In order to understand recursion, one must first understand recursion".
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: how many languages are neccesary for browser mmorpg?

Post by Jackolantern »

Verahta wrote:Where does HTML5 and Jquery fit in with node, express, mongo, connect?
HTML5 and jQuery are client-side technologies. This means they work in the browser. Node, Express (which has Connect in it), and Mongo are all on the server-side. Express will have you creating "routes" that correspond to the HTTP request the user sent to your server, such as get:mygame.com/users/map. The route can have server-side JS logic in it to do anything you need to do, such as hit the database, MongoDB, for data, and much more. Then you call a "view", which is written in EJS or Jade (simple view templating systems). In these EJS or Jade views is where the HTML5 and jQuery code are (although you may separate out the client-side JS/jQuery code in its own file, the idea is the same). Express combines the data your route logic produced/retrieved with the EJS or Jade view, and then sends that as the final response to the user's HTTP request. The final output of the HTML5 and jQuery travel through the Internet to the user, where it is finally parsed and executed in the user's browser to create the final website they see.

That may have been an info overload, but the short answer is that while HTML5 and jQuery code will be visible in your node application, it won't be executed there. It is executed in the browser after the final server response is sent.
The indelible lord of tl;dr
KaL
Posts: 344
Joined: Mon Jan 13, 2014 5:44 am

Re: how many languages are neccesary for browser mmorpg?

Post by KaL »

what type of game that require node.js? what type of server should i look for? I was planning to merge: Construct 2/PHP/MySql for an mmo street fighter mobile app. Is that enough to build a game? or do i need node.js?
Last edited by KaL on Tue Aug 05, 2014 7:31 am, edited 1 time in total.
uh oh
Posts: 17
Joined: Sun Jul 27, 2014 7:28 pm

Re: how many languages are neccesary for browser mmorpg?

Post by uh oh »

Thanks Jackolantern, my picture of inner workings of these things is still pretty vague so please excuse my next question;
I was speculating that, if the less dynamic parts of the game like various setups, options, stats etc. were done in php, whether it would help the server with performance regarding game logic and tasks that require fast responses?
User avatar
Verahta
Posts: 441
Joined: Wed Aug 24, 2011 1:50 am

Re: how many languages are neccesary for browser mmorpg?

Post by Verahta »

Thanks Jack. What about JSON? I have read it's better than XML for changing data-types?
"In order to understand recursion, one must first understand recursion".
User avatar
kaos78414
Posts: 507
Joined: Thu Jul 22, 2010 5:36 am

Re: how many languages are neccesary for browser mmorpg?

Post by kaos78414 »

Verahta wrote:Where does HTML5 and Jquery fit in with node, express, mongo, connect?
HTML5 is a spec for clientside javascript, and jQuery is a library meant for manipulating the DOM, which is usually only available on the client (browser). Since node operates on the server, it is unlikely that you would use either of these in server side code - relegating most of this to publicly served files (/public/js ?), and your view/template files.

Node, in your case, would be your server. Express is a server-side javascript framework written for Node, originally built on Connect (which is a suite of tools designed for use with HTTP servers built in Node). Mongo is a key-document store designed with performance in mind. There are lots of options for your data layer, but I'd say it is increasingly more common that node is associated with Mongo.
KaL wrote:what type of game that require node.js? what type of server should i look for? I was planning to merge: Construct 2/PHP/MySql for an mmo street fighter mobile app. Is that enough to build a game? or do i need node.js?
Your server needs depend on what your game needs. Is it real time? You may want to implement websockets, which I would say is easier to do in Node then in PHP. How is your data stored? What does your schema look like? Analyze your requirements for the project and research the tools that would be best for the job. Not the least of your concerns is how familiar you are with each of these platforms and whether you have a deadline that would be impacted by learning new tools. You can build the game server in any language: Python, Ruby, Javascript (Node), PHP, C++, whatever you want. And you have just as many choices for the data layer, MySQL, Mongo, CouchDB, ElasticSearch, Cassandra, MSSQL, Postgresql.

What I'm trying to say is, don't get hung up on the tools you want to use for too long - do some initial research, and don't go back and say "I could have used something better." That said, Node is excellent and highly recommended as a game server platform. It's very fun and satisfying to program in IMO. You don't ever *need* Node, but it's definitely an awesome platform with a lot to offer.
uh oh wrote:Thanks Jackolantern, my picture of inner workings of these things is still pretty vague so please excuse my next question;
I was speculating that, if the less dynamic parts of the game like various setups, options, stats etc. were done in php, whether it would help the server with performance regarding game logic and tasks that require fast responses?
I think that's an awesome question, and one that shows you're thinking ahead ;)

I think the architecture of your application is very important. Depending on size, separating concerns into a separate server dedicated to serving less dynamic resources (it doesn't have to be PHP, you could offload these tasks onto another Node application) might have very slight performance gains. But if the game is small, the gains would be so minimal as to probably have made things easier on you to just combine them.
Verahta wrote:Thanks Jack. What about JSON? I have read it's better than XML for changing data-types?
JSON seems to be the standard. I don't know if it's better then XML, but IMO it is easier to read and debug.
w00t
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: how many languages are neccesary for browser mmorpg?

Post by hallsofvallhalla »

2... Javascript and HTML

Nodejs, Mongo, Jquery, JSON, ect are all Javascript.
KaL
Posts: 344
Joined: Mon Jan 13, 2014 5:44 am

Re: how many languages are neccesary for browser mmorpg?

Post by KaL »

the node.js server hosting is expensive. -how many people can i hold on my pc if i'm making a street fighter 2d platform mmo? 1vs 1 in real time when the fight is over they can pick another player to fight if they are online. can this hold 5,000 players like a turn base game like mafiawar?
Post Reply

Return to “Beginner Help and Support”