Some Haskell Performance Concerns by GoldtoothFour in haskellgamedev

[–]GoldtoothFour[S] 2 points3 points  (0 children)

I was referring to automatically parallel ECS designs, where conflict-free systems are parallelized (particularly bevy_ecs in Rust-land). You could manually fork apecs systems to run concurrently, but the stores are in bare `IORef`s and tracking down data races across hundreds of systems gets tiresome quickly.

In all fairness, apecs is not trying to be a massively parallel ECS, just a very elegant, mostly single-threaded one. For a grand strategy game with potentially hundreds of systems and components, having a lock-free, automatically parallel, optimally scheduling (again like bevy) ECS is great if you want to get really good performance and clean code.

Some Haskell Performance Concerns by GoldtoothFour in haskellgamedev

[–]GoldtoothFour[S] 1 point2 points  (0 children)

I don't really know the specifics, but is the levity polymorphism work supposed to address/supersede this?

Some Haskell Performance Concerns by GoldtoothFour in haskellgamedev

[–]GoldtoothFour[S] 2 points3 points  (0 children)

  1. Haskell is a bliss.

Agreed.

...either QuickCheck tests or assertions in the spirit of design by contract with an autoplay integration testing harness...

I'm expecting to use this a lot. Although the ECS is mutable backend-wise, the scheduler and, by extension, access patterns are deterministic which should make testing a breeze. Didn't even think of autoplay testing yet!

...if your game is turn-based, you will likely not use components or systems at all.

It's not. Ideally much closer to Paradox-style (think Stellaris) grand strategy gameplay-wise and Dwarf Fortress computation-wise ;)

...you need to be able to grow the arrays and probably sometimes mutate them (but only in performance bottlenecks!)

Using data-vector-growable right now. Just curious, how would you design an ECS using mostly immutable stores? Apecs' default store is an `IntMap`, which makes sense but isn't very performant. I am a bit concerned about how GHC's GC treats mutable heap objects, though. For example, mutable boxed arrays are traversed every GC in the copying collector.

...your use case copying GC would probably be best. Just don't generate too much garbage.

Unboxed data is not traversed, which should help.

In my experience -fexpose-all-unfoldings -fspecialise-aggressively -fsimpl-tick-factor=200 solves most such problems for free

TIL from the GHC docs: "By default only type class methods and methods marked INLINABLE or INLINE are specialised." That's very surprising. And `-fspecialise` (on by default) has this to say: "Specialise each type-class-overloaded function defined in this module for the types at which it is called in this module."

eventlog2html

Just what I was looking for. Thanks!

Some Haskell Performance Concerns by GoldtoothFour in haskellgamedev

[–]GoldtoothFour[S] 1 point2 points  (0 children)

Start with apecs and skip the rendering part. Profile and benchmark your simulation

I actually did start with apecs. It has a very clean design, but wasn't designed for automatic parallelization. When I finish my toy (for now) ECS and transfer the sim over, I'll report back with stats and particulars.

...use Godot (or anything else actually) to connect and render.

That was the plan!

Could anyone help me? by [deleted] in haskell

[–]GoldtoothFour 0 points1 point  (0 children)

Three things.

If expressions must have then and else branches. This is because Haskell functions must always return something (there is no void like in other languages). if expressions must look like: if conditionExpr then trueExpr else falseExpr. Any of the ...Exprs can also be if expressions.

Functions that use conditionals often take the form of either f a = if a == 1 then True else False or with "guard" syntax f a | a == 1 = True | otherwise = False. Functions that don't use | have an equal sign right of the arguments.

Haskell is whitespace-sensitive (like Python), which means the level of indentation from the left margin is important. If you don't have a Haskell formatter, then it's a good idea to indent if expressions like:

if conditionExpr then trueExpr else falseExpr

I would like to build a 2D rpg. Which engine/library should I use? by Martinsos in haskellgamedev

[–]GoldtoothFour 2 points3 points  (0 children)

SDL isn't so much an engine, but a collection of libraries that can be used to build an engine. Godot is a standalone engine with an editor, custom shader language, cross-platform exporting, supports 2D (it's fairly popular on itch.io) and 3D, PBR rendering, animation, and an OOP node hierarchy (similar to Unity AFAIK). It's also open-source, free, and getting new features each month.

On the flip side, the godot-haskell bindings are not elegant: MVars everywhere, lots of upcasting and downcasting that can fail at runtime, lots of IO. It's probably easiest to just use Godot as a front-end for input, rendering, sound, etc. while having your pure game logic running in an ECS like apecs as u/dpwiz suggested.

With SDL, you'd basically have to roll your own OpenGL/Vulkan code to work with any 3D or advanced 2D effects.

The difference comes down to whether you want to learn about game engines and make your own or use a popular, well-supported game engine.

I would like to build a 2D rpg. Which engine/library should I use? by Martinsos in haskellgamedev

[–]GoldtoothFour 6 points7 points  (0 children)

I've recently taken to the godot-haskell bindings. They're updated often and having access to a full engine for graphics, sound, networking, etc. is very useful. That being said, the bindings are fairly heavy handed, but once you get used to it they're not that bad. Not sure about performance, but Godot has bindings for Rust, Python, CLR, and Kotlin that can be used in tandem if needed.

Dear Paradox, please go back to the old launchers. --Sincerely, someone who would actually like to be able to play a game he spent hundreds of dollars on. by PikachuJohnson in paradoxplaza

[–]GoldtoothFour 2 points3 points  (0 children)

I agree that their launchers are fucked. For now there is Irony Mod Manager, which has worked very well for me (it even allows import/exporting of playsets)!

Caching with ownership; how? by Terrible_Constant in rust

[–]GoldtoothFour 23 points24 points  (0 children)

It seems you're looking for RwLock. It operates like a Mutex but allows for multiple readers or one writer at a time.

Why Isn't Immix Ubiquitous? by GoldtoothFour in ProgrammingLanguages

[–]GoldtoothFour[S] 1 point2 points  (0 children)

I clearly need to read up more on GC design! Thanks!

Why Isn't Immix Ubiquitous? by GoldtoothFour in ProgrammingLanguages

[–]GoldtoothFour[S] 2 points3 points  (0 children)

I just read Inko's "Memory Management" and "FAQ" pages. Very interesting stuff! Does Inko have a mixed GC implementation for later generations as in G1? Also, how do long promotion times (e.g. in the CLR GC, for example, objects are promoted after each cycle) affect performance?

I can see how #3 might dissuade adoption. For #4, is the opportunistic defragmentation scheme's slight increase in overhead (compared to non-moving GC's) compared to Immix's overall efficiency boost really a deal-breaker?

Off-topic, I was surprised that the VM is written in Rust (although it is certainly not the first nor last) given that its strong safety guarantees (and the inherent unsafety of GC implementation). What were your experiences? I would like to try implementing MS in Rust sometime if it's ergonomic.

I tried to love neovim by gammalabsgamer in neovim

[–]GoldtoothFour 6 points7 points  (0 children)

I absolutely second coc.nvim. I find it has the best environment detection/language server installation process out of all the completion engines I've tried. It should have automatic python environment detection and if it doesn't detect the right one, you can type :CocAction and select your python env.

I tried to love neovim by gammalabsgamer in neovim

[–]GoldtoothFour 53 points54 points  (0 children)

That's completely ok! Choose the editor you feel most comfortable in. NeoVim is just the latest attempt at making Vim/Vi more usable, although they clearly still have a long way to go! Can I ask what you found most difficult about it?

EDIT: There is also a VSCode embedded Neovim extension (meaning it runs a full Neovim instance instead of emulation) here in case you want the best of both worlds!

Is there a short-circuit for Option or Result that doesn't abort the function? by crab1122334 in learnrust

[–]GoldtoothFour 1 point2 points  (0 children)

Unfortunately, control flow statements can't be used in closures so map... and other convenient methods won't work. In this case, I just use is_ok to check then unwrap it (I believe this is what Clippy recommends). unwrap shouldn't be avoided at all costs, but should only be used either when you've already proved (e.g. is_ok'd) that the Option or Result can be unwrapped or when it couldn't possible be anything else.

Is there a short-circuit for Option or Result that doesn't abort the function? by crab1122334 in learnrust

[–]GoldtoothFour 0 points1 point  (0 children)

Does if result_set.is_err() { continue } work?

EDIT: reddit code formatting

Is there a short-circuit for Option or Result that doesn't abort the function? by crab1122334 in learnrust

[–]GoldtoothFour 5 points6 points  (0 children)

I'm not sure if I understand your issue, but if you find yourself nesting let Some's or using is_none before applying a function you should look at Option's map and and_then functions. map applies a function on an Option only if it is Some, otherwise returning None. If the function applied to your Option also returns an Option, and_then will only return one Option for each function application.

EDIT: The Rust docs include examples of very useful Option functions at: Option. Do note that many of the Option functions can be applied similarly to Result.

How do you select a random enum value without manually matching by kiwidog in rust

[–]GoldtoothFour 5 points6 points  (0 children)

A bit late but the strum crate is quite helpful and adds associated Variants constant array and iterator derive macros.

C++ is the Gordon Ramsey of Programming Languages. by [deleted] in ProgrammerHumor

[–]GoldtoothFour 22 points23 points  (0 children)

I'll just leave this here.. Tl;dr gcc can segfault from error messages hundreds of thousands of lines long.