🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

What is the light weight alternative to Unity ?

Started by
30 comments, last by Gnollrunner 5 years, 11 months ago
24 minutes ago, SillyCow said:

The number of times I have to open a browser and google something when I work with Unreal is much larger, because C++ is harder for the IDE to parse. 

Well C++ does work with intellisense, It may not work as well as with C#. I can't speak to that because I haven't programmed in C# much. I find the main trick to using intellisense with C++ is to keep your code in a pretty good state. That means compile often to at least get rid of syntax errors, especially where templates are involved.

I don't really have a problem with C# or Java, but they do have some major performance hits, and put some big constraints on how you can do things.

Advertisement
1 hour ago, gaxio said:

A few things in your code are needlessly verbose.

Picking up my programming habits, sorry about that; at this point it is ingrained into me.

Because I make a lot of games on mobile I have run into some problems when multiplying vectors with other data types. So because vector * float is slower than float * float I avoid it.

The way I would have done this if used in my own game is like this:


void MoveObject(float InXAxis, float InYAxis){
	transform.position +=
      new vector3(InXAxis * Speed * Time.DeltaTime, InYAxis * Speed * Time.DeltaTime,0);
}

 

2 hours ago, gaxio said:

And you're really all over the place with your naming

As you can see my real naming methods are even worse. I add "In" to everything that goes into a function. All functions must have two descriptive properties in the name, so I get less naming problems like damage.damage(). Lastly all my own code should start with a capital letter, that way I can see what functions are my own; because it is more likely to have bugs.

All these tricks are things I developed while coding my own games. I am not a programmer, everything I know I learned the hard way. They are redundant but has helped me makeover sixteen games from start to end now.

The other problems is probably from me not testing the code.

 

As a non programmer I prefer the whole over naming thing if it helps make things clear.

I only avoid words like "manager" and "system" that don't actually mean much, even so I still use them from time to time. Object here tells me the function moves a Unity object and won't work on moving a pixel or something else.

2 hours ago, Gnollrunner said:

Well C++ does work with intellisense, It may not work as well as with C#. I can't speak to that because I haven't programmed in C# much. I find the main trick to using intellisense with C++ is to keep your code in a pretty good state. That means compile often to at least get rid of syntax errors, especially where templates are involved.

The best code completion and refactoring tools for the other popular languages. (Javascript[webstorm] ,Python[pycharm] ,C++[visual-assist] ,etc...)

do not come close to what you get for C# and Java.

In C# and Java I sometimes create whole classes and interfaces just by using automatic refactoring tools. In C++ for example refactoring doesn't yield the same trusted result, and usually fails for all but the most trivial refactoring tasks. Same goes for auto completion. I think that the preprocessor is to blame for this. And many engines make heavy use of preprocessor directives.

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

22 minutes ago, Scouting Ninja said:

Because I make a lot of games on mobile I have run into some problems when multiplying vectors with other data types. So because vector * float is slower than float * float I avoid it.

What ? You mean you have run into performance problems because of something like that ? That doesn't sound likely at all. All vector * float really is, is:
 


    public static Vector3 operator *(Vector3 lhs, float rhs)
    {
        return new Vector3(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs);
    }

Apart from that, that code snippet isn't too bad. If you're working with the separate components instead of directly using the constructor, that's really just style at that point. ("this" is pretty redundant though, yeah.)

Btw.

Quote

I want to point out that Java is no longer supported by Unity. C# is Unity's main language for users now.

That's "Javascript" or rather UnityScript right there. Doesn't have too much in common with Java.

3 minutes ago, SillyCow said:

The best code completion and refactoring tools for the other popular languages. (Javascript[webstorm] ,Python[pycharm] ,C++[visual-assist] ,etc...)

do not come close to what you get for C# and Java.

In C# and Java I sometimes create whole classes and interfaces just by using automatic refactoring tools. In C++ for example refactoring doesn't yield the same trusted result, and usually fails for all but the most trivial refactoring tasks. Same goes for auto completion. I think that the preprocessor is to blame for this. And many engines make heavy use of preprocessor directives.

I don't think I want whole classes being created for me, but I suppose that's a matter of preference.  Auto completion with C++ however works fine for me in Visual Studio. If it ever stops working it means I've messed something up big time which means I immediately go and fix it.

For me most of this is kind of irrelevant however, because again, I don't want to take the performance hit, I don't want to use a GC, I  sometimes use multiple inheritance which C# doesn't support, and I often use arrays of classes and/or structs (not references to them) which Java doesn't support. (correct me if I wrong on any of this because it's been a while since I programmed in Java or C#, so things may have changed)

59 minutes ago, Gnollrunner said:

I don't want to use a GC

If it's only the GC that's bothering you, you can circumvent this problem by not using the "new" keyword too often and recycling your classes. Using "new" in C++ isn't such a great idea either because it will lead to alot memory fragmentation. I tend to try and avoid heap memory allocation in real time games altogether. In unity's C# for example "new Vector3" does not create a reference.

1 hour ago, Gnollrunner said:

I often use arrays of classes and/or structs (not references to them) which Java doesn't support. (correct me if I wrong on any of this because it's been a while since I programmed in Java or C#, so things may have changed)

You are completely right. But what kind of game are you making (and on what hardware?) where this is a real performance issue? Today's smartphones are powerful enough to overcome most of this. And the really core performance code in engines is written in C++ anyway. Whether  you are using Unity or Unreal, both engines' core functions are not written in a scripting language. While you might be coding for some extremely low spec device, I doubt any of the engines target such devices so I assume you are talking about smartphones here. And with smartphones, it's usually the GPU's fragment shaders that set the performance bottleneck. 

With CPUs, unless you are writing your own physics, or some really fancy AI I doubt any of this would matter. Unless you are note optimising your code (making too many real time memory allocations and such). But you can write bad code in any language...

 

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

1 minute ago, SillyCow said:

If it's only the GC that's bothering you, you can circumvent this problem by not using the "new" keyword too often and recycling your classes. Using "new" in C++ isn't such a great idea either because it will lead to alot memory fragmentation. I tend to try and avoid heap memory allocation in real time games altogether. In unity's C# for example "new Vector3" does not create a reference.

 

I don't know how anyone can avoid heap allocation in programs of any size. That goes for Java, C# or C++. Objects on the stack go away when you leave a routine. The only other option is static/global objects, so yeah I guess if you want to go back to old Fortran style you can do it, but you can end up with a lot of wasted memory.

New in C++ is only as bad as the implementation and I would guess in most performance sensitive cases it's generally overloaded. I almost never use stock new.  I only use it for the simplest things. My current heap implementation uses VirtualAlloc and has slabs, free-lists,8 byte aligned 32 bit pointers (on 64 bit machines) and other such things to make allocation as fast as possible and use as little memory as I can get away with.

Quote

You are completely right. But what kind of game are you making (and on what hardware?) where this is a real performance issue? Today's smartphones are powerful enough to overcome most of this. And the really core performance code in engines is written in C++ anyway.

 

Well I'm working on an MMO planet engine. It uses voxels, run time fractal functions and stuff like that. It has to be capable of generating terrain for a whole planet without actually storing it on disk.  It has to generate two versions of the planet, one for viewing and a very localized version for physics, although admittedly the physics isn't so complex. It's just basically pill to mesh collision and response, and gravity, but since the planet is spherical I can't use any cheats that require one axis to always be "up". 

 

Quote

With CPUs, unless you are writing your own physics, or some really fancy AI I doubt any of this would matter. Unless you are note optimising your code (making too many real time memory allocations and such). But you can write bad code in any language...

 While it's true that some applications can afford to give away performance, that's far from universally true especially with cutting edge games.  With efficient code you can always do more with less. If nothing else, the game will run decently on older computers. I've bench-marked C++ vs C# vs Java many times, and C++ always comes out much faster, sometimes several times faster.

One more comment, memory allocations can be nearly free.  Most of time time when I allocate something it just pops a bit of memory off of a free list. The code for it is even in the header file so it's inlined. Only on occasion do I have to allocate a new slab. Freeing memory is the same story. I would much rather have a good heap system then trying to reuse memory from old objects in the code of the application.  That sounds like a nightmare to me.

23 minutes ago, Gnollrunner said:

I've bench-marked C++ vs C# vs Java many times, and C++ always comes out much faster, sometimes several times faster.

Good C++ is always faster than good C# or Java. However the point I was trying to make about game engines is that even if you write your game logic in C#, it is very rare for most of your execution time to be gamelogic. And the actual engine core code is usually written in C++.

Compare this to the mobile browser wars of earlier this decade: Android always boasted a faster JavaScript engine than iOS. Yet mobile Safari allways blew it away in terms of performance. Why? Because when dealing with multimedia web-sites, Javascript was rarely the performance bottleneck. It was the browser's rendering engine which was doing all the heavy lifting.

Game engine performance tends to work in much the same way.

However, if you are one of the rare few doing cutting edge CPU work on your game, then you should be using C++.

23 minutes ago, Gnollrunner said:

I don't know how anyone can avoid heap allocation in programs of any size. That goes for Java, C# or C++. Objects on the stack go away when you leave a routine

It's not about "no heap allocation whatsoever". But rather trying not to do any real time heap allocations. Try not to call "new/malloc" when your game is running. If you are using C++ try not to call "delete/free" when your game is running. Just preallocate as much as you can at the beginning and recycle it as much as you can. For ex: I wrote a rather complex pathfinding algorithm for an RTS. The performance more than doubled if I "recycled" my memory structures when I was done with them. So subsequent calls would just reinitialise the memory structures from the previous calls.

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

8 hours ago, SillyCow said:

Same goes for auto completion. I think that the preprocessor is to blame for this. And many engines make heavy use of preprocessor directives.

Funny, I rarely if ever have issues with Visual Studios auto completion.  Been using it for years too.  Now and then it gets the wrong type, but like, once a week.  Might be more often then C# or Java but honestly, it's actually really good considering how much more complex C++ is compared to Java or C#.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

5 hours ago, SillyCow said:

Good C++ is always faster than good C# or Java. However the point I was trying to make about game engines is that even if you write your game logic in C#, it is very rare for most of your execution time to be gamelogic. And the actual engine core code is usually written in C++.

This is very true indeed.  Game logic is rarely a bottle neck, and honestly if it is, the culprit can be extracted and moved into the C++ side of things in a lot of cases (not so much with Unity though) or likely given a very heavy working over to optimize it for the current language.  For game logic I prefer languages like C#/Lua as C++ is very much overkill.

Now for @sprotz

Quote

I am a natural programmer, I simply prefer simplicity.  and neatness.

The irony in that "sentence" is rather strong, but I'm just hopeful you were going for humor.  Yes, simplistic code is preferred by most programmers.  But simplistic rarely means short.  You want verbose but still concise names for functions and variables so when you return to the code in several months or years, it takes mere minutes to get back up to speed instead of hours.  Single and double letter variables should be outlawed with penalty of death, in most cases.  And just an aside, I've never met a programmer, "natural" or not, that really balked at such trivial things in a language that actually benefit them like you do, especially in such popular languages (they're popular for a reason, typically simplicity or usability).  But YMMV.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

This topic is closed to new replies.

Advertisement