I re-created the game of life in Assembly

Поділитися
Вставка
  • Опубліковано 27 лис 2024

КОМЕНТАРІ • 124

  • @JaredFL
    @JaredFL 5 місяців тому +258

    Assembly is high level. If you haven't manually applied electricity to the individual grains of sand, you aren't a senior developer.

    • @WifeWantsAWizard
      @WifeWantsAWizard 5 місяців тому +10

      Grains of sand are high level. Hey, everyone! Jared doesn't know about robust qubits on super-cooled semiconductor platters. Senior, indeed!

    • @DiegoGamboa-lo2lw
      @DiegoGamboa-lo2lw 5 місяців тому

      This comment shows you are not a senior developer

  • @tanko.reactions176
    @tanko.reactions176 5 місяців тому +133

    now.. start writing some macros for common coding tasks, like for loops.
    call it "for"..
    repeat writing such macros and you will end up with C

    • @daniel_77.
      @daniel_77. 5 місяців тому +4

      I know this is meant to be a joke comment, but is it accurate?

    • @jan.tichavsky
      @jan.tichavsky 5 місяців тому +6

      @@daniel_77. Not really. Macros are afaik fixed substition rules, you still end up with straightforward translation to machine code at most with two passes of the file. Now compiling C to machine code is a dynamic process which you can tune and the result depends on context of the rest of your program.

    • @daniel_77.
      @daniel_77. 5 місяців тому

      @@jan.tichavsky is the speed similar?

    • @neniugrava
      @neniugrava 5 місяців тому

      ​@@daniel_77. Not even close to accurate. Compilers are typically very complex pieces of software that parse your code and convert it into an intermediate representation (an abstract syntax tree) and then use some fancy algorithms to optimize out redundancies (and more). Then you've got the linker that figures out how to combine all of your files/classes with libraries you use.
      An assembly macro system is more like the C preprocessor. A few of the assembly statements in this video are macros.
      it is very unlikely that you'd beat a compiler in speed or code size with hand-written assembly code (compared to a low-level compiled language like C).

    • @noelgallagher3646
      @noelgallagher3646 5 місяців тому +4

      ​@@neniugravaI don't know why people keep repeating this. Handwritten ASM is faster and the binary is smaller. for example, compilers suck at SIMD and intrinsics are ugly as hell to work with. Advantage of higher level languages is portability. No need to write ASM targeting x86, ARM, whatever

  • @ashutoshj
    @ashutoshj 5 місяців тому +57

    I graduated last year, seems like my CS degree wasn’t just for writing code-it was also my secret decoder ring for getting those cryptic tech stuff. Awesome vid!

    • @markamber1480
      @markamber1480 5 місяців тому

      They teach computer engineering, assembly, etc in CS yes?

    • @ashutoshj
      @ashutoshj 5 місяців тому

      ​@@markamber1480 Yes, I had a course on Microprocessors and Microcontrollers where we had to write some programmes in assembly and verilog.

    • @m33r61
      @m33r61 5 місяців тому

      @@markamber1480they teach computer engineering in computer engineering

    • @אקרמיצאלח
      @אקרמיצאלח 5 місяців тому

      Its hard to answer for all universities globally, but in my country at least every university has a couse in which you will learn assembly although its not the main focus of the course​@@markamber1480

    • @osayemeokwechime2456
      @osayemeokwechime2456 5 місяців тому +1

      @@markamber1480 I was taught computer architecture and assembly in my CS program.

  • @iCrimzon
    @iCrimzon 5 місяців тому +37

    Now make a tutorial for a neural network in ASM x86 pls bro

    • @Takyodor2
      @Takyodor2 5 місяців тому +12

      It's funny because the x86 part is much scarier than the neural network part 😂

    • @enricofischer1330
      @enricofischer1330 5 місяців тому

      ​@@Takyodor2 True, one comand compiles to different oppcodes lol

    • @notsojharedtroll23
      @notsojharedtroll23 5 місяців тому

      This, but unironically

    • @Takyodor2
      @Takyodor2 5 місяців тому

      @@notsojharedtroll23 I'm not sure it would be a good idea. Most use-cases for neural networks I can think of involve images (or other complex file types), and I think writing ASM to unpack the training data would be both tedious and hard.

    • @raphaelfrey9061
      @raphaelfrey9061 4 місяці тому

      The only hard thing is keeping track of the loops, activation functions and floating point values.

  • @EdwinMartin
    @EdwinMartin 5 місяців тому +27

    What do you mean there's no "if". A conditional branch instruction in assembler is the same thing but with more words.

  • @mahakleung6992
    @mahakleung6992 5 місяців тому +4

    As a retired software engineer who grew up in the analog age, I say BRAVO! I always thought OO was way too much abstraction. I have coded in hex embedded processors and worked with data scopes. BTW, you can do assembly directly in C via macros. You can interface assembly into anything using a linker or DLLs. Efficient coding is a long since dead art if you are not doing RTOS like missile guidance.

  • @igorvasylchenko8293
    @igorvasylchenko8293 5 місяців тому +1

    Python: gets ready working example of Conway's Game of Life with GUI in under 2 min. (including intro)
    Java: proceeds to write server with single GET endpoint
    C++: implements custom classes to handle routine file management
    C: writes text editor in terminal
    Assembly: spends more than a half of video to write terminal version of Conway's Game of Life (not including off-screen time which I suspect is SLIGHTLY bigger considering debugging mentioned bugs)
    Classic at its best)

  • @Grahamaan27
    @Grahamaan27 5 місяців тому +10

    "to me [classes] just look like meaningless boilerplate"
    What did you just say?

  • @Slicudis
    @Slicudis 5 місяців тому +6

    I hate x86, ARM and RISC-V so much, leading me to design my own architecture lol (I'm not joking)

  • @thenameisluk
    @thenameisluk 5 місяців тому +8

    nice video

  • @friedmule5403
    @friedmule5403 5 місяців тому +1

    LOL, Oh the good old days:-)
    I have to say that your version of Assembler is a fairly high level, compare to the start 80s.
    You had no way to just add ASCII, you had to call the letters from the right memory, switch them, combine them and then start up the memory part that had to do with the screen, then set the screen up, tell the CPU to calculate, add the result to the address that you had made for a buffer and send it to the screen.

  • @naghs2726
    @naghs2726 5 місяців тому +3

    with assembly sometimes it can help to write equivalent C code then paste it into godbolt to see the assembly at different optimization levels and how you might code it in assembly

  • @mou8842
    @mou8842 5 місяців тому +2

    i really struggled to read the code in the c++ part, guess i'm addicted to colorschemes

  • @cvabds
    @cvabds 5 місяців тому +10

    Can you do that but in TempleOS?

    • @white_145
      @white_145 5 місяців тому

      isnt templeos just funny c?

  • @denissorn
    @denissorn 5 місяців тому +4

    Java AoT... There are options like GraalVM, but normally you only AoT compile to bytecode.

  • @uuu12343
    @uuu12343 5 місяців тому +5

    Big OO is a real Pain

  • @NostraDavid2
    @NostraDavid2 5 місяців тому +2

    I would argue that Haskell is the highest level language there is, since you kinda need to know Category Theory (very abstract math) before you can understand the Monad.
    But maybe that's just me.

    • @pdr.
      @pdr. 5 місяців тому +1

      I would agree that Haskell is a very high level language but completely disagree that you need category theory to understand what a monad is in Haskell.
      By the way, @OP, when did C become a _low-level_ language? Basically, any language above assembler is considered high level.

    • @pdr.
      @pdr. 5 місяців тому

      And to explain why Haskell is very high level, you can think of functional programming as a higher level of discipline. That is, you are more restricted in what you can do. This allows for easier analysis at the cost of being less verbose. Similar to how electrical engineers use discrete components and operate those components under strict conditions, like standardising what high and low voltage signals are which allow you to forget about voltages completely and start talking in 1s and 0s instead.

    • @vidal9747
      @vidal9747 5 місяців тому +1

      ​@@pdr.C is lower level than most. Some people call it middle level even.

    • @willmungas8964
      @willmungas8964 5 місяців тому +2

      @@vidal9747I think it’s fair to say C is high level from a systems and OS programming perspective, but low level for any kind of application programming. It offers useful abstractions to be just above assembly, but those who are familiar with assembly have a fairly easy time conceptualizing what assembly code will be generated by a given piece of C code because the abstractions are so direct.

    • @kehindeakiode2865
      @kehindeakiode2865 5 місяців тому

      ​@@willmungas8964Very true. It was from learning C that I really understood what the processor was doing under the hood.

  • @xcoder1122
    @xcoder1122 5 місяців тому +22

    "Assembly is better than Python" - Better at what? I'm pretty sure if you put two random people side by side, person A and person B, you can always say that person A is better than person B because there surely is at least one thing, person A will be better at than person B. But you can say the same for person B, as it surely also works the other way round. So the term "better" on its own is meaningless unless you also name a property that you are comparing.

    • @pro_gemer
      @pro_gemer 5 місяців тому

      Python cccp brainwashing
      accept assembly as your superior and future manager

    • @no_nuts0614
      @no_nuts0614 5 місяців тому +4

      it's better at coding

    • @baraka629
      @baraka629 5 місяців тому +5

      "assembly is better" - 💪😎
      "b-b-better at what?" - ☝️🤓💬

    • @jorgedavid726
      @jorgedavid726 5 місяців тому +1

      Now say it again without criying

    • @xcoder1122
      @xcoder1122 5 місяців тому +1

      @@jorgedavid726 You seem to have posted to the wrong thread. Your comment doesn't even make sense in this context.

  • @F100cTomas
    @F100cTomas 5 місяців тому +1

    I don't think your C++ code has any memory leaks. Shared pointers are just really smart. When you copy them a counter goes up and when you destroy them or reassign them the counter goes down. When the last shared pointer stops pointing at that address, the memory gets freed.

  • @brunojcm
    @brunojcm 5 місяців тому +3

    so, you don't use any "heap", just registers and the stack? writing something without heap is pretty cool :)

    • @tom-delalande
      @tom-delalande  5 місяців тому +2

      I am not ready for the heap yet, but I will try it some day

    • @batatanna
      @batatanna 5 місяців тому +1

      ​@@tom-delalandeOnce you use it you can never go back

    • @thewholeworldisburningharry123
      @thewholeworldisburningharry123 5 місяців тому +1

      I remember about Low Level Learning video on NASA’s procedure to writing safe code. And the 3rd rule is not using the heap !!

    • @brunojcm
      @brunojcm 5 місяців тому +1

      @@thewholeworldisburningharry123 keen to what this one :) That's easier on arm, anyway, it seems to have plenty of registers. IIRC from my uni times x86 has AX BX CX DX and that's it.

    • @jan.tichavsky
      @jan.tichavsky 5 місяців тому

      @@brunojcm x86 64 has more, then you can use all the different extensions and multimedia features, boom you have tons of rregisters to use. RISC based CPUs have at least uniform bank of registers which is easier to think about.

  • @cook5436
    @cook5436 Місяць тому

    Great! Did you use ChatGPT as an aid for the file explorer?

  • @ninetydirectory3798
    @ninetydirectory3798 5 місяців тому

    Every software is open sauce once learned Assembly.

  • @beradeep
    @beradeep 5 місяців тому

    Can you please bring a playlist on Kotlin and Htmx?

  • @zxuiji
    @zxuiji 5 місяців тому

    5:29, The only time you should not be setting up the free() and fclose() call at the end straight away is if you're returning it or passing that responsibility to a specific thread. In all cases you should have a fallback free() and fclose() call.

  • @Cronay
    @Cronay 5 місяців тому +1

    Liked the video! The repository is still private I guess.

    • @tom-delalande
      @tom-delalande  5 місяців тому +2

      Thanks! I knew I forgot something

  • @d3adstarr
    @d3adstarr 5 місяців тому +1

    cool video man

  • @Somfic
    @Somfic 5 місяців тому +4

    pretty much anything is better than python

  • @replikvltyoutube3727
    @replikvltyoutube3727 5 місяців тому +2

    Now write it in bash

  • @timondalton8731
    @timondalton8731 5 місяців тому

    Loved slapping HTML/CSS🤣

  • @AndrewTSq
    @AndrewTSq 5 місяців тому

    Next we do it in Machine Code :) nice one

  • @tempname8263
    @tempname8263 5 місяців тому

    It'd be nice to see how fast can your program execute, it being plain asm with minimal memory access.

  • @peterwilson7532
    @peterwilson7532 5 місяців тому

    Assembler is too high level for me, I prefer to punch in a series of ones and zeros with a handheld switch! Machine Code baby, yeah. 😂
    My computer BIOS Bootstrap is made of diodes soldered to a motherboard. You have to get the soldering iron out to edit the code. I spend almost my entire life, programming my computer to add two numbers, outputting the answer on binary coded individual LEDS.
    It would only take me three months to input the code for ”The Game of Life". Drawing the output to paper for the first move would probably take a day. After three months I could clamp all the drawings along one edge and flick through them quickly, creating the animation of the screen on a regular computer.
    At 50Hz I would have 2 whole seconds of gameplay after 3 months, so fast, phew!

  • @xcoder1122
    @xcoder1122 5 місяців тому

    It looks like you might have missed it, but Python is an object-oriented language. All data types in Python are actually classes. Even "int" is a class in Python, but "int" isn't a class in C++ or Java. Also, the NoneType is a class in Python, so even the thing that represents no value whatsoever is a class in Python. This means that Python is more object-oriented than C++ and Java, not less. Python is as object-oriented as Smalltalk when it comes to data types. Smalltalk goes one step further by making every instruction a method (even "if" and "while" are not language constructs, they are methods in Smalltalk). So it doesn't make sense to bash on Java and C++ for being object-oriented languages but not on Python.
    Python's OO approach just makes it seem less OO at first glance. E.g. you may criticize that in Java every function must belong to a class, while in Python you can have functions that don't belong to any class; but the reason for this is that functions are objects themselves in Python, so they don't need to belong to a class, they can exist on their own, but not in Java; Java functions are not objects, so again, Python is way more object oriented than Java.

    • @Chr0n0s38
      @Chr0n0s38 5 місяців тому

      In all fairness with Java, int is a primitive but there is a class wrapper around it.
      Java doesn't have functions, but rather methods, for exactly the reason you stated. It is fully OO because of that. You never have to use a primitive in your code directly. It's a different approach to implementing OO, that doesn't make it less OO.

    • @xcoder1122
      @xcoder1122 5 місяців тому

      @@Chr0n0s38 "Java doesn't have functions, but rather methods" - Methods are functions. There is no objective distinction between those two terms. In Swift for example. classes also have functions, yet those functions are basically what Java would call methods. Dito Rust. In JavaScript there are only functions, yet JS is an OO language with objects. The original idea of OO did not include methods but "messages". Objects would exchange messages but the concept does not define what a message looks like or how it is implemented. A static method in Java is conceptional no different to a function in C and if you use only static methods in Java and only primitives, you can do functional programming in Java, nobody is stopping you from doing that (just search Google for "functional programming in java" and you will find thousands of code samples).
      And yes, Java has wrappers, but that's not the point. The point is that it has primitives and that makes it less OO to a language where everything is an object. In Python, everything is an object, because in Python everything must be an object as Python only knows objects, in Java not everything is an object. The fact that you can wrap primitives in objects doesn't change the fact that in Java not all data types are objects.

    • @Chr0n0s38
      @Chr0n0s38 5 місяців тому

      @@xcoder1122 There is a distinction. Functions exist outside classes, methods do not. That distinction does matter when you try to say that the lack of functions as objects makes Java less OO than Python. If anything, the fact Python lets you avoid OO makes it less OO (hence why it is called general purpose and not OO). If you're going to count primitive ints against Java when object wrappers exist, then you should count stand-alone functions against Python.
      All of this is ultimately purity spiraling though. Python works best when used as a declarative functional language, going against OO. OO is just bad design.

    • @xcoder1122
      @xcoder1122 5 місяців тому

      @@Chr0n0s38 Again, not true for many languages where functions do live within classes or are parts of objects because what Java calls methods is called function in many languages and that is totally okay. Just because Java decided to call their functions methods does not mean that a function that is part of an object or a class must be called method. There is no such rule anywhere in the entire IT industry. When yo make you own programming language tomorrow, you are free to call your functions methods and you methods functions or call both by entirely different names and nobody will forbid you to do that. The term "function" existed in mathematics long before there even used to be programming languages. Swift always calls them functions, whether they are attached to class or not doesn't matter. Javascript always calls them functions, whether they exist standalone or are part of an object. Rust uses functions as a superordinate concept; there are methods and closures and Higher Order Functions (HOF) and Diverging functions, and those are all different types of functions according to the rust manual (so rust even literally says methods *are* functions). There is no rule that a function belonging to a class must be named a method, just because that's how Java names them.
      And no, Python does not let you avoid OO. You use a data type in Python, you use an object. You cannot write any Python code whatsoever that does not use objects. You seem to be under the incorrect impression that OO means your code must look in a certain way or you must design your code to OO principles. Just because you don't follow OO principles does not mean that you are not using OO. In Python you have no choice, you always use OO. Just because your code doesn't look that way means nothing. Did you perform the Google search I told you? If you did, you had seen plenty of Java Code that also follows no OO principles and does not look like OO code at all. You cannot use Python as a "a declarative functional language" because the moment you use any data type, that is an object and a a declarative functional language has no objects.

    • @Chr0n0s38
      @Chr0n0s38 5 місяців тому

      @@xcoder1122 Again, that distinction does matter. Functions in classes are methods, even in other languages.
      Now that said, other languages may not choose to follow that distinction for themselves, but it doesn't mean the distinction isn't there. They just choose to ignore it.
      And yes, Python does let you ignore OO. OO isn't just "everything is an object" it's a programming style. Smalltalk forces, as does Java (seeing as how not even main exists outside of an object). When writing Python code you can choose to ignore that full feature set. I do that all the time, favoring a functional style instead. What the language uses under the hood doesn't matter, if it did then nothing would be OO because under the hood it's all actually procedural. Style is entirely in how you use it.
      You need to brush up on your vocab, badly.

  • @sillybuttons925
    @sillybuttons925 5 місяців тому

    Ha, I loved VIN! Looking forward to the release to switch off neovim.

  • @atrbulldog5955
    @atrbulldog5955 5 місяців тому +9

    Everything is better than python, most of its libraries are written in different languages lol

    • @zill150
      @zill150 5 місяців тому +2

      The fact that people rewrite Python into libraries in different languages only to continue to use Python is pretty telling

    • @charlieking7600
      @charlieking7600 5 місяців тому +2

      ​@@zill150well, some people don't get the concept of scripting language and the fact that not everyone is a professional programmer.
      Even scientists use Python, because they have already difficult work and low-level programming isn't going to help.

    • @pubdigitalix
      @pubdigitalix 5 місяців тому

      @@charlieking7600 Some people are lazy. Most scientific programs for the 70s was writing in Fortran and most scientists of that time are not professional programmers either.

  • @Quanayman
    @Quanayman 5 місяців тому

    0:28 nothing like RUST.. most loved language XD

  • @Progaros
    @Progaros 5 місяців тому

    Great comparison!

  • @vidal9747
    @vidal9747 5 місяців тому

    7:55 let me tell you how godamn awful Fortran documentation is... Most of it is for stuff that is in the lengugae but is not good practice to use anymore.

  • @henning4327
    @henning4327 Місяць тому

    Uuhm ... You do know that this still runs on a bloated OS, right?
    Make it run on bare metal!

  • @sidharthcs2110
    @sidharthcs2110 5 місяців тому

    I guess 1s and 0s are even better

  • @W0lfCL
    @W0lfCL 5 місяців тому

    Pfft, Imagine not passing bits to the processor and just lazily coding in assembly

  • @whiskerskitten513
    @whiskerskitten513 5 місяців тому +2

    Loved the vid, should try code in Windows batch file since its inbetween c and assembly.

    • @nou4605
      @nou4605 5 місяців тому +4

      Wut no. Batch scripting is pretty high level. On the same level as Python.

  • @brunojcm
    @brunojcm 5 місяців тому

    I could smell something going wrong when you said shift right... but for some reason XOR came to my mind instead of AND, which is indeed the best option.

  • @marko9900
    @marko9900 5 місяців тому

    Assembly is just a low low level language. You need to go deeper. Machine Code. only 1's and 0's. Its low low low level language :D

  • @BinaryMaestro1
    @BinaryMaestro1 5 місяців тому +1

    html and css are not programming languages bros honest at least also why didnt u try zig instead of C?

    • @willmungas8964
      @willmungas8964 5 місяців тому +2

      Because Zig has barely been around and is relatively unknown, and C is only one of the oldest, most stable, and most well known languages still in use today

    • @jan.tichavsky
      @jan.tichavsky 5 місяців тому

      CSS is complex and offers interactive features, conditions, complex selector options and so on. You can do multi level interactive menu with it as well as actuate stuff with simple checkbox (hide, show, move, etc.).

    • @zeektm1762
      @zeektm1762 5 місяців тому

      @@willmungas8964Fortran

  • @xorxpert
    @xorxpert 5 місяців тому

    Java is memory efficient? Haha, consult with the garbage collection department

  • @accountlinkingmail
    @accountlinkingmail 5 місяців тому +4

    1st

  • @frytura
    @frytura 5 місяців тому

    binary is not a programming language?

  • @m4rt_
    @m4rt_ 5 місяців тому

    That C code is awful...
    though I guess it's fine since it gets the job done.

  • @Charlyzard_ssb
    @Charlyzard_ssb 5 місяців тому

    you smell like a webdev

    • @xxXXuser69420XXxx
      @xxXXuser69420XXxx 5 місяців тому +8

      bro coded GoL in ASM and that's what you extrapolate? Low T energy frfr