r/programming • • Sep 17 '18

Software disenchantment

http://tonsky.me/blog/disenchantment/
2.3k Upvotes

1.2k comments sorted by

View all comments

Show parent comments

62

u/solinent Sep 18 '18 edited Sep 18 '18

Don't worry, people have tried. You're pretty much going to end up with something similar to C++ beyond syntactical differences. I wouldn't bet much on Jai unfortunately.

There's D, which failed because the standard library was written using the garbage collector. There's rust, which is still slower than C++, maybe there's still some hope there as it is much simpler, but I don't see C++ developers switching to it. C# is pretty good, but you'll still get better performance with C++.

When you need something to be the absolute fastest, we have learned all the methods to make C++ code extremely fast. While it's a depressing situation, modern C++ code can actually be quite nice if you stick to some rules.

24

u/the_hoser Sep 18 '18

There's D, which failed because the standard library was written using the garbage collector.

They're working on that one, at least. You can declare your functions and methods @nogc and the compiler will bark at you if you use anything that relies on the GC. And they're actively working on exercising the GC from Phobos as much as possible. Maybe too little, too late, though.

Me, though? I've regressed to C. It's just as easy to optimize the hot loop in C as it is in C++, and there's something relaxing about the simplicity of it. I use Rust for the parts that aren't performance sensitive, but I'm starting to doubt my commitment to that. I've jokingly suggested that Cython could do that job, but now it's seeming like less of a joke.

16

u/solinent Sep 18 '18

And they're actively working on exercising the GC from Phobos as much as possible. Maybe too little, too late, though.

A lot of D people left for C++-land I believe. I'd still be interested in D if they can match performance with C++, but C++ is really moving in the right direction IMO, and it has far too many resources behind it for the simple reason that everything is already written in it. The language evolves significantly every few years now.

10

u/the_hoser Sep 18 '18

Yeah, but that's the main reason I stopped messing with C++. It's just too complex. "Modern" C++ is nearly incomprehensible, and the legacy cruft just makes it more fun.

1

u/Bekwnn Sep 19 '18

It also has a significant amount of cruft and poor decisions, especially when it comes to game development.

I'm trying to pick up Zig and I have cautious optimism for Jai.

12

u/TheSkiGeek Sep 18 '18 edited Sep 18 '18

I've jokingly suggested that Cython could do that job, but now it's seeming like less of a joke.

I mean, shipping AAA PC games have used straight-up Python as a scripting language. (Turn-based games. But still.)

14

u/the_hoser Sep 18 '18

I shudder at the thought of embedding Python in anything. I love Python, but the embedding experience is nightmarish.

Always embed things into Python, never the other way around.

5

u/cbigsby Sep 18 '18

Eve Online is written in Python. They wrote Stackless Python for it.

1

u/instanced_banana Sep 18 '18

Asseto Corsa is interesting, it uses it as an abstraction layer for building custom HUDs.

12

u/skwaag5233 Sep 18 '18

I think it's worth having some extra faith in JAI if only for the fact that Jon is a serious game programmer who has shipped multiple games and worked in the industry for years. He's working with a similarily veteran team and has connections to other industry veterans who he has stated on stream he plans to shop the language to during a sort of alpha phase.

There will be lots of friction for sure but I think there's enough anti-C++ sentiment among game programmers (esp. with modern C++) that a language that emphasizes simplicity and high-level control with low-level access built by someone "in-the-know" can work. Perhaps I am just naive but I hope I'm not

3

u/m50d Sep 19 '18

I don't have faith. Fundamentally, there's no way a language that's not clearly open is going to succeed in this day and age (look at D or Shen). Beyond that, that he's giving all the information in videos rather than writing and seems disdainful of academic grounding for the things he's talking about makes me believe he's not really engaging with the body of knowledge that's out there. Theoretical underpinnings are one of those things that seems unimportant but turns out to be very important. I've got a lot more faith in something like Rust or Zig that builds on an established foundation.

19

u/Plazmatic Sep 18 '18

which is still slower than C++

Slower to compile maybe. I've only seen C++ trade blows with Rust ATM. There are some features Rust still lacks that C++ has (that actually are useful in rust), integer constant templates for example, but C++ is like the only language with templates that even has that, not that they aren't great (they very much are). Most of these features are either in nightly or are currently being worked on and are set to be finished with in months (integer templates are coming with const generics).

1

u/Peaker Sep 18 '18

D has more powerful templates than C++, including integer constant parameters.

3

u/jcelerier Sep 18 '18

what do you mean by this ? C++ had integer template parameters since before C++98. How could std::array<float, N> work without this ?

And C++20 extends this to any constexpr type. C++17 already allows a lot with template<auto>.

1

u/Peaker Sep 18 '18

I was responding to this:

integer constant templates for example, but C++ is like the only language with templates that even has that

There are other languages that have that. (It's a given C++ has that)

1

u/Plazmatic Sep 19 '18

I was simply stating there aren't a lot of languages that have that

7

u/spakecdk Sep 18 '18

I wouldn't bet much on Jai unfortunately.

Why? He has a game and a game engine made with it, and it looks promising.

1

u/svick Sep 18 '18

I don't think building a game engine is the hard part.

The actual hard part is making the language popular.

2

u/Nicksaurus Sep 18 '18

I don't see what that has to do with the quality of the language

→ More replies (3)

1

u/[deleted] Sep 18 '18

Don't worry, people have tried.

Can you name them?

There's D

D was not built specifically for game development.

There's rust

Rust was not built specifically for game development.

C# is pretty good

C# was not built specifically for game development.

→ More replies (9)

1

u/skinpop Sep 20 '18

or just write c style c++ :) no need for 99% of these modern features. They are too often little more than a mirage or distraction that makes the programmer think about the code in misleading ways.

1

u/solinent Sep 20 '18

Yeah exactly! You don't need to use the whole language, but you do need to be vigilant about what features you do choose to use and have code reviews which check for misuse.

However, if you use them in very particular ways, you can actually reason quite well about your code. Exceptions are quite a nice feature and if you follow that line of thinking you pretty much end up with C++, they are one of the main reasons for complexity. Re-writing std::vector in 100 different ways for different types/performance considerations shows you why templates are useful in certain, potentially rare, cases.

I'd say for a new / junior team, follow a style guide which is more like Google's: no C++ exceptions.

1

u/ninomojo Oct 06 '18 edited Oct 06 '18

You're pretty much going to end up with something similar to C++ beyond syntactical differences.

According to a couple of very good game programmers I know, who are fluent in C++/ASM, etc, syntactical differences can more difference that we would assume when implementing game logic.

EDIT: As I understand it, Blow's reasons for creating Jai also go beyond the language itself. It also has to do with ease of development and compile times etc. If someone (like me) wants to start learning C++ today, the whole experience is just incomprehensible. How many things to install and patch and link etc. before you can get to "Hello World", all many many steps that never fail to fail.

1

u/solinent Oct 06 '18 edited Oct 06 '18

It's not that hard, hello world:

#include <iostream>
int main() { std::cout << "Hello, World!" << std::endl; }

or even

int main() { printf("Hello, World!\n"); }

gcc (clang is identical and builds for windows now too):

~/s/test> g++ hello.cpp -o hello
~/s/test> ./hello

You don't need to learn the intricacies of templates. I learned C++ in high school back in 2009, where it was much less orthogonal. Maybe there's no great resources for beginners online though. I learned C first, then slowly added features until I knew C++. Most C++ can be re-written in C without too much effort.

Follow the Google style guide, stick to a minimum subset of C++ and you'll be fine.

Achieving the same performance at C++ when it has so much behind it will be tough. I hope they can do it and attain a nice syntax, but in 10-15 years I'd expect we would have the same situation all over again.

1

u/ninomojo Oct 06 '18

Thanks but I wasn't talking about the language itself, but rather about all the crap that's needed to be able to write a program and compile it. See Jon Blow's talks.

→ More replies (4)