Building a Toy Programming Language in Python, Part 2

Posted by
on under

Welcome to the second part of my tutorial on creating a toy language I called my in Python. In the first part I showed how how to implement the lexer, parser and interpreter for a very simple version of the language that did only one thing: print numbers.

With the first phase of the project completed, and with a solid base to start building from, I'll show you how to extend the language in a few ways. The purpose of this is to demonstrate how to modify this language, so that you can then build your own extensions. If you need a reference for the code, this GitHub repository has the working code that you can try.

Building a Toy Programming Language in Python

Posted by
on under

I thought it would be fun to go outside of my comfort zone of web development topics and write about something completely different and new, something I have never written about before. So today, I'm going to show you how to implement a programming language!

The project will parse and execute programs written in a simple language I called my (I know it's a lame name, but hey, it is "my" language). The implementation is going to be in Python, without any external dependencies. The my language is simple enough to make this project reasonably short, but also complex enough to make it interesting. If you are only interested in the complete code, you can find it in this GitHub repository. If you want to learn, then read on!

In this first installment of this series, I'll show you how to build a very basic programming language that implements a print statement. Then in the second part I'll extend the language to support variables and mathematical expressions. The end goal is a programming language implementation that can execute programs such as this one:

a = 3
b = 4 + a * 2
print b + 1

Once you learn the techniques involved in bringing my to life, you will be able to extend the language in any way you like and make it yours too. Sounds interesting? Let's get started!

Goodbye, Twilio

Posted by
on under

As of this week and after almost four years, I'm not a Twilio employee anymore. I'm writing this while I work through a range of conflicting emotions, and try to adapt to new daily routines without Twilio in my life. Before you jump to conclusions let me clarify that I have not been laid off. The decision to leave the company was mine alone.

When I joined Twilio in 2019, this is how the company presented itself to the world, as seen through the famous billboard on the 101 freeway in San Francisco:


Twilio - Ask Your Developer

The three words in this billboard are possibly one of the best marketing campaigns of all times (I'm not the only one who thinks so). With such a simple message, Twilio established itself as a company for and by developers. Even though I never lived in San Francisco, I visited for work and pleasure countless times, and have always considered the Twilio billboard a welcoming landmark as I drove from the airport to the city. When I eventually joined Twilio, it was a dream come true for me.

OAuth Authentication with Flask in 2023

Posted by
on under

A long time ago I wrote a tutorial on how to add logins with a social network to your Flask application, using the OAuth protocol. It's been almost 9 years since I wrote that article, and believe it or not, the OAuth protocol continues to be well supported by all major players including Twitter, Facebook, Google, GitHub and many more.

But of course, 9 years is a very long time in tech. Even though not much has changed in terms of how this method of authentication works, some of the packages that I've used back then have had major upgrades, while others have become unmaintained, so an update is due.


Flask + OAuth 2.0 Demo

Create a MySQL Database using Docker

Posted by
on under

MySQL is an open-source relational database owned by Oracle Corporation. The instructions I'm going to share in this article demonstrate how to install and set up a MySQL server along with the popular phpMyAdmin management application. As a bonus, I will also show you how to set up Python to access your MySQL database.

This article is an excerpt from my book SQLAlchemy 2 In Practice, where I show how to work with relational databases using Python and the SQLAlchemy library.

What's New in SQLAlchemy 2.0?

Posted by
on under

You may have heard that a major version of SQLAlchemy, version 2.0, has been released in January 2023. Or maybe you missed the announcement and this is news to you. Either way, I thought you'd be curious to know what's new in it, if it is worth upgrading and how difficult the upgrade is.

As with previous software reviews, this is going to be an opinionated overview. I have been using the SQLAlchemy ORM in web projects for a long time, so in this article I will discuss the features that affect my own work, both in positive or negative ways. If instead you are interested to see a list of every change that went into this new release, then the official change log is the place to go.

The React Mega-Tutorial, Chapter 12: Production Builds

Posted by
on under

You have an application that you have been using in your own computer during development. How do you put this application in front of your users? In this chapter you are going to learn how to work with production builds of your application.

The React Mega-Tutorial, Chapter 11: Automated Testing

Posted by
on under

Up to now, all the testing done on the application you've built was manual. Manual testing as you develop your application is useful, but as the application grows the required testing effort grows as well, until it becomes so time-consuming that the only way to keep up is to test less, or to find a way to automate some testing work. In this chapter you are going to learn some techniques to create automated tests for your React application.

The React Mega-Tutorial, Chapter 10: Memoization

Posted by
on under

An important part of React that you haven't seen yet is memoization, a technique that helps prevent unnecessary renders and improve the overall performance of the application. In this chapter you are going to learn how the React rendering algorithm works, and how you can make it work efficiently for your application.

The React Mega-Tutorial, Chapter 9: Application Features

Posted by
on under

By now you have learned most of the React concepts you need to complete this application. This chapter is dedicated to building the remaining features of the application, with the goal of solidifying the knowledge you acquired in previous chapters.