📜 ⬆️ ⬇️

Why am I writing C games (yes, C)

I am one more fruit. All my personal game projects that I have been doing lately have been written on “vanilla” C. Nobody else does that, so I think you might be interested to know why I made this choice.
Written further contains an opinion about programming languages ​​that you may not like. I warned .

What do i need from language


Some requirements are not negotiable or compromise. First, the language must be reliable. I can not afford to spend my time looking for errors that I did not commit.

I wrote a large number of games in Flash, and now, Flash died. I do not want to spend time porting old games to modern platforms, I want to write new games. I need a platform, in which durability I will be sure.
')
What I really want is to avoid depending on a particular OS. Ideally, be able to develop for consoles. Therefore, it is important that the language allows you to easily port written in it, and also has good support for cross-platform libraries.

What do I want from the language


The most important, but not mandatory requirement is simplicity. Studying the features of the language and its wonderful “smart” API, I find it insanely boring. An ideal language can be studied once and never again use its documentation.

Finding and fixing bugs drains creativity. I want to leave fewer bugs, because I want strong typing, high-quality error messages and static code analysis. I want to simplify the search for errors, and, therefore, good debugging tools and dynamic analysis.

I am not interested in a beautiful realistic picture, but I care about performance. Lower resource requirements expand the range of possibilities available for implementation. It is especially interesting to watch what happens with modern powerful computers when the developer does not think about performance.

I worry even more about compiler speed. I am not a Buddhist master of concentration, and to wait more than 10 seconds is a waste. Worse, it knocks out of the stream. It seems only looked Twitter, and 5 minutes disappeared somewhere.

I am not an OOP adept. Most of the time spent at work, I dealt with classes and objects. But the further, the less I understand why it is necessary so hard to combine code and data. I want to work with data as with data, and write code that is best suited for a particular situation.

Alternatives


C ++ continues to be the most common language for game development, and for good reason. Until now, most of my custom projects are written on it, and I don’t like it.

C ++ covers my needs, but does not meet the desires. He is wildly complicated. Despite the availability of good tools, it is easy to make insidious errors on it. Also, compared to C, it compiles slowly. C ++ has high performance and provides features that are not in C, but this is not what I want, and this is achieved at the cost of great complexity.

C # and Java have similar problems. These are wordy and complex monsters, but I need a small simple animal. Both languages ​​send the programmer straight into the depths of OOP, and I am against it. As in most high-level languages, many complex things are hidden here so that nothing prevents you from accidentally shooting yourself in the foot.

I really like Go. In many aspects, it was an invented C, with the amendment that it had been thought through for several years before it was presented to the public. I would like to use Go, but there is one huge caveat - garbage collection. Game development on Go is doubtful, because the garbage collector will suspend the entire game world, which the developer cannot allow. Also here everything is not very good with game libraries. And although it is always possible to adapt a library for C for this purpose, and without any special problems, it still generates a lot of extra work. In addition, I have doubts about the prospects. Go would be nice for the web, but this is a rapidly changing environment. This was especially felt with the death of Flash.

I absolutely do not like JavaScript. It provides so much freedom that it is incomprehensible to me how people manage to write any complicated projects on it. And I do not even want to try it.

Haxe looks much more promising than other languages ​​in this list. He has no problems with libraries. If I start writing again under the web, I’ll definitely get to know him better. Somewhat worried about the relative youth of the language, will it live? I have nothing more to add, I managed to play with Haxe only a little, without going deep.

Jonathan Blow writes his tongue. The language that he himself would like to use. I admire his decision, sometimes I myself get excited about the idea of ​​doing the same. But do not throw out all the existing libraries. And to realize full compatibility with them is not so easy. And in general it is difficult, I would prefer to continue to write games, rather than programming languages.

Why C is the best choice for me


Although C is dangerous, it is reliable. This is a very sharp knife that can cut off fingers as easily as cutting vegetables. But it is simple, and learning to use it correctly will not make up.

Hi's fast. And when it comes to compilation, I can’t imagine that any language can do it faster.
It is possible to write code so that it works everywhere. And it's usually relatively easy. It is hard to imagine that one day this will change.

There is excellent support for libraries and tools.

Although it saddens me a little, C still remains the best language for me.

I don’t want to say something like “Hey, you should also write in C”. I am aware that my preferences are very specific. In addition, according to the number written by me in different languages, the code for “vanilla” C occupies a leading position, so this is already part of my comfort zone.

So yes, C is the best choice for me.

From translator


Translation in places is quite free, but not to the detriment of the meaning or content.

I prepared the translation specifically for Friday, on this day it is especially appropriate, in my opinion. Although the author of the original text and writes, it seems, in all seriousness ... you yourself understand everything if you read. As the truth is not perceived read.

With suggestions, suggestions and comments, as usual, in drugs.

Source: https://habr.com/ru/post/275135/


All Articles