Advertisement

Game engine in C and open source, The Box, structural programming

Started by December 22, 2019 10:49 AM
129 comments, last by alex4 4 years, 8 months ago

I notice a couple of people asking for non standard engines, so i decided to make this topic.

This is not a personal thing there are several reasons for this :

One is code automation, if you using Unity3D or Uneal Engine, they don't do code automation for you because if they do, can't sell lather the engine if one person can make all the projects with just a couple of clicks.

Another thing. To do a engine in C is because, all languages can communicate with it and is very high performance, much more then C++ because of large objects waste a bit of data.

The main thing is to automate code, click and the engine do all the work for you.

It uses file objects instead of memory objects this way it can have high performance, with out using to much memory. Still can become maintainable.

C will become to large? Due to file object not that much, it have zero repetition or close to it. Still the project is large, but it can be develop by the community i just setting the structures. Maybe lather ask for help in schools, in company's open source, etc... .

Another thing if is not open source people can't help.

Is not an engine, but a development software.

I plan to release version 0.0.2 with much more info. First version was only the structure. for 2º planning to have a couple of tools working. You can follow the page on Facebook. Is posted more detail on the objects on "free game dev", but is down at the moment.

https://wwwtodo?modal=admin_todo_tour

jdc said:
It uses file objects instead of memory objects this way it can have high performance, with out using to much memory

This won't work. Using files won't be nearly as performant as using memory, simply because files are stored on storage, and SSD or not, storage is MUCH slower than RAM. Always. Not to mention the fact that CPU can't access storage data directly, therefore you need to load the files into RAM anyway, and there goes your "high performance" down on the sink. Google Memory-Hierarchy if in doubt. You'd need a computer made of memristors for this to be fast, it simply can't be done with a computer using classic memory architecture.

Why are you so afraid of using memory? That was the '80s. Today's computers have plenty of it. Even a mobile handheld has Gigabytes of RAM, long gone the days when you had to process files with limited buffers.

Otherwise nice idea!
bzt

Advertisement

You sure?

Quake 3 online is still one of the most fluid games. Barely there are any loss of frames, and is online. Is build in C. You can have this kind of fluid today only in a top computer.

ttps://www.youtube.com/watch?v=laVpV1PFziw

Compare to unreal tournament the amount of frames loss. and is build in C++

https://www.youtube.com/watch?v=4vHZcZJTegQ

The logic says other way, the lower the language faster it is because is less nested. High languages are very nested that's way they are slow, process large amount of information.

PHP is extremely slow it can only handle 2 or 3 services.

You are probably saying that it may gain in graphic effects, because they evolve and are process in graphys card, so it does not have that much effect maybe. Is that way but still you gain a lot in low level language.

jdc said:
you gain a lot in low level language.

You would need to back this claim with some profiling results and more detailed examples, currently it sounds more like a baseless prejudice. Some examples:

Can you compile a C program with both C and C++ compilers, and get significant performance difference?

Can you identify which features of C++ are 'slow' / have hidden costs? (e.g. memory overhead / runtime perf cost of inheritance, virtual functions etc.)

Can we in the end, assuming we are aware of those things, make an advantage from C++ even if we aim for highest performance? (Thinking of abstractions like templates or functors that bring lots of flexibility, make it easier to write reusable code without adding perf costs.)

Are there some examples of C++ features missing from C where C++ is faster because of that? (Guess not really, it's just more work with C, but more code -> harder to maintain)


In the end it remains a matter of personal preference, and performance differences might be more related to compilers than to language. But to make a decision, you have to know both options very well, and only then you can make recommendations to other people. If that's not the case, you can only do more harm than good.
Also there is no more need for another C vs. C++ flame wars, now with scripting languages being the true enemy, haha :)


jdc said:
One is code automation, if you using Unity3D or Uneal Engine, they don't do code automation for you because if they do, can't sell lather the engine if one person can make all the projects with just a couple of clicks.

Sounds interesting, but what do you talk about? What do you achieve with code automation?

bzt said:
jdc said:
It uses file objects instead of memory objects this way it can have high performance, with out using to much memory

This won't work. Using files won't be nearly as performant as using memory, simply because files are stored on storage, and SSD or not, storage is MUCH slower than RAM. Always. Not to mention the fact that CPU can't access storage data directly, therefore you need to load the files into RAM anyway, and there goes your "high performance" down on the sink. Google Memory-Hierarchy if in doubt. You'd need a computer made of memristors for this to be fast, it simply can't be done with a computer using classic memory architecture.

Why are you so afraid of using memory? That was the '80s. Today's computers have plenty of it. Even a mobile handheld has Gigabytes of RAM, long gone the days when you had to process files with limited buffers.

Otherwise nice idea!
bzt

@bzt mentions a concern regarding file objects, while @jdc response with C++ as a high level language. Did I miss something ?

jdc said:

You sure?

Quake 3 online is still one of the most fluid games. Barely there are any loss of frames, and is online. Is build in C. You can have this kind of fluid today only in a top computer.

ttps://www.youtube.com/watch?v=laVpV1PFziw

Compare to unreal tournament the amount of frames loss. and is build in C++

https://www.youtube.com/watch?v=4vHZcZJTegQ

The logic says other way, the lower the language faster it is because is less nested. High languages are very nested that's way they are slow, process large amount of information.

PHP is extremely slow it can only handle 2 or 3 services.

You are probably saying that it may gain in graphic effects, because they evolve and are process in graphys card, so it does not have that much effect maybe. Is that way but still you gain a lot in low level language.

The thing is, you can write equivalent or close, performance-wise, to C in C++. In fact you can just write C and compile the code in C++ compiler, and it should be just fine in most case. ... Interfacing with other languages are also the same story, if you expose C interface of your C++ code, then those language should be bind-able to the engine without much issue I think.

Anyway if you're all about the performance, then go ahead. You can go even further by using only ASM I think. The fact that you plan to use file objects indicates otherwise, and in this case even PHP should give you around the same performance (as things are bottlenecked by the disk I/O anyway).

http://9tawan.net/en/

Hi,

Yes, my concern was primarily about file objects vs. memory, and yes, I'm absolutely sure about that. As @mr_tawan pointed out, disk IO is the bottleneck (and the fact that the CPU can't access data on disks directly, you must load them into memory first, so even if it wasn't for the disk IO there would be still an overhead).

Usually a properly written C code is faster than C++ or PHP, however you can't say that in general. For example an object lookup code in PHP could utilize the built-in array index hashing, while a C implementation could use an O(n) lookup, in which case the PHP version would always be faster. Therefore as @JoeJ suggested, you should ALWAYS do profiling, before you do any claims. And again, only certain implementations can be compared, not languages in general. That would be like saying yellow cars are faster than blue cars. Nonsense, only a certain yellow car can be compared to a certain blue car.

I for one welcome the idea of writing it in C instead of C++, but that's just a personal preference. I had to fix way too much C++ code written by rookies over the years. To my findings only experienced programmers dare to use C, while C++ is much more likely chosen by seasoned programmers, therefore there are lot more high quality C code on the net than C++. But this has nothing to do with the languages itself, and my experience is not representative in any way. And just because I was unfortunate enough to struggle with lot of badly written C++ code definitely doesn't mean that a skilled C++ programmer can't write a good code, or that a seasoned C programmer can't write a bad C code. Same stands for any scripting language: it is much more important how experienced the programmer is in the given language than what that language actually is.

Cheers, and Merry Christmas to you all,
bzt

Advertisement

I disagree different types of languages can't be compared to different types of colors. An interpreted language will always be slower than a compiled language. The type of implementation is irrelevant because we are assuming the algorithms used have similar time complexity. This is why using Python for example for something that requires low latency such as games or stock trading would be a bad choice.

I also disagree that C++ tends to be used by "rookies" as opposed to C. That would be Python or Visual Basic. C programmers are usually nostalgics, or people who like to program low level stuff in smaller scale projects. C++ offers more room for abstraction and this is required for large projects such as games or game engines. Is it easier to misuse? Maybe but that does not mean these programmers are rookies. It just means that they might not use all of its numerous features well.

Unity, UE4 and Godot are all written in C++ for this very reason: because it lets you design abstraction well and is also very high in performance. Mastering it is also very difficult because it lets you do so much. Stroustrup said it himself that it is so powerful that IF you shoot yourself in the foot with it, you actually blow the whole leg off. Writing an engine as big as UE4 in C for example could be done but C++ is a better choice for the reasons I gave. Abstraction is very important but a bad abstraction can be worse than no abstraction at all. But again we are supposed to compare oranges with oranges and apples with apples, referring to comparing programmers who actually know what they are doing.

Merry Christmas to you too and everyone.

Hermetix said:
I disagree different types of languages can't be compared to different types of colors.

You have missed the whole point. I wasn't comparing colors. I was comparing speed of cars, read back by post.

Hermetix said:
An interpreted language will always be slower than a compiled language.

Claim without any proof, which is not surprising as the claim is wrong in the first place. Have you read what I wrote? Consider an O(n^2) implementation in C and a O(1) in PHP of the same algorithm. The scripting language version of that algorithm will always run faster, regardless to the interpreter overhead.

Simple homework for you: implement unique array elements with bubble sort in C/C++ (natively, without any libraries, no "#include" allowed). Then implement the same using array index hash and ksort() in PHP (natively, without any extensions or additional classes, "include", "require" or class autoload not allowed). Generate a million test numbers, feed that list to both implementations and measure which one will throw out the duplications and sort the numbers faster.

Go ahead, do profile both!

Hermetix said:
I also disagree that C++ tends to be used by "rookies" as opposed to C.

You may disagree but under no circumstances can you deny my personal experience :-)

Also, how would you explain "It just means that they might not use all of its numerous features well." In my vocabulary that reads as they are not experts of the language, which was exactly my point when I said "it is much more important how experienced the programmer is in the given language than what that language actually is".

Cheers,
bzt

bzt said:
Simple homework for you: implement unique array elements with bubble sort in C/C++ (natively, without any libraries, no

That's not fair. Why can use ksort but not standard library?

And it's also pointless, because afaik the php interpreter is written in C.


As long as we talk about games, which means realtime and low level optimizations being critical, it's quite ok to say interpreted languages are slower IMO.

(Surely time complexity is more important than that, but that's obvious.)

bzt said:
You have missed the whole point. I wasn't comparing colors. I was comparing speed of cars, read back by post.

I understood what you meant, I mentionned speed right in the sentence after. IMO, you could have used another analogy such as comparing an SUV with a sports car. Now that would have been futile since you can't say which is "better" in their general use, but speed? You sure can say which is faster.

bzt said:
Claim without any proof, which is not surprising as the claim is wrong in the first place. Have you read what I wrote? Consider an O(n^2) implementation in C and a O(1) in PHP of the same algorithm. The scripting language version of that algorithm will always run faster, regardless to the interpreter overhead.

Again, I got you meant. I said that the time complexity is assumed to be the same. You have to compare similar implementations to say which language executes code faster.

bzt said:
You may disagree but under no circumstances can you deny my personal experience :-)

Well in my own experience, I tend to see people use other languages before C++ because it looks intimidating to them.


bzt said:
In my vocabulary that reads as they are not experts of the language, which was exactly my point when I said

Well C++ is a multi-paradigm language, you can program structurally with it, or object oriented. It has so many features that mastering all of them is almost impossible. But it's a lot easier to master one paradigm in this language and use it well than be able to use it well in all ways possible.

But to go back to the OP's point, how many things can you do with UE4 for example as opposed to having to read 160k+ lines of code such as Quake 3's source code? You can do much more with UE4 and it's not just about code automation. John Carmack switched to C++ to make DOOM 3 for a reason, and it is very probably because he needed a higher level of abstraction to make a bigger game in terms of lines of code. And if you want to compare Unreal with Quake, Unreal started with better graphics (16 bit textures) so that takes a toll on the performance. And its code architecture is what lead to UE4 probably because I doubt that he rewrote the engine from scratch after each new game.



This topic is closed to new replies.

Advertisement