I made the same game in Assembly, C and C++

I made the same game in Assembly, C and C++

Nathan Baggs

1 год назад

663,417 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

airstrike
airstrike - 24.09.2023 14:47

"In this video, we try to create linked lists directly in x86 to learn how painful that is"

Ответить
marzacdev
marzacdev - 04.09.2023 03:19

I respect the craft and the intention but at no point one need malloc or a linked list to make a break out game. Just declare an array on the heap and you're good to go.

Ответить
Jonathan Mosley
Jonathan Mosley - 25.08.2023 01:38

Now go higher still and see how efficient Python and JavaScript are

Ответить
Saturn
Saturn - 10.08.2023 21:12

Ummm.... can someone explain that how the c compiler optimisations are better than C. I Truly believe thst in somecases, assembly code optimizations should be faster than the compiler optimizations, right? Even if no, assembly tskes less memory and cpu power.

Ответить
sirius707
sirius707 - 29.07.2023 11:53

nice work. but data hiding is overrated. and you shouldn't use exception handling in games.

Ответить
Mohammad Alaa Elghamry
Mohammad Alaa Elghamry - 23.07.2023 06:15

That is very useful and impressive. Thank you.

Ответить
Foxer
Foxer - 07.07.2023 20:39

i dare you to use assemble and vulkan to make a fps game

Ответить
0x3F
0x3F - 12.06.2023 00:59

Why is your taskbar so tiny? Do you have an 8K monitor or what?! 🤯

Ответить
Saksham
Saksham - 20.05.2023 16:45

I was thinking about learning assembly, thank you for changing my mind

Ответить
Bubblun The Bubble Dragon (Bubble Bobble Leader)
Bubblun The Bubble Dragon (Bubble Bobble Leader) - 10.05.2023 01:34

Not Enough Filesize after making Breakout.
Upgrade to Arkanoid?

Ответить
imran boutadghart
imran boutadghart - 26.04.2023 05:49

don't know if you still look at comments on this video but I'd just like to say that your video was amazing except for two things one is that you switch between a complete dark screen to a completely white screen without notice and it hurt my eyes 3 times, two is that your video is too good to be 4 minutes long, i would've watched it completely even if it was 2 hours or so

Ответить
nobdy sus
nobdy sus - 08.04.2023 17:49

How do use x86 in windows

Ответить
andrews odyssey
andrews odyssey - 06.04.2023 23:52

Yeah assembly aucks on windows

Ответить
Slydime
Slydime - 05.04.2023 11:46

How tf did Chris Sawyer create a whole game engine, UI, AI, graphics with Assembly???

Ответить
Ello
Ello - 03.03.2023 09:57

I don’t get why you decided on c and c++, since c++ is basically just bloated c so you could’ve done something else

Ответить
megax5000
megax5000 - 20.02.2023 10:24

you guys wanna REALLY have your minds blown?

nearly all 8-bit and 16-bit games were designed in assembly

let THAT sink in

Ответить
Peter .Källviks
Peter .Källviks - 29.01.2023 13:26

Great video but it had been more interesting if you included C# as well.

Ответить
Eka Al-amin
Eka Al-amin - 24.01.2023 07:34

cool video, its make me want to learn again about low level and assembly deeper

Ответить
camthesaxman
camthesaxman - 22.12.2022 16:33

No idea why you'd need a linked list to implement Breakout.

Ответить
Sebastian Coetzee
Sebastian Coetzee - 09.12.2022 21:38

You should use Rust mate

Ответить
Shigidaropupay Pups
Shigidaropupay Pups - 09.12.2022 17:57

Why didn't you use in assembly the same libraries as in C program?

Ответить
Ivan Desiatov
Ivan Desiatov - 09.12.2022 17:56

std::vector is not a linked list

Ответить
fafa Ł
fafa Ł - 03.12.2022 01:02

If you have more time please make more video's tutorial about assembly its not the easiest and i have to learn it haha gj like:)

Ответить
Sophie 🏳️‍⚧️
Sophie 🏳️‍⚧️ - 02.12.2022 15:53

Now write it in IA-32e

Ответить
typedeaf
typedeaf - 02.12.2022 09:25

Not sure why you didnt make syscalls (call into the system API) with assembly. In C or C++ did you refuse to use any of the std libs? Why would you write in asm completely differentlly?

Ответить
James
James - 02.12.2022 09:12

What C offers over assembly first of all, is complex data structure.
Sure, you can create the same complex data structure in assembly; but it would be difficult to read or to keep track of. Or to explain, or to document.
C provides powerful syntax and symbols for you to visualize the layout of the data structures.
When you manipulate the data structure variables in assembly, all you have are registers, and you have to memorize what each register represents at each instance of time.
This is a common mistake in assembly coding; getting confused or mixed up with the registers.
What C++ offers over C is not only standardized data structure templates, but also the functions and algorithm to manipulate each data structure variable, freeing you from having to reinvent the wheel each time.
A tremendous time saver; with the added bonus of having the code completely readable by anyone.

Ответить
NoodleFlame
NoodleFlame - 02.12.2022 02:57

Boooo, you cheated with SDL. Creating an X11 windows is not that hard, especially after all of your asm triumphs! Seriously though, nice job! I've done similar using 68k for the megadrive, C win32 software renderer and C with OpenGL using no loader/binding/extension libraries. I found the last to be the most painful, not because it is difficult, infact the majority of the opengl loading is just tedius definitions and function ptrs. The headache was figuring out that to get the function ptrs you needed to create an opengl context, you first needed an opengl context, admittedly a dummy one you throw away once you've done getting them, but that took me a while to figure out on my own! Oh and also opengl errors are as helpful as the blank screen you see when you get the tiniest thing wrong.

Ответить
George Albany
George Albany - 01.12.2022 06:13

What makes compiler optimization so great is its not just a single bit of contributed ideas from a single person whose smart in the field of assembly, but its a collection of all the smartest techniques anyone could functionally think of to optimize your code, as a result the compiler is the culmination of every idea of almost every geniuses' demonstrably proven optimization technique, its basically the collective execution of every single engineering wizard in a singular binary who also knows exactly how to evaluate your code most efficiently almost all the time. (granted we assume all compilers do the same optimizations to low level machine code, which outside of edge cases and small processing differences that's pretty much true)

Ответить
LazerEye
LazerEye - 30.11.2022 16:12

sees assembly
shudders

Ответить
Adam Schlinker
Adam Schlinker - 30.11.2022 10:01

This makes the fact that Roller Coaster Tycoon was written in Assembly even more mind blowing.

Ответить
P
P - 28.11.2022 15:27

The ease of having high-level language commands, features, and libraries is important for large, complex, or integrated projects. It would take thousands of hours to write a simple OS in pure assembly. And thousands of thousands more to troubleshoot or debug it. Big programs in assembly are indeed a pain, that's why people avoid using assembly for big programs unless they absolutely need to.

But the advantages of assembly are not shown in this video.

The final executable file for something like this game would probably be around 20 kilobytes instead of being bloated up to maybe 20 megabytes.
And small code runs faster. Much, much, much faster. It would still contain delay cycles to be human-playable, but it could execute many more instructions during those clocks. This is admittedly not significant on a simple arcade game like this - but it is fundamentally important in more complex assembly programs.

Ответить
Developer Tips
Developer Tips - 27.11.2022 21:51

Its all funny until you try to 1v1 the person who wrote the C Compiler in assembly

Ответить
Shorttimer
Shorttimer - 27.11.2022 08:46

All this is way over my head, I used C in the past but that was in the eighties running on SCO Xenix.

But I do remember the code for this same game written in the Basic that came with the first gen Apple 2, I doubt if it was much longer than 30 lines due to the graphics and paddle capabilities that Woz built in when he wrote the language. It ran seamlessly on a 1Mhz CPU with the 32k Ram I started out with.

Ответить
Handle Needs 3 Characters Or More
Handle Needs 3 Characters Or More - 27.11.2022 05:38

Goes to show that assembly is faster only when the programmer is proficient in it

Ответить
P W
P W - 27.11.2022 03:01

Very cool, but may need a new graphics card... Looks like you are getting 5 fps

Ответить
Julian Skidmore
Julian Skidmore - 26.11.2022 15:28

Why would you need malloc to code a version of Breakout in assembler? Surely everything would just be statically allocated and you don't need anything more than simple arrays to represent the set of bricks on the screen (e.g. 1 byte per brick with each brick within a grid: 14 column x 8 rows). An early assembly programmer wouldn't even do that, they'd allocate 1 bit per brick. Then you'd first check the location of the ball: ball_y>=brickmap_y; && ball_y<brickmap_y+brickmap_height (but using MOV, CMP, JGE, JL type instructions instead). If the y coordinate is in range, you'd convert it to a brick location and check if the brick was present. Are any more complex data structures needed for Breakout - after all, the first version was created by Steve Wozniak without even a CPU in 40-odd TTL chips.

Ответить
Brock Savage
Brock Savage - 26.11.2022 06:28

Next, I tried python. Here's the code: import breakout

Ответить
David Plass
David Plass - 26.11.2022 05:40

Why'd you let yourself use a library in C but not in assembly language? You can call library functions from assembly, you know.

Ответить
charles d
charles d - 26.11.2022 00:19

Why did you not just use malloc in the x86 implementation. Was it because you didn't want to have to include the C runtime?

Ответить
AKoribut
AKoribut - 25.11.2022 19:38

Assembly is not that horrible. One doesn’t need to make everything from scratch. All these Libc functions are easily accessible in assembly. And I don’t understand why do you have to implement Malloc at all. You can allocate uninitialised data if you need it. Resulting binary won’t become bigger even if you asked for gigabytes. I know that is bad option for big project but for a tiny game like this… Why not?

Good thing in assembly. Using powerful macro language you can tune into something that suits you perfectly. In smallest details possible.
Bad thing. After this tuning is made no one is capable of reading your code(

Ответить
Marton Szasz
Marton Szasz - 25.11.2022 16:37

Why would you choose to use a linked list as your default container? Dynamic arrays are simpler and more efficient in most cases.

Ответить
Ari Archer
Ari Archer - 25.11.2022 12:19

.. this is why you do assembly in Linux or BSD omfg

Ответить
Kenneth Bæver Bjerke
Kenneth Bæver Bjerke - 25.11.2022 11:38

Nice one! Id love to see Rust added to this mix

Ответить
Péter Kovács
Péter Kovács - 25.11.2022 10:38

Well if you code in assembly with a c++ mindset no surprise you'll find c++ more comfortable. Same happens if you come from python to c++. Not to care about pointers and memory allocations is a "breath of fresh air" in python after c++. However if you do care about efficiency you'll find python frustrating, since you can't controll what the computer is actually doing. So if you learn the c++ mindset you'll find python extremely limiting. The same applies to assembly: if you wanna squize the last bit of performance out of the computer you'll find c or c++ limiting after assembly. Of course it doesn't really apply to moder PCs but could be a real issue with programing microcontrollers, 8 bit retro computers or other devices with limited resources.

Ответить
Tim Hofstetter
Tim Hofstetter - 25.11.2022 05:48

...but you've not only lost control with C++, you've also lost your ability to perform human optimization, which is capable of being far better than any automated optimization can ever be. You've also made the program more cryptic and less intuitive to maintain.

Watch your resulting C++ program sometime in a debugger as it makes system calls that leave you scratching your head because they look just... stupid. I've done exactly that, very many times... and with the progression of time and the greater tendency to lean on OOP languages I see a growing number of just stupid, wasteful system calls in software that has been "optimized" by the compiler / linker. You see... that was my last occupation before I finally retired. And... it just didn't happen with software written in good ol' C. It's little wonder that Linus Torvalds despised C++.

Ответить
Bridiro
Bridiro - 24.11.2022 23:28

Just remember that in 1999 a crazy man completely developed a game called RollerCoaster Tycoon in just Assembly, and it was the only game that could run on most of the computers at that time. So don't uderstimate the power of Assembly, maybe the slowest to develop, but most of the time the fastest to run

Ответить