<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Syed Faraaz Ahmad</title>
    <description>The latest articles on DEV Community by Syed Faraaz Ahmad (@faraazahmad).</description>
    <link>https://dev.to/faraazahmad</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F94451%2F1653d497-de9d-40cf-a147-c93dc7a9e1b9.jpg</url>
      <title>DEV Community: Syed Faraaz Ahmad</title>
      <link>https://dev.to/faraazahmad</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/faraazahmad"/>
    <language>en</language>
    <item>
      <title>How GraalVM improves Ruby</title>
      <dc:creator>Syed Faraaz Ahmad</dc:creator>
      <pubDate>Tue, 20 Dec 2022 13:41:16 +0000</pubDate>
      <link>https://dev.to/faraazahmad/how-graalvm-improves-ruby-5b4k</link>
      <guid>https://dev.to/faraazahmad/how-graalvm-improves-ruby-5b4k</guid>
      <description>&lt;p&gt;Recently, there was a Java meetup held at work (&lt;a href="https://deepsource.io"&gt;Deepsource&lt;/a&gt;) where I gave my first ever talk, "How GraalVM improves Ruby".&lt;/p&gt;

&lt;p&gt;In this I talk about how the Java ecosystem has become so much larger than just Java the language, that it's optimizations get carried over to other languages (in this case, Ruby) which ends up improving them. &lt;/p&gt;

&lt;p&gt;I hope you find this talk useful!&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/jKERKt9BptM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>java</category>
    </item>
    <item>
      <title>web3 does a lot more than you've been told</title>
      <dc:creator>Syed Faraaz Ahmad</dc:creator>
      <pubDate>Fri, 31 Dec 2021 18:43:56 +0000</pubDate>
      <link>https://dev.to/faraazahmad/blockchains-do-a-lot-more-than-you-think-58li</link>
      <guid>https://dev.to/faraazahmad/blockchains-do-a-lot-more-than-you-think-58li</guid>
      <description>&lt;p&gt;Look, I get it.&lt;/p&gt;

&lt;p&gt;The past few years have been full of cryptocurrency scams, thinly veiled Ponzi schemes, widespread art fraud for NFTs, and all the other stuff that didn't make the news. Blockchains have been the underlying tech powering all of that, so you have no reason to be be lending any of your trust to them.&lt;/p&gt;

&lt;p&gt;Yes, blockchains are overhyped, and yet they do a lot of good work that you haven't heard of. Just because there are people being stabbed with knives doesn't mean someone somewhere isn't doing a &lt;a href="https://www.youtube.com/watch?v=dCGS067s0zo" rel="noopener noreferrer"&gt;masterful job cutting onions!&lt;/a&gt; (weird analogy but bear with me for a moment)&lt;/p&gt;

&lt;h4&gt;
  
  
  So where are all the onion masters?
&lt;/h4&gt;

&lt;p&gt;All right, lets assume blockchains actually do some good stuff. Then why haven't I heard about them? Where is that big app that will make me believe in blockchains?&lt;/p&gt;

&lt;p&gt;Unfortunately, the answer is not very simple.&lt;/p&gt;

&lt;p&gt;No one is going to use something just because its built on blockchains. It has to be good enough to be the best option to choose at the time, never mind what tech is used to build it. Let me explain a bit why a blockchain could be needed.&lt;/p&gt;

&lt;p&gt;I'll raise you a scenario -- You're happily (or begrudgingly) working along on that task that you need to finish by tonight. Maybe it is so boring and soul-crushing that you're starting to contemplate leaving your job. But that doesn't matter right now,  you're already 2 weeks late and you've run out of excuses. So your only option is to grind through, pull up some NPM packages and finally finish that damn thing.&lt;/p&gt;

&lt;p&gt;But wait here's the fun part, &lt;strong&gt;NPM is down&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpbs.twimg.com%2Fmedia%2FFGwZTczXwA4djk5%3Fformat%3Djpg%26name%3Dlarge" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpbs.twimg.com%2Fmedia%2FFGwZTczXwA4djk5%3Fformat%3Djpg%26name%3Dlarge" alt="NPM is down"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But that wont stop you today! You know that package's Github repo. So you go there, download and store it in your &lt;code&gt;node_modules&lt;/code&gt;. You hack along undeterred, convinced that you're going to finish it by tonight. Finally its done, reviewed and merged into the dev branch. But wait! Why's it not showing up on the site? The deploy seems to be failing. You google around, ask your team members who are going through their own personal hell, and then finally in your late night, coffee fueled frenzy open up twitter to check what the heck's going on.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1471148104057458691-319" src="https://platform.twitter.com/embed/Tweet.html?id=1471148104057458691"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1471148104057458691-319');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1471148104057458691&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;Great. AWS is down again. So you just sit there like...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/tJDAeuB5NMtNUx1Swx/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/tJDAeuB5NMtNUx1Swx/giphy.gif" alt="I'm so done"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you look deeper than the surface level, these are problems that arise due to single points of failure. Its these problems that a decentralised network aims to fix. What's "decentralised"? well, it just means that no single entity is in control of the whole thing. If one node goes down, there's lots of other ones to keep it afloat. When you have your app hosted on a fairly large decentralised network (like ethereum), you essentially have a failsafe for the moment of a node failure. For when one node goes down, the app will just be moved to another node. &lt;/p&gt;

&lt;p&gt;Now you certainly don't need a blockchain for everything, especially if you have control of all the hardware on the network. But in blockchains when anyone can join the network from anywhere in the world, how do you know which node is a bad actor and which isn't. To put it differently, &lt;strong&gt;who do you trust?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/xT8qBnutCq8NxHOn5K/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/xT8qBnutCq8NxHOn5K/giphy.gif" alt="Mr. Robot GIF"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, you cant trust anyone over the internet. So you simply take trust out of the equation, that's why you'll often hear the word "trustless" in the context of blockchains. What enables these trustless networks are "consensus algorithms". Simply put, they make sure all the nodes are doing what they're supposed to. They reward the nodes that do good and in a way punish those who don't.&lt;/p&gt;

&lt;h3&gt;
  
  
  Now on to the onion masters.
&lt;/h3&gt;

&lt;p&gt;Hopefully my rambling has made at least some sense to you and you see value in the existence of the blockchain. Now lets introduce you to some of the big (and small) names taking the industry forward:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb5ibxpdcf9b0jnk73n3s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb5ibxpdcf9b0jnk73n3s.png" alt="Ethereum homepage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Ethereum &lt;a href="https://ethereum.org" rel="noopener noreferrer"&gt;(Website link)&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;Unlike Bitcoin, which was made to be a currency, Ethereum lets you write something called "Smart Contracts" which basically enable you to run your app on the blockchain. This way your app is up 24/7 and you wont have to deal with &lt;strong&gt;us-east-1&lt;/strong&gt; going down yet again. Although, the main Ethereum network has become quite slow and has a very high transaction fees, there are Level 2 chains that are built on top of Ethereum and are faster and cheaper (but that's a topic for another day).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4tke9m0uera0tans2gdl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4tke9m0uera0tans2gdl.png" alt="Filecoin website"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Filecoin &lt;a href="https://filecoin.io" rel="noopener noreferrer"&gt;(Website link)&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;What if you have a lot of important files stored on Dropbox and it goes down just as you want to access one of them? Yes, we're back to that idea of the centralised service that can fail anytime. Filecoin is another blockchain that stores files on a decentralised network. Anyone who stores the files reliably on the network, is paid "Filecoin" (its the name of the organisation AND the cryptocurrency) and whenever someone wants to retrieve those files, they need to pay Filecoin. Think Dropbox, but where all the servers that store data are owned by unrelated individuals around the world who're paid to reliably store data. There's a very good introduction about Filecoin over at their website, I highly encourage you to check it out.&lt;/p&gt;

&lt;h4&gt;
  
  
  Fleek &lt;a href="https://fleek.co" rel="noopener noreferrer"&gt;(Website link)&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5il0tuzwl2eoivlqd5dp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5il0tuzwl2eoivlqd5dp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember how I told you your app can go offline anytime the centralised cloud you're hosting it on experiences an outage? Here's the alternative. Fleek is a "cloud provider" that lets you host apps on Ethereum and files on Filecoin to get rid of the single point of failure problem. It's as easy to use as any cloud provider &lt;a href="https://www.reddit.com/r/aws/comments/h09wl5/dear_aws_stop_ruining_the_freaking_console_ui_rant/" rel="noopener noreferrer"&gt;(probably easier)&lt;/a&gt;. This whole goes back to the concept of being the best tool to use irrespective of the underlying tech.&lt;/p&gt;

&lt;h4&gt;
  
  
  ThirdWeb &lt;a href="https://thirdweb.com" rel="noopener noreferrer"&gt;(Website link)&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwj5kbn61qy6tanw8ob0f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwj5kbn61qy6tanw8ob0f.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Like any new technology, building for blockchains is initially hard and cumbersome. It's not as bad as writing machine code by hand, but its certainly not as easy as scaffolding an app with Ruby on Rails (if you know you know). You need to write smart contracts in another language called Solidity, or in the case of &lt;a href="https://solana.com/" rel="noopener noreferrer"&gt;Solana&lt;/a&gt;, you need to write it in Rust. And deploying your app to the chain is certainly not as easy as a &lt;code&gt;git push&lt;/code&gt;ing your Node.js app. But all is not lost, ThirdWeb has recently come up with SDKs in languages like Javascript, Python and Go which makes astonishingly easy to write and deploy "web3" code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo1vx1tp8lre21gcegl9m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo1vx1tp8lre21gcegl9m.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Take back control
&lt;/h3&gt;

&lt;p&gt;If you've made it this far into the post you probably see a pattern in all these services. These systems are set up in a way that takes power away from a centralised entity and distributes it to the individual nodes. Ideally these individual nodes are run by one person or a small group of people (which is where a potential problem lies).&lt;/p&gt;

&lt;h3&gt;
  
  
  It's not all sunshine and rainbows
&lt;/h3&gt;

&lt;p&gt;If everything goes well, blockchain tech will take away or at least reduce the power held by big tech companies (Meta, Amazon, Apple, Google, Microsoft, etc.). What's bad about them having all this power? Well, if they one day decide to be more greedy, there won't be a viable option elsewhere and people will just have to follow suit regardless. Sure, legal courts can intervene. But that process starts when the damage has already been done, and to be fair legal proceedings can take a fairly long time.&lt;/p&gt;

&lt;p&gt;But there's a loophole in blockchains too. It's fine if each person runs one node, then the system is truly decentralised and each person gets their own say. But nothing's stopping you from pooling resources with people and start a crypto mining farm that out competes most single person nodes, and essentially centralises power again (we're already seeing this happen extensively). And remember big tech and its &lt;em&gt;prophecised&lt;/em&gt; demise? Well, nothing's stopping them to start their own mining farm and earn through that.&lt;/p&gt;

&lt;p&gt;The mere existence of blockchain does not guarantee a better future for tech. It has to be actively worked on by enthusiastic developers in every corner to make it work. Or else, it will be just another piece of tech that gets dominated by soulless large corporations whose only aim is to make profits. Which is why you will see supporters of blockchain or "web3" hype it up so much. It is to get more individuals get involved and have a majority stake in it, so that when the big corporations want to have a piece of it, they can only be a minority.&lt;/p&gt;

&lt;p&gt;So will you help bring power back to the individual or will you let big tech have it all? Will you take the blue pill or the red pill?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You take the blue pill, the story ends. You wake up in your bed and believe whatever you want to believe. You take the red pill, you stay in Wonderland, and I show you how deep the rabbit hole goes&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/zE7PKRjrid4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;NOTE: I am in no way affiliated to or supported by any of the above services. I don't even hold any Ethereum (!)&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>web3</category>
      <category>systems</category>
      <category>security</category>
    </item>
    <item>
      <title>What frustrates you most about developers' hiring process?</title>
      <dc:creator>Syed Faraaz Ahmad</dc:creator>
      <pubDate>Thu, 20 May 2021 14:24:35 +0000</pubDate>
      <link>https://dev.to/faraazahmad/what-are-your-pain-points-when-hiring-developers-1fe0</link>
      <guid>https://dev.to/faraazahmad/what-are-your-pain-points-when-hiring-developers-1fe0</guid>
      <description>&lt;p&gt;While hiring developers for your organisation, what are the biggest challenges you have come across? If you could change some things in the hiring process, as a recruiter or a developer what would they be?&lt;/p&gt;

&lt;p&gt;I would love to chat.&lt;/p&gt;

</description>
      <category>help</category>
      <category>discuss</category>
    </item>
    <item>
      <title>I was bored, so I built a programming language</title>
      <dc:creator>Syed Faraaz Ahmad</dc:creator>
      <pubDate>Wed, 24 Mar 2021 19:49:37 +0000</pubDate>
      <link>https://dev.to/faraazahmad/i-was-bored-so-i-built-my-own-programming-language-30f1</link>
      <guid>https://dev.to/faraazahmad/i-was-bored-so-i-built-my-own-programming-language-30f1</guid>
      <description>&lt;p&gt;One fine evening in the first lockdown of 2020, there I was, sitting idly, not knowing what to do. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Calmly freaking out.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You see, I really needed something to do. I had been doing a few web related projects on the side and that was something I didn't want to do any more, at least for a while. So I looked into doing something "closer to the metal", something much lower level than sending requests back and forth to a web server. So I quickly fired up &lt;a href="https://aquadzn.github.io/learn-x-by-doing-y/" rel="noopener noreferrer"&gt;Learn X by doing Y&lt;/a&gt; and searched for something interesting, eventually ending up on Building your own &lt;a href="https://en.wikipedia.org/wiki/Lisp_(programming_language)" rel="noopener noreferrer"&gt;Lisp&lt;/a&gt; (We all have a Lisp phase, it was just my turn).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdutz9hefvgcubc4n7rwd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdutz9hefvgcubc4n7rwd.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the uninitiated, Lisp is (simply put) a family of programming languages whose syntax looks more or less like this (You can quickly see where the parentheses jokes stem from).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight clojure"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;defun&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;area-circle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;rad&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="s"&gt;"Calculates area of a circle with given radius"&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;terpri&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Radius: ~5f"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;rad&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"~%Area: ~10f"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;3.141592&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;rad&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;rad&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;area-circle&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;But I didn't just want to create any Lisp, I wanted to make some modifications as per my preference. So there was only 1 way to go about doing this.&lt;/p&gt;
&lt;h2&gt;
  
  
  Coming up with a syntax
&lt;/h2&gt;

&lt;p&gt;What got me into lisps and writing Lisp was (suprisingly) the &lt;a href="https://www.gnu.org/software/emacs/" rel="noopener noreferrer"&gt;Emacs text editor&lt;/a&gt; (or Emacs OS for the hardcore users). What was I doing going anywhere even remotely near Emacs? I don't know, I'll tell you some other day. You see, writing Emacs Lisp is the recommended way of configuring Emacs. Even though I didn't write a lot of Emacs Lisp, a few of the keywords I saw there didn't feel very natural to me (especially coming from using Ruby). So one of the major goals would be to &lt;strong&gt;have more "natural" sounding keywords&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffxsfh7j9rdvh0e5132uf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffxsfh7j9rdvh0e5132uf.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can't talk about Lisp without talking about the parentheses. A big advantage in readability for other languages is that everything isn't inside a parenthesis. Square brackets usually denote an array, braces usually denote code blocks, while parenthesis are used for function calls. It leads to easier visual grepping of code, not so much in Lisp, especially as a beginner. So I need to reduce the usage of parentheses, but I cant just change all of its syntax because then it might not stay a Lisp anymore (&lt;a href="https://en.wikipedia.org/wiki/Ship_of_Theseus" rel="noopener noreferrer"&gt;Ship of Theseus&lt;/a&gt;, anyone?). I think &lt;a href="https://clojure.org/" rel="noopener noreferrer"&gt;Clojure&lt;/a&gt; strikes a good balance between staying a Lisp and improving visual grepping. So another goal would be to &lt;strong&gt;reduce the reliance on parentheses so that the code can be more readable&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight clojure"&gt;&lt;code&gt;&lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="c1"&gt;; list&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="c1"&gt;; vector&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="c1"&gt;; set&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="no"&gt;:a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="n"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="no"&gt;:b&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;; map&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;(Example from &lt;a href="https://clojure.org/guides/learn/syntax" rel="noopener noreferrer"&gt;Clojure syntax guide&lt;/a&gt;)&lt;/p&gt;
&lt;h2&gt;
  
  
  So it began
&lt;/h2&gt;

&lt;p&gt;After setting all these requirements for the language, I set out to finally start building it. I chose Rust to build it because it seemed like the right tool to do so because of it's speed and memory safety. I was building my own programming language, I felt like a "real programmer" (no such thing btw) so naturally I started tweeting about it.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1329145543314980865-337" src="https://platform.twitter.com/embed/Tweet.html?id=1329145543314980865"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1329145543314980865-337');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1329145543314980865&amp;amp;theme=dark"
  }



&lt;/p&gt;
&lt;h3&gt;
  
  
  Starting simple
&lt;/h3&gt;

&lt;p&gt;I wanted to start off with something as simple as possible, like adding a few numbers. It felt like the perfect starting point. I'll be evaluating a simple arithmetic expression written in Lisp, for example, &lt;strong&gt;2 * 3 + 1 - 4&lt;/strong&gt;, which would be written as &lt;strong&gt;(- (+ 1 (* 2 3)) 4)&lt;/strong&gt; in Lisp. To the unaware, this is in the form of Polish notation, just think of it as a simple function with multiple arguments. &lt;code&gt;(+ 1 2 3)&lt;/code&gt; is simply the sum of 1, 2 &amp;amp; 3. Its result can then be used as an argument to a parent function, and then that gets evaluated. Similarly the whole expression can be solved using the method below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7s1v3oj835ycju53ku8s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7s1v3oj835ycju53ku8s.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
(Source: &lt;a href="https://craftinginterpreters.com/representing-code.html" rel="noopener noreferrer"&gt;Crafting Interpreters&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;After building the initial prototype I tested it with &lt;strong&gt;(+ 2 (- 4 6) 8)&lt;/strong&gt;. Doing it manually, you can tell it's &lt;strong&gt;4 - 6 + 2 + 8 = 8&lt;/strong&gt;. And if you see the result in the bottom red rectangle, the result is indeed 8.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe1uvr33yv9l7x9vc9egp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe1uvr33yv9l7x9vc9egp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Laying the building blocks
&lt;/h3&gt;

&lt;p&gt;Now that we've had something to play around with, it's time to grow up and lay the foundations for a proper compiler. The first step for any compiler is to read the source file and turn it into a stream machine readable objects called tokens. This step is called &lt;strong&gt;lexical analysis&lt;/strong&gt;, or lexing. It simply maps all possible characters in the programming language to a Token object. Like so:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Character&lt;/th&gt;
&lt;th&gt;Token&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;(&lt;/td&gt;
&lt;td&gt;Token { kind: OpenParen, value: None }&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;let&lt;/td&gt;
&lt;td&gt;Token { kind: Identifier, value: Some("let") }&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-?([0-9])+&lt;/td&gt;
&lt;td&gt;Token { kind: Number, value: Some(getVal()) }&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In this way you can build a mapping for token and their various types, so that its easier to build your syntax tree in the next step.&lt;/p&gt;

&lt;p&gt;Cool, now that I can generate tokens, it was time to build on top of this abstraction and give this stream of tokens a proper structure so that it's easier to work with. We're going to go examine every token and make sense of it all by generating a syntax tree. This step is called parsing and at its end, we going to have something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu61nka1vzs6rcu0tstzt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu61nka1vzs6rcu0tstzt.png" alt="Abstract syntax tree"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(Source: &lt;a href="https://en.wikipedia.org/wiki/Abstract_syntax_tree" rel="noopener noreferrer"&gt;Abstract Syntax tree:Wikipedia&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So I go about trying to build a syntax tree, starting with defining a basic grammar in the form of an enum which looked something like this&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;enum&lt;/span&gt; &lt;span class="n"&gt;Expr&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;Constant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nf"&gt;Builtin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Ident&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; 
    &lt;span class="nf"&gt;Call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Box&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Expr&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;Vec&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Expr&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;While&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Box&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Expr&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Vec&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Expr&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Reading the &lt;a href="https://doc.rust-lang.org/stable/nightly-rustc/src/rustc_parse/lib.rs.html" rel="noopener noreferrer"&gt;source code of the Rust programming language&lt;/a&gt; was very helpful and I might have &lt;em&gt;stolen&lt;/em&gt; some concepts from it. Let me just quickly define what these types are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Constant: Any literal of type &lt;code&gt;Value&lt;/code&gt; (number, string, boolean)&lt;/li&gt;
&lt;li&gt;Builtin: Any builtin token like an operator (+,-,*,/) or a keyword (let, print, if)&lt;/li&gt;
&lt;li&gt;Call: this is simple, any function call (truth be told, everything should just be a function call since Lisp is a functional language)&lt;/li&gt;
&lt;li&gt;While: A while loop (duh)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(If you're wondering, &lt;a href="https://doc.rust-lang.org/std/boxed/struct.Box.html" rel="noopener noreferrer"&gt;Box&lt;/a&gt; is Rust's built-in type for pointers, broadly speaking.)&lt;/p&gt;

&lt;p&gt;This is the gist of it, rest of the process was just finding ways to build this syntax tree using the token stream I had. Slowly but surely, I was making progress.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1330497714107404291-774" src="https://platform.twitter.com/embed/Tweet.html?id=1330497714107404291"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1330497714107404291-774');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1330497714107404291&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8n95mahek3ahzpxcg6rv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8n95mahek3ahzpxcg6rv.png" alt="Alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, the syntax tree felt robust enough for what I wanted the language to do for now. It was &lt;strong&gt;time to move on to bigger and better things&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  LLVM
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Low..Level..Virtual Machine?&lt;/em&gt; good guess, but &lt;a href="https://lists.llvm.org/pipermail/llvm-dev/2011-December/046445.html" rel="noopener noreferrer"&gt;not anymore&lt;/a&gt;. What is LLVM? let's first take a step back and see why it's needed in the first place. You see, a compiler has 2 sides - a frontend and a backend - the former containing lexing and parsing, while the latter has intermediate code generation, optimisation and target code generation. What I'd built until now was just the frontend, and I had the internal representation that can be used by the backend.&lt;/p&gt;

&lt;p&gt;To build all the backend from scratch, here's what I would have to do. Firstly, limit myself to an architecture since supporting multiple processor architectures was not an option, simply because of the intricacies of the way processors work. After selecting the most popular processor architecture I'd need to get a good grasp of its assembly language. You see, because of the different ways microprocessors are designed and made, they all have different instruction sets. To support an instruction set, you need to take the code the user has written in your language and translate it in the form of instructions of that specific set. Processors can work in weird ways, sometimes for compatibility reasons and sometimes just because they can. So when you optimise your generated code, you have to take all that into account. Let's say you do manage to support one architecture successfully but now there's (somehow) popular demand for your language on some other architecture, you will have to repeat this process all over again, and then again for another architecture, and so on. Don't even get me started on how you would debug errors that are specific to only some architectures. It would be a huge mess.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr37gv9mm9718s1pl773g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr37gv9mm9718s1pl773g.png" alt="LLVM being an abstraction"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is where LLVM comes in, it provides a convenient abstraction layer over all the instruction sets that you can target. You only need to worry about translating to its own internal representation (LLVM IR). LLVM will then handle all the code optimisation to its IR, and then for the instruction set you're targetting. But it's still a good idea to first optimise your code and then give it to LLVM, instead of just expecting LLVM to do it all. &lt;/p&gt;

&lt;p&gt;So to use LLVM, all I needed to do was to take my AST and convert it into LLVM IR. I did it using &lt;a href="https://github.com/thedan64/inkwell" rel="noopener noreferrer"&gt;Inkwell&lt;/a&gt; the LLVM API in Rust. It is a wrapper around the C API that LLVM has built, and on top of that provides the memory safety guaranteed by Rust. Oh, and this is what LLVM IR looks like in text format (&lt;a href="https://www.youtube.com/watch?v=tPEhCcluVdM" rel="noopener noreferrer"&gt;Don't try to understand it, feel it&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight llvm"&gt;&lt;code&gt;&lt;span class="c1"&gt;; ModuleID = 'example'&lt;/span&gt;
&lt;span class="k"&gt;source_filename&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"/home/faraaz/hello.tp"&lt;/span&gt;

&lt;span class="vg"&gt;@format_string&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;unnamed_addr&lt;/span&gt; &lt;span class="k"&gt;constant&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt; &lt;span class="p"&gt;x&lt;/span&gt; &lt;span class="kt"&gt;i8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="s"&gt;c"%f \00"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;align&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;define&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt; &lt;span class="vg"&gt;@main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;i32&lt;/span&gt; &lt;span class="nv"&gt;%0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;entry:&lt;/span&gt;
  &lt;span class="nv"&gt;%num&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;alloca&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt;
  &lt;span class="k"&gt;store&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="m"&gt;4.200000e+02&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;%num&lt;/span&gt;
  &lt;span class="nv"&gt;%num1&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;load&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;%num&lt;/span&gt;
  &lt;span class="nv"&gt;%printf&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;call&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;i8&lt;/span&gt;&lt;span class="p"&gt;*,&lt;/span&gt; &lt;span class="p"&gt;...)&lt;/span&gt; &lt;span class="vg"&gt;@printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;i8&lt;/span&gt;&lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="k"&gt;getelementptr&lt;/span&gt; &lt;span class="k"&gt;inbounds&lt;/span&gt; &lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt; &lt;span class="p"&gt;x&lt;/span&gt; &lt;span class="kt"&gt;i8&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt; &lt;span class="p"&gt;x&lt;/span&gt; &lt;span class="kt"&gt;i8&lt;/span&gt;&lt;span class="p"&gt;]*&lt;/span&gt; &lt;span class="vg"&gt;@format_string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nv"&gt;%num1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;ret&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;declare&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="vg"&gt;@printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;i8&lt;/span&gt;&lt;span class="p"&gt;*,&lt;/span&gt; &lt;span class="p"&gt;...)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;em&gt;Code in LLVM IR that sets a variable to 420 and prints it&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Making it all legit
&lt;/h3&gt;

&lt;p&gt;Until now, executing the compiler's binary did only one thing and it wasn't very configurable or helpful for someone using it for the first time. I wanted it to have a proper Command Line Interface (CLI), something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flulmuxnm6puhz24rp38x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flulmuxnm6puhz24rp38x.png" alt="CLI for htop tool"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I used the &lt;a href="https://github.com/clap-rs/clap" rel="noopener noreferrer"&gt;Clap&lt;/a&gt; crate (aka package) to build the CLI and I think it turned out all right.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjcvitgywjex23ycfxsu5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjcvitgywjex23ycfxsu5.png" alt="CLI for Tisp"&gt;&lt;/a&gt;  &lt;/p&gt;
&lt;h2&gt;
  
  
  Bringing it all together
&lt;/h2&gt;

&lt;p&gt;Now that I have the compiler set up, and the language has features like storing variables, performing arithmetic, looping (nested loops don't work yet) and printing to screen, it was time to make a small program with it. Here's me writing a program to compute the first 5 Fibonacci numbers in Tisp and then compile and run it:&lt;/p&gt;


&lt;div class="ltag_asciinema"&gt;
  
&lt;/div&gt;



&lt;p&gt;Here's the project if you want to check it out yourself.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/faraazahmad" rel="noopener noreferrer"&gt;
        faraazahmad
      &lt;/a&gt; / &lt;a href="https://github.com/faraazahmad/tisp" rel="noopener noreferrer"&gt;
        tisp
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A toy programming language based on Lisp and built in Rust &amp;amp; LLVM
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Tisp (&lt;strong&gt;T&lt;/strong&gt;oy L&lt;strong&gt;isp&lt;/strong&gt;)&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;A Lisp-like programming language that is typed and compiled. It aims to
support multiple processor architectures by being built upon LLVM. It takes
inspiration from programming languages like Rust, Lisp and Elixir.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Current working example&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;A program to compute first 5 fibonacci numbers:&lt;/p&gt;
&lt;div class="highlight highlight-source-commonlisp notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;(&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-c1"&gt;first&lt;/span&gt; &lt;span class="pl-c1"&gt;0&lt;/span&gt;)
(&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-c1"&gt;second&lt;/span&gt; &lt;span class="pl-c1"&gt;1&lt;/span&gt;)
(&lt;span class="pl-k"&gt;let&lt;/span&gt; fib)
(&lt;span class="pl-k"&gt;let&lt;/span&gt; n &lt;span class="pl-c1"&gt;0&lt;/span&gt;)

(while (&lt;span class="pl-c1"&gt;&amp;lt;&lt;/span&gt; n &lt;span class="pl-c1"&gt;5&lt;/span&gt;)
    (&lt;span class="pl-k"&gt;let&lt;/span&gt; fib (&lt;span class="pl-c1"&gt;+&lt;/span&gt; &lt;span class="pl-c1"&gt;first&lt;/span&gt; &lt;span class="pl-c1"&gt;second&lt;/span&gt;))
    (&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-c1"&gt;second&lt;/span&gt; &lt;span class="pl-c1"&gt;first&lt;/span&gt;)
    (&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-c1"&gt;first&lt;/span&gt; fib)

    (&lt;span class="pl-k"&gt;let&lt;/span&gt; n (&lt;span class="pl-c1"&gt;+&lt;/span&gt; n &lt;span class="pl-c1"&gt;1&lt;/span&gt;))
    (&lt;span class="pl-c1"&gt;print&lt;/span&gt; fib)
)
&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Features to build&lt;/h2&gt;

&lt;/div&gt;
&lt;ul class="contains-task-list"&gt;
&lt;li class="task-list-item"&gt;
 Convert raw code into token stream&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 Convert token stream into Expression tree&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 Handle multiple levels of nested expressions&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 Have multiple (independent) expressions per file&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 Generate LLVM IR for the currently supported features&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 add CLI flag to emit llvm&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 add while loop&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 Declare variables&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 add…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/faraazahmad/tisp" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Here's what I learned
&lt;/h2&gt;

&lt;p&gt;Programming languages are hard. Its' hard to read code in the first place. To understand and learn one is way harder. One can only imagine how hard it is to build one, let alone build one that is widely used. &lt;strong&gt;This project was mostly me trying to answer the question "How hard can it really be?"&lt;/strong&gt;, I guess I have my answer now. But it's also kinda easy low-key. Once you dip your toes in the hard parts, the next time you do it, it feels a little easier. Every day you do something hard, it gets a little easier, but you gotta do it everyday, that's the hard part.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/R2_Mn-qRKjA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>rust</category>
      <category>computerscience</category>
      <category>functional</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Can "good code" be measured?</title>
      <dc:creator>Syed Faraaz Ahmad</dc:creator>
      <pubDate>Tue, 23 Feb 2021 07:51:10 +0000</pubDate>
      <link>https://dev.to/faraazahmad/can-good-code-be-measured-38lb</link>
      <guid>https://dev.to/faraazahmad/can-good-code-be-measured-38lb</guid>
      <description>&lt;p&gt;I was recently reading &lt;a href="https://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670"&gt;Code Complete&lt;/a&gt;, a really good book on writing better software. Naturally, I had a lot of questions while reading it, but the biggest one that kept coming up was, "Can I measure this?" or "Can I quantify this?"&lt;/p&gt;

&lt;p&gt;I'm aware of static code analysers, and the vast improvements they bring, but I don't think they can do most of what the book teaches.&lt;/p&gt;

&lt;p&gt;So can we write software that "measures" the quality of our software?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>testing</category>
    </item>
    <item>
      <title>Discussion: It should be hard to write bad code</title>
      <dc:creator>Syed Faraaz Ahmad</dc:creator>
      <pubDate>Thu, 21 Jan 2021 19:01:02 +0000</pubDate>
      <link>https://dev.to/faraazahmad/discussion-it-should-be-hard-to-write-bad-code-3bh3</link>
      <guid>https://dev.to/faraazahmad/discussion-it-should-be-hard-to-write-bad-code-3bh3</guid>
      <description>&lt;p&gt;So I recently came across a huge React codebase that was hard to understand. There was no proper documentation, it wasn't clear how data is passed around and there are no automated unit tests. Now this is just the tip of the iceberg and I don't want to waste your time with a long rant. I would rather spend time discussing and coming up with solutions.&lt;/p&gt;

&lt;p&gt;I think people write bad code (myself included) not because they are bad people but because it is easy to do so, unrealistic deadlines make it even worse. I think if it were hard to write bad code, there would be less of it around.&lt;/p&gt;

&lt;p&gt;It is also not just a technical problem, people have to enforce it too. Have a well defined spec on how your codebase should be structured, documented and tested. Then  don't approve that PR unless it passes those specs.&lt;/p&gt;

&lt;p&gt;I could go on about this, I want to know how you feel on this topic and how you go about fixing it.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>I'm building a programming language: Creating tokens</title>
      <dc:creator>Syed Faraaz Ahmad</dc:creator>
      <pubDate>Sat, 19 Dec 2020 16:14:33 +0000</pubDate>
      <link>https://dev.to/faraazahmad/i-m-building-a-programming-language-creating-tokens-78b</link>
      <guid>https://dev.to/faraazahmad/i-m-building-a-programming-language-creating-tokens-78b</guid>
      <description>&lt;p&gt;Last time around I told you why I'm making this programming language, and how I'm going to go about doing it. Here, we're going to read the code file and start working with it.&lt;/p&gt;

&lt;p&gt;When evaluating code of a programming language, you can't just work with raw text all of the time.You see, working with text is expensive, as in, it is (relatively) slow to work with. Not to forget, cumbersome, let me show you how.&lt;/p&gt;

&lt;p&gt;Let's say you have a module (a collection of functions) in your code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;  &lt;span class="nx"&gt;my_module&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;say_hello&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;my_module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_name&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, ${name}!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;get_name&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;What is your name? &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_input&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then lets say you called one function in the module, like so:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;my_module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;say_hello&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If you're working off of just text, you'll have to search for a &lt;code&gt;my_module&lt;/code&gt; module in the file, then search for a function &lt;code&gt;say_hello&lt;/code&gt; in there. Great you got the function. But here's the thing, this function has a call to &lt;code&gt;my_module.get_name&lt;/code&gt; inside it. So you got to find the module in the file again, then in that module you need to find the func...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/UWse77aqHkxCFEdUPB/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/UWse77aqHkxCFEdUPB/giphy.gif" alt="Here we go again"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You get the point, its a lot of repetitive process and doing with raw text, makes it even slower. Sure, you could argue that its only 2 functions, how long could it even take on modern hardware. And you're right, it doesn't take long in this example. But you also know that code files are usually fairly long and doing this over and over in big files would add up to a really long time.&lt;/p&gt;

&lt;p&gt;This is why we don't want to work with text directly all the time. We read the text once, build some in-memory abstractions for them in our code, then build abstractions upon abstractions to make it easier to create our programming language. The first step of that is called Lexical Analysis (or Lexing).&lt;/p&gt;

&lt;p&gt;In lexing, we go through our raw code in text format, and convert that into tokens, the smallest level of abstraction we can create (as far as I know).&lt;/p&gt;

&lt;p&gt;Let me show you how a simple expression would be &lt;strong&gt;tokenised&lt;/strong&gt;. Consider a simple expression:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;It should converted into a token stream as follows:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="nx"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;OpenParen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;None&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nx"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Plus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;None&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nx"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Literal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nx"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Literal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;5.0&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nx"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CloseParen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;None&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I looked at a few approaches to do this step. One was to write a separate Lexer, and the other was to write a parser-combinator (a method that combines lexing and the next step, i.e. parsing). While parser-combinators are amazing, it's not the route I felt like I wanted to take at the time. Also, a I wasn't too excited about scanning the source file character by character myself, so I started looking into some libraries that would ease up that work for me. That's when I stumbled upon &lt;strong&gt;Logos&lt;/strong&gt;.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/maciejhirsz" rel="noopener noreferrer"&gt;
        maciejhirsz
      &lt;/a&gt; / &lt;a href="https://github.com/maciejhirsz/logos" rel="noopener noreferrer"&gt;
        logos
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Create ridiculously fast Lexers
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer nofollow" href="https://raw.githubusercontent.com/maciejhirsz/logos/master/logos.svg?sanitize=true"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fmaciejhirsz%2Flogos%2Fmaster%2Flogos.svg%3Fsanitize%3Dtrue" alt="Logos logo" width="250"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Logos&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/maciejhirsz/logos/workflows/Test/badge.svg?branch=master"&gt;&lt;img src="https://github.com/maciejhirsz/logos/workflows/Test/badge.svg?branch=master" alt="Test"&gt;&lt;/a&gt;
&lt;a href="https://crates.io/crates/logos" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/85ba64341aa3a711e682b870d5f9d8b1c484b77dd726198a6068a894a68a0760/68747470733a2f2f696d672e736869656c64732e696f2f6372617465732f762f6c6f676f732e737667" alt="Crates.io version shield"&gt;&lt;/a&gt;
&lt;a href="https://docs.rs/logos" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/2a1ccff831f1994d86cdad3d83a2463a7ed2d595b5a960cb856083a1733b8a31/68747470733a2f2f646f63732e72732f6c6f676f732f62616467652e737667" alt="Docs"&gt;&lt;/a&gt;
&lt;a href="https://crates.io/crates/logos" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/f6497dea3b7942d643d33fcc6d87f307db54ed01999c34b4c9e5cbe25b3817d4/68747470733a2f2f696d672e736869656c64732e696f2f6372617465732f6c2f6c6f676f732e737667" alt="Crates.io license shield"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Create ridiculously fast Lexers.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Logos&lt;/strong&gt; has two goals:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;To make it easy to create a Lexer, so you can focus on more complex problems.&lt;/li&gt;
&lt;li&gt;To make the generated Lexer faster than anything you'd write by hand.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To achieve those, &lt;strong&gt;Logos&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Combines all token definitions into a single &lt;a href="https://en.wikipedia.org/wiki/Deterministic_finite_automaton" rel="nofollow noopener noreferrer"&gt;deterministic state machine&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Optimizes branches into &lt;a href="https://en.wikipedia.org/wiki/Lookup_table" rel="nofollow noopener noreferrer"&gt;lookup tables&lt;/a&gt; or &lt;a href="https://en.wikipedia.org/wiki/Branch_table" rel="nofollow noopener noreferrer"&gt;jump tables&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Prevents &lt;a href="https://en.wikipedia.org/wiki/ReDoS" rel="nofollow noopener noreferrer"&gt;backtracking&lt;/a&gt; inside token definitions.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://en.wikipedia.org/wiki/Loop_unrolling" rel="nofollow noopener noreferrer"&gt;Unwinds loops&lt;/a&gt;, and batches reads to minimize bounds checking.&lt;/li&gt;
&lt;li&gt;Does all of that heavy lifting at compile time.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Example&lt;/h2&gt;
&lt;/div&gt;
&lt;div class="highlight highlight-source-rust notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt; &lt;span class="pl-k"&gt;use&lt;/span&gt; logos&lt;span class="pl-kos"&gt;::&lt;/span&gt;&lt;span class="pl-v"&gt;Logos&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
 &lt;span class="pl-c1"&gt;#&lt;span class="pl-kos"&gt;[&lt;/span&gt;derive&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-v"&gt;Logos&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-v"&gt;Debug&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-v"&gt;PartialEq&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;]&lt;/span&gt;&lt;/span&gt;
 &lt;span class="pl-c1"&gt;#&lt;span class="pl-kos"&gt;[&lt;/span&gt;logos&lt;span class="pl-kos"&gt;(&lt;/span&gt;skip &lt;span class="pl-s"&gt;r"[ \t\n\f]+"&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;]&lt;/span&gt;&lt;/span&gt; &lt;span class="pl-c"&gt;// Ignore this regex pattern between tokens&lt;/span&gt;
 &lt;span class="pl-k"&gt;enum&lt;/span&gt; &lt;span class="pl-smi"&gt;Token&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt;
     &lt;span class="pl-c"&gt;// Tokens can be literal strings, of any length.&lt;/span&gt;
     &lt;span class="pl-c1"&gt;#&lt;span class="pl-kos"&gt;[&lt;/span&gt;token&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s"&gt;"fast"&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;]&lt;/span&gt;&lt;/span&gt;
     &lt;span class="pl-v"&gt;Fast&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;

     &lt;span class="pl-c1"&gt;#&lt;span class="pl-kos"&gt;[&lt;/span&gt;token&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s"&gt;"."&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;]&lt;/span&gt;&lt;/span&gt;
     &lt;span class="pl-v"&gt;Period&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;

     &lt;span class="pl-c"&gt;//&lt;/span&gt;&lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/maciejhirsz/logos" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;It is a library that generates optimised, fast lexers and that are extremely easy to use. Since they claim to generate lexers that are faster than anything I could write by hand, and is used by lots of people, I guess I gotta take their word for it. They also promised that it will be extremely easy to use, and what do you know, it really is. &lt;/p&gt;

&lt;p&gt;It is as easy as mapping an enum value to a string or regex expression, and Logos does everything for you.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nd"&gt;#[derive(Debug,&lt;/span&gt; &lt;span class="nd"&gt;PartialEq,&lt;/span&gt; &lt;span class="nd"&gt;Logos)]&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;enum&lt;/span&gt; &lt;span class="n"&gt;TokenKind&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nv"&gt;'a&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;#[token(&lt;/span&gt;&lt;span class="s"&gt;"("&lt;/span&gt;&lt;span class="nd"&gt;)]&lt;/span&gt;
    &lt;span class="n"&gt;OpenParen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="nd"&gt;#[token(&lt;/span&gt;&lt;span class="s"&gt;")"&lt;/span&gt;&lt;span class="nd"&gt;)]&lt;/span&gt;
    &lt;span class="n"&gt;CloseParen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="nd"&gt;#[token(&lt;/span&gt;&lt;span class="s"&gt;"+"&lt;/span&gt;&lt;span class="nd"&gt;)]&lt;/span&gt;
    &lt;span class="n"&gt;Plus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="nd"&gt;#[token(&lt;/span&gt;&lt;span class="s"&gt;"-"&lt;/span&gt;&lt;span class="nd"&gt;)]&lt;/span&gt;
    &lt;span class="n"&gt;Minus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="nd"&gt;#[regex(&lt;/span&gt;&lt;span class="s"&gt;"-?([0-9])+"&lt;/span&gt;&lt;span class="nd"&gt;,&lt;/span&gt; &lt;span class="err"&gt;|&lt;/span&gt;&lt;span class="nd"&gt;lex&lt;/span&gt;&lt;span class="err"&gt;|&lt;/span&gt; &lt;span class="nd"&gt;lex&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="nd"&gt;slice()&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="nd"&gt;parse())]&lt;/span&gt;
    &lt;span class="nf"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;f64&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;

    &lt;span class="nd"&gt;#[regex(&lt;/span&gt;&lt;span class="s"&gt;r"[ \t\n\f]+"&lt;/span&gt;&lt;span class="nd"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;logos::skip)]&lt;/span&gt;
    &lt;span class="n"&gt;Whitespace&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="nd"&gt;#[error]&lt;/span&gt;
    &lt;span class="n"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Yes, its a very simple lexer. But that's what I want right now. I want it to be able to parse a small, simple (but valid) expression. Like this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And it does do that, as you can see below. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note that the lexer code you just read doesn't automatically produce the list of Tokens below. &lt;code&gt;Token&lt;/code&gt; is an abstraction similar to what I saw in the Rust codebase. It reduces the work that the parser would need to do when consuming this token stream.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;OpenParen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;None&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; 
  &lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Plus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;None&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; 
  &lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;Literal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;2.0&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; 
  &lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;OpenParen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;None&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; 
  &lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Minus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;None&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; 
  &lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;Literal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;4.0&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; 
  &lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;Literal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;6.0&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; 
  &lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;CloseParen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;None&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; 
  &lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;Literal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;8.0&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; 
  &lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;CloseParen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;None&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; 
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;em&gt;The &lt;code&gt;Some&lt;/code&gt;s you see in this token stream is an &lt;code&gt;Option&lt;/code&gt; type in Rust, since some tokens don't have any use for the value field&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Remember how I wanted each step in the development process to be "able to take me from source code to executable binary in some form or another"? Well, Now I want to evaluate this simple expression and show me the result.&lt;/p&gt;

&lt;p&gt;I will use a simple stack based approach for this. Essentially, push all tokens to the stack, and when you get a &lt;code&gt;CloseParen&lt;/code&gt;, pop the values for that expression and push the result of the expression back into the stack.&lt;/p&gt;

&lt;p&gt;And I ran the code:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2bbfdd67q1bhgmd96h52.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2bbfdd67q1bhgmd96h52.png" alt="Output shows correct evaluation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr36vdhi7ojwzkwpej4t3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr36vdhi7ojwzkwpej4t3.gif" alt="It worked"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It worked! As you can see, the result is a token with a value of 8. &lt;/p&gt;

&lt;p&gt;I guess that's it for now. See you in the next post.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note (this is the last one I promise): In order to keep the quality of my posts to an acceptable level, the rate at which I submit posts is much slower to the rate at which I'm adding features to the language.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you would like to see the codebase and maybe even contribute, you can head over here:&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/faraazahmad" rel="noopener noreferrer"&gt;
        faraazahmad
      &lt;/a&gt; / &lt;a href="https://github.com/faraazahmad/tisp" rel="noopener noreferrer"&gt;
        tisp
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A toy programming language based on Lisp and built in Rust &amp;amp; LLVM
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Tisp (&lt;strong&gt;T&lt;/strong&gt;oy L&lt;strong&gt;isp&lt;/strong&gt;)&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;A Lisp-like programming language that is typed and compiled. It aims to
support multiple processor architectures by being built upon LLVM. It takes
inspiration from programming languages like Rust, Lisp and Elixir.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Current working example&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;A program to compute first 5 fibonacci numbers:&lt;/p&gt;
&lt;div class="highlight highlight-source-commonlisp notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;(&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-c1"&gt;first&lt;/span&gt; &lt;span class="pl-c1"&gt;0&lt;/span&gt;)
(&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-c1"&gt;second&lt;/span&gt; &lt;span class="pl-c1"&gt;1&lt;/span&gt;)
(&lt;span class="pl-k"&gt;let&lt;/span&gt; fib)
(&lt;span class="pl-k"&gt;let&lt;/span&gt; n &lt;span class="pl-c1"&gt;0&lt;/span&gt;)

(while (&lt;span class="pl-c1"&gt;&amp;lt;&lt;/span&gt; n &lt;span class="pl-c1"&gt;5&lt;/span&gt;)
    (&lt;span class="pl-k"&gt;let&lt;/span&gt; fib (&lt;span class="pl-c1"&gt;+&lt;/span&gt; &lt;span class="pl-c1"&gt;first&lt;/span&gt; &lt;span class="pl-c1"&gt;second&lt;/span&gt;))
    (&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-c1"&gt;second&lt;/span&gt; &lt;span class="pl-c1"&gt;first&lt;/span&gt;)
    (&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-c1"&gt;first&lt;/span&gt; fib)

    (&lt;span class="pl-k"&gt;let&lt;/span&gt; n (&lt;span class="pl-c1"&gt;+&lt;/span&gt; n &lt;span class="pl-c1"&gt;1&lt;/span&gt;))
    (&lt;span class="pl-c1"&gt;print&lt;/span&gt; fib)
)
&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Features to build&lt;/h2&gt;

&lt;/div&gt;
&lt;ul class="contains-task-list"&gt;
&lt;li class="task-list-item"&gt;
 Convert raw code into token stream&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 Convert token stream into Expression tree&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 Handle multiple levels of nested expressions&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 Have multiple (independent) expressions per file&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 Generate LLVM IR for the currently supported features&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 add CLI flag to emit llvm&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 add while loop&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 Declare variables&lt;/li&gt;
&lt;li class="task-list-item"&gt;
 add…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/faraazahmad/tisp" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>showdev</category>
      <category>rust</category>
      <category>computerscience</category>
      <category>lisp</category>
    </item>
    <item>
      <title>I'm building a programming language</title>
      <dc:creator>Syed Faraaz Ahmad</dc:creator>
      <pubDate>Mon, 14 Dec 2020 15:00:35 +0000</pubDate>
      <link>https://dev.to/faraazahmad/i-m-building-a-programming-language-9eo</link>
      <guid>https://dev.to/faraazahmad/i-m-building-a-programming-language-9eo</guid>
      <description>&lt;p&gt;A lot of people that talk about building their own programming language, have a lot of lofty goals for them. They want them to have this feature, that feature, to conquer the world and back.&lt;/p&gt;

&lt;p&gt;Me? not so much. I'm building one just to learn how to do it "for real". Sure, I have some opinions about what features I would like more. I would use them as goals for the whole project, not just as design goals for the language.&lt;/p&gt;

&lt;p&gt;So what are my goals, well...&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;I want to build it using Rust&lt;/strong&gt;: I've been trying to learn &lt;a href="https://rust-lang.org" rel="noopener noreferrer"&gt;Rust&lt;/a&gt; for a long time now, and while I've learnt a lot, built a few side projects here and there, there's still a lot I don't know. So I thought, "Why not just go for it and throw myself in the deep end", and that's what I'll be doing. Using Rust to build the language and learn Rust as I move along.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Truly experience how to build a compiler&lt;/strong&gt;: Sure I've learnt how to do so at university, wrote some code for building automata etc. But nothing beats the experience of actually building it all on your own.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Have a Lisp like syntax&lt;/strong&gt;: This is really not a big deal. I've recently been diving into Lisp dialects and I like some concepts and some syntax in it, so I'll try adding some of those in my language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Be fast and support multiple platforms&lt;/strong&gt;: I don't think there's much benefit building a programming language that's painfully slow to use. To make it fast I want it to be a compiled language (as opposed to an interpreted one), Rust also helps in this area as it is pretty fast. Since it's also going to be multi-platform, I will be using &lt;a href="http://llvm.org/" rel="noopener noreferrer"&gt;LLVM&lt;/a&gt; because I don't want to be dealing with any assembly code and optimisations yet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Be usable at every step of development&lt;/strong&gt;: I will be gradually adding features, but I want every feature made to be able to show me some visible output.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjskoe1pmxjxk5fhfkstm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjskoe1pmxjxk5fhfkstm.png" alt="Building an MVP"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Like the image above, I want each step in the development process be able to take me from source code to program in some way or another. Instead of building perfect separate components like the perfect parser and perfect lexer that on their own cannot (obviously) get me from source to program. I want to build a lexer than kinda works and a parser that kinda works (and so on) which combined can get me from source code to executable program.&lt;/p&gt;

&lt;p&gt;I hope I come out the other side, having a lot more knowledge in this area than I do now (which is really tiny).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/kyuVXoo0Ywh2iY4fxB/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/kyuVXoo0Ywh2iY4fxB/giphy.gif" alt="see you around"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See you around!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>rust</category>
      <category>computerscience</category>
      <category>showdev</category>
    </item>
    <item>
      <title>APIs to help build your next side project</title>
      <dc:creator>Syed Faraaz Ahmad</dc:creator>
      <pubDate>Sat, 29 Aug 2020 20:14:51 +0000</pubDate>
      <link>https://dev.to/faraazahmad/apis-to-help-build-your-next-side-project-1f91</link>
      <guid>https://dev.to/faraazahmad/apis-to-help-build-your-next-side-project-1f91</guid>
      <description>&lt;p&gt;Say you have an idea for a new side project, but dont know what topic to base it on (for example: Bears, Beets, Battlestar Galactica). You really don't wanna be building another to-do list.&lt;/p&gt;

&lt;p&gt;You might want to test only a small idea you have, and dont want to build a full fledged app. Here's where you can use APIs as substitutes for parts of the app you're not focusing on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://faraazahmad.github.io/apiland"&gt;I made a project&lt;/a&gt; using Vue that lists all publicly available APIs for you to use.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JOeZMLGM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ogn13464bsce1leu1kco.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JOeZMLGM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ogn13464bsce1leu1kco.png" alt="API Land screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see there are a lot of APIs to choose from (643 to be accurate), going through all of them to select one is counter productive. So I have provided a way to filter them by category, and am working on adding more filtering and search options.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AC8k0k9t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/75nazr3gu2snq2r2wqal.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AC8k0k9t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/75nazr3gu2snq2r2wqal.png" alt="Filter APIs screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's open source so you can help me improve this project &lt;a href="https://github.com/faraazahmad/apiland"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Github Link: &lt;a href="https://github.com/faraazahmad/apiland"&gt;https://github.com/faraazahmad/apiland&lt;/a&gt;&lt;br&gt;
Live Demo: &lt;a href="https://faraazahmad.github.io/apiland"&gt;https://faraazahmad.github.io/apiland&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sideprojects</category>
      <category>showdev</category>
      <category>vue</category>
    </item>
    <item>
      <title>How do you manage your reading list(s)?</title>
      <dc:creator>Syed Faraaz Ahmad</dc:creator>
      <pubDate>Fri, 14 Aug 2020 09:55:04 +0000</pubDate>
      <link>https://dev.to/faraazahmad/how-do-you-manage-your-reading-list-s-2jj7</link>
      <guid>https://dev.to/faraazahmad/how-do-you-manage-your-reading-list-s-2jj7</guid>
      <description>&lt;p&gt;As programmers, we require lots of reading on a daily basis. Be it code, documentation or any article that interests us. However there isn't enough time to read all the interesting articles you come across, so you save them for later (in a reading list)&lt;/p&gt;

&lt;p&gt;Over time, &lt;strong&gt;reading lists get larger and larger if not dealt with properly&lt;/strong&gt;, I want to know how you manage this problem&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Do you use an app (ex. Pocket, Instapaper, etc.) to manage tour reading lists?&lt;/li&gt;
&lt;li&gt;Do you have your personal routines to deal with this problem? (ex. getting through maximum possible articles on weekends, deleting old articles, etc.)&lt;/li&gt;
&lt;li&gt;What would be your ideal app to help fix this problem for you?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I'm asking this because I've had this problem for a long time, and I really want to do something to fix it. Thanks&lt;/p&gt;

</description>
      <category>reading</category>
      <category>help</category>
      <category>organisation</category>
    </item>
    <item>
      <title>I had nothing to do, so I built a text editor.</title>
      <dc:creator>Syed Faraaz Ahmad</dc:creator>
      <pubDate>Tue, 07 Apr 2020 20:30:37 +0000</pubDate>
      <link>https://dev.to/faraazahmad/i-had-nothing-to-do-so-i-built-a-text-editor-468n</link>
      <guid>https://dev.to/faraazahmad/i-had-nothing-to-do-so-i-built-a-text-editor-468n</guid>
      <description>&lt;blockquote&gt;
&lt;h1&gt;
  
  
  What do you do when you have nothing else left to do? I freak out.
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;So there I was, furiously looking for something to do. Maybe I could start a new open source project (because obviously I'm not going to complete my half finished ones), maybe learn a new programming language, maybe I could finally learn &lt;a href="https://svelte.dev"&gt;Svelte&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Needless to say, I had &lt;a href="https://en.wikipedia.org/wiki/Analysis_paralysis"&gt;analysis paralysis&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But then it hit me, I was recently having problems sticking to a single text editor. I liked Sublime because of its speed but couldn't use it for much because of a lack of plugins support. I mostly use Visual Studio Code because its extensive plugins support but sometimes it can get really slow (thanks electron), its not that big a deal but if you encounter something slightly annoying way too many times, it will get on your nerves. I also tried Vim/Neovim and Emacs and my likeness for them (or lack thereof) is pretty much equal. So go away with your Vim vs Emacs arguments :)&lt;/p&gt;

&lt;p&gt;So yeah, I started building my own, this is what it looks like right now.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e_02Pr_u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/njucwgxgsi9pa5t2fynd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e_02Pr_u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/njucwgxgsi9pa5t2fynd.png" alt="Alt Text" width="880" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I first thought of using Electron to build it, since it would be easy (yeah, right) building in technologies I already know. But wouldn't that be counter-productive in the end? The whole vscode community is doing the best job they possibly can and there's no way I can make a faster text editor in electron than they do.&lt;/p&gt;

&lt;p&gt;So after a lot of irrelevant steps in my thinking process, I went with creating a text editor in the terminal with Rust &lt;a href="https://www.youtube.com/watch?v=K2tNxoXh-aU"&gt;(because I wanted to! and I liked it!)&lt;/a&gt;. Now I'm not some genius who conceptualised all of this out of thin air, I followed&lt;br&gt;
a &lt;a href="https://www.philippflenker.com/hecto"&gt;tutorial by Philipp Flenker&lt;/a&gt; which is (thankfully) &lt;a href="https://viewsourcecode.org/snaptoken/kilo/"&gt;based on a tutorial&lt;/a&gt; I'd previously tried but didn't complete because it was in C.&lt;/p&gt;

&lt;p&gt;Building a text editor for the terminal is super challenging as you have to build a lot of UI stuff from scratch and I will never take GUIs for granted ever again.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/26gR2BuE0fSoYzzfG/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/26gR2BuE0fSoYzzfG/giphy.gif" alt="Never Again" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  How'd I do it?
&lt;/h1&gt;

&lt;p&gt;To begin with, you need to clear the terminal window. You can do that you need to print the escape sequence &lt;code&gt;\x1b[2J&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Escape sequences instruct the terminal to do various text formatting tasks, such as coloring text, moving the cursor around, and clearing parts of the screen.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Reading Key presses
&lt;/h2&gt;

&lt;p&gt;In a terminal, all you have are key presses. You need to bind those key presses and their combinations to specific functions you want them to perform. Each key on your keyboard refers to a different byte. You can check them out by running a loop and printing all the input. In C, it is done like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;scanf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you press the arrow keys you can see how pressing letter keys and character keys produces different output bytes. From here on out, handling key presses is just matching the input against the bytes and performing the required actions.&lt;/p&gt;

&lt;p&gt;I'm using a (great) package called &lt;code&gt;termion&lt;/code&gt; that abstracts away these little details and makes my life easier. Here's some actual Rust code from the editor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;process_keypress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Result&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nn"&gt;std&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;io&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Error&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;pressed_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;Terminal&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;read_key&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="n"&gt;pressed_key&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Ctrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sc"&gt;'q'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="nf"&gt;.quit&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Ctrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sc"&gt;'f'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="nf"&gt;.search&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
            &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Ctrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sc"&gt;'s'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="nf"&gt;.save&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
            &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Ctrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sc"&gt;'h'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="nf"&gt;.show_help&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
            &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Char&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="c1"&gt;// don't move cursor to the right if enter is pressed&lt;/span&gt;
                &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="nf"&gt;.move_cursor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nb"&gt;Right&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.document&lt;/span&gt;&lt;span class="nf"&gt;.insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.cursor_position&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Delete&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.document&lt;/span&gt;&lt;span class="nf"&gt;.delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.cursor_position&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Backspace&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="c1"&gt;// Backspace = going left and perform delete&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.cursor_position.x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;||&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.cursor_position.y&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="nf"&gt;.move_cursor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nb"&gt;Left&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                    &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.document&lt;/span&gt;&lt;span class="nf"&gt;.delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.cursor_position&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Up&lt;/span&gt;
            &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Down&lt;/span&gt;
            &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nb"&gt;Left&lt;/span&gt;
            &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nb"&gt;Right&lt;/span&gt;
            &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;PageUp&lt;/span&gt;
            &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;PageDown&lt;/span&gt;
            &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Home&lt;/span&gt;
            &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nn"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;End&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="nf"&gt;.move_cursor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pressed_key&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// ...&lt;/span&gt;

        &lt;span class="nf"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(())&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;NOTE: Some code has been omitted to make it simple and readable for this post&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can see how the package provides abstractions for the &lt;code&gt;Key&lt;/code&gt;s that eliminates my need to work with bytes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Displaying a status bar
&lt;/h2&gt;

&lt;p&gt;I think a text editor is not a serious text editor until it has a status bar. I kid of course, but it does provide a good user experience by displaying some important info while editing files. The message bar below it can show useful info like help messages and a text input while searching in file.&lt;/p&gt;

&lt;h1&gt;
  
  
  Roadmap
&lt;/h1&gt;

&lt;p&gt;Although I've managed to build some basic functionality into the editor, there are a lot of features I'd like it to have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Syntax highlighting&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A gutter that displays line numbers&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multiple tabs support&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Autocomplete&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;User specific preferences&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Help me out
&lt;/h1&gt;

&lt;p&gt;If this project interests you and you would like to help out or if you just want to take a look at the code, you can visit the &lt;a href="https://github.com/faraazahmad/loop"&gt;Github repo here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Why do I call it Loop? Well I've been watching &lt;a href="https://www.rottentomatoes.com/tv/tales_from_the_loop/s01"&gt;Tales from The Loop&lt;/a&gt; and couldn't think of another name.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>rust</category>
    </item>
    <item>
      <title>Do you like interactive tutorials?</title>
      <dc:creator>Syed Faraaz Ahmad</dc:creator>
      <pubDate>Sun, 15 Mar 2020 19:08:28 +0000</pubDate>
      <link>https://dev.to/faraazahmad/do-you-prefer-interactive-tutorials-2bb2</link>
      <guid>https://dev.to/faraazahmad/do-you-prefer-interactive-tutorials-2bb2</guid>
      <description>&lt;p&gt;By interactive tutorial I mean, tutorials that contain unit tests for the tasks that you are supposed to achieve in that tutorial. One example is &lt;a href="https://github.com/workshopper/learnyounode"&gt;LearnYouNode&lt;/a&gt;. It is a tutorial series containing 13 problems that teach you Node.js&lt;/p&gt;

&lt;p&gt;&lt;a href="https://camo.githubusercontent.com/17955d1d684a9a0b3fd9d5d863393e6e952cc3b4/68747470733a2f2f7261772e6769746875622e636f6d2f72766167672f6c6561726e796f756e6f64652f6d61737465722f6c6561726e796f756e6f64652e706e67" class="article-body-image-wrapper"&gt;&lt;img src="https://camo.githubusercontent.com/17955d1d684a9a0b3fd9d5d863393e6e952cc3b4/68747470733a2f2f7261772e6769746875622e636f6d2f72766167672f6c6561726e796f756e6f64652f6d61737465722f6c6561726e796f756e6f64652e706e67" alt="Learn You Node Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each problems has fixed task(s) that you need to complete and there are unit tests in place to check whether you've completed the tutorial properly, there is no guessing work.&lt;/p&gt;

&lt;p&gt;So, do you like such tutorials? Have you ever seen similar ones? I'd really like to know.&lt;/p&gt;

</description>
      <category>help</category>
      <category>discuss</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
