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.
@Susandwyer38 минут бұрын
Interesting video, nice comb over, thanks.
@Musa03571Сағат бұрын
Hi dear brother, your videos are very informative. I have a question for you. Can I develop my own desktop application using the method you showed? For example, I want to make a simple application that calculates the acceleration of an object under the influence of the applied force (for example). This app needs to be downloadable for everyone. Is the path you showed suitable for this? If not, can you guide me? Thank you for this tutorial
@javidx915 минут бұрын
This is a great way to start desktop programming. Your application sounds simple, so maybe a simpler approach is better, for example something that runs in the browser, that way anyone can run it with no fuss?
@Musa03571Минут бұрын
@@javidx9 Thank you for your answer. I will explain this application as an example. My main goal is to develop a more advanced application. For example, an application that will track the real-time landing process of a vertical landing rocket. How so? For example, imagine a rocket with a mass of 70 kg. When you drop it from a height of 10 meters, it will fall to the ground freely. Yes, that's right. So, what do I want to do here? I want to develop an application that calculates the force required to bring that object down to the ground at a speed of 1.5 m/s, where that force will act and how many seconds it should take. Of course, there are too many details to explain here, basically the aim is to create a flight concept. Well, can't all of these be calculated with formulas? Yes, it can be calculated, but it requires a lot of processing. My goal here is to calculate the change due to mass. (I don't know if such an application exists, I did some research and couldn't find it)
@kinershah4642 сағат бұрын
You code on Windows, what do you think? Is Windows better to code on than Linux?
@javidx92 сағат бұрын
For me, yes.
@kinershah4642 сағат бұрын
@@javidx9 thanks for the response. I feel Windows provides good dev env.
@Zooiest3 сағат бұрын
I think goto has a place in the language, or at least until the spec maintainers add labeled control flow statements. for (/* blabla */) { for (/* blabla */) { if (/* blabla */) { // Exit out of both loops goto break_outer; } } } break_outer:; Edit: I should've watched just a few more seconds to see that this use case was already covered in the video
@petermather30494 сағат бұрын
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) ?
@mynameisfoxxy61107 сағат бұрын
Say that 10 times fast 23:52 (reversh polish notashion expreshion)
@nikkehtine9 сағат бұрын
I've been looking into this for a while now, thanks so much for this video
@davep717611 сағат бұрын
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.
@chap666ish11 сағат бұрын
That's a great demonstration of how to get to Reverse Polish Notation. I remember learning that in, I guess, 1977. A few of my classmates had the Sinclair Scientific pocket calculator only understood RPN so that's how you had to enter your calculations! en.wikipedia.org/wiki/Sinclair_Scientific
@PaulSpades12 сағат бұрын
Unpopular opinion: Any new language should completely ignore arithmetic precedence in expressions. I'm surely not the only experienced programmer that parenthesizes all expressions in source code. Operator precedence is a hazard, with too many quirks and different order tables in different languages, some of them are different than mathematical rules. RegEx has fewer and more straightforward rules, and we consider that an unreadable menace. Either go with polish or reverse polish with no exceptions, forth or lisp. It's the only logical and reliable solution for communicating expressions.
@iv399512 сағат бұрын
Would interpreting every subtraction as “+0-“ work, so you don’t have to keep track of the previous character? Im interested to know if this would be faster, since code would only run when i sees a ‘-‘ instead of every character
@user-kb2qz3gj6k13 сағат бұрын
Thank you teacher
@MatthewBishop6414 сағат бұрын
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.
@v-for-victory16 сағат бұрын
Wow. So great, thanks!
@whiskeyoo16 сағат бұрын
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 :)
@johnboyboy91917 сағат бұрын
So thats the “computing” thing CPUs are so good at
@anthonydistel17 сағат бұрын
We learn it as "Please Excuse My Dear Aunt Sally" or PEMDAS.
@Sfaxx18 сағат бұрын
I'd love to see an algorithm for covering expression into Polish Notation (instead of RPN) as well :) Thanks for such an informative video! 😊
@sbarracudaxКүн бұрын
We were taught BEDMAS back in the 1980's/90's where I grew up in Canada. I'm pretty sure they teach PEDMAS now.
@hamesparde9888Күн бұрын
They taught BODMAS at the school I went to (which is in Victoria Australian.)
@kplays_6000Күн бұрын
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
@williamsquires3070Күн бұрын
(@1:59) don’t forget exponentiation! 😌
@sanderbos4243Күн бұрын
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 :)
@Sam-hu3xtКүн бұрын
I love how eloquent you are explaining alien stuff like this.
@OlosannКүн бұрын
The best ever use case for kitchen table. Thanks!!!
@devpoodleКүн бұрын
Great vid! I never really knew where to start when it came to evaluating expressions.
@tsol9097Күн бұрын
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.
@rulojuka2 күн бұрын
Nice video as always! Thanks!! 33:24 This is why I hate auto (and every other programming language feature of this sort): the compiler knows the type, the editor knows the type, heck, even the writer knows the type most of the time. The only one who doesn't know the type is the reader. All because the writer wanted to save something very small (like pressing ctrl . or similar in the IDE or using 10 characters worth of display real-estate). I really don't see the point..
@rulojukaКүн бұрын
Sorry for not being complete: I think you specifically did it to aid in the explanation, avoiding complexity until it was necessary, as a great teacher would do! I was talking about auto's use in production code, not here!
@emjizone2 күн бұрын
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.
@emjizone2 күн бұрын
13:00 Do you really want to check the whole operator stack every time you add an operator instead of keeping track of the minimum required precedence?! Good grief...
@javidx9Күн бұрын
I dont, its a stack, it works backwards from the top and aborts early as soon as state is valid.
@Nodsaibot2 күн бұрын
he has gone mad! lol
@TheMyHalo2 күн бұрын
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
@christophfriedrich50922 күн бұрын
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.
@terminallumbago55822 күн бұрын
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. 😂
@persona-qs5sj2 күн бұрын
👍👍👍
@nimcompoo2 күн бұрын
We also learned BODMAS in India! Its quite funny because bodmas in bengali means 'brat' 😂
@luckybearthing17962 күн бұрын
Ironic I finish a course in Uni about this and you post the video after i am done lol
@RoryBecker2 күн бұрын
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 :)
@brockormond41312 күн бұрын
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.
@CrankViewer2 күн бұрын
Great Vid. Thank you.
@ilhanilhanDev2 күн бұрын
Yeah
@music4life4672 күн бұрын
too many features added in c++
@music4life4672 күн бұрын
one of great of c++ because of the template where vector and list are standard lib in c++
@kodosunofficial2 күн бұрын
Finally, Javid makes video about compiler.
@ryanlarge62962 күн бұрын
This was a fantastic educational video! Thank you for your time with this one. Very excited to see what comes next in the series!
@user-br6ku7jj6n2 күн бұрын
thank you so much, I've long been wondering how parsing mathematical expression works
@Paulie680002 күн бұрын
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!
@psodq2 күн бұрын
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!
@MoritzWallis2 күн бұрын
Love your videos! Going to implement this right now myself.