<?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: Meghan (she/her)</title>
    <description>The latest articles on DEV Community by Meghan (she/her) (@nektro).</description>
    <link>https://dev.to/nektro</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%2F10538%2F7b306000-9464-4426-9f7e-400f0bdbc59d.jpg</url>
      <title>DEV Community: Meghan (she/her)</title>
      <link>https://dev.to/nektro</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nektro"/>
    <language>en</language>
    <item>
      <title>Making Slate [Part 2.1]</title>
      <dc:creator>Meghan (she/her)</dc:creator>
      <pubDate>Sun, 13 Sep 2020 01:08:00 +0000</pubDate>
      <link>https://dev.to/nektro/making-slate-part-2-1-3kk5</link>
      <guid>https://dev.to/nektro/making-slate-part-2-1-3kk5</guid>
      <description>&lt;p&gt;I realized I left a big part out of my last article so today I'm here to fill you all in.&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/nektro" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--80YF7bf---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--1zwQ-zJV--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/10538/7b306000-9464-4426-9f7e-400f0bdbc59d.jpg" alt="nektro"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/nektro/the-making-of-slate-part-2-30ll" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;The Making of Slate [Part 2]&lt;/h2&gt;
      &lt;h3&gt;Meghan (she/her) ・ Sep 9 '20 ・ 4 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#slate&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#computerscience&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#tutorial&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;One of the big changes I mentioned over part 1 was the switch from using Wasm to using LLVM and I accidentally completely glossed over it. Super sorry about that one.&lt;/p&gt;

&lt;p&gt;So,&lt;br&gt;
LLVM is a pseudo-assembly and program collection that takes this "intermediate representation" as they call it and does the actual compilation into machine code. It's very type strong and looks familiar yet foreign.&lt;/p&gt;

&lt;p&gt;And once the program is able to produce an AST from the code, it's the Slate compiler's job to then produce LLVM IR.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/nektro/a61777bbcb818d99dddf579b031e9798"&gt;https://gist.github.com/nektro/a61777bbcb818d99dddf579b031e9798&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This gist contains both the code we're working on and the desired LLVM IR output wer're going to produce. Thankfully, the LLVM project provides a Go library we can use. Actually generating IR takes many things to consider, so today is going to cover the first part.&lt;/p&gt;
&lt;h2&gt;
  
  
  Picking Declaration Order
&lt;/h2&gt;

&lt;p&gt;In our code we have 4 &lt;code&gt;const&lt;/code&gt; declarations that equal to functions with some calls in each one. This is no matter, except for if we go to compile these in the order they're written. If this is the case, then we'll create a function object for &lt;code&gt;main&lt;/code&gt;, but then when we try to find the function object for &lt;code&gt;print&lt;/code&gt; it isn't there (because it's lower down in the file and we haven't compiled it yet). Bummer. Unfortunately this is our problem because we don't want to copy C's behavior of having to put your functions in the order they're used.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Current Approach
&lt;/h2&gt;

&lt;p&gt;First we set up two variables. The first is a &lt;code&gt;completed&lt;/code&gt; map that associates &lt;code&gt;const&lt;/code&gt; names to their IR objects. This will contain the declarations that have been completed and can be referenced later at any time.&lt;/p&gt;

&lt;p&gt;At the start this will be empty. Secondly, we also need a &lt;code&gt;todo&lt;/code&gt; string array of the uncompiled &lt;code&gt;const&lt;/code&gt; declarations. It will contain their names so long as they still need to processed. At the start all declarations will be placed into &lt;code&gt;todo&lt;/code&gt;. (For our example this will be &lt;code&gt;[main, print, write, syscall3]&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;Then, it loops through the &lt;code&gt;todo&lt;/code&gt; array and calculates the "dependencies" of each item. Remember earlier when we were going to parse &lt;code&gt;main&lt;/code&gt; and needed &lt;code&gt;print&lt;/code&gt;? That info is calculated here. After that we then have the following information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main: [print]
print: [write]
write: [syscall3]
syscall3: []
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: &lt;code&gt;write&lt;/code&gt; calls syscall3 because the convention is the direct call-path for x86_64 Linux, which is what this base example was made for.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;-&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;syscall3&lt;/code&gt; has no "dependencies" because the only call it makes is inline assembly and will just about be directly inserted into the binary with its arguments.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now, it will make the IR conversion for all AST objects whose calculated dependencies are all elements of the &lt;code&gt;completed&lt;/code&gt; map object and remove them from &lt;code&gt;todo&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For our example, that will be &lt;code&gt;syscall3&lt;/code&gt;. &lt;code&gt;syscall3&lt;/code&gt; will then get sent to the LLVM Go library and placed into &lt;code&gt;completed&lt;/code&gt;. The compiler will then repeat this loop until &lt;code&gt;todo&lt;/code&gt; is empty and finally exit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Future Improvements
&lt;/h2&gt;

&lt;p&gt;This approach worked because the example was very direct and there are no imports or anything like that. Additionally, it's not very type-safe.&lt;/p&gt;

&lt;p&gt;I'm conflicted on whether I want to eventually allow name overloading, but I want it to be able to throw an error if &lt;code&gt;print(string)&lt;/code&gt; exists but you try and call &lt;code&gt;print(int)&lt;/code&gt;, etc.&lt;/p&gt;

&lt;p&gt;On top of that, tree shaking for the benefit of smaller binary outputs would be great. This could be achieved by starting at &lt;code&gt;main&lt;/code&gt; and diving into each dependency until it parses all that have none. It would then work backwards and only compile the functions/objects referenced through the &lt;code&gt;main&lt;/code&gt; pathway. This would have the added benefit of giving me dead code analysis for free.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrap up
&lt;/h2&gt;

&lt;p&gt;I hope this explains the internals a lot better than the last article and I'll try my best to leave out jarring wholes next time. Blogging is very much its own skill and kudos to those who do this regularly.&lt;/p&gt;

&lt;p&gt;The project can still be found here &lt;a href="https://github.com/nektro/slate"&gt;https://github.com/nektro/slate&lt;/a&gt; and I can found here on DEV, Github, and Twitter all &lt;a class="mentioned-user" href="https://dev.to/nektro"&gt;@nektro&lt;/a&gt;
.&lt;/p&gt;

&lt;p&gt;Thanks for reading, and I'll see you next time ❤&lt;/p&gt;

</description>
      <category>slate</category>
      <category>computerscience</category>
      <category>llvm</category>
    </item>
    <item>
      <title>The Making of Slate [Part 2]</title>
      <dc:creator>Meghan (she/her)</dc:creator>
      <pubDate>Wed, 09 Sep 2020 08:21:00 +0000</pubDate>
      <link>https://dev.to/nektro/the-making-of-slate-part-2-30ll</link>
      <guid>https://dev.to/nektro/the-making-of-slate-part-2-30ll</guid>
      <description>&lt;p&gt;This is an update article of progress made since this one.&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/nektro" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F10538%2F7b306000-9464-4426-9f7e-400f0bdbc59d.jpg" alt="nektro"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/nektro/the-making-of-a-programming-language-slate-part-1-4528" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;The Making of a Programming Language: Slate [Part 1]&lt;/h2&gt;
      &lt;h3&gt;Meghan (she/her) ・ Jul 10 '18&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#webassembly&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#slate&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#slatedev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#computerscience&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;Wew! And quite a lot has changed indeed. This is still at the phase where it is still only an exercise in learning about compilers and languages, but the architecture has changed completely in many parts.&lt;/p&gt;

&lt;p&gt;The process of taking source text and converting it into code is largely the same as I described in the previous post, but the stack I am using and the methods I used to get there are completely different now.&lt;/p&gt;

&lt;p&gt;First off, before the idea is that it was going to be largely based on JS/TS and then compile direct to WebAssembly&lt;a href="https://webassembly.org/" rel="noopener noreferrer"&gt;1&lt;/a&gt;. However, at the time of me writing the last post, Wasm was significantly less featureful and so wanting to make a full language in that state was not the best move. On top of that, Wasm's ISA&lt;a href="https://en.wikipedia.org/wiki/Instruction_set_architecture" rel="noopener noreferrer"&gt;2&lt;/a&gt; is based on a stack machine, which makes the output text fairly different from your typical assembly code.&lt;/p&gt;

&lt;p&gt;Nowadays, Slate runs on the desktop but I am still keeping the scripting domain in mind. For now, it uses the LLVM&lt;a href="http://llvm.org/" rel="noopener noreferrer"&gt;3&lt;/a&gt; compiler backend which takes a custom IR&lt;a href="https://cs.lmu.edu/~ray/notes/ir/" rel="noopener noreferrer"&gt;4&lt;/a&gt; text format, which is like a pseudo-assembly, and converts that into the actual machine code and binary format&lt;a href="https://en.wikipedia.org/wiki/Executable_and_Linkable_Format" rel="noopener noreferrer"&gt;5&lt;/a&gt; for your system. This output you can then run as an actual program.&lt;/p&gt;

&lt;p&gt;Also, the program is written in Go&lt;a href="https://golang.org/" rel="noopener noreferrer"&gt;6&lt;/a&gt;, but the end goal is to eventually get it to a point where it could compile&lt;a href="https://en.wikipedia.org/wiki/Self-hosting_(compilers)" rel="noopener noreferrer"&gt;7&lt;/a&gt; itself&lt;a href="https://en.wikipedia.org/wiki/Bootstrapping_(compilers)" rel="noopener noreferrer"&gt;8&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lexing
&lt;/h2&gt;

&lt;p&gt;This is done the same as before, and the code involved can be found here: &lt;a href="https://github.com/nektro/slate/blob/master/pgk/slate/lexer.go" rel="noopener noreferrer"&gt;https://github.com/nektro/slate/blob/master/pgk/slate/lexer.go&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This process is abstracted away and the actual lexing in done in another supporter package. Languages in this step only have to provide the list of keywords, a list of valid symbols, and characters used for strings. The &lt;code&gt;lex&lt;/code&gt; package will then take this info and read the source text for a Slate file and return an array of tokens if it is valid.&lt;/p&gt;

&lt;p&gt;This step is where simple errors such as illegal characters or words will be risen.&lt;/p&gt;

&lt;h2&gt;
  
  
  Parsing
&lt;/h2&gt;

&lt;p&gt;This step is architecturally done completely different than before and the source can be found here: &lt;a href="https://github.com/nektro/slate/blob/master/pgk/slate/parser.go" rel="noopener noreferrer"&gt;https://github.com/nektro/slate/blob/master/pgk/slate/parser.go&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Trying to figure this stage out was a huge source of struggle and stopped work on this project for quite a while. But then, one day I was watching a stream by &lt;a href="https://github.com/andrewrk" rel="noopener noreferrer"&gt;Andrew Kelley&lt;/a&gt;, the creator of the wonderful &lt;a href="https://github.com/ziglang/zig" rel="noopener noreferrer"&gt;Zig&lt;/a&gt; language.&lt;/p&gt;

&lt;p&gt;The a-ha I had whilst watching &lt;a href="https://www.youtube.com/watch?v=iWRrkuFCYXQ&amp;amp;t=8010s" rel="noopener noreferrer"&gt;this stream&lt;/a&gt; was that you can take advantage of grammar to make the parser and get a bunch of really cool features for free. For instance, in English if you have a &lt;code&gt;q&lt;/code&gt; you can practically guarantee that there is going to be a &lt;code&gt;u&lt;/code&gt; after it. You can take advantage of this in programming language parsing as well. You know that if you run into the &lt;code&gt;if&lt;/code&gt; keyword, then there is going to be a &lt;code&gt;(&lt;/code&gt; after it, because that's how you defined the language. So in the parser you can codify that and then produce really nice errors if you didn't see it.&lt;/p&gt;

&lt;p&gt;Similar to rust errors&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;error: in if statement, expected `(` saw `pub`
  --&amp;gt; src/main.slate:11:5
   |
11 |     if pub {
   |        ^^^
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Compiling
&lt;/h2&gt;

&lt;p&gt;If the parser has completed its job and no errors have been produced, then we now have a single AST&lt;a href="https://golang.org/" rel="noopener noreferrer"&gt;6&lt;/a&gt; object that represents the entirety of our program that we can work with.&lt;/p&gt;

&lt;p&gt;Using another helper package, this AST object gets output to LLVM IR text which we can then pass to LLVM to generate our program.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where We're At Now
&lt;/h2&gt;

&lt;p&gt;The basic program it can compile is located here: &lt;a href="https://github.com/nektro/slate/blob/master/tests/basics/01.slate" rel="noopener noreferrer"&gt;https://github.com/nektro/slate/blob/master/tests/basics/01.slate&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The LLVM output of which can be found here: &lt;a href="https://gist.github.com/nektro/a61777bbcb818d99dddf579b031e9798" rel="noopener noreferrer"&gt;https://gist.github.com/nektro/a61777bbcb818d99dddf579b031e9798&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Going forward
&lt;/h2&gt;

&lt;p&gt;Given how experimental this is, I really wanna try out some ideas that I've had about languages for a while and see where it goes. If it works out then great! I made something cool. If not, I still learned a ton.&lt;/p&gt;

&lt;p&gt;I have some ideas about syntax changes and upgrades to the languages I'm familiar with. I want to try and take a more functional approach than the popular languages as of late and I need to add recursion and more type checking.&lt;/p&gt;




&lt;p&gt;The project can be found here &lt;a href="https://github.com/nektro/slate" rel="noopener noreferrer"&gt;https://github.com/nektro/slate&lt;/a&gt; and contains all the source code and documentation up to this point, as well as links to my social medias and ways to support me if you so choose.&lt;/p&gt;




</description>
      <category>slate</category>
      <category>computerscience</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Centralization is rampant. And I'm not sure how we should fix it..</title>
      <dc:creator>Meghan (she/her)</dc:creator>
      <pubDate>Wed, 13 Nov 2019 10:07:56 +0000</pubDate>
      <link>https://dev.to/nektro/the-internet-is-broken-and-i-m-not-sure-how-we-should-fix-it-1ii3</link>
      <guid>https://dev.to/nektro/the-internet-is-broken-and-i-m-not-sure-how-we-should-fix-it-1ii3</guid>
      <description>&lt;p&gt;I love self-hosted apps and the idea of making the Web decentralized again.&lt;/p&gt;

&lt;p&gt;I make multiple apps that are coming into maturity the more I work on them (and don't worry, will all get posts 👀), but recently started using Gitea for a few projects for a group I volunteer for. And I love it!&lt;/p&gt;

&lt;p&gt;Once I'm able to, I'm tempted to run and/or move many of my projects to my own instance, but I'm worried about stigma/FOMO of not being on GitHub. This is very akin to the Twitter/mastodon conversation. Everyone's on GitHub. Developers are on GitHub, companies are on GitHub, non-profit organizations are on GitHub.&lt;/p&gt;

&lt;p&gt;I was thinking about this, and realized it's tough because even if Gitea/other git server apps made federation work in a way where you could star/follow members from any instance, GitHub won't. Or at least would be very unlikely to. Integrating with federation is something I imagine investors would think is a bad idea, particularly this late in the game. GitHub's already at the top, so why help people leave the platform?&lt;/p&gt;

&lt;p&gt;How do you think we should go about breaking the centralized bubble? Should we?&lt;/p&gt;

</description>
      <category>watercooler</category>
      <category>selfhosted</category>
      <category>github</category>
      <category>gitea</category>
    </item>
    <item>
      <title>I saw "Ajax" was trending on Twitter...</title>
      <dc:creator>Meghan (she/her)</dc:creator>
      <pubDate>Thu, 29 Aug 2019 19:42:17 +0000</pubDate>
      <link>https://dev.to/nektro/i-saw-ajax-was-trending-on-twitter-6cm</link>
      <guid>https://dev.to/nektro/i-saw-ajax-was-trending-on-twitter-6cm</guid>
      <description>&lt;p&gt;And my first thought was definitely &lt;em&gt;not&lt;/em&gt; soccer/football xD&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;
      &lt;div class="ltag__twitter-tweet__media"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--__1j-2jD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/EDKB9eUXYAAj0Vt.jpg" alt="unknown tweet media content"&gt;
      &lt;/div&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--MGDap0fY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/913882366011199489/A5hcSxhA_normal.jpg" alt="Goal profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Goal
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @goal
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      Ajax and Chelsea have never played each other in Europe before 🤯 
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      18:13 PM - 29 Aug 2019
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1167138201699528708" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1167138201699528708" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1167138201699528708" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


</description>
      <category>jokes</category>
      <category>watercooler</category>
    </item>
    <item>
      <title>Language Proposal: The 'Any' Switch Case</title>
      <dc:creator>Meghan (she/her)</dc:creator>
      <pubDate>Thu, 18 Jul 2019 06:20:49 +0000</pubDate>
      <link>https://dev.to/nektro/language-proposal-the-any-switch-case-5a5h</link>
      <guid>https://dev.to/nektro/language-proposal-the-any-switch-case-5a5h</guid>
      <description>&lt;p&gt;This feature proposal is language agnostic, as I have not seen this in any language before. If you know of an existing better way to do this, please let me know :)&lt;/p&gt;

&lt;p&gt;The tagline for this feature is like if &lt;code&gt;switch&lt;/code&gt; had a &lt;code&gt;finally&lt;/code&gt; block, but only ran if the successful &lt;code&gt;case&lt;/code&gt; found was not &lt;code&gt;default&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here's what it would look like in code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;switch&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="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt;
  &lt;span class="n"&gt;any&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt;
  &lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;any&lt;/code&gt; block would be ran in this case if and only if case 1, 2, or 3 were also caught.&lt;/p&gt;

&lt;p&gt;As far as whether or not the block would be run before or after the given &lt;code&gt;case&lt;/code&gt; block is up to debate, and I could see scenarios where either would be useful. So it would be ideal to allow both, but I don't have a clear idea on how you could separate the difference between a before &lt;code&gt;any&lt;/code&gt; clause and an after &lt;code&gt;any&lt;/code&gt; clause.&lt;/p&gt;

&lt;p&gt;Something I've been pondering the past few days. Feedback welcome! 😃&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Debugging Travis CI is very hard.</title>
      <dc:creator>Meghan (she/her)</dc:creator>
      <pubDate>Tue, 16 Jul 2019 02:47:58 +0000</pubDate>
      <link>https://dev.to/nektro/debugging-travis-ci-is-so-hard-31j2</link>
      <guid>https://dev.to/nektro/debugging-travis-ci-is-so-hard-31j2</guid>
      <description>&lt;p&gt;I had the "simple" goal of setting up automatic builds for my Go project. And it's been a nightmare.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/nektro/andesite"&gt;https://github.com/nektro/andesite&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://travis-ci.org/nektro/andesite"&gt;https://travis-ci.org/nektro/andesite&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The docs are hard to follow, the error messages aren't descriptive, and it has taken up most of my afternoon.&lt;/p&gt;

&lt;p&gt;In other news, I switched from Windows to Debian on my main machine and I've been loving every second of it.&lt;/p&gt;

</description>
      <category>watercooler</category>
      <category>devops</category>
    </item>
    <item>
      <title>Captain Marvel's Official Website is Amazing</title>
      <dc:creator>Meghan (she/her)</dc:creator>
      <pubDate>Sun, 10 Feb 2019 09:40:31 +0000</pubDate>
      <link>https://dev.to/nektro/captain-marvels-official-website-is-amazing-25pd</link>
      <guid>https://dev.to/nektro/captain-marvels-official-website-is-amazing-25pd</guid>
      <description>&lt;p&gt;In a blast from the past, Marvel Studios brings us a fantastically designed, fast, and easy to use website to showcase Captain Marvel which comes to theaters March 8, 2019.&lt;/p&gt;

&lt;p&gt;Check it out for yourself here: &lt;a href="https://www.marvel.com/captainmarvel"&gt;https://www.marvel.com/captainmarvel&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>webdev</category>
      <category>captainmarvel</category>
    </item>
    <item>
      <title>Facebook.com is Down</title>
      <dc:creator>Meghan (she/her)</dc:creator>
      <pubDate>Mon, 12 Nov 2018 18:04:05 +0000</pubDate>
      <link>https://dev.to/nektro/facebookcom-is-down-29n9</link>
      <guid>https://dev.to/nektro/facebookcom-is-down-29n9</guid>
      <description>&lt;p&gt;&lt;a href="https://www.facebook.com/" rel="noopener noreferrer"&gt;https://www.facebook.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F80oizlvy2ncwacrj67l6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F80oizlvy2ncwacrj67l6.png" alt="image" width="800" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>facebook</category>
      <category>devops</category>
    </item>
    <item>
      <title>Thoughts on interpreted vs compiled languages?</title>
      <dc:creator>Meghan (she/her)</dc:creator>
      <pubDate>Thu, 20 Sep 2018 18:12:57 +0000</pubDate>
      <link>https://dev.to/nektro/thoughts-on-scripting-vs-compiled-languages-1i9n</link>
      <guid>https://dev.to/nektro/thoughts-on-scripting-vs-compiled-languages-1i9n</guid>
      <description>&lt;p&gt;Are there inherent advantages/disadvantages to either option? If a new language was to be made which would you prefer it to be?&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>I really don't like the reactions stickied at the bottom of the screen.</title>
      <dc:creator>Meghan (she/her)</dc:creator>
      <pubDate>Thu, 13 Sep 2018 20:59:36 +0000</pubDate>
      <link>https://dev.to/nektro/i-really-dont-like-the-reactions-stickied-at-the-bottom-of-the-screen-47o6</link>
      <guid>https://dev.to/nektro/i-really-dont-like-the-reactions-stickied-at-the-bottom-of-the-screen-47o6</guid>
      <description>&lt;p&gt;I feel really bad this is my first post in a while, life's been really busy lately, but I just got the update that puts the article reactions stickied to the bottom of the screen (at least on desktop, haven't checked on mobile) but I really don't like it and it feels like a very unnecessary and unnatural too. After the article but before the comments is exactly when the user should be sending those reactions. After reading the whole article. And when you're reading the comments the reactions take up space because by then you already left your reaction.&lt;/p&gt;

&lt;p&gt;I'll delete this tomorrow probably but I wanted to get my thoughts out there and see if maybe I'm thinking about it all wrong.&lt;/p&gt;

&lt;p&gt;💖 you DEV&lt;/p&gt;

</description>
      <category>meta</category>
    </item>
    <item>
      <title>Search/replace file names in Powershell</title>
      <dc:creator>Meghan (she/her)</dc:creator>
      <pubDate>Tue, 10 Jul 2018 23:05:11 +0000</pubDate>
      <link>https://dev.to/nektro/searchreplace-file-names-in-powershell-10d9</link>
      <guid>https://dev.to/nektro/searchreplace-file-names-in-powershell-10d9</guid>
      <description>&lt;p&gt;Posting a command I recently found that allows you find/replace file names in Powershell on Windows. &lt;code&gt;&amp;lt;search&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;replace&amp;gt;&lt;/code&gt; both accept a regex or you can also add the &lt;code&gt;-LiteralPath&lt;/code&gt; option to &lt;code&gt;rename-item&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;get-childitem *.txt | foreach { rename-item $_ $_.Name.Replace("&amp;lt;search&amp;gt;", "&amp;lt;replace&amp;gt;") }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;a href="https://xkcd.com/979/"&gt;In a world where Denvercoder69 actually does come back and reply to that blog post.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>powershell</category>
      <category>productivity</category>
      <category>devtips</category>
    </item>
    <item>
      <title>The Making of a Programming Language: Slate [Part 1]</title>
      <dc:creator>Meghan (she/her)</dc:creator>
      <pubDate>Tue, 10 Jul 2018 02:45:44 +0000</pubDate>
      <link>https://dev.to/nektro/the-making-of-a-programming-language-slate-part-1-4528</link>
      <guid>https://dev.to/nektro/the-making-of-a-programming-language-slate-part-1-4528</guid>
      <description>&lt;p&gt;I made a new programming language! (((Note: right now it can only add number literals to each other and export constants, but it runs!!))&lt;/p&gt;

&lt;h1&gt;
  
  
  [Part 1] Introduction
&lt;/h1&gt;

&lt;h1&gt;
  
  
  Slate!
&lt;/h1&gt;

&lt;p&gt;In the recent time, I've been working on making a brand new programming language and it's called Slate! This is going to be a series, more or less start to "finish" as I document my progress making the compiler, standard library, and maybe even some programs in Slate.&lt;/p&gt;

&lt;p&gt;Slate is the (first?) programming language that compiles directly from source code to &lt;a href="https://webassembly.org/"&gt;WebAssembly&lt;/a&gt;. Yes, that's why I've been asking about WASM for so long :). The syntax is largely inspired by JavaScript ES2015+ with other influences from Java, Kotlin, and more.&lt;/p&gt;

&lt;h1&gt;
  
  
  So what can it do right now? A new language? Why? How is it different? Can I use it?
&lt;/h1&gt;

&lt;p&gt;Right now this is about all it does.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
 * https://github.com/nektro/slate/blob/master/tests/02.grammar/01.operators/001.slate
 */
//
export const expected = 80;
//
export function main(): i32 {
    return 48 + 32;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What do?&lt;/p&gt;

&lt;p&gt;You can export integer constant literals and export a function that adds integer literals together. That's about it. But &lt;code&gt;slate.js&lt;/code&gt; can fully parse this and export a WASM Module that does the same, albeit very literal for now.&lt;/p&gt;

&lt;p&gt;Why make?&lt;/p&gt;

&lt;p&gt;I really love JavaScript. This love stems from a broader love of the Web as a platform as a whole and JS is all we get. Until now! WebAssembly is the answer to the old question "is the Web getting any other languages other than JavaScript?". With WASM gains access ALL THE LANGUAGES[1]. So in part of a love for JS, part for a desire to make my own language because, and to try to implement features I've never seen before, I set out to make a language specifically for the Web through WASM.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[1]: provided aforementioned language has the proper toolchain&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And through this series I'm going to document more or less the entire journey.&lt;/p&gt;

&lt;p&gt;How different?&lt;/p&gt;

&lt;p&gt;Slate is strongly typed. So that's one thing that's different. But I also want to add things like operator overloading, object extensions(Like adding onto &lt;code&gt;&amp;lt;Object&amp;gt;.prototype&lt;/code&gt; but in a statically typed lang), and more.&lt;/p&gt;

&lt;p&gt;Can I use it?&lt;/p&gt;

&lt;p&gt;Technically yes! If you'd like to compile the program above and run it in your very own WebAssembly-supporting browser then you can do the following:&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="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;slate&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://rawgit.com/nektro/slate/master/src/slate.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;slate_program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`
/**
 *
 */
//
export const expected = 80;
//
export function main(): i32 {
    return 48 + 32;
}
`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;slate_program&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;slate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// `x` == { expected: 80, main: func() { [native code] } }&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  How did you do it?
&lt;/h1&gt;

&lt;p&gt;Like any other language, there are a number of steps that are similar between making a compiler and all of them take place in Slate as well.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lexical Analysis&lt;/li&gt;
&lt;li&gt;Parser&lt;/li&gt;
&lt;li&gt;Semantic Analyzer&lt;/li&gt;
&lt;li&gt;Code Generation&lt;/li&gt;
&lt;li&gt;Linker&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Lexical Analysis
&lt;/h2&gt;

&lt;p&gt;This step was made easy because the majority of code used for this part was already written &lt;a href="https://dev.to/nektro/how-i-accidentally-wrote-an-awesome-html-preprocessor-995"&gt;when I made an HTML preprocessor&lt;/a&gt; and added to my &lt;a href="https://github.com/nektro/basalt/blob/master/src/lex.js"&gt;basalt&lt;/a&gt; javascript library. The code for Slate's lexer can be &lt;a href="https://github.com/nektro/slate/blob/master/src/lexer.js"&gt;found here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Our lexer will take the text of our program and do some really handy things for us. It has to remove the comments, as well as convert the code into a list of tokens with data that we can then later pass onto the parser.&lt;/p&gt;

&lt;p&gt;So with the lexer set up properly, basalt will turn our test program into something like the code below.&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;Key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;export&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nx"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;const&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nx"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;expected&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nb"&gt;Symbol&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="nx"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nb"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;(;),&lt;/span&gt;
    &lt;span class="nx"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;export&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nx"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nx"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;main&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nb"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nb"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nb"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nx"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;i32&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nb"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nx"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;return&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nx"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;48&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nb"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;+&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nx"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nb"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nb"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;}&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Parser
&lt;/h2&gt;

&lt;p&gt;This part of the process was also very involved when I made my HTML preprocessor so parsing is also a &lt;a href="https://github.com/nektro/basalt/blob/master/src/parse.js"&gt;module in basalt&lt;/a&gt;. Basalt helps us build a parser but we still have to add all the magic. Slate's parser &lt;a href="https://github.com/nektro/slate/blob/master/src/parser.js"&gt;is here&lt;/a&gt;. Those familiar with the computer science here, we are attempting to create a &lt;a href="https://en.wikipedia.org/wiki/Formal_language"&gt;formal language&lt;/a&gt; by means of a pseudo-&lt;a href="https://en.wikipedia.org/wiki/Context-free_grammar"&gt;context-free grammar&lt;/a&gt;. &lt;a href="http://www.antlr.org/"&gt;ANTLR&lt;/a&gt; is another big project in this space of creating a lexer/parser in a format much more similar to &lt;a href="https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form"&gt;Backus–Naur form&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Simply put, we have to come up with a series of patters that can take our token list from before and compress it down into a single express that we can then analyze later to create our program.&lt;/p&gt;

&lt;p&gt;After that process, our test program looks more like this:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: I'm skipping the code demo part because the output from the parser is very verbose and the next step we're going to condense it down a bit to show the same information but in a lot more useful format&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Semantic Analyzer
&lt;/h2&gt;

&lt;p&gt;This part is done in Slate by the "converter" which takes the very verbose output from the parser, verifies it, and generates the &lt;a href="https://en.wikipedia.org/wiki/Abstract_syntax_tree"&gt;AST&lt;/a&gt;. The source for the Slate converter can be &lt;a href="https://github.com/nektro/slate/blob/master/src/converter.js"&gt;found here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So now what does our program look like?&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;File&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;Export&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nx"&gt;Const&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;expected&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="mi"&gt;80&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;Export&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nb"&gt;Function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;main&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="nx"&gt;Parameters&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;i32&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="nx"&gt;Block&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="nx"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="nx"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                        &lt;span class="mi"&gt;48&lt;/span&gt;
                        &lt;span class="mi"&gt;32&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="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;h2&gt;
  
  
  4. Code Generation
&lt;/h2&gt;

&lt;p&gt;Whew! Almost there! At this point we have a nice AST but now need to compile to WebAssembly so that it's able to run by &lt;code&gt;WebAssembly.instantiateStreaming()&lt;/code&gt;, etc. Since I wanted to make this a &lt;em&gt;little&lt;/em&gt; easier on myself, I decided to have my compiler generate WASM in the &lt;a href="https://webassembly.org/docs/text-format/"&gt;text format&lt;/a&gt; as opposed to the &lt;a href="https://webassembly.org/docs/binary-encoding/"&gt;binary format&lt;/a&gt; and then to use &lt;a href="https://github.com/WebAssembly/wabt/"&gt;wabt&lt;/a&gt; to convert the text to binary WASM. Trust me, I love WebAssembly and what it stands for, but even trying to figure out the text format has been &lt;em&gt;difficult&lt;/em&gt;. There is very little docs on the formats currently and most of what I've going off is the WASM platform spec tests and output from various WASM playgrounds.&lt;/p&gt;

&lt;p&gt;The code for generating WAST from our AST is actually attached to the objects sent out of the converter, so that code &lt;a href="https://github.com/nektro/slate/blob/master/src/objects.js"&gt;is here&lt;/a&gt;. After generation of said WAST we shoudld get the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(module
    (memory $0 1)
    (global i32 (i32.const 80) )
    (export "expected" (global 0) )
    (func (export "main") (result i32)
        (i32.add (i32.const 48) (i32.const 32) )
    )
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hooray! 🙌&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Linker
&lt;/h2&gt;

&lt;p&gt;For now we're actually done. Imports are not currently implemented and there is no standard library yet, so this phase will have to come later.&lt;/p&gt;




&lt;p&gt;Thanks for reading! If you liked this, let me know what you'd like to see in the future of Slate and stay tuned for more!&lt;/p&gt;

&lt;p&gt;Coming up in future installments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Design ideas and long term goals&lt;/li&gt;
&lt;li&gt;More operators&lt;/li&gt;
&lt;li&gt;Type inference to add support for floating point numbers and objects&lt;/li&gt;
&lt;li&gt;Variables&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;if&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt;, etc&lt;/li&gt;
&lt;li&gt;Strings&lt;/li&gt;
&lt;li&gt;More functions&lt;/li&gt;
&lt;li&gt;Classes&lt;/li&gt;
&lt;li&gt;Metaprogramming&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Links to save you a scroll:&lt;/p&gt;

&lt;p&gt;Follow Slate on GitHub! &lt;a href="https://github.com/nektro/slate"&gt;https://github.com/nektro/slate&lt;/a&gt;&lt;br&gt;
Follow me on Twitter! &lt;a href="https://twitter.com/nektro"&gt;https://twitter.com/nektro&lt;/a&gt;&lt;br&gt;
Follow me on Dev! &lt;a href="https://dev.to/nektro"&gt;https://dev.to/nektro&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webassembly</category>
      <category>slate</category>
      <category>slatedev</category>
      <category>computerscience</category>
    </item>
  </channel>
</rss>
