Learning a programming language to use Unity

So, I’m dabbling in Unity and learned that even though Unity does a fair bit of coding for you, you still have to know how to code.

Unity uses JavaScript but Unity tutorials I’ve seen seem to emphasize C# with C++ sometimes being mentioned.

So, what should one learn, presuming no prior coding knowledge on my part? If I learn C#, will the transition to JavaScript be easy? I’ve heard that the main difference between C++ and C# is that C++ includes allocating memory, is that really the main difference?

I haven’t heard of Unity, maybe because I’m out of touch. I’ve got some hobbyist experience with the other three.

JavaScript, C++, and C# are all pretty similar for general syntax. They differ a quite a bit in the details. JavaScript is interpreted by your computer ‘on-the-fly’. C++ is pretty completely compiled beforehand, and - as you’ve noted - requires some attention to memory management. C# compiles into something called byte-code, and so requires the underlying semi-interpreter libraries to be preinstalled.

C# is the most completely object-oriented, but both JavaScript and C++ allow the definition of classes, though they’re not required. JavaScript doesn’t require any declaration of variable types, but a variable’s value type will dictate what can be done with the value, so it’s still something that comes up.

I’ll say that learning C# would be a decent start to learning JavaScript. Some might say that JavaScript is ‘simpler’ than C#, so if you get too bogged down with the details of C#, switch to JavaScript sooner.

Having dabbled a bit with both, I think that C# is much easier to learn and use than C++, but C++ might be more powerful because it really doesn’t stop you from doing anything you want to do, even if you shouldn’t be doing it.

That’s my experience as well, although it doesn’t really help the OP: his choice is C# or Java. Unity doesn’t support C++.

Simply in terms of what’s easiest to use with Unity, I don’t think it matters which one you pick. I’ve been working in Unity with C# for about two years now, and I haven’t come across anything I needed in C# that could only be done in Java. I assume the reverse is true. I don’t know Java, so I can’t compare them directly. Almost every website that has tutorials for Unity has them in both Java and C#, so you should be able to get help online, regardless of which language you learn.

Er, the OP said JavaScript. Java and JavaScript are not the same thing, and are not even particularly related to one another beyond the name and the fact that both were designed to be able to be run from a web page, in a client browser.

I have no idea what Unity is, so I do not know whether it is MichaelEmouse or Miller who is confused here, but one of you seems to be.

Here’s Wiki on the subject.

All of those languages are similar enough that once you learn any one of them, you can almost immediately sit down and program in any other of them, with only occasional need to reference a book or other source to refresh your memory. Even with widely-unrelated languages, learning to program, in general, is a much bigger deal than learning any specific language.

Yeah, what he said.

Javascript is really one of the worst misnomers in the tech field. It should have been called HTML Script, or maybe WebScript, or possibly anything but Java. The people who named it were playing off the fact that Java was the new hip thing at the time and wanted to leverage that. But the only thing it really has in common with Java is that it uses some of the same syntax.

But C-script is closer to actual C, and VBScript is closer to Visual Basic, than Javascript is to actual Java, because the first two were actually derived from their namesakes.

And at the end of the day, they’re all scripting languages, the large majority of which aren’t Turing complete–unlike Java, C, C++, and C#.

I’m also dabbling in Unity (new year’s resolution to start making games too? ;)) and I decided to go c#, on the basis that it’s probably more portable, and because Javascript in Unity isn’t really javascript, as I understand. There are some ares where Unity has its own implementation of javascript, and rather than futz about with figuring out what those are, it’s probably better to just go ahead and learn a new language.

Incidentally, if you’re getting into hobby game development, I’d like to follow your progress if you’re charting it. :slight_smile: I started my blog, tabbynat devblog, to chart my progress, and I’d like to follow along with other hobby game developers as well!

I don’t think I’ve ever seen a scripting language that wasn’t Turing complete. It may be a royal pain to write complex code in some of them, but it can be done.

C++ is probably going to be the most foreign because it’s the only one of them that has manual memory management. It will also almost surely be harder to read arbitrary C++ after learning the others because of all the goddamned features in the language. He’ll be able to write a basic C++ with references, sure, but he won’t be able to read any implementation with template-based metaprogramming or any of that nonsense.

I wouldn’t call C# “portable”. It’s developed by Microsoft, and runs best on Windows. C# only runs on other platforms by grace of a toolchain called Mono, which has decent support but I hear is recently becoming sketchy. Javascript is probably the most platform independent choice between C# and Javascript, but C# probably gives you the best performance if you use it correctly.

As far as Javascript, C#, and C++, I don’t think you can write GameObject components in C++ in Unity. I think you’re stuck between UnityScript (Unity’s Javascript) and C#, I’ve never seen reference to people being able to use C++ for it.

If you can simulate an object with a tape and one read head, such that the head can move left and write, read a symbol, write a symbol, and perform a state transition, your language is Turing Complete. I think all the languages mentioned qualify.

A slight hijack, but I too am in the trying to learn Unity without much programming experience boat. I didn’t get terribly far when I tried last year, but the introduction of built in 2D features has inspired me to give it another go. If anyone can point me in the direction of some good tutorials I would appreciate it greatly. My problem before was that there were a ton of “this is an if statement” absolute beginner level tutorials and guides, and plenty of advanced guides for specific features, but very little in the way of intermediate level help.

I used this, http://pixelnest.io/tutorials/2d-game-unity/.

Honestly, though, it depends on what you want to make, and what you already know. The tutorial above teaches you how to use Unity as a sort of “game maker”, relying mostly on Unity to handle physics and collisions etc, but the same may not be as relevant if you’re say programming snake.

When you say “not much experience”, can you make a simple program in any language? Making say a match 3 is very different from making pong, or snake, for that matter. Each will require different structures and skills.

The exercise I’m working on now is to make snake, one of the old games I used to be able to make in Pascal, and learn how different things are in c#. One piece of advice I thought was useful was to make a 70s game first (like pong, or snake), and then an 80s game, then a 90s game, and work your way up.

Snake is teaching me about objects and the new list functions, and how the game functions through an update loop (as well as the whole “scope of variables” thing that never came up in functional programming). The next thing I’m going to learn is to make an endless runner, that will probably teach me about the physics engine and platforming.

C# is usually the language best supported by the community. Whether you’re writing an app, a desktop application or what have you, you can usually find a ton of examples for a C# implementation. And from what I’ve seen of Unity, it doesn’t deviate from this.

So I’d say go with C# for the best chance at having any issues you might run into explained online someplace.

For the most part, the level of coding you would be doing in Unity isn’t very complex anyway, Define an entity here, leverage pathfinding algorithm/collision detection API there, etc. so in terms of difficulty, you’re probably looking at about the same level of effort whether you go for C# or js.

That’s actually the exact tutorial I’ve been working through recently. I wouldn’t really know how to quantify my ability, to be honest. I certainly don’t know how to use many languages, pretty much just basic C# stuff through Unity. When it comes right down to it, I’m not particularly interested in learning low level programming, I just want to be able to make games as a hobby project.

I’ve been developing for Unity at work for about a year and a half. I normally do a lot of development in Java, Javascript, Python, and sometimes when I’m feeling masochistic, Perl. I generally pretty much hate doing development on windows, so I haven’t done much .net.

I’d say go with C#.

Most of the examples and tutorials, as well as the help you might get on the Unity message boards, is going to be in C#. Unity’s Javascript implementation is quirky enough that knowing Javascript, or using 3rd party Javascript documentation, may actually be more of a hinderance than a help.

Really, when you’re programming for Unity you’re mostly setting up basic data structures and calling Unity API calls, so it’s not like the language matters that much. Everything is running inside Unity anyway, so it’s not like you can get performance increases simply by switching languages.

Unity certainly seems popular. Any reasons for a single dev to go with anything else?

I have a small game in production and I’ve been iterating on the engine (c++ DX 11) but It’s getting way complex for what is a simple game.

I dunno. If you’re not doing 3d, I guess there are other leaner engines out there, probably more suited to what you’re doing (rpg, platformer), but as a general tool, Unity seems to do fine. Scales up all the way to AAA games, so you know that your skills will always be relevant (somehow, I doubt big studios use Game Maker).

Also, the ability to port quickly to just about every platform out there is really nice.

The downside is that if you’re making enough money, Unity wants a cut, but hey…

I’ve been working through the tutorials from the Walker Boys.

The tutorials contain a huge amount of professional content (300+ video lectures) and you will build 4 types of games (a point and click game, a space shooter, a 2D Mario clone, and a 3D Mario clone).

All the examples and coding in the tutorials are in JavaScript. It should be also noted that the tutorials were done about 2 years ago, so occasionally you will have to tweak something because of changes to Unity. The particle system in particular is something that has been completely overhauled since then. There are beginner sections on coding, but those can be skipped.

I think for 2D in particular, you should try and look for tutorials that address the new 2D system that Unity has in 4.3. From tutorials I have seen, apparently 2d in the past was handled really kludgily.