Advertisement

Functional Programming for Gamedev

Started by March 02, 2021 04:06 PM
2 comments, last by kvltd00d 3 years, 8 months ago

I know there's been similar questions, but I am trying to be as specific as possible, plus I haven't seen any threads that are still open to newer responses. I have been a professional Scala dev for the past 4 years and I'm looking to uplevel my FP skills while doing something fun (gamedev). I'm torn between really learning cats, or switching languages altogether to Haskell… I'm not an expert in any of these things, and I know the challenges that will come with using these tools for gamedev (breathing, eating, and dreaming of monads everywhere), but in my limited experience, here are the pros and cons I've thought of:

Haskell:

pros:

  • no JVM
  • easier to work with C libraries
  • cats and other functional frameworks for Scala are heavily inspired by it, so if I want to switch back MAYBE a lot of the knowledge will translate?

cons:

  • I'm not very familiar with it

Scala+cats:

pros:

  • my favorite language to work with so far
  • hybrid language (I do love using case classes for pattern-matching)
  • maybe a slight advantage in terms of general job opportunities

cons:

  • JVM (in the eventuality that I might want to make a game that runs on the Switch, for instance, this might be problematic, maybe?)

Other than that I haven't found a lot on established game engines or frameworks for either (Scala can use Java engines and frameworks, I guess, but the reason I even got into Scala in the first place was because I did not want to write a single line of Java code if I could help it)?

You seem very open to learning new programming languages and sufficiently particular about them ("not want to write a single line of Java code if I could help it") to spend some effort evaluating non-mainstream alternatives.

So you should first look for adequate libraries for functional languages you like (maybe good SDL bindings, or lower level 3D APIs, or higher level scene graphs and ready-made game engines), evaluate the languages themselves for game development suitability (portable compilation, performance, garbage collection…) and only if multiple promising platforms remain choose the language you like best.

Omae Wa Mou Shindeiru

Advertisement

@LorenzoGatti Thanks, that's helpful! I'll be on the lookout particularly for SDL bindings, OpenGL/Vulkan API's, physics frameworks, ready-made engines, etc, and go from there. I've also thought about just implementing the bare minimum of Pong (paddles, ball, collision detection) and use that as a means to evaluate tools.

This topic is closed to new replies.

Advertisement