Welcome, Guest. Please login or register.
May 23, 2012, 09:49:30 AM

Login with username, password and session length
Search:     Advanced search
Sometimes you feel like a nut, sometimes you don't.
109672 Posts in 6137 Topics by 2510 Members
Latest Member: vivahazelbaker
* Home Help Search Calendar Login Register
+  ROME.RO GameTalk
|-+  Gaming
| |-+  Game Development/Asset Production (Moderators: Bad Sector, daemonwolf)
| | |-+  Runtime Engine (and other stuff) DevBlog
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Print
Author Topic: Runtime Engine (and other stuff) DevBlog  (Read 1188 times)
Bad Sector
Big Fat Code Bastard
Moderator
Post Monkey
*****
Offline Offline

Posts: 1495


Braaaiins!

WWW
« on: April 15, 2009, 08:20:59 PM »

I've made a blog for the development of my new 3D game engine, Runtime Engine. You can check it here:

http://badsector.slashstone.com/

Currently there are two posts related to the engine (i'll actually post more stuff in there about what i make and most of them will be about the engine, but not all). One explain the engine so far and what are my general thoughts about it and the other explains the goals for the first milestone (i decided to try to be a little more organized this time - who knows, i might actually manage to finish something :-P).
Logged

CRC failed
Hugo
GameTalk Friend
**
Offline Offline

Posts: 182


WWW
« Reply #1 on: April 18, 2009, 10:11:32 AM »

Okay, I’m curious to see where this is going. I will keep an eye on the site, for new screenshots
(I just love fancy shots, like you had for your undead engine!).

However, I don’t understand it when choose C (instead of C++) for speed. Are you really sacrificing
efficiency and usability (I presume the engine is going to be opensource ?) for compiler speed ?

But besides that, why do you find C++ slow ? I’ve worked on multiple commercial engines and libraries
(such as edgelib , http://www.edgelib.com) which were all made in C++ . And I just don’t  get it.

If you set your project up right, it only compiles the code you changed. So that’s like 1 second maybe
3 seconds in worst case scenario . Does that bother you ? or are you talking about more than a few seconds ?

You’re also talking about how C makes your think simpler, and that the engine is all about simplicity.
How are the C namespaces, structs and global vars simpler then classes with getters and setters.
Especially for an outsider (i.e. somebody using the engine for his own project).

Don’t get me wrong. I love C. I always start/prototype in C. But as soon as the team grows I need to convert
it to C++ (because they all find it more simpler to use). So I’m just really curious  to see how you deal with those things.






Good luck with your engine!
Logged

..
Bad Sector
Big Fat Code Bastard
Moderator
Post Monkey
*****
Offline Offline

Posts: 1495


Braaaiins!

WWW
« Reply #2 on: April 19, 2009, 09:12:35 PM »

The engine won't be opensource, at least not at this point. If i decide to stop working on it (like i did with IUE - the UE version available at the site) i might release it though, but at this point i don't care what others will do with it :-P.

I find C++ slow (for compilation - for executable speed the difference is very minimal and in some cases i find the code generated by g++ to be slightly faster than the C code generated by gcc) because it takes a lot of time to process a "proper C++" source code file (with proper i might files that use C++ features such as classes, templates, namespaces, etc). I've used and wrote a lot of engines and libraries too and i still have this impression.

When i'm talking about simplicity i'm also including the ability to have everything in one's head (mine actually) and being able to follow the program's flow easily. For example this code:

Code: [Select]
foo = bar[3];

is straight dead simple what will do in C. But in C++ it is not. The assignment operator for foo might be overloaded. Or the index operator for bar. Or both. To be sure you have to know what foo's and bar's classes are and what operators they have overloaded (and looking at the class declaration code isn't enough - you have to be sure that there isn't any toplevel operator declared either). This isn't something hard to do of course, but it adds extra micromanagement overhead when you are debugging and simple things such as this is the source of most bugs. Not to mention that this sort of things add up quickly - you're not going to use the overloaded operator in a single place or else you wouldn't overload it at all.

Do not focus on this example, btw. It is just that: an example. There are other issues i have with C++, including style issues (f.e. i hate the foo_cast syntax - it looks plain ugly and i can't really say that i like the Class::Field syntax too).

Keep in mind that getters and setters have nothing to do with classes. There isn't much difference between

Code: [Select]
e->getHealth()

and

Code: [Select]
ent_get_health(e)

Of course you type a little more code in the second case, but it has been more than a decade that i've got past the mark where typing a few extra characters makes any difference in the time i need to finish something :-). Besides i wouldn't use "get_health", but simply "health" since i prefer to avoid using the "get" and "set" words unless the function's purpose is not clear.

Although at this point one might ask: why you need a getter and not use e->health directly? This is the "rethink" part that i like to do that keeps things simple. In this case i would use e->health directly and make sure that it gets the right values.

Note, btw, that C isn't immune to all C++ issues. In practice you can do in C whatever you can do in C++, but its a little harder and in the process you know you're abusing the language and, at least in my case, you come to think if this is the right way to do it. But C has its issues too - which exist in C++ btw. An example is the abuse of macros, which is a reason i try to avoid them unless they're very simple.

Someone else using the engine will have a problem understanding the engine in any case - being written in C++ or C wont help much. This is why documentation exists. But i believe there will be more issues with understanding an engine using C++ than a C engine because of the language's simplicity. At least that is the case with me.

Logged

CRC failed
Hugo
GameTalk Friend
**
Offline Offline

Posts: 182


WWW
« Reply #3 on: April 20, 2009, 03:25:39 AM »

I can see the difference now. Your engine (as opposed to the libs/engine I wrote) isn’t designed around the
idea that other people might use it. In that case, I would prefer C as well (like I said, I always prototype with it).

I would still however like to argue that setters and getters have a lot to do with classes, and that there’s  a
huge difference between : e->getHealth() and ent_get_health(e). Mainly the fact that in the case of classes you can
declare the vars private and handle them with getters/setters. That way you have more protection over your code
(i.e. health can never be set over 100%).

I use get/set because I find it more readable. Sure, if you’re the only one on the project this might not be needed
(since you know what the function does). But otherwise It would require you to look at the function
(and thus adds the micromanagement you disliked so much).
Logged

..
Bad Sector
Big Fat Code Bastard
Moderator
Post Monkey
*****
Offline Offline

Posts: 1495


Braaaiins!

WWW
« Reply #4 on: April 20, 2009, 04:43:34 AM »

As i said, "In this case i would use e->health directly and make sure that it gets the right values.". This wasn't clear, but i meant that i would use a setter for setting health that clamps the value to 0..100 (or whatever) and access it directly for reading it. However i prefer to make sure my code is correct in the first place, which is why i want to keep things simple: bad code will stand out by itself and not be hidden behind structures such as getter, setters, classes, hierarchy, etc.

Also what matters is defining a "protocol" - practices for using the code. If i know, for example, that i shouldn't set the health var directly, then i wont. And to make sure i won't forget it, i document such things - and expect from anyone willing to use my engine to read the documentation :-).
Logged

CRC failed
Hugo
GameTalk Friend
**
Offline Offline

Posts: 182


WWW
« Reply #5 on: April 20, 2009, 09:05:32 AM »

As i said, "In this case i would use e->health directly and make sure that it gets the right values.". This wasn't clear, but i meant that i would use a setter for setting health that clamps the value to 0..100 (or whatever) and access it directly for reading it. However i prefer to make sure my code is correct in the first place, which is why i want to keep things simple: bad code will stand out by itself and not be hidden behind structures such as getter, setters, classes, hierarchy, etc.

I agree, it's better to write correct code in the first place instead of using setters/getters to make things right.

Also what matters is defining a "protocol" - practices for using the code. If i know, for example, that i shouldn't set the health var directly, then i wont. And to make sure i won't forget it, i document such things - and expect from anyone willing to use my engine to read the documentation :-).

Well, in a perfect world that should work. But I guess we both know there are a lot of dumb programmers out there who
(against better advice) set the health var directly anyway, and then complain about it :D (especially when they paid for the engine/lib).

Logged

..
Pages: [1] Go Up Print 
« previous next »
 

Powered by MySQL Powered by PHP Powered by SMF 2.0 Beta 4 | SMF © 2006–2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!