Building Your Own Programming Language

Adding to the Standard Library

Steve Kinney

Steve Kinney

Temporal
Building Your Own Programming Language

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

The "Adding to 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 goes over the solution of the basic evaluation, and succinctly reviews the different elements necessary to create a REPL.

Preview
Close

Transcript from the "Adding to the Standard Library" Lesson

[00:00:00]
>> Steve Kinney: It's our mission is to get this test passing, and let's go and spoil the surprise for ourselves right now.
>> Steve Kinney: All right, it doesn't, right? We can see our new error message though, right? It gave us the right error message, cuz we wrote it. If you wrote something either nicer or meaner, you should see your custom error message as well.

[00:00:31]
You can put emoji in there. I think emoji should be an important part of this programming language. I think that was a thing that I definitely messed up on. Maybe a panda instead of add. But you can also alias things, so you can just have things point other things.

[00:00:44]
So let's go ahead and let's add it in there, cuz it'll be real quick.
>> Steve Kinney: We can go into the standard library and we can basically add anything we want. We can say max. And max doesn't need to get wrapped in that all because it takes a bunch of stuff as arguments.

[00:01:03]
And so we'll have it take a bunch of args and we'll go through it. We'll basically say,
>> Steve Kinney: That will return,
>> Steve Kinney: That, and what's cool about this is because it's your own language, you don't have to deal with the drama of the fact that MooTools used flatten a decade ago and now JavaScript can't have it on arrays.

[00:01:33]
You can put whatever methods you want from any library. You can kinda compile your own utility belt of methods and functions that you can start whipping around code with real fast. So you see this test is passing. So let's review. We can now evaluate effectively anything that we can type in this language, so far, right?

[00:01:54]
I would love to stop running tests all the time, to see my program language in action. So we have actually, now we can evaluate. We're able to read, we're now able to evaluate. Printing's gonna be console log. Sorry to break that to you. And then we need the loop.

[00:02:11]
And we have everything we need for Repl and everything we need for a command line interface to actually just take a given file in the file system and run it through drop air and get the result out. So that's what we'll take on next.

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