C++ For C# Developers: Part 5 – Build Model

Today’s article continues the series by introducing C++’s build model, which is very different from C#. We’ll go into preprocessing, compiling, linking, header files, the one definition rule, and many other aspects of how our source code gets built into an executable.

Read the rest of this article »

C++ For C# Developers: Part 4 – Functions

The series continues today with functions. These are obviously core to any programming language, but it’s not obvious how many ways they differ from functions in C#. From compile-time execution to automatic return value types, there are a lot of differences to cover today.

Read the rest of this article »

C++ For C# Developers: Part 3 – Variables and Initialization

Today we continue the series by introducing variables and how they’re initialized. This is another basic topic with surprising complexity for C# developers.

Read the rest of this article »

C++ For C# Developers: Part 2 – Primitive Types and Literals

The series continues today with our first actual C++ code! Today we’ll start with the absolute fundamentals—primitive types and literals—on which we’ll build through the rest of the series. As basic as this topic sounds, some of it can be pretty shocking when coming from a language like C#.

Read the rest of this article »

C++ For C# Developers: Part 1 – Introduction

Outside of Unity, C# is rarely used as a game programming language. C++ is used heavily in Unreal, Cryengine, Lumberyard, and almost all proprietary game studio engines. This series is for Unity game programmers who know C# and want to broaden their skills so they can effectively write code for other engines, or even write C++ scripts for Unity. Today we’ll begin with an introduction to C++’s history, standard library, tools, community, and documentation. Read on to get started!

Read the rest of this article »

LINQ-Style Generic Algorithms for Burst

We’ve seen how to create powerful, Burst-compatible generic algorithms already, but today we’ll take another approach to generic algorithms and implement them in the style of C#’s LINQ. Along the way, we’ll tackle a new challenge by implementing a generic algorithm that allocates a new collection.

Read the rest of this article »

Thread Synchronization Performance

Multi-threading is essential to performance on all modern processors. Using multiple threads brings along with it the challenge of synchronizing data access across those threads. Unity’s job system can do some of this for us, but it certainly doesn’t handle every case. For times when it doesn’t, C# provides us with a bunch of synchronization options. Which are fastest? Today we’ll find out!

Read the rest of this article »

Type-Agnostic Generic Algorithms

We looked at some generic algorithm examples in the previous article, but they weren’t very generic in one respect: they all required a NativeArray<T>. What if we wanted to make them more generic so they could work on any type of collection? Today’s article shows two ways to do just that!

Read the rest of this article »

Generic Algorithm Examples

There are many common algorithms that we use constantly: searching, filtering, mapping, and so forth. Today we’ll write a few in the Burst-friendly way as examples of how to write Burst-friendly code that’s still reusable and efficient.

Read the rest of this article »

How SharedStatic Works

Burst 1.2 comes with a new feature: SharedStatic<T>. This allows us to write to static variables from within Burst-compiled code like jobs and function pointers. Today we’ll look at how this is implemented by Burst and IL2CPP. We’ll also put them to a performance test to see how fast they are.

Read the rest of this article »