Check out a free preview of the full Building Your Own Programming Language course

The "Adding the Standard Library" Lesson is part of the full, Building Your Own Programming Language course featured in this preview video. Here's what you'd learn in this lesson:

Steve explains what are the basic functions put in place in the standard library, and mentions a helper included in the library.

Preview
Close

Transcript from the "Adding the Standard Library" Lesson

[00:00:00]
>> Steve Kinney: All right, so they go over into this, well, named file called standard library. There's a few things happening, there are some basic functions that I've put in place. And I'll talk a little bit about this helper up here as well. But we've got the ability to add, subtract, multiply, divide, modulo, and console log, cuz that could be helpful.

[00:00:24]
We're not gonna be able to use it just yet, but we can put in constants that are available like pi or anything else that you want, right? You can add as many things to this object as you would like. And we will add a few things over the course of the day.

[00:00:39]
All these orders is it takes a list, right? So remember we had that first the function name, and then we had like a whole series of arguments. It basically takes two of them at a time and runs them through the function, right? And so this allows us to say add one, two, three, four, five, six, seven, and they'll first take one and two and add them together, then that three, the resulted.

[00:01:04]
And the other three and add them together, then the six, and the four, so on and so forth, right? And we'll go ahead and just like run through the entire series of arguments, right? You could not do this if you just want to have it take two, like where there's gonna be things where we only care about two like when we want to be able to eventually define variables.

[00:01:21]
Like I couldn't come up with like, as the language designer in this case, I couldn't come up with a reason why I would say define x and give a random series of things, right? But you could, right? You're in charge of your language, I'm in charge of my language, you don't tell me what to do, I don't tell you what to do.

[00:01:37]
So this is our standard library and then we've got our evaluate.
>> Steve Kinney: Know up, okay, that we're eventually going to need to implement as well. So we know that there's a really effectively like two things that we need to worry about which is our expressions and our actual values.

[00:02:00]
We know when we get to an actual value like we're done. And we know our expression, we actually have to call it. So let's just start with the base case of, I got a two, a two has a value to it, right? Like we're done there.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now