How to stay SAFE with UNSAFE code | Unity Engine

preview_player
Показать описание
Hey There! 👋
Unsafe code in C# is pretty scary. But lets figure it out together.

Рекомендации по теме
Комментарии
Автор

Unsafe is such a misnomer. There isn't anything inherently unsafe with unmanaged code if you know what you are doing. You can just as easily crash a C# program as you can a C/C++ program. If you don't believe me try this code: void foo(int bar) { foo(bar+1); } foo(0);, so just because something is garbage collected doesn't mean it's safe from stupid code. The difference is that it's easier to write dumb code in C/C++ if you don't know what you are doing. That doesn't make the code unsafe, it makes the unskilled, unknowledgeable programmer unsafe. That's the case with any language though. I've been using C# since it was in alpha - my company was a Microsoft subsidarary and we were alpha and beta testers for C#. We rewrote our entire ISAPI layer in C#. Previously it was C++ mixed with some XML. If you got email from Outlook or Lotus Domino delivered to your blackberry or WML/WAP device in the early 00s then it was going through my code :).

BitwiseMobile
Автор

I didn't know C# even had this -- though it doesn't sound that scary if you learned C++ before C#.
Learning what assemblies are and how to make them might be the next step, since I'm still relatively new to C# and have seen the term thrown around without a real explanation, while C++ and Java lack them (at least in the versions I learned, I'm a bit behind the times with those languages now).

BlackJar
Автор

Thank you so much for these videos! It's really piqued my interest in this kind of programming in Unity, although it's still pretty tricky to full understand. I tried messing around with your audio generation code and after a long while I was able to successfully get it to output white noise, but that process made me realize there really doesn't seem to be a whole lot of documentation online for how to go about using unsafe code, and there's even less for using the Burst compiler outside of the context of the Job system.

I was curious how you went about learning how to write unsafe code correctly in Unity, and if you have any resources you could possibly share? Either way, thanks for the videos and keep them coming!

shmunkyman
Автор

This video is so good. The explanations and editing are clear. You just got yourself a subscriber! I hope to see more videos like this and I can see this channel getting real big!

nicholashendrata
Автор

I actually understand this video perfectly. Nicely done!

lemetamax
Автор

Hi, I've been a teacher for 5+ years trying to make educational videos interesting for kids around this topic blabla... but THIS VIDEO...

... 30 seconds in...
.. THIS FORMAT..
.. IT WORKS ..

you found it sir, the perfect balance between too much and too little

educational vs entertaining

50/50

enjoyable and instructable

VERY good job whoever you are!

PS. this is the first video I've seen from you hope the others arent shit :D

forrestgump
Автор

Great video! I wish someone explained me that way what a pointer is 30 years ago :)

ozanyasindogan
Автор

That's some nice editing! Keep up the good work!

codingpeanuts
Автор

Is there any issue getting games through iOS/android App Store approval when using unsafe code?

SteelyEyedH
Автор

In the NativeBox<T> class you created, instead of creating _data and a T Data reference, is it okay to just use T Data {get; private set; } or are there other implications to it?

gustavosalmeron
Автор

this is such a masterpiece of a video, keep up the good job!

pedroalonsoms