C# or JS

I am a C coder, I tryed python in past and had a hard time. But I am moving to unity in hope to get a better support on the scripting part (on a game engine). So for me C# might be more suitable (maybe not), but what support from community will I get. Should I try JS? Also I have alot to learn and I usualy read demo codes to get to know something, is all doc in JS?

Thanks

yes, i think you should try Js.
i was scripting with Adobe flash CS4 (actionscript) and when i tried Unity, i had to try Js, and yet, 1 month after it, i can make a networking multiplayer FPS, so, i think that you can easly try Js :wink:

I recommend c# .

I have a background with c++ and maya’s mel script .
C# seemed to be a breeze to move to .

What I recommend is any of the .js scripts that are supplied and you use convert them to c#. I did this for the camera and it was a great way to learn c# syntax (vs .js)

Also I totally recommend the Visual Studio c# express. Its free and integrates awesomely with unity.

http://lucasmeijer.com/posts/visualstudio-integration-for-unity25-itemtemplates/

Also… get onto the unity3d irc channel. Its full of tonnes of really useful coders (many using c#)

-LW

There’s a significant difference between C C++ or C#; just try both out.

I think it doesn’t really matter which one you pick.

While there are certainly many differences between the two languages, they are almost all of them very superficial (especially within the context of programming for Unity). Most people here will be able to help you out regardless of which scripting language you use and the quality of your games will not differ if you pick one over the other.

In other words: pick the one you prefer! :wink:

(says the 15 year C++ veteran who opted for JavaScript)

JS is opted for simplicity and C# for power.
The later has many professional features you don’t have in JS, also you have the 10’000 as large pool of resources and naturally also devs should you need them

Use both:

I quite like the Javascript syntax, when I started out with unity I used it quite a bit just because it was fun. It’s also useful to learn even if you’re going to be doing most of your code in C# because there are a lot of Javascript examples.

As I started doing more advanced work I found it easier to do it in C#.

When you start including other assemblies and you need to be a more explicit it just seems more natural.

Oh… another thing that’s important to consider.

With Unity javascript you will typically only do a single implementation of MonoBehaviour per file. Every function you declare is pretty much a method. So it means that you have to type a bit less boilerplate code but it also means that you can’t do class declarations.

With C# it’s easier to put multiple class definitions in the same file. So If you’re doing anything that requires you to create your own class definitions besides MonoBehaviour implementations C# seems like the better way to go.

One thing which Dreamora mentioned, and which I find one of the biggest factors, is the amount of help each language has associated with it. Nothing to do with your actual personal knowledge, but your ability to find answers to your questions.

Unity’s version of Javascript is not mainstream JavaScript, which is one barrier. Generally JavaScript is not used for complicated programming, so you won’t have as many programming sites featuring JavaScript as opposed to C#. Lastly, I expect most of the programmers who frequent this forum use C#, and not JavaScript, so when asking scripting related questions, I believe it’s easier to do so with C#.

The amount of material, websites, books, etc, is greater for C#, then JavaScript, especially this derivative, UnityScript. So, getting through the basics may be easier with JS, but in the long term, you’re going to wish you had Google behind you to answer your questions.

Additionally, if you intend to go to the iphone with your project, keep in mind that the simplicity is gone.
You will have to learn things like casting as well as different other things.

Ahem

Google Maps? Gmail? Mobile Me? Just to name a few…

I dunno what your definition of “complicated programming” is, but I’d say those should all fall well within your definition! :stuck_out_tongue:

In the end, talking about C# vs JavaScript is a bit like carpenters arguing about which is the finest brand of hammer. Better spend your time driving down those nails! :wink:

Those applications are not scripted completely in JavaScript, but use a handful of languages and technologies. They Use JavaScript, yes, especially on the front-end, but not in the actual core of the app which really gives it power.

And I have to disagree about the brand of hammer argument. That’s how most of this JS vs C# topics go. “Whatever you’re comfortable with, they’re both equal!” When in fact, they are not. Whatever you’re comfortable with will surely help you get started, but in the long run you will need reference material, and the more reference material available, the better you will be even if you are using a language you initially weren’t familiar with.

Yes, your personal history with JS or C will come in to play, but you need to keep in mind the available references there are for C#, versus JavaScript, as well as the fact that Unity uses .Net C# (not the latest version, but the standard one), while the JavaScript is modified, and not the same as the typical browser language.

What matters is your understanding of the Unity API, not which language you type your scripts in. Especially when we’re talking about such syntactically similar languages as C# and JavaScript. They’re basically two different dialects of the same root language (namely C).

It doesn’t really matter whether or not there are more reference materials available for C# (which I seriously doubt, since JavaScript is a much older language with a much wider user base). If YOU have an easier time writing JavaScript, use that! If YOU have an easier time writing C#, use that! Heck, you can even mix the two if that rocks your boat.

In the end, all that matters are two things:

  1. that you finish your game
  2. that other people enjoy playing it

If as you say you’re familiar with C syntax, then you should be able to pick up and run with either language quite easily.

Personally I prefer javascript. It’s not just that all the docs have javascript examples and 90% of the forum posts have answers in the same. It’s that C# is a very verbose language. Each of the two languages is equally capable of producing the same game. Just one of can do it with a hell of a lot less typing.

I use both C# and Unity Javascript, and I recommend learning the best of both. I’m quite impressed at how easily it is for the two languages to cross-interact in Unity (cross-dependencies must be in certain folders).

Unity Javascript is great if you have jack-of-all-trades development partners. The way it hides MonoBehaviour derivation details and initialization makes it much easier to deal with and comprehend. Its simple approach to untyped variables (and ease of calling member functions of such variables) is well suited to coders with little experience, where efficiency isn’t a big concern. It’s cool that you can access the C# standard classes and functions from Javascript.

C# is the way to go for efficient array usage, virtual functions, interfaces and get/set properties.

Boo seems to be forgotten in most of these so I thought I’d pop in and mention that. If you’re familiar with Python, it’ll have a familiar syntax. If you’re not, it’ll still save you years of life from semi-colon and brace typing!

The only caveat is there’s not many examples in it, so you have to be comfortable translating C#/JS code into Boo which is not hard but may be an extra unwanted step for someone new to writing code.

C# has much better cross-platform prospects aswell, with much greater opportunities for code reuse if you decide to use other platforms/engines.

This is all true however I would give my left nut to for Unity’s official docs to have a C# version. :slight_smile:

Was mentioned to happen :slight_smile:

THank guy. I am looking at the tutorial, quite confuing. I think JS is object oriented. I learned programmation with Basic, autohotkey, C. I think I am missing something. On section 4 of the scrip tutorial
they say: “function belonging to the transform”
why not just saying transfor (x,y,z)

no I have to type
transform.Translate(x,y,z)
?