javascript vs C#

we’re at the beginning of a potentially large project, and although we just jumped in using javascript (mostly because most of the examples are in javascript) it’s not at all to late to standardize on C#.

my worry really has to do with code reuse and the creation of clean, oo code. C# gives you all the language and oo advantages of java (inheritance, extension, interfaces, etc). javascript can to some extent emulate things like that, as a prototype based language it will always feel a little like a hack.

so people, lets hear it: if you want to invest a lot of money on a project, with high hopes w/r/t creating reusable code libs on the way, what’s it gonna be: javascript or C#?

thanks!

Unity’s Javascript isn’t actually like that. It does do extensions etc., and doesn’t do the prototype thing. I’d say use whatever language you’re more comfortable with. (See, this is why Javascript in Unity should be called something else, 'cause it’s not really Javascript in a lot of ways and thus gives the wrong impression. :wink: )

–Eric

C# is faster because it’s a strongly typed languge, so the compiler don’t have to guess what’s going on. For the same reason I think it’s easyer to mantain a big project or create reusable code in c#. If you choose it, search the forum about programming/debugging unity code with visual studio 2005.

C# is not faster…this has been mentioned a number of times now. :wink: The Javascript in Unity is also strongly typed (unlike that other Javascript), although you can use dynamic typing if you want to (which is slower, yes). You can also completely prevent it from ever happening (put #pragma strict at the top of your scripts), though it normally doesn’t happen anyway.

From a OO/performance point of view, there’s no reason to choose C# over Unity’s Javascript. The only reason is if you have a preference for the language, or want to use something like Visual Studio.

–Eric

I’ve gone with C# because of the difference a really good, language-aware editor (Visual Studio w/ VMWare, and, recently, MonoDevelop) makes to productivity, as well as to the understanding / learning of a new language. While most of the examples are in JS and JS is less verbose, I find the feed back and assistance I get from the editors mentioned above are invaluable.

Now, having said that, JS is the simpler of the two, which means that non-programmers will probably find it easier to work with if they have to. Also, JS has been around longer and is a pretty popular language so, if you need additional programming help, you’ll probably be able to find people who have some familiarity with JS.

HTH,
David

Unless things have changed while I wasn’t watching, Unity’s Javascript doesn’t seem to support virtual methods, so that could be an impediment for certain kinds of OO design.

To me, there’s a few reasons for using C#: I like the language a lot more and I have a much better “editor” for it (namely Visual Studio 2005 / 2008, running in VMWare Fusion). There may be JavaScript editors out there with Intellisense (er, Visual Studio 2008, for instance :wink: ), but I think C# simply sits much better in the .NET environment than UnityScript (let’s not call it JavaScript anymore :wink: ).

Also C# is standardized and behaves like C# everywhere else, while UnityScript is pretty much proprietary and is probable “almost the same as JavaScript” in many cases, but “well, better” (but how exactly) in other cases…

I’d say “IDEs that support intellisense, IDEs that support refactoring, IDEs that support version control integration, IDEs that support UML class modelling” :wink:

When it comes to refactoring: Just be sure to do class renames in Unity first (i.e. renaming the filename), so it keeps the references. And concerning version control: It’s probably best to use the Asset Server with Unity…

… if somebody shows me a tool that does roundtrip-engineering UML-modelling with JavaScript, I might change my mind about JavaScript, though (now that C# also supports dynamic typing, which looks kind of like JavaScript, eeek :wink: - but to avoid confusion: not YET in Unity, and it probably will take some time before they adopt .NET 3.0/3.5, if they do that at all). Currently, I’m not using UML modelling - but with the complexities involved in networking, I probably will again pretty soon :wink:

Jashan