Handmade Hero » Forums » Code » Unity Builds in Practice
occamin
Mike
4 posts
#13239 Unity Builds in Practice
1 week, 2 days ago

Hey everyone,

I'm not too active on the forums but I've been lurking in the background following the series here and there, mostly referencing parts of interest and not following in a sequential matter.

Recently I came across the idea of a unity build and it blew my mind in a good way. I'm not really as interested by the compilation performance benefits (although those are nice), but the epiphany was the realisation that most model languages seem to conflate code organisation and dependency management.

Now as a *cough* web developer *cough* I'm pretty familiar with the idea of organising code into modules/namespaces and using some kind of import mechanism. Conceptually most modern languages end up building up a graph of code dependencies that can be difficult to reason about of often result in annoying issues like cyclic dependencies where there cycle is a few steps removed.

Conceptually it's much simpler (and in my mind simpler is generally better) to conceptually think of most of you application as a single file/compilation unit that is split among multiple files.

When researching unity builds I noticed that the general sentiment tends to be that they are good as some kind of "compilation performance hack", but not really as a way to structure programs. I've been looking through some open source game engines (gemrb, stratagus, etc) and unexpectly none of them use a structure like this.

How common is it to structure projects where is compilation unit is a unity build in practice? My feeling is that it is uncommon, and if so is there a good reason why one might not want to build their application this way?

I'm a Clojure developer by trade so I'm pretty unfamiliar C/C++ normals and common industry practices in general so I'd love to hear opinions from people who work with C/C++ on a regular basis.
mmozeiko
Mārtiņš Možeiko
1485 posts
1 project
#13241 Unity Builds in Practice
1 week, 1 day ago

occamin
they are good as some kind of "compilation performance hack", but not really as a way to structure programs.

Exactly. Unity builds are just a way how to get good compilation performance for C/C++ compilers. Not because its "easier" to organize the code like that. Just because otherwise your compile times will be in minutes if not hours. For other languages like C# or Java this is less of an issue. You don't need to do this for these languages, because they will be doing something similar internally anyways.
abnercoimbre
Abner Coimbre
211 posts
2 projects

Community Manager

#13299 Unity Builds in Practice
1 day, 9 hours ago

occamin
I'm a Clojure developer by trade so I'm pretty unfamiliar C/C++ normals and common industry practices in general so I'd love to hear opinions from people who work with C/C++ on a regular basis.

I would express to you the opposite!

I'm a proponent of low-level things and have lived my (admittedly short) professional life encouraging folks to be close to the machine. That said, I'm exploring other programming models so I may take insights from solving problems in those languages back into my daily grind -- and perhaps every programmer should do this at some point.

I purchased Seven Languages in Seven Weeks, and one of their languages is Clojure. A book is great, but I'd love to hear a summary of your experiences developing software with it.

Programmer for a certain space agency