DIY Programming Language #1: The Shunting Yard Algorithm

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

КОМЕНТАРІ • 292

  • @javidx9
    @javidx9  6 місяців тому +65

    So are you BODMAS, or PEDMAS, or something else?

    • @samuelhulme8347
      @samuelhulme8347 6 місяців тому +13

      I’m BIDMAS, taught that by a UK school.

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

      BIMDAS im from Ireland

    • @stephenkamenar
      @stephenkamenar 6 місяців тому +61

      i've only ever heard PEMDAS

    • @TheHackysack
      @TheHackysack 6 місяців тому +32

      PEMDAS

    • @mantictac
      @mantictac 6 місяців тому +17

      BEDMAS (Ontario, Canada)

  • @ModernVintageGamer
    @ModernVintageGamer 6 місяців тому +203

    i've been writing code for almost 30 years and im still learning new things. thank you so much

    • @irishbruse
      @irishbruse 6 місяців тому +12

      Ah a man of culture nice to see you here

    • @javidx9
      @javidx9  6 місяців тому +42

      Im in the same boat, fancied trying to understand how the languages work for a bit, rather than just using them lol

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

      @@javidx9 great idea for a series! 🙂

    • @markuszeller_official
      @markuszeller_official 6 місяців тому +2

      Same to me! Still hungry for coding entertainment and algos.

    • @jhfoleiss
      @jhfoleiss 6 місяців тому +3

      It's so awesome to see one of my favorite UA-camrs watch videos by another one of my favorite UA-camrs!

  • @psodq
    @psodq 6 місяців тому +24

    During the first 8 minutes I was thinking: You know he is a programmer when he does not need a computer to program! Thumbs up!

  • @user-ov5nd1fb7s
    @user-ov5nd1fb7s 6 місяців тому +54

    Dude, I started following your stuff when I was a junior dev. Almost 10 years have passed, nice to see you still make great content.

  • @Barnardrab
    @Barnardrab 6 місяців тому +16

    In school, we were taught "Please Excuse My Dear Aunt Sally" as the acronym for the order of operations.
    Also, another word for value is operand. For instance, in 4 + 5, the "+" is the operator and "4" and "5" are the operands.

    • @TheSelfUnemployed
      @TheSelfUnemployed 6 місяців тому +3

      kids now learn PEMDAS as Please Excuse My Dope Ass Swag

    • @YourMom-rg5jk
      @YourMom-rg5jk 6 місяців тому

      ​@@TheSelfUnemployedI really missed out

  • @kplays_6000
    @kplays_6000 6 місяців тому +55

    Just as a callout to people who learn alternatives such as PEMDAS and BIDMAS - the order of multiplication and division doesn't matter - they have the same precedence and are just done from left to right together. The same with addition and subtraction. You can swap M/D and A/S if you feel more comfortable that way, but these are within the scope of this video the only pairs that are interchangeable as of right now!

    • @BlastinRope
      @BlastinRope 6 місяців тому +4

      To add more context, division is just multiplication with a number between -1 and 1, just like subtraction is just addition with a number that is less than 0.

    • @CJBurkey
      @CJBurkey 6 місяців тому +11

      @@BlastinRope (division is multiplication by the reciprocal, I think that's what you're saying)

    • @JayDee-b5u
      @JayDee-b5u 6 місяців тому

      This is good but those rules are kind of arbitrary. It would be better to have an order of precedence list that can be 'modified' as per the grammar/language requirements, otherwise you get this monolithic structure which isn't easy to extend.

    • @williamsquires3070
      @williamsquires3070 6 місяців тому

      Exactly, and I would lump exponentiation in with other functions (or their equivalent symbology, such as |x| to means abs(x), or x! to mean factorial(x)), so that e^x-2 is exp(e, x)-2, but e^(x-2) would be exp(e, x-2); this makes sense in terms of computer programming where these are often in a library, like in C/C++. So the order of precedence becomes; parentheses, functions, multiplication/division in order from left to right, then finally addition/subtraction in order from left to right.

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

      PE(MD)(AS)

  • @TheSelfUnemployed
    @TheSelfUnemployed 6 місяців тому +10

    Just got into the Pixel Game Engine and happy to see you still making content! Thanks for everything you do for the community, you are appreciated!

    • @javidx9
      @javidx9  6 місяців тому +4

      Thanks buddy!

  • @antonpieper
    @antonpieper 6 місяців тому +14

    Custom programming languages are an interesting topic that plagued my mind for years! Great to see you covering this

  • @landmanland
    @landmanland 6 місяців тому +9

    I never knew that it was called the shunting yard algorithm. I still remember that creating a calculator was one of the first programs I had to write while studying 35 years ago.

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

    My mind was blown when I combined Recursive Descent statement parsing and Pratt expression parsing constructed with compile time curried functions. Great analysis of this expression parsing algorithm!

  • @coronelkittycannon
    @coronelkittycannon 6 місяців тому +3

    Shoutous to the Stack Overflow answer that gave a fully functional recursive parser in Java! Really helped me in highschool!

  • @GRAHAMAUS
    @GRAHAMAUS 6 місяців тому +3

    Familiar algorithm, well explained -- good job! One thing you might have added is why it's called the "shunting yard algorithm", because it can be explained by analogy to shunting railway wagons in a yard in such a way as to build a train in the necessary order. In that analogy, only one stack is generally used (though another is needed for evaluating the solution, though in fact it can be the same stack with a bit of cunning).

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

    programming language development on this channel, I'm all for it!!

  • @Sam-hu3xt
    @Sam-hu3xt 6 місяців тому +2

    I love how eloquent you are explaining alien stuff like this.

  • @devpoodle
    @devpoodle 6 місяців тому +3

    Great vid! I never really knew where to start when it came to evaluating expressions.

  • @pixelfingers
    @pixelfingers 6 місяців тому

    I once read about the shunting algorithm but couldn’t work out what was going on. Being able to visualise it with bits of paper is such a good way of explaining it - I get it now - thank you. Brilliant video 👍🙂

  • @Olosann
    @Olosann 6 місяців тому +3

    The best ever use case for kitchen table. Thanks!!!

  • @CediCore
    @CediCore 6 місяців тому +1

    I love your lovely placed remarks, like the "system("pause")" one ❤

  • @petacardi
    @petacardi 6 місяців тому +1

    It has been a while since I last watched one of your videos, it feels like meeting with an old friend after a long time.
    Now I miss programming c++

  • @jhfoleiss
    @jhfoleiss 6 місяців тому

    I teach this algorithm in an introductory data structures course. It's a fun algorithm that makes students "get" the importance of using appropriate data structures to solve problems (in this case, the stack). Great explanation, btw!

  • @ryanlarge6296
    @ryanlarge6296 6 місяців тому +2

    This was a fantastic educational video! Thank you for your time with this one. Very excited to see what comes next in the series!

  • @Z80Fan
    @Z80Fan 6 місяців тому +16

    25:50 The answer is 2 but not for the reason given: multiplication and division have the same priority so they are evaluated left-to-right, so: 1x(2+4)/3 = 1x6/3 = 6/3 = 2. The same for addition and subtraction.

    • @AliceErishech
      @AliceErishech 6 місяців тому +1

      I wonder if his implementation might have some errors somewhere due to prioritizing those differently.

    • @javidx9
      @javidx9  6 місяців тому +4

      Not yet, but it could. I've not mentioned "associativity" once in the video, and for good reason, it does introduce complexity to what is otherwise a very approachable algorithm. However we can't escape associativity should we need more interesting operators, which potentially disrupt the natural left to right bias of the solution stack. Interestingly, negation unary operator is contrary to this, but because we know it's the unary operator it's actually handled differently anyway during solving, but that might not always be the case moving forward.

    • @CharnelMouse
      @CharnelMouse 6 місяців тому +7

      @@AliceErishech You can see an error appearing at 15:22, where
      1 + 2*4 - 3 + 5/6 * 2 + 6 - 1 - 4 + 7
      is effectively parsed as
      1 + 2*4 - (3 + 5/6 * 2 + 6) - 1 - (4 + 7)
      More simply, 1 - 2 + 3 would be computed to be -4 rather than 2, since it's parsed as 1 - (2 + 3).

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

      ​@@javidx9Doesn't it already fail for 2 - 1 + 3 which should evaluate to (2 - 1) + 3 = 4, but instead evaluates to 2 - (1 + 3) = -2 because + has a higher precedence than -? Or am I not understanding something (a distinct and likely possibility)?

    • @MrChannel42
      @MrChannel42 6 місяців тому

      Powers are an interesting exception here though as they're evaluated right to left (or at least that's what I was taught - wikipedia and google's built in maths evaluation function seem to agree). So 2^2^3 = 2^(2^3) = 2^8 = 256, whereas if you go left to right you would get 64.

  • @tsol9097
    @tsol9097 6 місяців тому +1

    We called this postfix notation when I was learning compiler design - there's also a prefix way to do it. I believe we used an operator stack and a literal stack, but essentially the same process.

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

    Great work mate.
    If I had existed 10 years ago I would have had an easier time writing my compiler in college. I’m glad creators like yourself are out there.

    • @zorg-in8423
      @zorg-in8423 3 місяці тому

      Are you less than 10 years old or there is a typo?

  • @PabloSanchez-th5em
    @PabloSanchez-th5em 6 місяців тому

    Always, Aaalways I come back to Javid channel I learn something new! Thank you so much for all!

  • @Andrew90046zero
    @Andrew90046zero 6 місяців тому +1

    I hope this series gets into tokenization and other related topics.
    A while ago I tried to make an assembly parser, and only got so far, lol.

  • @vitoralmeidasilva
    @vitoralmeidasilva 6 місяців тому +2

    The master has returned. Always good to see amazing content with value from you and the community.
    Keep it up javid, and congratulations on X10 growing health:)

  • @angelstojanov2346
    @angelstojanov2346 6 місяців тому

    Thank you so much for this video, I've been really looking into how to create a programming language and this has helped me tremendously. Please do a whole series on how to lex, parse, compile/solve/interpret a language, really looking forward to this

  • @SahraDrama
    @SahraDrama 6 місяців тому +1

    Amazing explanation as always, thanks a lot
    But a side note, without considering left-to-right evaluation unpredictable results will occur `1+1-1` & `1-1+1`
    Also waiting your approach for multiple digits numbers

  • @craigberry5713
    @craigberry5713 6 місяців тому

    Dang I've missed these videos. You have a real gift for making the complex simple. Thank you!

  • @Adowrath
    @Adowrath 6 місяців тому

    A neat detail with the arity check could be to track, whenever either a constant gets pushed to the output stack or an operator gets flushed onto it, you'd be able to track the amount of "available" values there are lower in the stack -- thus the error could be localized better too.

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

    Thanks for this. I have always used recursive descent when playing with parsing. I really enjoyed learning the shunting yard algorithm. I implemented this in Python using a regex tokenizer and output RiscV assembly instead on interpreting. So, where you made an interpreter with a compiler, I made a compiler with an interpreter.

  • @terminallumbago5582
    @terminallumbago5582 6 місяців тому

    When I was an intern, many years ago now, I had to write a basic scientific calculator. This is what I used. Was fun. I wrote it in Java. Brings back memories. 😂

  • @Paulie68000
    @Paulie68000 6 місяців тому +1

    I learned RPN when tinkering with the Jupiter Ace with its inbuilt FORTH programming language back in the eighties! A doomed computer if ever there was one!

  • @xybersurfer
    @xybersurfer 6 місяців тому

    nice explanation. i had heard about this algorithm but hadn't looked into it yet

  • @sossesam
    @sossesam 6 місяців тому

    Love the way you explained the algorithm. Although i learnt C, i would like to learn C++ to follow along. Great job.

  • @sanderbos4243
    @sanderbos4243 6 місяців тому +1

    Great video! I used Recursive Descent rather than the Shunting Yard Algorithm to parse my programming language, as Recursive Descent was a bit simpler for me to implement in C and wrap my head around, since it just uses the function call stack :)

  • @brockormond4131
    @brockormond4131 6 місяців тому

    When I learned to do this, I don't think I was told what it was called. Our assignment was to make a roman numerical calculator so we had an addition layer to tokenize roman numerials and calculate their value. It was fun, the teacher didn't require 'correct' roman numeral notation (i.e. VIIII counted as 9 rather than IX for 9), but I made it work both ways.

  • @GodofWar1515
    @GodofWar1515 6 місяців тому

    This is gonna be a real treat! Looking forward to your upcomming videos.

  • @Shineglow
    @Shineglow 6 місяців тому

    Nice to see you again and thanks for the video. I've been studying splines not so long ago and was trying to make an extension for the unity editor to change values on the fly and immediately see the result in runtime. But the order of operations became something I couldn't overcome. My solution was very close to what you showed though. Thank you very much!

  • @emjizone
    @emjizone 6 місяців тому +1

    It would be much more fun to start solving what can be solved before you finish writing the stack, thus preventing it from growing larger than necessary. It also saves you the trouble of double-checking whether a symbol is an operator or not.

  • @ocayaro
    @ocayaro 6 місяців тому

    We each had to create a compiler for honors project in Computer Science in the 90s. Tokens, lexical analysis, etc. In retrospect it was the hardest thing I ever did. I somehow scored 90%.

  • @cariyaputta
    @cariyaputta 6 місяців тому +1

    New series to look forward to.

  • @mikefochtman7164
    @mikefochtman7164 6 місяців тому +1

    Had to write a parser for expressions that included logical operators. Much the same, of course the logical operators also had a '!' which was also uniary. Then we created uniary 'conversion' operators that would take logical and return '1' or '0' for true or false and similar conversion for returning 't' or 'f' for 0 and ==0.
    Writing this sort of 'mini language' was actually kind of fun. Of course the users had trouble because they just never bothered to read my documentation. lol

  • @jordixboy
    @jordixboy 6 місяців тому +2

    As a self taught software engineer, with deep interests in computer science, if you want to build up a computer from nand gates, write an assembler, a compiler and an OS for that hardware, I highly suggest you to take the courses nand2tetris and nand2tetris2.

  • @davep7176
    @davep7176 6 місяців тому

    I love your channel and glad to see you again haven't seen in a while.... one thing though when I was in school (a long time ago now lol) I was taught the multiplication would only be done first if it was in a bracket. So 1+2*4-3 is actually the same as 3*4-3. I guess I was taught wrong and so for 30-40 years I would have just been giving the wrong answer if I was ever asked. The weird part is that hasn't really hurt me when making computer programs. I suppose this is why when I write code, I use the brackets a lot more than necessary.

  • @InfiniteCoder01
    @InfiniteCoder01 6 місяців тому

    I was used to making classic nested parsers and a tree-walking interpreter for that

  • @nikkehtine
    @nikkehtine 6 місяців тому

    I've been looking into this for a while now, thanks so much for this video

  • @nandomax3
    @nandomax3 6 місяців тому

    Amazing, I'll implement it with golang which is my main object of study nowadays

  • @Sfaxx
    @Sfaxx 6 місяців тому

    I'd love to see an algorithm for covering expression into Polish Notation (instead of RPN) as well :)
    Thanks for such an informative video! 😊

  • @samuelschwager
    @samuelschwager 3 місяці тому

    I like the way lisp does it (+ 1 2), aka polish notation. no ambiguity with precedence at all.

  • @whiskeyoo
    @whiskeyoo 6 місяців тому +4

    I love your videos, but there is one thing getting me stuck from time to time - naming conventions. Could you please describe why do they differ so much? Once you create a variable using camelCase (e.g. stkHolding), then you create some other variable using snake_case (new_op), and also the operator struct is called sOperator (afaik structs are usually called with UpperCamelCase). Also, is there any reason of shortening variable/constant names? imo "stkHolding" is not as user-friendly as "stackHolding", especially if you watch the video in parts :)

  • @liorean
    @liorean 6 місяців тому

    The real problem is the division sign if used as an infix operator instead of as a horizontal line with one expression above and one below. In school I learned that a slash was to be considered a horizontal line slanted and everything on the left to be considered above the line, everything on the right to be considered below the line, while the ÷ sign is to be considered like a multiplication, so they would be handled differently.

  • @MatthewBishop64
    @MatthewBishop64 6 місяців тому

    Sick dude. I implemented a "Countdown solver", you know, like TV show. It could solve the numbers game in Countdown. Implemented as an expression tree. I didn't use this shunting algorithm, but it would have worked great.

  • @calcal6508
    @calcal6508 6 місяців тому

    quite the coincidence that you upload this a couple of days after I start looking into ebnf and making a programming language haha

  • @SpringySpring04
    @SpringySpring04 6 місяців тому +13

    Where I'm from we learned "PEMDAS". A phrase we use is "please excuse my dear Aunt Sally"

  • @segsfault
    @segsfault 2 місяці тому

    BODMAS is famous in India, it stands for Brackets Open, Divide, Multiply, Add, Subtract.

  • @MoritzWallis
    @MoritzWallis 6 місяців тому

    Love your videos! Going to implement this right now myself.

  • @RoryBecker
    @RoryBecker 6 місяців тому

    Absolutely facinating.
    As per usual @javidx9, I love the combination of your cool-as-a-cucumber delivery and exceptionally clear explanations.
    Your videos always distract from other side-projects I might be involved in, but it's always such a pleasure, I couldn't possibly complain :)

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

    I actually wanted to write my own C parser so this is very helpful :)

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

    I am really impressed with the teaching style and choice of difficult but important topics.
    Any chance you will try automatic differentiation (mainly applied in neural network training)? This is also kind of difficult but also interesting.

  • @ablonix
    @ablonix 6 місяців тому +2

    Maybe I misunderstood the code but at 10:00 if '+' has higher precedence than '-' then wouldn't 1 - 2 + 3 be evaluated as 1 - (2 + 3)? That would be unusual, IME. Plus and minus normally have the same precedence and would be evaluated left-to-right.

    • @vitoswat
      @vitoswat 6 місяців тому

      Same with multiplication and division

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

      @@vitoswat
      I think the problem exist only for addition and subtraction. Because in the case of 1-2+3 the minus can be translated (by humans) as unary minus and become 1+(-2)+3 and if we calculate now -2+3 first the rsult is correct.
      In division and multiplication there is no "sign" problem. Hence:
      18*3/2 = 18*(3/2) = (18*3)/2 = 27
      I think that operators (-) and (+) and should be labeled with the same precedence level, and the rule of popping operator in case that it is with higher precedence should be applied even on the same precedence.
      I would also mark (/) and (*) with the same precedence level.

  • @c0smeticplagu3
    @c0smeticplagu3 6 місяців тому

    Best UA-cam channel and it's not even close

  • @petermather3049
    @petermather3049 6 місяців тому

    Great video - thanks. I hope you will extend this further. I'm interested in the treatment of functions e.g. sqrt() - probably easy, but what about functions with more than one argument e.g. atan2(x,y) ?

  • @bronsonmagnan9055
    @bronsonmagnan9055 6 місяців тому

    I am secretly hoping this adventure is the start of a 6502 compiler for the NES emulator project.

  • @dixztube
    @dixztube 6 місяців тому

    Pedmas > bodmas, math < maths

  • @Imm0rtal101
    @Imm0rtal101 6 місяців тому +4

    bro's full metalhead mode

    • @SoDamnMetal
      @SoDamnMetal 6 місяців тому +2

      The best kind of mode

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

    太好了,这是我一直等待的教程。感谢

  • @christophfriedrich5092
    @christophfriedrich5092 6 місяців тому +1

    I am wondering: for the unary operators you used the pass counter variable. Why not change the type of the initial value of the last symbol variable to unknown? That way your code would have been worked from the beginning without the pass counter variable.

  • @mortenlund1418
    @mortenlund1418 6 місяців тому

    Thank you for sharing. Great explanation!

  • @Hector-bj3ls
    @Hector-bj3ls 6 місяців тому

    I'm also from the UK and ive never referred to subtraction as take. I'd normally pronounce it minus.
    Also, on BODMAS. I learned that, but my younger sister was taught PEMDAS. At first I was confused because M and D had swapped place. Turns out they have the same precedence so it doesn't matter.

  • @ThePandaGuitar
    @ThePandaGuitar 6 місяців тому

    Incredible explanation

  • @sg4644
    @sg4644 6 місяців тому

    In India, we use BODMAS. I was confused when I first heard of PEMDAS when reading an American textbook!

  • @chaeju106
    @chaeju106 6 місяців тому +2

    Since there is #1, i assume this is going to be a series to make a programming language, is it?

  • @nimcompoo
    @nimcompoo 6 місяців тому +1

    We also learned BODMAS in India! Its quite funny because bodmas in bengali means 'brat' 😂

  • @Cmanorange
    @Cmanorange 6 місяців тому

    to alleviate issue of the unary negate and unary plus having the same symbol as addition and subtraction, i like how some languages have moved to ` for negate. easy to carry to written notation too, just superscript your dash. looks clear and is "backwards compatible" with external brains who don't do it :)

    • @Cmanorange
      @Cmanorange 6 місяців тому

      (i wasn't able to find a nice way to differentiate unary plus other than to ignore it lol. it's the no-op of math)

  • @bronsonmagnan9055
    @bronsonmagnan9055 6 місяців тому

    There is a problem with PEDMAS/PEMDAS. While explicit multiplication and division do have the same precedence, implicit multiplication must always be computed first. This is the source of the trolling on facebook with order of operations. Those are specific expressions that exploit the corner case of implicit multiplication.
    Pemdas only: 8/2(2+2) = 8/2(4) = 4(4) = 16
    Pemdas with implicit multiplication acknowledged 8/2(2+2) = 8/2(4) = 8/8 = 1 (this is the correct answer)

  • @BudgiePanic
    @BudgiePanic 6 місяців тому

    In my school we learned BEDMAS (brackets, exponents, division, multiplication, addition, subtraction) so a weird mixing of different countries terms

  • @kalasmalarious
    @kalasmalarious 6 місяців тому +1

    We learn it as "Please Excuse My Dear Aunt Sally" or PEMDAS.

  • @Red-di7zb
    @Red-di7zb 6 місяців тому

    Thank you Javid for always amazing videos.

  • @music4life467
    @music4life467 6 місяців тому

    one of great of c++ because of the template where vector and list are standard lib in c++

  • @vast634
    @vast634 6 місяців тому +2

    So if there are 5 apples and take 3 apples I have 3 apples, However if there are 5 apples and I substract 3 apples, I have 2 apples. Got you there Brits.

    • @benholroyd5221
      @benholroyd5221 2 місяці тому

      Take as in take away.
      If you take away 3 of the 5 apples from your fruit basket, you have 2 apples left

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

      it's how many are left over not how many you have

  • @luckybearthing1796
    @luckybearthing1796 6 місяців тому

    Ironic I finish a course in Uni about this and you post the video after i am done lol

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

    PEMDAS
    Parenthesis
    Exponents
    Multiplication / Division (left to right)
    Addition / Subtraction (left to right)

  • @kplays_6000
    @kplays_6000 6 місяців тому

    rather than setting the params to 1 and implementing a special case in the solver, can we just up the precedence and push a '0'? And rather than tracking whether the number of passes is 0, can we not just initialise previous symbol to "Unknown"?
    We also need to be careful if we're differentiating + and - in precedence - if you do so, 1 - 2 + 3 would first do 2 + 3, then 1 - 5, which is incorrect - I hope we fix this next episode by either giving them equal precedence or checking if we're making an addition before a subtraction

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

    you could technically do (0-n) to do negative numbers, but it's probably better just to implement negative numbers in the input

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

      It's tricky situation. What is expected result of -5^2 ? If "-5" is parsed as negative number, then it gets squared to get 25. But usually minus sign doesn't seem to be part of number in this case, that is we first squared 5 to get 25 and only then assigned minus to it. That's why unary minus which has lower precedence than power is better approach.
      Got there, had to rewrite big chunks of my code to get this right...

  • @jakubfrei3757
    @jakubfrei3757 6 місяців тому

    Hi there mate, i really enjoyed your video about math for game devs. I wanted to ask if you considerd to do some series for it, i would really appreciate that, you have gift for teaching

    • @javidx9
      @javidx9  6 місяців тому

      Thanks! I've no plans specifically as it's just regular maths! Instead I try to approach it from the gamedev angle by exploring those topics and the maths required to do those things at that time.

  • @williamsquires3070
    @williamsquires3070 6 місяців тому +1

    (@1:59) don’t forget exponentiation! 😌

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

    I think there is a problem with the precedence of the addition (+) and subtraction (-) operators.
    Consider the expression 3-1+1 that should be equal to 3.
    Using the specified precedence rules (addition = 2, subtraction = 1) we get:
    RPN: 3 1 1 + -
    Then:
    Calculation 1st round: 3 2 -
    Calculation 2nd round: 1
    Which is obviously wrong!
    In the case of 3-1+1 the minus can be translated (*by humans*) as unary minus and become 3+(-1)+1 and then if we calculate first -1+1 we get 0 and finally 3+0 is the correct answer 3.
    But in the described algorithm we treat this minus as binary operator.
    In division and multiplication there is no "sign" problem. Hence:
    18*3/2 = 18*(3/2) = (18*3)/2 = 27
    Or maybe I miss something?!
    I think that operators (-) and (+) and should be marked with the same precedence level, and the rule of popping operator in case that it is with higher precedence should be applied even on the same precedence level.
    I would also mark (/) and (*) with the same precedence level.
    Please, tell me where I'm wrong?!

  • @rednibcoding3412
    @rednibcoding3412 6 місяців тому +3

    This is awesome!

  • @TheMyHalo
    @TheMyHalo 6 місяців тому

    Can you already tell what kind of programming language? Ive written a stack machine myself once, would love to see a video about register machines like LUA uses

  • @doggone-mn3uu
    @doggone-mn3uu 6 місяців тому

    Precedence climbing is another nice algorithm

  • @JujuAdams
    @JujuAdams 6 місяців тому

    woo! Looking forward to this series

  • @jackpioneer3566
    @jackpioneer3566 6 місяців тому

    great explanation!

  • @tissuepaper9962
    @tissuepaper9962 6 місяців тому

    For some reason after "If I'm about to solve your homework for you.." I was expecting "...you can summarily fuck off".

  • @strayling1
    @strayling1 6 місяців тому +1

    Uh oh, here be dragons!

  • @strick9red
    @strick9red 6 місяців тому

    Great lesson.

  • @ChrisCarlos64
    @ChrisCarlos64 6 місяців тому +2

    For me in the US I learned it PEMDAS (Please Excuse My Dear Aunt Sally) who I hear is a lovely woman, why she needs to be excused is unbeknownst to me. Hope all is well...

    • @skilz8098
      @skilz8098 6 місяців тому

      That's because all woman fart too!

  • @v-for-victory
    @v-for-victory 6 місяців тому

    Wow. So great, thanks!

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

    Great stuff as always. 👍