This summer, I’ve been spending some of my free time learning game
programming. Rather than learning how to use any particular game engine, I’m
somewhat insane and decided to go a little more low level than that — game
programming with a framework!

I started with SDL2, but I eventually stopped and moved onto SFML. There are a
lot of compelling reasons to use SDL2, but if you’re just starting out like I
am, it might make more sense to start with SFML and then revisit SDL2 once
you become more experienced.

I switched to SFML because…

It reduces boilerplate code

My language of choice for game programming is currently C++. I typically program
object-oriented solutions in C++ and there’s no denying that OOP has a place in
game programming.

With SDL2, I spent a lot of time writing thin RAII wrapper classes around common
SDL2 functionality. This is a really tedious step — especially when you’re just
starting out. In my experience, creating small projects is a great way to learn
programming in general. However, I felt that my learning was getting really
bogged down by the sheer amount of set-up required to graft OOP bells and
whistles onto the SDL2 library.

“But Connor, couldn’t you have just written some reusable wrappers or used some
already existing ones?”
Sure, but I didn’t want to. My focus has been learning
game programming, not creating a comprehensive wrapper around a library. I
wanted to focus on the core material and absorb as much as I possibly could in a
short amount of time.

In short, the setup can be cumbersome when you’re iterating over practice
projects that gradually get larger.

The documentation is excellent

SDL2 has a wiki and most common functionality is accompanied by code samples.
Although, it’s not uncommon to find some functions without any code samples or
even without some description! I spent a fair amount of time supplementing the wiki with online tutorials. Some material you’ll find online is outdated (SDL has been
around for awhile), other material seems kind of hack-y. Although, it seems the
latter could be applied to a lot of game programming tutorials that are out
there, regardless of framework.

SFML has a great set of documentation. It’s accompanied by “getting started” for
each major development platform with code snippets.

This has a major appeal to people who are new and looking for information
straight from the source.

The trade-off doesn’t sting for beginners

SDL2 is hailed for its portability and simplicity. I’m under the impression that
you could compile a running build SDL2 for your toaster if you tried hard enough.

Deploy targets don’t even register with me while I’m just trying to learn the
basics of game programming. If I can compile and run it on whatever desktop
platform I’m developing on — it’s good enough for me.

For what it’s worth, it seems SFML has been hard at work for adding
functionality to deploy on mobile.

Programmers are framework agnostic

Yep. I’m framework agnostic. You’re framework agnostic. It’s no secret that
programmers aren’t married to any APIs — especially in this context. The idea
is to learn good game programming habits almost from the ground up. That means
the “engine” architecture, the gameplay mechanics, resource management, etc.
This concept is prevalent in programming in general. Programming languages are
tools. APIs are tools. Any craftsperson should be able to pick up a tool and use
it if it’s the right tool for the job.

This is the exact same thing. SFML suits my needs as a beginner because I have
no idea what I’m doing! I want to minimize the extraneous details while focusing
on the things that matter: OOP game design, game programming patterns, C++. This
is the easiest way for me to learn.

I can speak from experience: it was easy for me to switch from SDL2 to SFML
and it will be easy for me to switch back eventually (if I do).

At the end of the day…

I’m not trying to say that SFML is better than SDL2 or vice versa. SFML is just easier
to get started with if you’re a beginner game programmer working with C++.