So, I’m new to Unity and it seems to be fantastic. I’ve previously made, and released an iPhone game (all in XCode). I was paying a lot of attention to Apple’s policies on “3rd Party Tools” and that whole firestorm.
So, I thought that C# wouldn’t work for doing an iOS game - from a few things I’ve seen in documentation, would I be correct in saying that C# is suggested for development of an iOS game?
I know both C# and JS equally well (a little bit), so the learning curve would be the same. I just thought that since Apple is anti-everything-not-apple that C# on iOS wouldn’t work.
So, which language would yield better performance (iOS) and cleaner code (i.e. less hoops to jump through to get things done)?
No, that’s irrelevant now. Even if it wasn’t, JS wouldn’t be any more “acceptable” than C# anyway.
Neither, they are the same.
Depends on what you’re doing, but for typical game stuff, coroutines, etc. it would be JS. C# has some “programmy” things that JS lacks though. If you’re using iOS Pro, JS adds a tiny bit to the file size, but if you don’t have Pro, it adds a few hundred KB.
Excellent. Thanks for the replies, it’s down to flavor for me then. Great to hear that performance is the same in either. I guess the guys at Unity did a great job! I’m loving the tool, that’s for sure.
@anomalous, not quite. JS doesn’t get LINQ, extensions methods and gazillion tutorials all over the web like C# does. Nor does it get anywhere near the level of autocomplete assistance from MonoDevelop. As time goes on and we get dual core CPU’s (I’m looking at you iPad 2) PLINQ and the Parallel family of methods in C# will be huge gains for next to no extra coding.
Just the autocomplete is enough for me to go with C# - throw in LINQ as Prime31 said and you’ve got knock-down killer development going on. I’m quite glad I made this post because of all the information coming out of it.
@anomalous, LINQ to SQL isn’t present in Unity. You get all the standard LINQ extensions. Check out my YouTube channel for more info. I have been pushing out some tutorials on some of the neater aspects of C# that most folks don’t know about. There are a couple with LINQ in them and more on the way. There is a whole pile of relatively untapped tricks out there that help make cleaner code that is easier to write and maintain. YouTube videos
PLINQ etc don’t give you any gain for the time being if you touch unity classes as they are not threadsafe.
If you care for your stability, don’t touch “P” extensions to “in calling thread executed” systems like LINQ, unless you operate on non-unity data only with them.
Should you have doubts, try it on the desktop to see unity fly around your head.
Trying it on iOS right now is useless as iOS has no possiblity to execute 2 threads in parallel, so you can never replicate non-threasafeness related instability at all.
They might at some future point be of importance, but for the coming months, they are nearly as irrelevant as .NET 4.0 is to us, which would be completely irrelevant
@dreamora, PLINQ most definitely has it’s place right now and it will definitely be nice to have for the iPad 2. Think about all the operations that happen on collections that dont write to Unity objects: pathfinding, culling calculations, etc. These types of operations can put PLINQ to great use right now. Let Mono handle distributing expensive calculations to multiple threads then once done you can modify the Unity objects with the result on the main thread.
I’m open to use benefits, but we will see what the gain of PLINQ will be.
Culling is done on C++ level by unity, wouldn’t touch it in the scripting end at all, as we don’t have access to hook in at the relevant points when the internal calc takes place, and redoing the same stuff again is definitely not going to gain much, we just burn additional power.
Pathfinding can gain naturally, but if I would use plinq, unsure, cause you would run the path finding on a thread from a worker thread pool already, spawning of more threads isn’t going to help, only hurt (also even there are problems, Aron Granbergs A* which had multithreading 2.8 switched it out again in 2.9 for example due to bite the back issues you get as unity has no fully standard mono)
I fail to see what PLINQ could gain anyway on path finding as the effective work is nothing that plinq can do and finding the nodes to work on next is nothing you would get a gain from LINQ / PLINQ as you don’t query into the blue on an unstructured set but have priority queues and alike where the overhead of the thread spawning and alike hits badly.
But I might be on the wrong path there on what you see its use being in.
If you would have said BeginInvoke to let mono handle the offloading and if BeginInvoke would use a thread pool in unity, then fully agreed