5 ms·
I can see why it would be bad for drivers, but why games? Functional programming has started to become popular in that space lately, and for good reason
by _bxg1 8y ago
I can see why it would be bad for drivers, but why games? Functional programming has started to become popular in that space lately, and for good reason
- marshray 8y agoGames are all about keeping the user in the 'flow'. Humans are really good at picking up on unpredictable timing. Action games are thus fundamentally hard-real-time systems.
- _bxg1 8y agoMy thinking was to have a top game loop that "ticks", and then passes the current game state + the time delta to a pure function which returns the new game state, which gets stored. Is the concern that Haskell's lazy-evaluation might lead to a higher level of variance in frame-rate than another language?
- marshray 8y agoRight. One technique used for writing games to run on GC'd runtimes is to avoid allocations entirely in the game loop. With a lot of work, you can preallocate everything you're going to need and just modify it as you run. This technique is not a good match for Haskell's primary design principle of avoiding mutable state.
- _bxg1 8y agoTo be clear, I'm not aiming to build the next Call of Duty; these days you can get pretty far building a medium-sized 3D game out of unoptimized JavaScript running on a web page. The GC optimization you mention is interesting to learn of, but probably irrelevant for the kinds of things I would be doing. Does that change your assessment of Haskell for this purpose?
- marcosdumay 8y agoThat depends on how large is your state. The GHC GC is normally fast, but gets slower the more objects you keep around. Lazyness can severely increase the number of such objects. If your game has real time dynamics, it's not worth it. If it's some turn-based one without animation, it's not a problem.
- marcosdumay 8y agoHaskell state keeping is either fast or convenient, not both. Timing has several issues, not only GC pauses, but the entire functional paradigm was not created for real time. Lazyness adds up fast if you keep passing stuff through clock ticks. None of that is a showstopper. But I'd rather use a language that doesn't suffer from fundamental drawbacks on the domain I will work. That said, Haskell is very promising for AI. If I ever get to that game again, I'm writing the main loop in Rust with an asynchronous AI in Haskell.
- platz 8y agohttps://github.com/Gabriel439/post-rfc/blob/master/sotu.md https://github.com/Gabriel439/post-rfc/blob/master/sotu.md Game programming Rating: Immature > Haskell is a garbage collected language, so Haskell is more appropriate for the scripting / logic layer of a game but not suitable manipulating a large object graph or for implementing a high-performance game engine due to the risk of introducing perceptible pauses due to GC pauses. Also, for simple games you can realistically use Haskell for the entire stack.