JavaScript VS Java for browser games

JavaScript VS Java for browser games
0

#1

Hello everybody,

Just want to ask a question which I have for a long period of time. This question is about games(browser games).
Which of these two languages are better for this JavaScript or Java? I mean which game will be better in all the parameters? Speaking only about browser games, no phone games.

Thanks.


#2

World of Warcraft or Hangman?


#3

Seeing that JavaScript works natively in the browser and Java doesn’t… I would assume JavaScript for basic games. If you are trying to make more complex browser games, you would probably want to use an engine such as unreal or unity.

I know a lot of nice browser games are made in unity, and C# is quite similar to Java in many regards.


#4

Warning: I am not an expert in the subject. My experience in this comes from Udacity courses: a now-retired course on HTML5 game development featuring PvP shooter game GRITS (written by a Google engineer who had worked at Blizzard before), and a purely front-end clone of Frogger project in their Object-Oriented Javascript course.

I guess it depends what kind of browser game you’re thinking of.

  • A game that entirely lives on the client will obviously need to be written in Javascript. There is no alternative. The ones I’ve seen use the canvas element.

  • A game with a back-end will usually have a javascript component.
    – In any game where speed is important, some of the code needs to live in the browser for reactivity. Again that means Javascript.
    – In games where speed and reactivity are not a factor, like turn-based games, you can probably get away with waiting for the round trip to the server. You’ll probably need some AJAX to update the server anyway so some Javascript is involved.

If you need a back-end, whether to keep a leaderboard or, in a multi-player game, to keep track of player positions and interactions, you can write the server code in anything you like.

Java is supposed to be fast so maybe that’s what you need. Node is pretty fast too however, and, since it’s Javascript, it allows you to share some of the code between the client and the server. You won’t need that for every game obviously. The GRITS game was written in Node so that it was possible to run the same code on the client (for reactivity) and the server (to keep track of things) with additional code to keep the two converging. But that’s a rather complex game to make.

If you’re just starting, make a simple front-end game with javascript, something like Breakout maybe. Use the experience to create something more complex next time. You can also use an engine like Unity. They also have good advice for beginners. Check out this video on their website on “How to start game development”. The advice makes a lot of sense whether you write your games from scratch or use a game engine.