Ruby
Just my type: things I learned from writing my own programming language

Summarized using AI

Just my type: things I learned from writing my own programming language

Lena Plaksina • February 21, 2020 • Earth

In her talk at RubyConf AU 2020, Lena Plaksina explores the intricacies of creating a programming language, using her own project, Wholesome Lang, as a case study. She reflects on how programming languages are not just technical tools but are also infused with the personality and values of their creators. Lena emphasizes the relationship between language and community, supported by Melvin Conway's theory that the structure of communication influences the design of organizations and their products.

Key Points:

- Introduction to Wholesome Lang:

Lena discusses the origins of her programming language, born out of a jest related to her unique speaking patterns and her friends' encouragement. The language is designed to be fun, utilizing an object-oriented paradigm, and is implemented in Ruby, a language she has been using since 2015.

- Technical Aspects:

- Tokenizer and Parser:

Lena details the importance of the tokenizer and parser in Wholesome Lang, explaining how they transform and process the source code.

- Debugging Capabilities:

Emphasizing her priorities in design, Lena mentions that debugging was a crucial feature from the start.

- Unique Features:

Lena highlights whimsical functionality, such as the language's rejection of unwholesome code and the use of 'friends' instead of traditional class structures in programming, reflecting her lighthearted approach to coding.

- Community and Influence:

She connects her personal experiences with language, being an immigrant and navigating multiple languages, to how these experiences shape the creation of programming languages. She remarks on how programming reflects the creator's thinking and style.

- Encouragement for Others:

Concluding her talk, Lena encourages attendees to consider creating their own programming languages, emphasizing that anyone with ideas can contribute to the development of new languages.

Lena's talk illustrates the creative and personal aspects of programming language development, ultimately inviting others to embark on their own journeys in language creation.

Just my type: things I learned from writing my own programming language
Lena Plaksina • February 21, 2020 • Earth

Lena Plaksina

If programming languages are about technology, why did Matz optimise Ruby for “developer happiness”? Computers pay little regard to how an instruction is expressed — whatever we write in Ruby can just as well be expressed in Java, C#, or Smalltalk. So, why do people gravitate to one language over another? How do programming communities form? What drives their ethos and manifestos?

Hi, I’m Lena. I’m an avid cat rescuer, learning enthusiast, and Rails Bridge Wellington organising committee member. I started out in design, but fell for web and software development during my first industry internship. I've been writing Ruby since 2015, and I'm currently learning other languages to expand my toolkit. I’m all about finding patterns, building and communicating software in a way that helps everyone understands it, and failing better – mistakes make me a better developer, and I believe that failing is just an opportunity to learn. When I’m not coding, I’m watching movies with my 3-legged rescue cat Warlock, collecting enamel pins, and helping out and/or presenting at tech community events around town.

Produced by NDV: https://youtube.com/channel/UCQ7dFBzZGlBvtU2hCecsBBg?sub_confirmation=1

#ruby #rubyconf #rubyconfau #rubyconf_au #rails #programming

Fri Feb 21 11:15:00 2020 at Plenary Room

RubyConf AU 2020

00:00:00.000 You see on our next speaker to you, and we'll do a quick swap to see if the laptop's there. So please welcome Lena Plaksina.
00:00:10.139 I actually know Lena because we both spoke together at Kiwi Ruby back in 2017, so I already have very good evidence that she's a fantastic speaker.
00:00:16.320 She's going to be talking to us about writing her own programming language. She's an avid cat rescuer, a learning enthusiast, and a member of the organizing committee for Rails Bridge Wellington.
00:00:28.380 She started out in design but fell for web and software development during her first industry internship. She's been writing Ruby since 2015 and is currently learning other languages to expand her toolkit.
00:00:40.620 Lena loves finding patterns, building and communicating software in a way that helps everyone understand it. She believes in failing better, as mistakes help her become a better developer.
00:00:52.610 When she's not coding, she's watching movies with her three-legged rescue cat, Warlock, collecting enamel pins, and helping out or presenting at tech community events around town.
00:01:11.390 Thank you very much! Hi everyone, welcome back! I'm going to try to be super chipper because we're back from a break, and it's day two, and it's going to be great.
00:01:16.710 To start us off and get into the spirit of things, I was thinking we could play a bit of a game. If any of you are familiar with a game called Animal, Vegetable, or Mineral, it's kind of like that—but not really.
00:01:30.180 In this game, you just have to think of the answer and keep it in your head. I'm going to think of something, and I'll give you three clues to guess what it is.
00:01:36.510 Clue number one: the thing I'm thinking of has something to do with the sea. I'll give you a second to think. I feel like this is an unfair clue because there are literally thousands of things related to the sea.
00:01:50.250 Clue number two: in addition to having something to do with the sea, it also has something to do with pigs. At this point, I know I made it too easy. By now, everyone probably knows what I'm thinking about.
00:02:04.860 Clue number three: it's not actually full-grown pigs; it's piglets. Clearly, I’m thinking of sea piglets! In Germany and Russia, these fluffy little creatures are known as sea piglets in a literal translation. However, if your native language isn't one of those, you might recognize the animal as a guinea pig.
00:02:42.420 All of this is to say that language cultivates meaning. I was born in Russia and spoke only Russian for the first ten years of my life. As an immigrant, English is my second language, so this small fact manifests in my having a slightly unusual accent and making small talk difficult.
00:03:19.849 However, it sometimes leads to funny situations. When I try to have conversations or deliver a talk at a conference, some words or even entire phrases can just drop out of my brain. Often, those words get replaced by the equivalent in my native language.
00:03:39.579 Why would someone like me conceptualize guinea pigs as little piglets from the sea? Despite speaking English for a long time, the language I first heard to describe those concepts formed strong links in my brain and cultivated different ways of thinking.
00:04:20.610 In the 1960s, Melvin Conway created a theory that suggests organizations which design systems are constrained to produce designs that mirror the communication structures of those organizations. This idea implies that the products we make reflect the teams that wrote them.
00:04:49.039 I’d like to propose that when writing your language, it can reflect the writer. We also join communities that reflect our personal ethos as a consequence of this concept. While all of this is interesting, I don't think you're here to learn about Conway’s theory or my origin story.
00:05:15.389 So, it’s about time I tell you a little bit about Wholesome Lang. Wholesome Lang is the name of the language I attempted to write. I started this journey nearly two years ago, and it began as a joke about my speaking patterns.
00:05:59.759 In my regular life, I’m a pretty silly person. I say a lot of silly things and make up silly words, and my friends like to tease me about it. One year for my birthday, they gifted me a dictionary that included silly words I've made up, creating a sort of 'English Plus Lena'.
00:06:32.549 Because I'm that kind of person, I decided to take the joke a bit too far and write an entire language around it. I wanted to create something cute and funny, similar to an esoteric programming language, and I decided to base it on object-oriented paradigms, implementing it in Ruby since I love Ruby.
00:07:07.259 This choice meant that I didn’t have to learn a whole bunch of new technologies while trying to do something I'd never attempted before. My friends helped me get started, and I looked through several tutorials online. Initially, I thought this would be difficult, but it turned out I could choose to make it as simple or as complex as I wanted.
00:07:39.459 One tool I found valuable was an article from FreeCodeCamp. It serves as a great reference for implementing a programming language and covering many concepts that I ended up using. The author provides excellent advice for anyone writing a new language, detailing their decisions and alternatives.
00:08:42.960 Naturally, I didn’t follow all their advice because I wasn’t trying to solve significant technical challenges with Wholesome Lang. I wasn't concerned about performance, speed, or even writing my own compiler. I chose to focus on having fun. Thus, I wrote the entire language in Ruby, making it an interpreted language sitting on top of an interpreted language.
00:09:22.370 One recommendation I did keep from the tutorial was creating my own custom tokenizer. There are two really cool components that I ended up using in Wholesome Lang: the tokenizer and the parser.
00:09:39.670 The tokenizer interprets the source code you provide, converting the states of symbols into tokens that the rest of the program can recognize, while the parser builds the abstract syntax tree for the rest of your program to interpret.
00:10:13.770 I would say that one of the main reasons languages benefit from having a tokenizer is that it introduces an intermediary agent to decipher what the individual blocks of symbols represent and what type of entity will eventually process them.
00:10:47.210 In Wholesome Lang, my tokenizer handles the bulk of the work, and I identified tokens by using regex matching. I cycle through all token class descendants until I can find a matching expression for the specific symbols I'm analyzing.
00:11:20.680 This was one of the first internal pieces of Wholesome Lang that I wrote, and I felt quite good about it. Once I began writing it, I started realizing many things about programming languages and what it takes to write them.
00:12:04.250 A programming language is essentially just another program, and like all other programs, it has a main runner that takes arguments like the file you want to execute. Wholesome Lang hasn’t been packaged or shipped for installation, so I run it on my machine by calling Ruby to grab Wholesome Lang.
00:12:40.100 Like any other program, a language runner can accept flags. Here, you can see Wholesome Lang attempting to process a file called samples.wl, which shows the flags it's using.
00:13:07.020 It also runs searches and validations, rejecting invalid data. However, I realize that with this slide, I’m making it look worse than it is. The example here depicts some errors, but this isn't the actual behavior of Wholesome Lang.
00:13:39.059 The flow of the Wholesome Lang program is straightforward. At the very start, file contents get passed to the tokenizer, which determines if the content is 'wholesome.' If it’s not, it raises a critical error and ceases further processing.
00:14:28.140 If it's wholesome, the tokens are passed to the parser, which builds a tree. The entire program execution involves walking down the nodes and processing the descendants.
00:15:01.470 Now that you know a bit about how Wholesome Lang works under the hood, let me share what it can actually do. I realize I said I started this project about two years ago, but this doesn't mean I've been developing it every day. What I have is a small subset of features.
00:15:57.290 One of the concepts I highly value is debugging. As such, Wholesome Lang has extensive debugging capabilities. During the initial stages, significant time was invested in creating different windows into the tokenizer and parser to ease the debugging process.
00:16:29.280 However, let's look at some features with a bit more personality and flavor. From the start, I found myself implementing features that I thought were funny rather than the most useful.
00:16:57.160 The very first function allows you to type a message, and it will print that to your console. This interaction creates a sense that you're communicating with a friend, which I find amusing. While this might not resonate with everyone, I think it’s cute.
00:17:50.260 Another ongoing feature I’m developing is the concept of 'friends' instead of classes. I find the term 'class' somewhat loaded, so when initializing a new friend, you can essentially meet them, which I think adds a fun twist.
00:18:12.360 As you've seen, Wholesome Lang's execution will not proceed if the source code contains any hate speech or insults. An interesting aspect behind this feature is what one of my friends described as 'an extremely long walk for an extremely short drink of water.' If you're curious about how this works, feel free to chat with me later.
00:18:39.460 The result is that Wholesome Lang won’t permit unwholesome code, not just in English, but in various languages, including Klingon. My programming language reflects my spoken language, which in turn mirrors my thought patterns.
00:19:36.450 At the highest level, my thinking is influenced conceptually. For example, when learning about object encapsulation, my mentor encouraged me to visualize objects as sentient beings with their jobs. This idea deeply integrated into Wholesome Lang, where every class is treated like a friend.
00:20:44.549 The way I code also led to certain assumptions. For instance, in the source code from the pot file WOL, I formatted assignment operators with spaces on either side, as that’s my habitual style. When somebody else attempted to run it, they were confused because their coding style differed.
00:21:57.190 As someone who enjoys Ruby and appreciates Matz's perspective about creating a programming language that brings happiness, I can relate to his sentiment. It’s clear that when designing a language, it greatly influences the community.
00:22:48.880 Programming languages are a product of their creators, reflecting their values, preferences, and personalities. This is evident in Wholesome Lang; my preferences for spacing and the absurdity of the whole concept shape its essence.
00:23:39.740 These operations and features created by the creator will often be intuitive for them. Programming languages aren't solely about machines; they act as tools for communication, and I would argue that developers are often communicating with future versions of themselves.
00:24:02.829 Reflecting on the experience of learning programming, I think about how almost all programming languages require translation. As developers, our jobs demand that we translate ideas and concepts from our minds into a language we know.
00:24:47.430 As someone whose native language isn't English, I navigate this translation with an additional challenge. For instance, if 'guinea pig' were a programming word, they would have to convert that concept into the correct programming term, a shape recognized by the machine.
00:25:51.870 Before starting to work with Wholesome Lang, I perceived programming languages as magical domains crafted by geniuses. It wasn’t until I started writing Wholesome Lang that I recognized these tools as approachable and within my reach.
00:26:38.960 Curious about how other languages began, I discovered that even Java started as a small project in 1991 called Green Talk. A handful of passionate developers aimed to construct something with simplicity that would become a mainstream language.
00:27:10.640 Java evolved through significant contributions over time and by the time it was officially released, it had acquired thousands of hours of development. Like many programming languages, it didn’t emerge as a polished product but rather as something built to suit the needs of its creators.
00:27:55.590 This realization helped me see writing a brand new language as achievable. The more I pondered this, the clearer it became: the question of who can write a programming language boils down to who has things to say.
00:28:38.260 Although I'm not trained in linguistics or programming language theory, I'm a Ruby developer who wanted to create something amusing for myself and my friends. Ultimately, everything we interact with was developed by individuals with ideas, and those ideas resonated with others.
00:29:22.080 At the end of the day, I created Wholesome Lang for me and my friends, as a lighthearted joke. I hope that sharing my journey encourages you to try your hand at writing your own programming language.
00:30:07.820 If you do decide to go for it, I wish for you to create a language that is just your type. Thank you!
Explore all talks recorded at RubyConf AU 2020
+15