Posts Tagged Programming

Unity3D: the editor/code duality

So as most of you know I have been doing Flash for a long time and recently I have been doing Unity3d (well mostly NGUI you could say). It has been mostly fun and mostly rigid.

Rigid???

Yeah I would say rigid. Unity3d imposes you a way to work that is mostly to use the editor and not programming. They really really want you to use the editor. And coming from Flash this feels really weird. Probably because after 6 years of using Flash you kinda learn that the most you can do in code, the better and easier it is. Also, if you constantly switch between the editor and the code, it gets confusing, always switching paradigms.

GameObject for president!

GameObject is the root of everything you do in Unity, but one of the most annoying thing is that you can’t extend GameObject… Come on, let me do it, just the tip ;) . Here is what I would do if I could; I would make myself APIs for 2D. Moving something in x would be

gameObject.x = 30;

instead of

gameObject.tranform.localPosition = new Vector3d (30,  gameObject.tranform.localPosition.y, gameObject.tranform.localPosition.z);

Man have you seen the size of that thing just to move something in x???? Let me make it better for myself, I don’t care about 3D, I wouldn’t have a z value I would call it depth and it would make the code way more readable.

Encapsulation, what encapsulation

The other thing that bugs me is that to interact through code with a gameObject hierarchy you created, you basically have to know how it is built and you have to get your pieces using Find or GetComponent. Find statements are the ugliest ones as they use a string to get you what you want and is really error prone.

So you add your Script to your gameObject (proof that the editor is taking precedence over code) but to have interactions between multiple gameObject you have to do it through their scripts which you have to know their types, but have no idea if they exist and are linked or not. You’ll know at runtime when the error pops up.

Everything on a GameObject

Basically my point here is that you can’t do anything if it ain’t on a gameObject. Some core functions just won’t work if it ain’t. Like the WWW function(used to load stuff from the web) (really cryptic name if you ask me). It won’t work if it ain’t called from a MonoBehavior and MonoBehaviors can’t be instantiated, it needs to be added to a GameObject. So what about Models, code that only keep the states of an application or that loads data to hold it. Models have nothing to do with GameObjects, they should be allowed to use the WWW function. But no, if you want to, you need to create a GameObject, add to it a loading script, and wait for it to pass you back the data. Doesn’t that sound devious to you?

Let it define itself

I like Unity3d; it allows you to build for Android / iOs very easily, but the way it is so rigid really annoys me. I think that a project that is so young like Unity3D should not force the users down some path, it should let them find incredible and unthought ways of using it. I want to do 2D / UI with it and right now it is pretty annoying to do so.

, , , , , ,

6 Comments


A language of my own

Today I was checking out an introduction video to CoffeeScript and it got me thinking about programming languages in general and where they were heading. The thing is, I think I would go in a different direction. Haha, that’s a pretty bold statement and I don’t know that many programming languages to be frank, but the last two I checked out, Python and Coffee Script didn’t have the same values that I think a future programming language should have.

You see if I look back in time ( with my time machine glasses) at first there was byte code, which was the summum of being cryptic, after that there was assembly code, which I manage to pass the class by acting as if I knew wtf it was meaning. C code was already more readable but still pretty hard to juggle with and I ended up with Java / ActionScript / C# which were the most readable in all the languages I had learned. When I say readable in all this I mean closer to the English language. That for me should be a primary value when creating a new language. I think the more readable a programming language is, the less barrier there is to creating code. You wouldn’t need to translate what you think into something else, you think, talk, write and program in the same language, that would be the best I think.

There is all lot of really easy thing we could do to turn Java into something already more readable without changing the syntax. Most of it would just be replacing shortcuts like for if statements “==” would be “is equal to” so

if (myCat == yourCat)

would become

if (myCat is equal to yourCat)

I mean this is a pretty simple example, but push this further and say we add a lot of these changes where we remove symbols like > < = ¬†/ ! || && and put words instead, I think it would make code really easy to read. I think that if it is easier to read, it is easier to grasp and if it is that way you can build more complex programs more easily. When all those simple swaps are done we could work on the syntax to make it more like English and then we would have a new programming language. I would like to reclaim the dot (“.”) to mark the end of a sentence like Latin languages.

So yeah I think we should create a new programming language where you have to write more code to get things done but that has less abstractions. That might sound stupid but I think it doesn’t matter, where the language gets longer to write the code editor should pick up and do code completion to speed things up, like FDT does so well for ActionScript.

Anyway, I will probably never do so because I am not a compiler genius, but I think it would be great to head in that direction and see where it leads. Anyone thinks the same? Anyone knows of a languages that tries to do this as its primary objective?

, , , , , ,

4 Comments