r/ProgrammerHumor • • Oct 07 '26

Meme minecraftException

Post image
9.3k Upvotes

830 comments sorted by

View all comments

Show parent comment

139

u/ComputerWhiz_ Oct 07 '26

cough Unity uses C# cough

67

u/im-a-guy-like-me Oct 07 '26

No it doesn't. Unity uses C++. It just let's devs use c# as a scripting language.

53

u/ComputerWhiz_ Oct 07 '26

Still uses garbage collection though

55

u/potzko2552 Oct 07 '26

When your engine is cpp and most of your mem is chandled in cpp, having a scripting language that is GCed doesn't change the majority of the project's behaviour. Like adding lua embedding doesn't mean your project is no longer strongly typed

4

u/kondorb Oct 07 '26

Tell it to KSP devs - that thing freezes for GC every 5 seconds even with barely anything spawned.

10

u/cpt_melon Oct 07 '26

Unity developers' habit of attaching a million scripts to everything instead consolidating their code and building larger systems wouldn't work any better even if the language used was C++

9

u/3131961357 Oct 07 '26

And the code you write is most un-C# C# you'll ever see.

https://i.imgflip.com/b2xjwp.jpg

4

u/RyanCargan Oct 07 '26

About that...

Unity has a garbage collected scripting language in C# yes.

But y'know what they advise when using it in hot loops?

Turning off the garbage collector 👀

It’s best practice to disable garbage collection during short, performance-critical parts of your application, when you’re able to calculate and control how much memory to allocate. After the performance-critical section is over, re-enable the garbage collector. Profile your project to ensure that you don’t trigger additional managed allocations which might cause the managed heap to get too big.

This type of reasoning is sorta how arena-style manual memory mgmt in GC-less langs works too. You can just escape it more easily in many places here I suppose. Arena meaning "everything here dies together".

Unity also offers something called Allocator.Temp as its arena/bump allocator too IIRC:

Allocator.Temp: The fastest allocator, for short-lived allocations. You can't pass this allocator to a job.

More about arenas here if curious. It's about a totally unrelated language I've never used called Odin, but the concept of an arena was explained there better than anywhere else I've seen.

→ More replies (1)

9

u/suvlub Oct 07 '26

And Godot uses some customized not-quite-python

28

u/agocs6921 Oct 07 '26

It's not customised, it's custom. Also, it has reference counting. Not garbage collection in the sense like Java, Go, or C#. It's more like how Windows does it.

1

u/WilkerS1 Oct 08 '26

i genuinely thought reference counting was a thing used in garbage collection for Godot

1

u/Acceptable_Handle_2 Oct 08 '26

It is if you want it to be, that's what RefCounted objects do.

1

u/WilkerS1 Oct 08 '26

oh... so it is in fact, not a default behavior in Godot?

1

u/Acceptable_Handle_2 Oct 08 '26

it is a thing used in garbage collection, just not the default thing.

1

u/agocs6921 Oct 08 '26

It is a form of garbage collection, but it's not garbage collection like in those languages I mentioned because those stop your program from executing while they are finding and freeing objects, Godot does not.

11

u/nekomata_58 Oct 07 '26

Godot has c# bindings as well

11

u/sfmqur Oct 07 '26 edited Oct 07 '26

Godot's GDScript isn't a garbage collected language, it is reference counted/manually managed. Once an object(Node, Object) is no longer referenced you have to free it. Some objects are refrence counted (Respurces mostly). And when the reference count gets to zero. The engine frees the memory.

Edit: clarity.

2

u/TheMusicalArtist12 Oct 07 '26

Objects are manually controlled, but most things inherit RefCounted, which uses a reference counter. Meaning that usually you don't need to manually free things, you just gotta stop holding onto it

→ More replies (1)

1

u/not_some_username Oct 07 '26

It’s not the same out of the box

1

u/Narfi1 Oct 07 '26

I don’t think it compiles to C#

8

u/Zincette Oct 07 '26

Unity actually gives you both options. You can run it through dotnet or use IL2CPP to translate it to C++ and yeah, if you do that it does run better.

→ More replies (1)

-8

u/Prawn1908 Oct 07 '26

Doesn't make it a good choice.

14

u/ComputerWhiz_ Oct 07 '26

I guess fair, but I'm just saying that there are literally millions of games that are using garbage collection without an issue.

-5

u/Prawn1908 Oct 07 '26

without an issue.

Are you sure about that? Games in general aren't quite known for being perfectly bug free with excellently optimized performance these days.

→ More replies (6)