News for hackers. Stuff that matters.
Re:CityBound – An open source city simulation game in Rust by taneq on Friday April 05, 2019 @12:40PM (#19584334)
This looks awesome! My question, coming from a self-identified "C/C++ person" who works in realtime control systems and who's been feeling increasingly uncomfortable with C++'s inherent footguns, is how has your choice of language helped or hindered this project?
Re:CityBound – An open source city simulation game in Rust by theanzelm on Friday April 05, 2019 @01:00PM (#19584582)
I had a nice comparison because I first tried to do a native implementation in C++ and - wanting to do some custom low-level "stuff" for my simulation actor system (related to allocation and networking) - I ran into so many footguns that it slowed me tremendously. As soon as I tried to do the same with Rust, it was a breeze and I was able to write a lot of unsafe code that does very particular things that I need, while exposing a completely safe API for the rest of the engine and game. Being then able to also use Rust in the browser quite seamlessly with WASM allowed me to have a super straightforward and high-perf communication channel between the simulation backend and browser UI. The only real Rust disadvantage that hurts a lot is compile times. Sometimes I do fight types/the borrow checker, but only when I try to do weird things, in general I perceive it as a huge help in scaffolding things.
Re:CityBound – An open source city simulation game in Rust by segmondy on Friday April 05, 2019 @03:44PM (#19586276)
Very nice, how did you decide on your simulation? did you build a generic simulation engine you can reuse, or is your simulation tightly coupled to the objects you are simulating? It's fun seeing this, I have been recently thinking of a simulation game and wondering if to use a generic simulation library such as SimPy
Re:CityBound – An open source city simulation game in Rust by theanzelm on Friday April 05, 2019 @03:58PM (#19586415)
I build a simulation engine, based on a high performance distributed actor system library I wrote for just this purpose. It is generic, but a lot of the performance trade-offs are with Citybound's needs as the main driver.
Re:CityBound – An open source city simulation game in Rust by izend on Friday April 05, 2019 @05:54PM (#19587404)
I see you didn't use Actix or even Tokio, could you please explain why?
Re:CityBound – An open source city simulation game in Rust by theanzelm on Friday April 05, 2019 @06:28PM (#19587621)
Their actor implementation / event loop works on a higher level than mine. Mine is super simplistic intentionally to offer high performance. Being optimised for cache locality, processing similar actors in batches, using custom allocators and having encoding-free communication, it has many parallels to data-driven game engine design or even entity component systems.
Re:CityBound – An open source city simulation game in Rust by izend on Friday April 05, 2019 @07:20PM (#19587969)
cargo +nightly run of the examples in your Kay project appears to be broken, I'd love to explore using it in a future project.
Re:CityBound – An open source city simulation game in Rust by 384028345 on Friday April 05, 2019 @09:22PM (#19588548)
First time I hear about compile times being an issue with Rust. Is that a general problem with bigger projects or can you identify language features that add specifically to the problem?
Re:CityBound – An open source city simulation game in Rust by felipellrocha on Friday April 05, 2019 @09:27PM (#19588561)
First compilation is slow. After that it’s much better during development times. This can mean that ci can take a ton of time if you don’t do even the smallest bit of optimization.

Otherwise, it’s a solid language choice. L

Re:CityBound – An open source city simulation game in Rust by theanzelm on Friday April 05, 2019 @09:37PM (#19588605)
As a point of reference "warmed up" compilation for me still takes ~1minute. Bearable for general work, horrible for quick tweaks or UI-related work.
Re:CityBound – An open source city simulation game in Rust by jeanmichelx on Saturday April 06, 2019 @10:25AM (#19590877)
I'm so jealous of software development tools.

Elaborating the hardware (systemverilog) I'm working on (about a year of work from scratch, nothing fancy) takes 8 minutes.

Re:CityBound – An open source city simulation game in Rust by jtms on Saturday April 06, 2019 @01:52PM (#19592022)
Wow, I get frustrated and feel unproductive if my feedback loop is longer than 2-5 SECONDS. This must require a seriously different approach to trial and error exploration
Re:CityBound – An open source city simulation game in Rust by dimfeld on Sunday April 07, 2019 @01:10AM (#19594953)
A lot of that is done in a simulator on the computer, which usually builds very quick once you get the environment and simulation scripts written.

The full build to a bit file that can be loaded into hardware is an NP-hard optimization problem, so as your design approaches the limits of either the desired clock speed or the amount of space in the chip, it can become very slow.

Re:CityBound – An open source city simulation game in Rust by jeanmichelx on Sunday April 07, 2019 @01:43PM (#19598467)
I wish. This figure is reloading the formal tool after a one line change in the RTL.

Placing (not routing!) takes around 24 hours since we need to run in a larger environment than just the block level to get realistic timing reports

Re:CityBound – An open source city simulation game in Rust by infogulch on Saturday April 06, 2019 @01:49AM (#19589472)
I've heard that long warm compilation times can be mitigated by breaking up code into separate modules so it doesn't recompile e.g. the actor system every time you adjust a layout. Basically caching works best on the module boundary. Is this something you've explored?
Re:CityBound – An open source city simulation game in Rust by theanzelm on Saturday April 06, 2019 @11:02AM (#19591059)
Yes, I factored out quite a bit of generic parts of the engine into libraries and took some steps to cut down on number of generics being instanced (which was one of the main drivers of compile time). Now I'm left with pretty much the game core, which is highly interdependent and thus nearly impossible to break up into crates (they can't mutually depend on each other). And it's still kinda slow.
Re:CityBound – An open source city simulation game in Rust by z0mbie42 on Saturday April 06, 2019 @10:31AM (#19590907)
+1

I've splitted a 20k+LOC Rust project into multiple crates and compilation time improved a lot (still slow compared to other languages) but it's now manageable.

Re:CityBound – An open source city simulation game in Rust by Twirrim on Saturday April 06, 2019 @10:38PM (#19594442)
Really? It has been quite a talking point for a while with Rust. Final binary performance is great, but compilation times hurt badly.
Re:CityBound – An open source city simulation game in Rust by taneq on Monday April 08, 2019 @10:40PM (#19611269)
Thanks for your answers here, I'm definitely going to look more closely at Rust for my next project!
Re:CityBound – An open source city simulation game in Rust by Zecc on Monday April 08, 2019 @05:52AM (#19603683)
You might be interested in hearing what Chucklefish, the creators of Starbound, have to say about Rust::

https://www.reddit.com/r/rust/comments/78bowa/hey_this_is_ky...

https://www.rust-lang.org/static/pdfs/Rust-Chucklefish-White...