
Does this make Rust inherently more complex? In this respect, Rust is closer to C++ than Go. But the bottom line, from threads, to channels, to generics, Rust provides the developer with more options. I could keep going, digging deeper into other language differences. Otherwise, there’s little difference, and it’s difficult to find an advantage one has over the other. Honestly, they’re both pretty similar, except for Rust forcing error checking. In the latter case, the error returned would have been ignored. Notice that this line: result, err := fooDivide(5, 4)Ĭould have been written as result, _ := fooDivide(5, 4) Here’s a simple example of the Result type being returned by a function in Rust: fn foo_divide(a: f32, b: f32) -> Result Given that most of Rust’s own libraries, as well as other third-party libraries, return one of these types, the developer will usually have to handle the case where nothing is returned, or where an error is returned.

The Option will return either None or Some(T) whereas Result will return either Ok(T) or Err(T). Rust enables the developer to handle errors cases through the use of the enum return types: Optionand Result. Here I think Rust and Go are quite similar.
#Getting started with rust video game code#
This greatly enhanced the performance of the game, and made it usable.Īnother crucial part of writing code is handling errors. So, using my handy Texas Instruments calculator, I pre-calculated a bunch of the sine values, carefully writing them down on paper, and then entering them in as constants for the game. But I was only ten or eleven years old at the time.ĭespite the “ power” of the processor, computing sine values at run-time was simply too much for it. The cave walls were sinusoidal, scrolling vertically on the left and right sides of the screen, and you had to make sure your craft didn’t crash into them. The game was simple: using the joystick, maneuver your spaceship through a randomly generated scrolling cave.

The compiler for it cost about $65, if I recall, which at the time equated to mowing ~13 or so lawns.

The first video game I ever wrote was written using 6502 Assembly for that console. Back then, I was just a kid exploring a new hobby - programming my Atari 2600. The song debuted back in 1982, a long time ago. I’m listening to it, right now, while I’m writing this article. “ Should I stay, or should I go?” Great song by the band The Clash.
