Unreal trivia: What does the 'F' prefix on classes and structs stand for?

This gets asked all the time and I thought I would share the official story, as I remember wondering the same thing.

‘U’ stands for UObject, ‘A’ stands for actor, ‘T’ stands for Template. Everyone gets that. But what does ‘F’ stand for? It’s used almost everywhere else!

The ‘F’ prefix actually stands for “Float” (as in Floating Point.)

Tim Sweeney wrote the original “FVector” class along with many of the original math classes, and the ‘F’ prefix was useful to distinguish from math constructs that would support either integers or doubles, even before such classes were written. Much of the engine code dealt with floating point values, so the pattern spread quickly to other new engine classes at the time, then eventually became standard everywhere.

This was in the mid-nineties sometime. Even though most of Unreal Engine has been rewritten a few times over since then, some of the original math classes still resemble their Unreal 1 counterparts, and certain idioms remain part of Epic’s coding standard today.

Just a quick and fun story about Unreal’s history I thought I’d share.

–Mike

22 Likes

Nice one :smiley:

So I guess than the ‘F’ prefix just grew to be used as the basic prefix for structs? (FUniqueNetId has little to do with floats :P)

4 Likes

That story is so 10 months ago Mike :stuck_out_tongue:

Yeah, and at this point UHT enforces it for all reflected USTRUCT() structs in order to have a consistent mapping from reflected data FName to C++ name, as we don’t store the prefix character in the FName.

Cheers,
Michael Noland

Hopefully someday we won’t have to require class prefixes on your own game’s classes (unless you want to use them, of course!) It is kind of one of those weird Unreal things that is a bit hard for us to fix and not requested very often, so it’s low on our todo list, but still bothers me.

9 Likes

Agreed, I’d love to get rid of this limitation in game code.

Cheers,
Michael Noland

2 Likes

That would be cool, sometimes I prefer to prefix stuff on a project basis instead of the type itself but after working with the engine (4, 3 and 2.5 :D) I kind of grew accustomed to prefix them always.

1 Like

Oh, thanks for the story! This thing was bothering me for quite some time.

My guess was that F stands for “Fast” to distinguish “fast” regular C++ classes from “heavy” and “slow” UObjects.

Now I see that the truth is much more amusing.

It means native class or struct without UObject garbage collections supports.

Framework:):):):slight_smile:

4 Likes

Does anyone else think that Tim Sweeney is really just Sweeney Tim the demon coder of Float street? jk jk It is cool history to look back at.

3 Likes

nice story, but, what F stands for then? Structure?

The F stands for Fantastic. Everyone knows that.

3 Likes

FWIW, it will absolutely drive my team nuts not having their class files the same name as the classes themselves.

is there any good memory management practices on making your own “F-Type” classes? … I made one and is leaking like a oil pipline

Unlike UObject derived classes, there isn’t a standard way to manage memory with F-classes, since they are just plain C++ classes. UObject derived classes which all participate in garbage collection while most regular classes do not (unless derived from FGCObject). Also, none of the Unreal Build Tool macros (i.e. UPROPERTY) work with regular classes.

If you’re developing a plain C++ class to work with a specific system (i.e., you’re making a Slate widget or a FPrimitiveSceneProxy sub-class), try to follow the example of any existing code.

You also have some utilities available to you in the Unreal Smart Pointer Library, and you can also use the collection (like TArray) to help to some extent.

I for one would like to see a livestream and/or more official documentation on memory management throughout the UE4 system.

https://docs.unrealengine.com/en-US/…ard/index.html

see the “Naming Conventions” part

1 Like

Is it me or the asset naming convention is gone from the ue4 doc ?

I wonder if the thinking was that the object is aligned on a Single (or float) boundary - I’m not as familiar with c++ compilers as I am with c#, but I know that due to the way the memory is moved from the dimms to the cpu cache that it’s faster if the memory blocks are aligned in predictable ways and the compilers generally take care of the padding necessary to accomplish this. Given that a struct is intended to represent the memory that is the object vs a class which is intended to represent an object split across multiple locations in memory (Due to the vtable & inheritance) - it would make sense to name your structs as F as a float aligned block… This is entirely speculation though.

Not saying that Sweeney knew when he first coded it, but that would be my assumption as to the reasoning if someone were to establish F in the naming convention.

The question is why is it mandatory