Advertisement

Browser-Based Game: Best Language?

Started by March 27, 2014 10:47 PM
19 comments, last by DareDeveloper 10 years, 5 months ago

Hi,

Although very naively, I have been contemplating finally getting a go at creating/idealising (the two are very distinct!) a game. Amidst such event, I stumbled upon a technical question in need of answer. What's the best language to code a 2D/Text-Based browser-based game on? The question itself may be lacking in depth so I'll list a few game references:

- Rail Nation | Travian Games

- OGame | Gameforge

- Brain Storm | Genia

Perhaps this is a good enough draft?

Thanks in advance,

Dialects

In the browser itself, barring plugins, you're pretty well limited to JavaScript. There are other languages you can use which can be compiled to JavaScript, but you can't escape the semantics of JS, so any such language is more or less syntactic sugar. They may add some static analysis, but my experience with TypeScript and CoffeeScript has been they are not worth the trouble.

For the server your choices are far more vast. Most contemporary languages have a web app stack (rails, grails, django, flask, ASP.NET MVC, sails, meteor...) that will help keep things organized and prevent you from rebuilding the wheel.

If you are new to programming or have absolutely no bias I'd go with Node.js along with one of the popular full stack frameworks like express or sails. This way you need only learn one language, and there's a chance you could share some code on the client and server side, though this usually is a minimal amount.
Advertisement

Only JavaScript? I usually see JavaScript, Java, or HTML5 mentioned for browser game development, but I've not done a browser game so I don't know if those are viable options too or not.

Hi,

You can also use Haxe ofcourse.

HyperV

smr

- Thanks for your kind and elaborate post. Given my zero experience with coding, should I go straight to JavaScript or would you recommend getting in touch with another language prior to Js?

BHXSpecter

- I am aware of the difference between Java and Javascript. Not entirely sure what the difference(s) is/are -- just aware that they're different. Are you saying HTML & CSS comes to play when coding a browser-based game, too?

HyperV

- Haxe being? Apologies. I'm not much a connoisseur at this point.

Edit: Just did a bit of research. By Haxe you mean http://haxe.org/ ? What are the advantages in using Haxe over hard-coding it by scratch and what's the learning curve of the language?

Thanks in advance,

Dialects

It depends on what is your intended audience. The most obvious solution would be JavaScript because the user won't need any additional plugins. But you should take into account that supporting JS on a wide range of clients is quite hard (especially if you look at Internet Explorer and mobile browsers). The compatibility is not much of a pain if you will use something like Flash (ActionScript), Java Applets (Java) or Unitiy3D (C#) but then the user would need to have the respective plugin installed and also the mobile experience would be limited or non existing.

Update:

Just for reference here are two libraries that I would recommend:

Phaser (JavaScrip/HTML5) - it's a game library for HTML5 games so will only work on new browsers that support Canvas or WebGL. This also has awesome compatibility and performance on mobile.

CitrusEngine (ActionScript 3) - It is actually a bundle of libraries that help you quickly get games working in either 2D or 3D and also takes the advantage of Stage3D technology (GPU acceleration). This will do fine for desktop browsers (even older ones) that have Flash Plugin installed and you can also publish the game for mobile environment (Android, iOS etc) using the AIR technology with minimum to no modification to the code.

Advertisement

Thanks for your elaborate reply, ram64.

You do raise a pertinent question -- what's my target audience? Albeit not much thought has been given to this yet it is somewhat safe to assume having a platform that is compatible with computers & mobiles is the way forward. 2D/Text-Based Strategy tends to gather interest from an adult-keen audience so I'll assume this to be my target audience to begin with.

I would like to ask for a bit more of detailed information when it comes to code languages. What are its pros and cons? So far these have been suggested:

- Javascript

- Node.js (which I suppose is a derivation of Js?)

- Java

- HTML 5

- Haxe

- Action Script (I've had some introduction to AS3 in the past!)

- C# (Unity 3D)

A hands-on look at the cons and pros of these would help me greatly in understanding which may be the best pick. Take into consideration:

- It's a browser-based game.

- Mobile-compatible is an option but not necessary.

- It takes on several aspects of the games I've mentioned before (Rail Nation being the biggest in terms of GUI, Dynamics, Animations, Game Mechanics, etc)

- I'm new to mostly all of the above mentioned languages. I have very little knowledge of Action Script 3.0.1, Python 3 & rudimentarily, HTML5 & CSS 3.

If there's anything else you'd like to know, ask away. I might not be providing the full-extent of information you'd expect out of lack of knowledge.

Thanks in advance,

Dialects

There is currently a catch with the following technologies:

Java

C# (Unity 3D)

C# (Silverlight)

AS3 (Flash)

They require your users to have a plugin (of the correct version) installed. This also means that your software will only work in specific browsers on a limited number of operating systems (that supports the plugin). Tablets in particular will not load them in their web browsers.

Plugins are a legacy technology that are slowly and surely moving over to Javascript / asm.js. Unity is making good progress at porting their plugin to pure Javascript via Emscripten, Unreal engine has done the same. Adobe have also stated that they are going to be migrating their tools and language over to HTML5. Unfortunately none of these are quite ready yet.

So instead, since you are starting from scratch anyway, I recommend the following choices.

Javascript (+ Canvas) - For 2D web games

Javascript (+ WebGL) - For 3D web games (perhaps using three.js to help)

HaXe / Typescript etc. export to JS too so these kind of things might suffice if you really dislike Javascript.

If you or anyone else in your team is interested in getting into programming in a big way, then this opens you guys up to Emscripten (C++ -> Javascript compiler) which is becoming very popular now with larger companies and native developers but also allows you to utilize a massive back catalogue of traditional C and C++ libraries to help you develop your game (rather than reinvent the wheel).

http://tinyurl.com/shewonyay - Thanks so much for those who voted on my GF's Competition Cosplay Entry for Cosplayzine. She won! I owe you all beers :)

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.


I would like to ask for a bit more of detailed information when it comes to code languages. What are its pros and cons? So far these have been suggested:

- Javascript
- Node.js (which I suppose is a derivation of Js?)
- Java
- HTML 5
- Haxe
- Action Script (I've had some introduction to AS3 in the past!)
- C# (Unity 3D)

JavaScript will be available on most of the browsers (mobile and desktops) but you have to take into account the implementation of JS engines in each of those browsers (or for which browser you want to support). This would be the language of choice for a 2D/Text game if the graphical part is not that advanced.

Node.js is a server side environment which uses JavaScript. This would be used for the back end of a game or an application (scoring system, server logic etc) in case you want a back end to your game.

Java is a powerful choice but the learning curve is quite steep.

HTML5 is actually the current/next standard of HTML and is just the markup. A game written in HTML5 would still need JavaScript to function. When stating that you are using HTML5 for games you actually are saying that you are using a combination of HTML5 (markup and Canvas tag), CSS3 (styling) and JavaScript (for logic and interactivity).

ActionScript is the programming language used in Flash. Most of the online games were and are still done in Flash but as HTML5 standard is refined more and more devs abandon Flash and AS for HTML5 and JS. But again, this really depends on your audience and on your type of game.

I have not used Unity before but as far as I understand it's a good solution for games (mostly 3D but recently I think they released some updates for 2D games). In my opinion this would be too powerful for a simple 2D text game.

As for HAXE I never used it but I think it's some kind of language that you can compile to other programming platforms (ActionScript, Java etc). Can't give you too much detail as I have no experience with it but you can read on the official site http://haxe.org/.

Also you should mention what's your overall programming experience. If you have no experience with browser games I would suggest just picking JavaScript and get on this path (as your game seems fit for it). You could also try TypeScript (which compiles to JavaScript) if you want type control and other goodies in JavaScript.

So instead, since you are starting from scratch anyway, I recommend the following choices.

Javascript (+ Canvas) - For 2D web games

Javascript (+ WebGL) - For 3D web games (perhaps using three.js to help)

HaXe / Typescript etc. export to JS too so these kind of things might suffice if you really dislike Javascript.

This, I suppose, nails my concerns summarily.

It is not that I do not like Javascript. I am not familiar with either Javascript nor HaXe which is why I asked assistance in understanding what the main differences and applications between the two are. HaXe may look like an easy starting-point though given that it exports and is based on JS (correct me if I'm wrong!) I might be better off understanding the core principle of the language itself before I start using applicants and derivations thereof.

I currently do not have a team. It may be slightly naive of me to think I'll find one or two willing candidates. No payments are being offered as is and although the prospects may be high (at least to myself -- I've been a vivid gamer for quite some time. The idea I have for the game is enthusiastic to me. That's the ground my hypothesis is sitting on, I suppose!) I can still not guarantee that those involved will be paid during development stage.

I come from a Design background w/ predominance in Art Direction. If anything, it makes it easier for me to understand methodically how a concept goes from being an idea to becoming a representation of that idea. I'll possibly venture myself in running the two tasks simultaneously: Working the concept up & learning Javascript.

I'd like to deeply thank everyone who has commented. You've all been very helpful! To conclude it all, can you guys direct me to some Javascript tutoring/books/videos? I have seen tids and bits of information pertaining Javascript at Gamedev. I've also registered at Codecademy and have started the Javascript Learning Program. Is there more I should be doing?

Kind regards,

Dialects

This topic is closed to new replies.

Advertisement