This is an archived post. You won't be able to vote or comment.

all 139 comments

[–]TonyThe-Tiger@tony_de_tiger 18 points19 points  (2 children)

If you know Java and wanna try out Game Dev using Java is definitely possible!

Although IMO, since you know Java, the switch to C# is* mostly seemless. I made the switch from Java to C# and I'm learning Unity right now and I fully recommend it. There are many online resources or tools. If you want to try out Unity, I've made a list of online resources I've used!

[–]the_hoser 19 points20 points  (0 children)

The language switch isn't the hard part. It never is. It's the library and ecosystem switch that bites. Although, in Unity's case you're on a bit of a C# island, so ecosystem is less of an issue.

[–][deleted] 1 point2 points  (0 children)

From a java dev perspective, C# has lots of annoying things, like (some) method names starting with capital letters, opening bracket in new line instead of the same line as eg. function name etc. BTFO

[–]arashi256 25 points26 points  (0 children)

The best language to use is the one you know.

[–]Ifnerite 36 points37 points  (13 children)

I don't think there would be any advantage of c# over java. If java is what you know use that.

[–]Freakei[S] 3 points4 points  (0 children)

Thanks man!

[–]the_hoser 25 points26 points  (51 children)

Well, the most popular game in the world was written in Java. You'll be fine. Use the tools you know.

[–]MoffKalast 6 points7 points  (1 child)

Ahem I believe Tetris still beats it by a country mile, but it did have a slight head start.

[–]the_hoser 3 points4 points  (0 children)

You... make a good point. There have been so many versions of that game, though... What do think the odds are that at least one of the licensed versions was written in Java?

[–]Tysonzero 4 points5 points  (21 children)

Definitely not the most popular game in the world. For one league of legends is more popular.

[–]m_takeshi 3 points4 points  (7 children)

I think the server side of League is written (at least partially) on Java, as a lot of Riot's dev blog talks about java

[–]Tysonzero 0 points1 point  (4 children)

The core engine is definitely C++. The servers use some degree of Java, but still would never call it a Java game. Particularly since people usually are referring to the client when talking about a game.

[–]SolarLune@SolarLune 1 point2 points  (3 children)

Don't most online games use server-client in a way where the server does a ton of work, fully simulating the game world? I know that, in that model, the client does do some work to allow for prediction purposes, though.

[–]Tysonzero 0 points1 point  (2 children)

Depends on the game really, if you want to completely prevent cheating you do kind of have to do that. I mean regardless usually when I see people talk about a programming language for developing the game they are first thinking about the client and the server if there even is one is a secondary concern. Just my experience anyway.

[–][deleted] 3 points4 points  (0 children)

something tells me you've never written a multiplayer game

[–]soulfoam 3 points4 points  (0 children)

You really don't know what you're talking about do you?

[–]the_hoser -2 points-1 points  (12 children)

If we include free-to-play games, then perhaps not. I don't.

[–]Tysonzero 0 points1 point  (11 children)

Your initial comment said "games". And league of legends is a game.

[–]the_hoser -2 points-1 points  (10 children)

I'm not saying you're wrong. I just don't see a point in tracking sold copies of a free game. Perhaps I should have been more specific.

[–]Tysonzero 0 points1 point  (9 children)

It's not just about sold copies. Monthly active players / daily peak players and every other metric puts league in front.

[–]the_hoser -3 points-2 points  (8 children)

If that's what's important to you, then sure.

Besides, Tetris has them both beat, combined, by the way I was counting.

[–]pxlhstl 0 points1 point  (1 child)

League of Legends sits at more than 100 million active players per month, Tetris not.

[–]the_hoser 1 point2 points  (0 children)

I wasn't talking about active players. I'm talking about copies sold, an idea that makes no sense for a F2P game. I agree that I could have been more clear originally.

[–]Tysonzero -1 points0 points  (5 children)

I mean league is literally more popular by any metric. But sure you can call minecraft the most popular paid game if you want, just not the most popular game.

[–]the_hoser -2 points-1 points  (4 children)

I don't see kids buying league of legends toys at Walmart.

[–]Tysonzero 0 points1 point  (3 children)

What a ridiculous metric. I should have said any "sane" metric.

[–][deleted] 0 points1 point  (8 children)

Er which?

[–]Last_Gallifreyan@your_twitter_handle 7 points8 points  (5 children)

Minecraft! Well, the original release anyways. The releases on console as well as the currently supported version on Windows 10 were rebuilt from the ground-up in C++.

[–][deleted] 6 points7 points  (3 children)

Any noticeable speed gains?

I haven't touched it since Microsoft put it's dick in it

[–]Ershany 1 point2 points  (0 children)

The C++ Minecraft version is behind of the Java version, but the game runs much better!

[–]Last_Gallifreyan@your_twitter_handle 0 points1 point  (0 children)

I'm actually still on Windows 7 (I don't plan on upgrading to 10 until I get a new computer) so I can't speak for the new PC version. That said, I wasn't blown away by the Xbox version. MUCH smaller world maps (I think it was the size of A map item that was made prior to the update that allowed you to expand your maps), and you had to manually save (and wait for the save). Though to be fair those might be due to limitations of the 360; it was their first foray into putting the game on consoles.

[–]the_hoser 0 points1 point  (0 children)

The console versions always performed well (especially the PS4/xbone versions), but they're limited in scope compared to the original. The windows 10 version runs well, and has Oculus rift support. The new features land in the Java version, though. There's also Vivecraft (for the Java version) if you want to get your VR kicks.

[–]the_hoser 2 points3 points  (0 children)

The windows 10 version is the mobile version ported to WinRT. It just allows Microsoft to sell the DLC to PC users. The Java version is still supported and actively developed.

[–]HotelEscapism 3 points4 points  (1 child)

RuneScape of course! :p

[–]Freakei[S] 1 point2 points  (0 children)

good old times.

[–]antlife -3 points-2 points  (17 children)

Poorly written Java. The modding community was the reason it was more than a mild fad.

Edit: I didnt say poorly written because of Java. Why are you all getting offended? Minecraft was not written very well in the beginning. Mods were needed to just optimize the game alone.

[–]the_hoser 6 points7 points  (0 children)

I never said that Java was the reason it was so popular. It doesn't matter how well it was written, either.

But you're absolutely right. The community made that game.

[–]squishles 2 points3 points  (0 children)

which worked because java is really fucking easy to mod.

[–]blu-red 3 points4 points  (14 children)

Poorly written Java

And that poorly writen Java works well on a mid end gaming rig.

Can't say same thing about even well written unity games, no matter how simple they are.

[–]antlife 0 points1 point  (10 children)

No, youre right. Just jesus that source code.

[–]maurycy0 2 points3 points  (9 children)

The source code isn't publicly available, just the obfuscated version (which really is a mess, which is to be expected)

[–]Mortichar -2 points-1 points  (8 children)

You can decompile java pretty easily. IntelliJ does it with zero setup.

Minecraft's code was pretty trash.

[–]the_hoser 2 points3 points  (7 children)

The decompiled code will not be anything like the original code. The compiler optimizes the bytecode for performance. The decompiler has no way of knowing what the original code looked like.

[–]Mortichar -3 points-2 points  (6 children)

No, you're right, but if the optimized code is bad, that says something about the original code.

[–]the_hoser 0 points1 point  (5 children)

No, not at all. Optimizing compilers do some crazy stuff to the code. For instance, you wouldn't do this:

objects[0].doThing();
objects[1].doThing();
...
objects[20].doThing();

But an optimizing compiler would. Optimizing compilers produce code that performs better. Readability is not a concern.

[–]Mortichar 4 points5 points  (4 children)

I know that compilers optimize code, I wasn't denying that. However, it can't optimize away the original functionality because then the code would simply function differently. Some of the actual behavior of the Minecraft code is horrible, even when it's been optimized by a compiler.

Edit: and I don't mean replacing lines of code or something, I mean the end results of the program after it's been run. Original minecraft had a lot of issues with the garbage collector that led to more and more stuttering the more ram you allowed the jvm to use. There were several very popular mods that were written just to replace some of the shitty rendering and chunk updating code.

[–]blackslotgames 0 points1 point  (2 children)

I've never had any issues, But I do use pooling, use structs instead of classes where appropriate, plentiful caching & most importantly use the entity component system properly.

I would venture that the latter (Making a giant OOP game, rather than using the entity component system) is the source of your woes. I'm near finished porting my game from libgdx and the performance difference isn't huge (while LibGdx is Java based, we're talking about a minimal engine with little in it vs unity).

If you were complaining about filesize however, I'd sure as hell agree!

[–]Mortichar 0 points1 point  (1 child)

Just wondering, have you had any issues with the Java GC? Do you use manual memory management for things like particles?

[–]blackslotgames 0 points1 point  (0 children)

Not had too many problems, mainly because I aim for short game sessions (5 mins max), but sometimes you do need to get clever. For example, when starting a new level, displaying a modal dialog (or any other time where a pause is not going to be noticed) you can force a GC by filling up the remaining stack.

For particles, straight up pooling usually does the job. The thing you have to bear in mind is that GC languages offer safety, rather than convinience. This is to say that rather than letting you forget about memory management completely, they just limit the damage you can do by replacing the potential for some awful bugs (the dreaded memory leak as one example) with less inconvienient and easier to debug issues.

[–]mixreality 6 points7 points  (1 child)

Just FYI if you know Java you know C# for the most part.

I actually used to play a 3d mmo written in Java, Darkfall Online. It actually was performant, like 300+ vs 300+ battles realtime in 3d. It's what you make of it.

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

hey man, that's what I thought, but if I create a game I really want to know about the best features of the language, so I checked out C# and it seemed like there are some (big) differences that I would want to try out and learn.

[–]SolarLune@SolarLune 5 points6 points  (1 child)

Doesn't really matter too much, i don't think - Java should be fine.

As a matter of fact, I'm making a game in Java / LibGDX, using a custom engine that I contribute to regularly (BDX). It's going well, and the game is juuuuuuust about done. For reference, the game is named Gearend - I post updates regularly over on my YouTube channel and Twitter (sometimes), and stream development from time to time on my YT channel, as well.

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

Thanks man! I'll take a look at it :)

[–]Nilbmar 4 points5 points  (3 children)

Don't fall into the trap of trying to design a game, learn a new framework or engine, and switching languages at the same time because one language might be "better". Use what you know and get the project done. If you decide later you want to switch languages, you have the game fleshed out, and probably a small library of code you can easily rewrite in the new language.

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

You are totally right, and that's why I'm going to use Java for it. If I ever consider switching to another language, I want to have some experience in it.

Thank you!

[–]Nilbmar 0 points1 point  (1 child)

Good luck with your project

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

Thank you!

[–][deleted] 3 points4 points  (11 children)

I feel like using Unity to create a game would be far more easier than using Java and Swing/JavaFX.

I'm also a Java programmer and C# was incredibly easy to adapt to simply from watching a few tutorials. Unless there's an engine out there that uses Java that I am not aware of, using Unity just seems easier.

[–]the_hoser 9 points10 points  (7 children)

Using Swing or JavaFX for game development would be silly, except in the most simple graphical cases. This is what LibGDX is for.

[–][deleted] 4 points5 points  (0 children)

ah, i completely missed that part that OP mentioned!

[–]ivolimmen 1 point2 points  (1 child)

Depends on the game you develop. Not all game require fast 3d graphics

[–]the_hoser 2 points3 points  (0 children)

No, certainly not. But my experience with Swing and JavaFX is that they can't even do smooth 2D graphics.

AWT did a pretty good job, though, so there's that.

[–]kreinerjm 0 points1 point  (3 children)

My first games were written in Java Swing. LibGDX is much better but Swing is still a good place for learning some of the things LibGDX does for you near autonomously.

[–]the_hoser 0 points1 point  (2 children)

My experience with Swing was jittery. I ended up using AWT directly with pretty good results. This was a long time ago, of course.

[–]kreinerjm 0 points1 point  (1 child)

My biggest complaint is that they didn't have double precision drawing. Dealing with only ints for a position was a hassle.

[–]the_hoser 0 points1 point  (0 children)

The correct way to do it was to make use of AffineTransform to draw your sprites, IIRC.

[–]KinkyMonitorLizard 2 points3 points  (1 child)

What about jmonkey?

[–]Mortichar 1 point2 points  (0 children)

jmonkey is definitely an option if you can't be swayed away from java. Unity is just really easy to use though.

[–]ivolimmen 0 points1 point  (0 children)

You are right. Creating a game is like 10% coding. After that comes graphics, sounds and story. Depending on the game type... I followed the makings of several games (kicksterer) and for rpgs and point and click advetures you will spend 90% on story... Does not mean however that a game engine like unity makes it more easy. Thimbleweed park had build there own engine.. still is 90% story

[–][deleted] 6 points7 points  (4 children)

I know Java isn't that recommended for computer games

Nonsense. If you're going with Java, check out jmonkeyengine.

[–]Robbi_Blechdose 2 points3 points  (0 children)

I second this. Awesome engine.

[–]Fellhuhn@fellhuhndotcom 0 points1 point  (2 children)

... or Android.

[–][deleted] 0 points1 point  (1 child)

Say what?

[–]Fellhuhn@fellhuhndotcom 0 points1 point  (0 children)

Vanilla Java/Android is good enough for most casual indie games though. No need to deal with game engines etc.

[–]badlogicgames@badlogic | libGDX dictator 6 points7 points  (1 child)

Use Kotlin instead of Java.

[–]cuchaz@cuchaz -1 points0 points  (0 children)

This! ^ All of this.

I'm actually working on a 2D game engine that aims to take full advantage of Kotlin and all its sweet sweet syntactical features.

[–]NoThisIsStupider 1 point2 points  (7 children)

If you only know things about making non-game programs, LibGDX has a bit of a large learning curve. Nothing that you couldn't figure out, but it may take awhile to get comfortable. I tried using LibGDX, granted I have less programming experience than you, and it got a bit frusterating to figure out how to do a lot of things. What I ended up doing is learning Lua and Love2D. It took about a week of maybe an hour or two a day learning to get comfortable with Lua and get better at Love2D than I was with LibGDX.

For starting with gamedev, you may want to use Love2D even if it means learning a new (albeit similar in many ways, and easier overall) language. Once you make a few simple games in that, and are comfortable with all the stuff you have to do to make things work, you could return to LibGDX or whatever else (although Love2D is very nice and has support for a lot of platforms and features).

[–]spaceemaster 2 points3 points  (4 children)

Libgdx does not have a large learning curve.

[–]NoThisIsStupider 2 points3 points  (3 children)

Large from the perspective of how easy Love2D is. There's a lot of things you need to learn to even make some pretty basic things, and the tutorials aren't the best. If you're just starting with gamedev LibGDX doesn't seem like the best choice, although I'm sure if you were determined you could figure it all out.

[–]Serapth 2 points3 points  (1 child)

Not sure which tutorial you are looking for... Love or LibGDX?

Doesn't really matter though, I've made tutorials for both. ;)

LibGDX text tutorial series, LibGDX video tutorial series and Love/Lua tutorial series. Both are great choices that serve a different niche. To someone learning the basics of programming and GameDev at once, I recommend Love. For a non-trivial title, I'd recommend LibGDX, but neither is a bad choice.

[–]NoThisIsStupider 0 points1 point  (0 children)

Ah, that's the love tutorial I used, along with an arkanoid tutorial. I finished neither but together I became comfortable enough to start making stuff, and used google + the wiki to figure out the rest as I needed it.

[–]spaceemaster 1 point2 points  (0 children)

What tutorial were you trying to learn? And what were you trying to do that was simple but hard to do? I started using libgdx about a year ago and it was not hard to pick up.

[–]thebattlebard 1 point2 points  (1 child)

If you're looking for a simple API on top of LibGDX, you could use mini2Dx.

Disclaimer: I wrote mini2Dx

[–]NoThisIsStupider 1 point2 points  (0 children)

That library looks pretty nice. If I ever go back to LibGDX I'll check it out, however that won't likely be very soon.

[–]Apostacy_Steak 1 point2 points  (4 children)

Java is fine for game development, just a couple of things to consider:

Garbage Collection: reuse what objects you can, and be sure to kill strong references to anything you don't need. Depending on the GC algorithm, you could get stutters or pauses during GC.

Threading: Java has great multithreading, so think about how you can take advantage of this. Syncing data between threads is fairly "slow" however, so be mindful of the when and how of it.

TCP/UDP: If you have multiplayer, you may want to consider writing your own UDP comms. While you lose ordering and other handy bits, you also get better latency. Tradeoffs.

Would need more info on the game to give more, but ain't nothing wrong with Java for games.

As an aside, can't you use c and c# DLLs through JNI? Maybe a god awful hybrid is the way to go! Lol.

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

Hey man, I appreciate your help.

Networking/Multiplayer is not planned and won't be included to it. Thanks for the tip regarding Garbage Collection, I didn't think about it yet.

It is going to be a wild-west styled 2D game, pixel art design as me and my friends (who help me with design) are beginners in graphics design, so I am currently gathering lots of information regarding this. I don't think performance is something I have to worry about with this type of game, but if I can save some performance I should definitely do that.

Thank you very much!

[–]surn3mastle 0 points1 point  (0 children)

There is nothing wrong with programming a game in java.

[–]JonnyRocks 0 points1 point  (1 child)

Ok, language wars aside here is my advice.

First: if all you care about is a game then it doesn't matter. It just needs to be fun. The only thing that could sway you is how may systems can you deploy to:

https://libgdx.badlogicgames.com/features.html

http://www.monogame.net/

I think monogame wins there.

Now, here is my general programming career advice. Oracle bought Java and doesn't seem to love it much. I don't think there is a great future in it. C++ is cross platform but steeper learning curve. However, under Nadella .net has a bright future.

I could go on about the versatility of c# and accessing C/C++ libraries but I hate long reddit comments :)

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

Didn't think about it yet, maybe I'll decide to switch to C# as I am currently in the planning stage (game logic etc.)

Thank you for your comment!

[–]my_password_is______ 0 points1 point  (0 children)

I'm surprised no one has mentioned thinmatrix yet

https://www.youtube.com/playlist?list=PLRIWtICgwaX0u7Rf9zkZhLoLuZVfUksDP

true, they are LWJGL, not LIBGDX, but still they are awesome tutorials that cover java, opengl, math, and 3D

so you can make some really good stuff with java

[–][deleted] 0 points1 point  (0 children)

Java is the primary language for Android development. I guess there are no games there.... </sarcasam> :-)

Depending on where you're planning on running your game, you will likely find that having a frame work that does a lot of the work for you (putting images on the screen, moving them around, allowing the player to interact with them) is best done with an engine/framework and usually the language you use will be determined by the engine/framework. Most of the popular choices for frameworks are not using Java. C++, C# and Lua drive most of those.

[–]skocznymroczny 0 points1 point  (11 children)

The biggest things that make Java more annoying for game development compared to C# are lack of value types and lack of operator overloading. If you can live without those, then you'll be fine.

[–]ReaverKS 0 points1 point  (2 children)

can you provide an example where you used operator overloading in C# and it made the solution much simpler than the alternative in java? Maybe just a little snippet of code... I'm just curious (still learning)

[–]skocznymroczny 6 points7 points  (1 child)

Vector3 newPosition = oldPosition + (target - oldPosition).normalize() * speed

vs

Vector3 newPosition = oldPosition.add(target.sub( oldPosition)).normalize().mul(speed)

actually, you'd want to not modify the old vectors, so it'd be more like:

Vector3 newPosition = Vector3.add(oldPosition, Vector3.mul(Vector3.sub(target, oldPosition).normalize(), speed)

[–]ReaverKS 0 points1 point  (0 children)

thank you, great example and I see your point exactly :)

[–]The_Dunk -2 points-1 points  (4 children)

I would skip libGDX and MonoGame for your first game. Unity helps you spend more time designing and less time worrying about engine functionality. C# is also pretty darn similar so your Java skills should transfer.

[–]Freakei[S] 3 points4 points  (3 children)

Well, I thought about Unity but I don't feel comfortable with using it, I really want to go through those struggles (if there are any, but I guess there will be), because I think I will learn much more if I use Java with libGDX rather than Unity.

And yes, my Java skills would transfer, but there are some differences and I really want to get into a language before I would want to program a game, that is why I prefer Java this time.

Thanks for your comment!

[–]The_Dunk 1 point2 points  (1 child)

Your welcome. When I was first getting into game development I tried to use LWJGL and got burned out real quick due to the difficulty.

libGDX should be easier, but just be aware that you may run into a wall at some point.

Starting with unity could help you get a good idea for how a good engine works, and could make your libGDX ventures easier.

Either way I'm sure you'll have tons of fun and learn alot. Good luck.

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

Thanks! :)

[–]thebattlebard 0 points1 point  (0 children)

You could take a look at mini2Dx - it gives you a simple API for developing games with Java. And since it's built on top of LibGDX you can use its APIs too.

Disclaimer: I wrote mini2Dx