News for hackers. Stuff that matters.
Re:Veloren – Open-source MMORPG written in Rust by moritonal on Friday February 05, 2021 @11:11AM (#26037820)
Looks neat. I'm struggling to get why Rust is important in this context? Is it a demo of Rust's features and a fun way to learn, or is it a major feature of the game which lets you do things that games like Miecraft (in Java) couldn't do?

* I'd assume peformance was great, but is there metrics to show?

* Is the client and server written in Rust, or just the server?

Re:Veloren – Open-source MMORPG written in Rust by mkl95 on Friday February 05, 2021 @11:45AM (#26038229)
As a part time game developer who uses mostly C++ and a bit of Python, I have considered writing a project with Rust a few times, but I've always struggled to find meaningful examples. This is game-changing.
Re:Veloren – Open-source MMORPG written in Rust by hinkley on Friday February 05, 2021 @03:26PM (#26040760)
As a wannabe game designer who moved on quickly to other things: object lifetime problems are a bane of game design. They give you memory leaks, and in some situations are how item duplication bugs work.

In particular if you do the engine as a collaborative piece, then running a game starts to look like any other volunteer group: a bimodal distribution where few old hands keep it on the rails, a lot of new people whose raw enthusiasm overpowers their lack of experience, who need to be given tasks they can not fuck up so badly.

In between it’s a race between burnout and life balance for the people who have shown up for three years. They provide a lot of the leadership and competence, but they also tend to disappear. So you need to groom the newbs to replace them regularly. The old hands are the scribes who provide historical data when those transitions don’t go smoothly. They are continuity and influence, not productivity.

Any system that provides some safety for people still working out how to contribute is going to fare much better than one that is alienating. Rust to me is a mix of both, therefore plausible but not a slam dunk.

Re:Veloren – Open-source MMORPG written in Rust by imbnwa on Friday February 05, 2021 @11:16AM (#26037896)
Superficially speaking, I've seen a lot of comments around Rust's mismatch for assuming C++'s duties in game development so perhaps this is one of those "Rust in Production" signals
Re:Veloren – Open-source MMORPG written in Rust by hombre_fatal on Friday February 05, 2021 @11:34AM (#26038098)
Minecraft was written in Java, so that can't be it.

Open-source + built in a slightly interesting language are the only reasons we'd be discussing an MMORPG.

Good luck to the team. MMORPG that anyone wants to play is probably the hardest challenge in gamedev and game design.

Re:Veloren – Open-source MMORPG written in Rust by Macha on Friday February 05, 2021 @02:47PM (#26040401)
> Minecraft was written in Java, so that can't be it.

And everyone who plays large modpacks, goes around large buildings, or just sets off a ton of TNT has seen how it has suffered for it.

On the other side, anyone who has seen the selection of mods available for Java edition vs bedrock edition (the C++ rewrite) despite a modding API for bedrock being officially supported has seen how it has benefitted from this.

Re:Veloren – Open-source MMORPG written in Rust by pjmlp on Friday February 05, 2021 @05:07PM (#26041831)
2nd system effect, badly written mods perform poorly regardless of the language.
Re:Veloren – Open-source MMORPG written in Rust by vlang1dot0 on Friday February 05, 2021 @12:23PM (#26038694)
> Minecraft was written in Java, so that can't be it.

What does that have to do with the parent comment? The usual argument I've seen is that game developers "move too fast", "don't have everything designed ahead of time", "have to iterate quickly" and Rust's insistence on writing correct code gets in the way of that during the prototype phase.

Java doesn't really have that issue as it is quite a bit more forgiving than C++ and will happily let you hammer a square peg into a round hole at the expense of performance, as evidenced by Minecraft.

Re:Veloren – Open-source MMORPG written in Rust by pjmlp on Friday February 05, 2021 @05:03PM (#26041792)
The only evidence is that school kids cannot write mods like AAA studios, it wouldn't be any different if those mods were written C++, or JavaScript (Bedrock)
Re:Veloren – Open-source MMORPG written in Rust by imbnwa on Friday February 05, 2021 @12:14PM (#26038598)
> Minecraft was written in Java

Did not know that

Re:Veloren – Open-source MMORPG written in Rust by zesterer on Friday February 05, 2021 @11:28AM (#26038027)
Hi, I'm the founder of the project.

We chose Rust because it's performant, memory-safe, and comes with a host of modern features that make writing code with the language very enjoyable.

We could have chosen C++, but I'm very glad that we didn't. Memory safety is great: I've not needed to break out gdb even once throughout the history of this project, despite the size of the project. This safety means that code is easier to review because it 'does what it says on the tin' and is much less prone to UB and non-local behaviours. It also reduces the prevalence of bugs. I've been shocked by just how much easier it is to write reliable and bug-free code with Rust than it is with languages that I've used in the past (C, C++, Python, Vala, amongst others).

The type system is also very powerful and it lets us encode a lot of useful invariants that can be checked by the compiler. Knowing that what you're doing is correct-by-nature is a great help and it frees your mind up to focus on the logic of what you're writing rather than getting distracted by irrelevant details like representation.

Rust plays very well with data-oriented design. This works great for us. At its heart, Veloren uses a high-performance ECS that is extremely cache-coherent. There's still lots of optimisation work to do, but we're already seeing that servers that can handle hundreds of players and millions of entities without issue, despite the fact that terrain generation is done server-side (and, as such, we have similar performance constraints to games like Minecraft).

The client, server and client/server frontends (frontends are logically independent and alternative frontends can be written for the game) are all written in Rust. In addition, the in-development plugin API will allow for plugins written in Rust and compiled to WASM.

In addition, Rust is also very portable. Compiling the game on (and for) many platforms is incredibly easy. The game runs well on Windows, Mac OS, Linux, BSD, and community members have even gotten it running on the Raspberry Pi and a hacked Nintendo Switch!

I hope this doesn't come across as being overly evangelical, but I think I speak for all of the developers when I say that we have no regrets in the slightest about choosing Rust! That doesn't mean it's the right choice for all projects, of course. The Rust gamedev ecosystem is still relatively immature. Although this is changing fast, don't expect to find any nuts-and-bolts game engines ready to go. However, if you're not afraid of diving down into low-level APIs here and there, Rust might be a great choice.

Edit: At a second glance, I see you're asking more about why mentioning the language is important. As a community-driven project, we rely on encouraging new contributors to work on the game and the choice of language is something that developers usually care about a lot. Extensibility and open development is really important for us and so 'showing the innards' is a big part of what we do when interacting with the community. Unless it's security-sensitive, we'll always discuss development issues and ideas in a public forum where anybody can add their input.

Re:Veloren – Open-source MMORPG written in Rust by moritonal on Friday February 05, 2021 @12:31PM (#26038807)
"I hope this doesn't come across as being overly evangelical"

Not at all, I'm worried now my post seemed mean! This was exactly what I was looking for. I wanted to know if this was chosen just as a PoC for Rust, or whether it actively made development better (which it sounds like it does :D). There's a big difference between "Here is X written in Rust" and "X is so much easier because we wrote it in Rust!".

The fact you then go on to use ECS within Rust must have amazing returns on metrics. Good luck on your progress!

Re:Veloren – Open-source MMORPG written in Rust by aimor on Friday February 05, 2021 @11:51AM (#26038326)
I heard about Veloren from the Rust Game Dev Podcast (Aug 2020). I really enjoyed listening to the team talk about details of the game's development, thank you for talking about it so openly.

https://rustgamedev.com/episodes/interview-with-team-veloren

Re:Veloren – Open-source MMORPG written in Rust by ksm1717 on Friday February 05, 2021 @11:37AM (#26038144)
I think they were more asking why Rust matters to us as readers or users. Not that it isn’t great insight, but your answer is more like why rust matters to you.
Re:Veloren – Open-source MMORPG written in Rust by lubesGordi on Friday February 05, 2021 @12:01PM (#26038453)
The answer matters to people who write games in C++, or anything in C++. They want to know that Rust can handle/be productive in various domains.
Re:Veloren – Open-source MMORPG written in Rust by ksm1717 on Friday February 05, 2021 @12:02PM (#26038472)
Agreed
Re:Veloren – Open-source MMORPG written in Rust by Narishma on Saturday February 06, 2021 @08:37AM (#26046397)
> At its heart, Veloren uses a high-performance ECS that is extremely cache-coherent.

I think you meant cache-efficient, ie: it uses the cache efficiently. Cache coherence is something completely different.

Re:Veloren – Open-source MMORPG written in Rust by Geminidog on Friday February 05, 2021 @12:15PM (#26038606)
The fact that you haven’t used gdb is a huge deal. This is very rare in large C++ projects.
Re:Veloren – Open-source MMORPG written in Rust by Macha on Friday February 05, 2021 @02:44PM (#26040370)
For certain classes of developers (of which I'd include myself), Rust is more accessible than C++. The tooling is more modern, the APIs feature functional constructs I'm used to for other languages, and it's not like C++ doesn't have its own feature explosion. If you're an open source game project, then it's signalling what developers might be most interested in the source in the hopes that some will then contribute, when addressing a forum of primarily developers.
Re:Veloren – Open-source MMORPG written in Rust by rowanG077 on Friday February 05, 2021 @11:30AM (#26038055)
In general in most modern languages there aren't really things you "cannot" do with one language that you could with another. It's more of a question of how easy it is to do something.

And in general is should be much easier to create a performance sensitive game in Rust then in Java. Besides that Rust is much more ergonomic to use.

Re:Veloren – Open-source MMORPG written in Rust by moldavi on Friday February 05, 2021 @06:34PM (#26042549)
Rust is more performant, but Java is actually much more ergonomic, since you dont need to worry about borrow checking concerns and its frequent refactoring. Still, the tradeoff is good for a game like this.
Re:Veloren – Open-source MMORPG written in Rust by rowanG077 on Saturday February 06, 2021 @06:40AM (#26045906)
I wouldn't say so. Rust borrow checker is really only an issue for novices. Whereas Javas NullPointerException is the bane of even the most experienced dev.
Re:Veloren – Open-source MMORPG written in Rust by zelphirkalt on Friday February 05, 2021 @11:15AM (#26037886)
Rust is probably mentioned for the more up to date language concepts and type safety, as in "Look, our code is probably more reliable than the code of many other games.", which in turn might mean, that the user experience will be better.

Those things could be a huge deal for any game developer, especially, when you already know Rust.

Re:Veloren – Open-source MMORPG written in Rust by hctaw on Friday February 05, 2021 @11:41AM (#26038183)
I think Rust makes a compelling case for production code with a high degree of reliability without sacrificing too much performance. Something I think developers don't appreciate enough is that Rust helps you write code that doesn't crash nearly as much as something in C/C++, particularly with respect to how library authors express fallable code with option/result types and the lack of memory safety footguns like iterator invalidation.

Consumer software is better without crashes. It's sad how rife software is these days with segfaults that can be prevented by design.

Re:Veloren – Open-source MMORPG written in Rust by musingsole on Friday February 05, 2021 @11:52AM (#26038341)
But is Skyrim even worth it if you don't have mammoths walking in the sky and broken necks from overzealous head tracking?
Re:Veloren – Open-source MMORPG written in Rust by renewiltord on Friday February 05, 2021 @12:06PM (#26038504)
It’s a dev community. The language is important as a hook for people interested in writing code in the language.
Re:Veloren – Open-source MMORPG written in Rust by emteycz on Friday February 05, 2021 @11:12AM (#26037830)
I think it's important piece of information for HN given it's open source. I wouldn't care if it was closed source.
Re:Veloren – Open-source MMORPG written in Rust by Kye on Friday February 05, 2021 @11:48AM (#26038285)
The #1 problem in MMORPGs is people exploiting bugs for personal gain at the expense of the game's economy and competitiveness in PvP. Some of those bugs end up being in NPC scripts, but most are the kind Rust helps prevent.
Re:Veloren – Open-source MMORPG written in Rust by spijdar on Friday February 05, 2021 @11:58AM (#26038418)
Which bugs? I wasn't under the impression that exploiting memory safety issues was the dominant type of bug to gain an advantage in multiplayer games, but usually logic errors or some kind of broken script, corner cases in nested control structures, that sort of thing.

I can see an argument that Rust could also help prevent those as it is a higher-level language and has a few language features to prevent some of the logic problems, but not that many?

Re:Veloren – Open-source MMORPG written in Rust by gpm on Friday February 05, 2021 @12:51PM (#26039097)
Honestly, I think rust actually prevents a lot of logic problems, but it's hard to quantify and a subjective feeling that I'm not sure how I'd even go about trying to "prove". Order of magnitude I'd say 50% less logic bugs than a language like Java.

Why? Just good language design. Things like "enums" (algebraic data types, not C-enums) making for type checked state machines, really strict typing, immutability by default, simple language semantics, good linters that people actually use, the borrow checker actually does usually lend itself to good design too, and so on.

Re:Veloren – Open-source MMORPG written in Rust by bcrosby95 on Friday February 05, 2021 @01:33PM (#26039631)
Why must you trigger my inability to stick to a programming language? Elixir, Clojure, or Rust - round-a-round in my head they go. Will it ever stop, hell if I know. sigh
Re:Veloren – Open-source MMORPG written in Rust by zesterer on Friday February 05, 2021 @01:09PM (#26039331)
This is a good summary tbh
Re:Veloren – Open-source MMORPG written in Rust by hctaw on Friday February 05, 2021 @01:46PM (#26039761)
There are memory safety bugs that won't cause a segmentation fault or create a buffer overflow exploit, but result in logical errors. For example:

    void inner (const T& t1, T& t2); 
    void outer (T* t, int i, int j) {
      inner(t[i], t[j]); 
    }
There are three memory safety bugs in that code:

  - the pointer `t` is not checked for null
  - the indices `i` and `j` are not checked to see if they are outside the bounds of `i` and `j` 
  - the indices `i` and `j` are not checked to see if they are the same. 
The first bug will cause a segfault and crash. The second is a potential buffer exploit. The third is a logical bug that can be exploited depending on what inner() is supposed to do. Most people know to check the first two, the third one is subtle and isn't necessarily a bug. But it may become a bug that can be exploited inside `inner`, especially over the lifetime of the code.

Rust will prevent all three, or force you to perform the checks before using an `unsafe` block.

But more than that, this kind of issue crops up due to an inherent weakness of code review - it catches errors in blocks of logic, but not in logic below it and logic above it. Since C/C++ don't have idiomatic error handling worth a damn (the only "idiomatic" errors in C++ are debug assertions, ime) you can't defend against silent logic bugs due to violating invariants of callers or callees that are expressed through Option/Result types in Rust (I mentioned this in a comment above). That's the real benefit of writing code in Rust, in addition to the absence of footguns.

Re:Veloren – Open-source MMORPG written in Rust by zesterer on Friday February 05, 2021 @02:01PM (#26039912)
> The first bug will cause a segfault and crash.

Or, you know, nasal demons

Re:Veloren – Open-source MMORPG written in Rust by zesterer on Friday February 05, 2021 @01:08PM (#26039320)
It's a mixed bag. Short of defining a formal spec and writing the program with a theorem prover, "bug-free" code isn't really a realistic goal. However, Rust does come with tools that at the very least allow the building of APIs that are very difficult to abuse via the trait system and other features such as sum types. Ultimately, spaghetti code is possible in virtually any language, so keeping a good eye on architecture is necessary no matter the language. What I would say is that Rust makes it easier to keep architecture constrained and correct.
Re:Veloren – Open-source MMORPG written in Rust by astrobe_ on Saturday February 06, 2021 @02:39AM (#26044883)
It is sad to see that sibling answers are somewhat avoiding the question. I concur, "exploits" in MMORPG are about abusing unintended consequences in the design of the world, not in the design of the program. Like spawn locations where mobs are trapped and easier to kill, or combinations of weapons/gears/abilities that give an unforeseen advantage.

That a stronger type system "eliminates a whole class of bugs" is nice and all, but users should be wary of the false sense of security it gives (in the same way that the weak type system of C gives a false sense of security when you come from assembler programming). You can have proven and certified bug-free crypto routines, and fail pathetically because their a giant hole in your crypto system. Just a friendly warning.

Re:Veloren – Open-source MMORPG written in Rust by Kye on Friday February 05, 2021 @12:02PM (#26038463)
My knowledge is many years out of date, so I might be wrong.
Re:Veloren – Open-source MMORPG written in Rust by spijdar on Friday February 05, 2021 @12:06PM (#26038509)
I'm also not really that familiar with either Rust or modern multiplayer games, I'm just speculating. It seems like if you could buffer-overflow the server, there are more sinister things you could do besides game-the-game...

(that said, I have personally found bugs in text-based MUDs that could have been prevented by Rust. They were all "just" DoS bugs though, instantly crash the server type things)

Re:Veloren – Open-source MMORPG written in Rust by Thaxll on Friday February 05, 2021 @12:12PM (#26038571)
This is not true, Rust woudn't prevent anything in most cheats / issues you see in online games. 99% of them are busines logic related.