Why all the C# vs Javascript bashing? It's all UnityScript anyway!

I have noticed all over (especially on other forums, or asset store script plugin comment sections or forums) there are a lot of people who bash Javascript, acting as though if the script package isn’t in C#, they refuse to buy it.

I may just be an amateur programmer, but I had started with C# (due to this bashing, and the unfounded claims that C# is superior) but was forced to change to Javascript when I accepted a position at a small game company. The result? I actually liked Javascript a lot better because it was simpler and time savvy, but in the end… it didn’t seem to matter. I’m back to C# just because burgzerg’s tutorials are in C#. Really I could care less, and view the differences to be null. I could easily buy a script package in Javascript and code in C#, and see no differences even if I have to edit. Who cares?

Honestly, it took me about 5 minutes to change from C# to Javascript, even though I had no experience with the latter. They are identical in Unity3D, calling the same functions, and declaring variables in only a slightly different way.
In Unity3D, they don’t seem to be different languages at all, but two dialects of the same language. You know one, you pretty much know the other.

My only rationale for the posh “Pft, it’s not in C#, thus it is worthless!” comments is that these are merely from former XNA fanboys whose programming knowledge is about as shallow as the differences between the two “Languages”. I severely doubt I am “special” and it was easy for only me to learn the differences and switch in a matter of minutes. Come on, if I can learn the differences and switch over at any time, I see no reason for all the bad vibes, childish fighting, or claims of superiority (which always seem to be on the C# side).

I’d be much more apt to bash Mac/PC than C#/Javascript, hahahahhaa jk :stuck_out_tongue:

Most of the people i talk to just say that C# has more control, but from what i’ve seen in Unity it doesn’t seem to be anything significant, more like wasting lines to do things that JS just goes ahead and implies. I figured people just liked seeing that extra information they’re used to.

Either way you’re right, one is not better than the other in Unity.

I don’t see much reason to bash on either one as long as the UScript is also strongly typed (#pragma strict). Any loosely typed scripting is bound to cause trouble eventually and is almost never a good ideea.

A lot of people do indeed sneer at unity js, and there’s really no reason they do except to feel superior.

c# is a better idea if you are intending to use plenty of online c# resources, but porting is trivial enough. I come from a C++ background so using c# isn’t hard - but I prefer js all the way. It is just enjoyable, isn’t slower and just as easy to code in. I don’t see any harm using unity js, I just wish they didn’t call it javascript. US or unityscript is fine.

There’s a small downside to working with both languages in the same project however (as said here http://forum.unity3d.com/threads/62049-Included-dll-filesize-info )

And as long as you type your variables and follow everything said here ( http://unity3d.com/support/documentation/ScriptReference/index.Performance_Optimization.html ) , UScript should do just fine.

UnityScript is Unity Only, compared to the Universal C#, so maybe because C# is the “industry standard”, people feel superior while using it. Maybe because it takes more to write the code, they belive it has more control, I dont know. I dont see what the big deal is if js can do what C# does but easier for me

It doesn’t (not in Unity anyway) and not if you’re using UScript the right way.

It does indeed have the benefit of learning the syntax of a more commonly used language.

Unfortunately… it does. It’s trivial but try this: obj.transform.position.x = 10; in c#. Bit more code eh? Its trivial, but its correct that c# does take more code.

I’m with hippocoder, both are fine, I just hate that they call it javascript when it’s really not. I prefer C# myself, but it’s only because it’s a better documented language. If I need to see the syntax for using Interfaces in C#, it’s there in MSDN docs. How bout the syntax for Generics? How about properties (getters/setters)? Anonymous functions? I haven’t found a good page that describes the US language. I know they’ve been steadily adding more features to US, but am not really sure how it compares to C# as far as basic language features because I haven’t been able to find the documentation.

Anyways, those are the reasons that I choose C# over US. The syntactical sugar US adds is nice for simple scripts, but not worth the documentation gap IMO.

I don’t see much point in “bashing” JavaScript/UnityScript because everyone has to use the language they can best work with. People are different, with different things they like or dislike, so what one person loves about UnityScript (or C#) is what another person hates about it.

However, I certainly wouldn’t buy packages that are not C# simply because I’ve had a lot of trouble with UnityScript code in my project. So basically, I have a policy that there can’t be any UnityScript in my project - only pure C#. It’s annoying enough that I have to convert some of the standard packages that come with Unity.

Some of the things that I ran into that made me come up with this policy:

  • DLLs included in iOS builds for no apparent reason (and I literally spent half a day trying to figure out which script caused this … eventually I found the script - but I wasn’t able to figure out why it caused the DLL to be included, so I also wasn’t able to fix it … some people may like that UnityScript isn’t as “verbose” as C# - this is one example for why personally, I absolutely do not like that “feature” of hiding quite a bit of stuff that in the end is still done “under the surface”)
  • Project being broken after the 3.4 update because UT changed how strict the UnityScript compiler was (and what broke was actually code that came from UT … wish they wouldn’t use UnityScript so much :-/ ) … basically, it turned out that the pre-3.4 UnityScript compiler was a complete failure - but seemingly, everyone was taking advantage of that including the folks at UT :wink:
  • Speaking of being “verbose”: UnityScript allows the developers to do a lot of things that make it much harder for me to understand what the code is actually doing. I know that for people that like UnityScript, this is a great “feature” - but for me, it’s a PITA. I want code that tells me exactly what it’s doing, and I want an IDE that also knows exactly what the code is doing.
  • Speaking of IDEs: I’m using Visual Studio - and Visual Studio doesn’t get along too well with that odd dialect of JavaScript that UnityScript is; so I’d have to use MonoDevelop for UnityScript (and last time I checked support wasn’t as good as support for C# is - which isn’t surprising), and Visual Studio for C# … I’d rather only use Visual Studio (because MonoDevelop just isn’t my IDE of choice)
  • Having to move stuff around so I can access it properly (“compilation order”)

While it’s possible to use all 3 languages in a project, I personally wouldn’t want to do it anymore. In Visual Studio, navigating any C# code - even code from other folks - is just fun. With UnityScript, it’s just not as convenient for me (MonoDevelop might eventually get there - Visual Studio never will).

That has nothing to do with C# being “superior” … it’s just that I happen to use C# in my project, have everything set up for C# development and adding stuff in other languages causes me more problems than it solves. So I made it a policy to not do it.

When I publish stuff to the AssetStore I try my best to support at least C# + UnityScript (I’d love to also support Boo but I’d first have to learn that, so for now, I simply can’t without spending more time than I’m willing to spend). In any case, that only covers code examples and only to the point where I get annoyed by adding the UnityScript stuff :wink:

Oh gosh, I can’t wait to get my one night a week class over with and clean up the house, so I can finally start making some programming progress my game! :slight_smile:

I’m so excited!!!

Thanks for the advise to try and not mix the languages. I’ll use javascript whenever I get better at programming, but for now I’ll stick with C# since that is what some of the heavier scripts in many tutorials use, like burgzerg’s.

But then again… perhaps I should implement everything in Unityscript (js) despite the tutorials being in C#. This allows me to actually better force myself to UNDERSTAND what is happening and why, because I’ll basically have to rewrite each script using the C# as reference.

Part of this is just the trap of the natural fear of “limitations”.
While the reality is that for 95 to 99% of projects, Unity Script is perfectly sufficient, people fear that last 1 to 5% and thus jump on the bandwagon of using C# because of it.

This is the same thought process that gets people to use Max, Maya, Softimage, etc. instead of Blender, Lightwave, etc. It’s also the same thought process that makes people jump on the UDK/Cryengine bandwagon rather than using Unity itself. It even gets people to purchase more expensive brand name items when something more generic may be sufficient for their needs.

No one wants to pick something up thinking that there may be a time down the road where they may find some “limitation” which may cause them more work (even if it’s a small amount) or cause them to have to do things in a different way than they’ve learned (even if the other way may be better), or may cause them to change their expectations of what will be in their project (even if this may be faster and/or more appropriate for their project).

Unfortunately, this thought process is seldom linked to what they are actually going to be accomplishing and/or what they’re currently capable of completing, and also obscures the limitations in the “name brand” they’ve chosen. Once that investment of time is made in learning something, they need to believe they made the right choice and don’t want to have to go back and start from scratch. These people become the spokesmen for their particular choice. This is how “brands” are created, and make no mistake, C# is a brand as much as Unity, or even Unityscript itself.

This is compounded by the fact that programming, modeling, etc., can be difficult for people to learn. Therefore, if people have to choose a path to start walking down, they may as well choose the path that (seemingly) has the least hiccups, even if that path may be more complex, more expensive, yet may not “really” be any faster or better. There’s the term “right tool for the right job”, but most often this gets bastardized into “pick the biggest tool with the broadest acceptance”, just in case, otherwise you may need to invest in another tool. Even though the two small tools may be less costly than the big tool, and you may have to go with another smaller tool anyway, even with the big tool.

This is perfectly natural, and a trap I sometimes fall into myself. It’s what inhibits progress in people who think too much about what they’re going to do, rather than just sitting down and doing it. However, it’s also the same type of thinking that pushes the economy forward and gets people to buy items at a premium price.

Not sure what unityscript can support out of these, but I mainly use c# for the following reasons:

sealed classes (runtime speedup. A good majority of classes can be declared as sealed in a unity project.)
structs (runtime speedup)
interfaces
default accessor is private, instead of public
#region
ide support (I prefer visual studio far more than monodevelop, and even monodevelop’s unityscript support is rather lacking)

I do use unityscript though if I have a really simple script, like function Update() { transform.Translate(Vector3.forward);}

edit:
Linq as well.

I’m fine with javascript as it is, in fact I think javascript is delicious, and I’d need a really good reason to switch to C#.

If I were used to C# instead, I reckon it should be exactly the opposite!

So far the heavier point (from my perspective) would be if I were to sell a script, I wouldn’t be supporting C# users! But then again, if I did everything in C#, what about javascript users?

My conclusion is, unless you’ve got the time/energy/focus/commitment to learn both, pick one, and go with the flow!

Why have multiple languages to begin with when they all offer (mostly) the same thing, and all write (mostly) the same,and all run the same?

Same reason spanish and portugese aren’t merged into Spantugese.

Or Portunhol.

As for my 2 cents on the US vs C#, one thing I really miss in UnityScript is generics, and not having a free IDE where you have a good code complete and an easy refactoring system, make C# with VisualStudio my favourite solution (Monodevelop, especially in this new 3.4 release, is an epic fail). I don’t mind typing more in C# when these two things work well.

C# is clear and neatly arranged to my brain.

@ dart what is your problem with Mono develop ?

@dart: You’re right! What about portunhol?? XD

I live in Chuy, Uruguay, btw! (there’s a lot of portunhol going around here!)

It doesn’t work well in OS X Lion, at least not for me, it crashes all the times and this new version generates a lot of confusing project files. It took me sometime to figure out which one to use. In the previous releases it was a regular option. Nothing compares to Visual Studio with Visual Assist Plugin when we’re talking about C#.