Making a parser generator doesn’t have to be hard.

I’m inspired to write this because of Russ Cox’ regular expression blogpost, which follows a similar format, although I’m not about to compare my implementation to others.

Recently, I decided to create a project called CCC, or Collin’s Compiler Creator, mostly because I want to use parser generators, but feel disingenuous if I were to use an existing one like Bison or YACC. I have the same problem as John Carmack, if I didn’t write all of the code, I don’t feel like I wrote any of the code. But aside from that, I embarked on making a parser generator… and finished in the same night, and in this post we will make another.

Before we begin, the complete code can be downloaded here.

Step 0: How does a parser generator work?

A parser generator simply takes in a list of tokens to parse for, and outputs code to do the actual parsing. The generator itself only outputs the code to be used, so effectively no matter what language you choose to write it in, it is an ahead of time operation. Why would this be useful? Well, I invite you to check out the source code for Blæst, which I wrote my own parser for without the use of a parser generator. To put it lightly, that parser is a mess of spaghetti code wrapped in duct tape and glue. It is horribly inefficient, and filled with bugs. And aside from all of that is horrible to look at, and even worse to add new features to. Now compare that to a parser generator, I could’ve generated those almost 1,000 lines by just feeding it an array of tokens to look for, and when it finds them, just have it return a number corresponding to the token it found. And apart from that, rather than have each token use its own string compare (something this is slow and inefficient), it could combine them, since it knows what strings to compare ahead of this. This approach makes the code much more easy to maintain, and also makes everything easier to upgrade and even port to different languages.

Step 1: Lets get a list of tokens

For this tutorial I will use Javascript. I personally like Javascript because it is fairly similar to languages like C++ or Java, which most people will be familiar with, and if you aren’t, Javascript itself is probably familair to you. I have rarely met someone who can’t at least read Javascript. If you have a problem with this, check out the Github for CCC, its written entirely in… well… C.

The first thing we need to do is get a list of tokens. For this I’ll just create an array that is already populated, you can get these values however you wish, maybe making inputs on a website or via the command line or whatever. But the array should look something like this once you’re done.

// Our list of tokens
var tokens = ["Hello", "Hi", "Goodbye", "Good", "World", "Wordlist"];

I have chosen these specific words because when we construct trees for making the branching parser, they are going to come in handy for demonstrating how we can reuse branches.

Step 2: Create the trees

Now we need to create our actual parser tree. A parser tree is the sequence of letters needed to make the word. We call it a tree because it can branch. For example, both “Hello” and “Hi” start with “H”, so our “H” branch then branches off into an “e” and an “i” branch. This allows our parser to effectively string compare anything that starts with “H” together. For reference, standard string compares go through entire strings in one pass, it would string compare our input to “Hello” by comparing each letter of our input to “Hello”, which takes time. Then it would do the same with “Hi”. Both “Hello” and “Hi” start with an “H”, so if our input doesn’t start with an “H”, we can be assured it isn’t either “Hello” or “Hi”, so we don’t waste our time.

Creating these branches is actually quite easy. We simply walk through our word, creating branches for points we don’t already have. First we need to go through every token, then create a list of “next letters” for each current letter. If that “next letter” is the next letter of our word, just go to it and repeat. If not we add it and go from there.

// We need to create a 'state' which holds the possible next letters, and a state for those as well
var initialState = {
        id: 0,
        next: []
};

// Keep track of how many states we have made for code generation later
var stateCounter = 0;

// Loop through our tokens
for(let i = 0; i < tokens.length; i++){
  
  // Our current token we are checking
  let currentToken = tokens[i];
  
  console.log("Current token: " + currentToken);
  
  // Reset to the initial state since we are on a new token
  let currentState = initialState;
  
  // Now loop through every letter in our token
  letterLoop: for(let j = 0; j < currentToken.length; j++){
    
    // Our current token letter
    let currentLetter = currentToken.at(j);
    
    // Go through every possible next letter
    for(let k = 0; k < currentState.next.length; k++){
      
      let possibleNextLetter = currentState.next[k];
      // If the possible next letter is our current letter, we follow it
      if(possibleNextLetter.letter == currentLetter){
        
        console.log("Found branch for: " + currentLetter);
        
        // Set the new current state to the branch we are following
        currentState = possibleNextLetter.state;
        
        // Go back to the letter loop
        continue letterLoop;
      }
    }
    
    console.log("Adding " + currentLetter);

    // If we get down here, its because we couldn't find a branch, so we need to add one
    currentState.next.push({
      letter: currentLetter,
      state: {
        id: ++stateCounter,
        next: []
      }
    });
    // Now set our state to the new state we made
    currentState = currentState.next.at(-1).state;
    console.log("ID: " + currentState.id);
  }
  
  console.log("Adding end of word marker");
  
  // Add our end of word marker, this contains the token number we return
  currentState.next.push({
    letter: 0,
    state: {
        id: ++stateCounter,
        next: []
    },
    token: i + 1
  });
}

Now we should have a tree of every possible letter combination, if it were drawn out it should look something like this:

   [Start]
   /  |  \
  H   G   W
 /|   |   |
i e   o   o
| |   |   |
$ l   o   r
  |   |   |\
  l   d   l d
  |  /|   | |
  o $ b   d l
  |   |   | |
  $   y   $ i
      |     |
      e     s
      |     |
      $     t
            |
            $

Where $ is an end of token marker.

Step 3: Code generation

This is easily the hardest part, because it takes the most thinking, turning our states into code. Almost every parser generator I’ve seen uses a state machine for parsing, and lucky for us, they are very easy to implement. A basic state machine looks like this:

var state = 0;
switch(state){
  case 0:
    state = 1;
    break;
  case 1:
    state = 0;
    break;
  default:
    state = 1;
    break;
}

We just need to make our state machine slightly more useful than this one.

First we need to come up with our states… wait… we made those already. The state numbers in the case are just the state IDs we just made. So then to set the next state we just need to check for the letters… wait… we did that too. So we literally just loop through every state we generated and output the information. How easy is that!?

The generator may look complicated, but thats just because its not very clean looking. Just read through it and you’ll see it s simply just outputting switch/case statements.

console.log("BELOW IS THE GENERATED PARSER CODE");

// Print the head to our function

// function parse(token){
//   let i = 0;
//   let state = 0;
//   switch(state){
console.log("function parse(token){");
console.log("\tlet i = 0;");
console.log("\tlet state = 0;");
console.log("\twhile(true){");
console.log("\t\tswitch(state){");

// Now go though each state and print out the imporant bits
// To do this I'll simply create a recursive function.

function printState(state){
 
  // Print our case
  console.log("\t\t\tcase " + state.id + ":");

  // Make our case for the next letter
  console.log("\t\t\t\tswitch(token.at(i)){");
  
  // And our conditions
  for(let i = 0; i < state.next.length; i++){

    let condition = state.next[i];

    // If our letter is 0, we are at the end of the string, in Javascript, the string.at should return undefined at the end, so we check for that
    if(condition.letter == 0){
     // If we are actually at the end of the string, return our token number
     console.log("\t\t\t\t\tcase undefined: return " + condition.token + ";");
    }
    else{
      // Otherwise make it so we go to the next state

      // case 'nextLetter':
      //   i++;
      //   state = nextStateId;
      //   break;
      console.log("\t\t\t\t\tcase '" + condition.letter + "':");
      console.log("\t\t\t\t\t\ti++;");
      console.log("\t\t\t\t\t\tstate = " + condition.state.id + ";");
      console.log("\t\t\t\t\t\tbreak;");
    }
  }
  // Make sure if we can't branch anymore, we return 0 so we don't hit an infinite loop
  
  // defualt: reutrn 0;
  console.log("\t\t\t\t\tdefault: return 0;");

  // And finally just close up the switch/case and this current case for the state machine.
  console.log("\t\t\t\t}");
  console.log("\t\t\tbreak;");
  
  // Now go through every next state and print it out again
  for(let i = 0; i < state.next.length; i++){
    // recursion is fun
    // recursion is fun
    // recursion is fun
    // recursion is fun
    printState(state.next[i].state);
  }
}

// Call the function on the initial state and it should go through everything 
printState(initialState);

// Now finish up the function
console.log("\t\t}");
console.log("\t}");
console.log("}");

// Now everything is done

And with that, concludes our parser generator. Now this generator is not the best. For example, if the token doesn’t start at the beginning of the line, for example “gHello”, it will not match it. It will also only match full words, so “Helloworld” will not match for “Hello”. Its also case sensitive.

Running the program will output a function ‘parse’ in the console. The basic usage of this is as follows. parse(string to parse). It will return a number, 0 if it did not match, or a number 1 to … if it did. and n corresponds to the array position of the token + 1. For example, in this example, “Hello” returns 1 because it is the first element in the array.

The output of the example run here should look something like this:

Current token: Hello
Adding H
ID: 1
Adding e
ID: 2
Adding l
ID: 3
Adding l
ID: 4
Adding o
ID: 5
Adding end of word marker
Current token: Hi
Found branch for: H
Adding i
ID: 7
Adding end of word marker
Current token: Goodbye
Adding G
ID: 9
Adding o
ID: 10
Adding o
ID: 11
Adding d
ID: 12
Adding b
ID: 13
Adding y
ID: 14
Adding e
ID: 15
Adding end of word marker
Current token: Good
Found branch for: G
Found branch for: o
Found branch for: o
Found branch for: d
Adding end of word marker
Current token: World
Adding W
ID: 18
Adding o
ID: 19
Adding r
ID: 20
Adding l
ID: 21
Adding d
ID: 22
Adding end of word marker
Current token: Wordlist
Found branch for: W
Found branch for: o
Found branch for: r
Adding d
ID: 24
Adding l
ID: 25
Adding i
ID: 26
Adding s
ID: 27
Adding t
ID: 28
Adding end of word marker
BELOW IS THE GENERATED PARSER CODE
function parse(token){
	let i = 0;
	let state = 0;
	while(true){
		switch(state){
			case 0:
				switch(token.at(i)){
					case 'H':
						i++;
						state = 1;
						break;
					case 'G':
						i++;
						state = 9;
						break;
					case 'W':
						i++;
						state = 18;
						break;
					default: return 0;
				}
			break;
			case 1:
				switch(token.at(i)){
					case 'e':
						i++;
						state = 2;
						break;
					case 'i':
						i++;
						state = 7;
						break;
					default: return 0;
				}
			break;
			case 2:
				switch(token.at(i)){
					case 'l':
						i++;
						state = 3;
						break;
					default: return 0;
				}
			break;
			case 3:
				switch(token.at(i)){
					case 'l':
						i++;
						state = 4;
						break;
					default: return 0;
				}
			break;
			case 4:
				switch(token.at(i)){
					case 'o':
						i++;
						state = 5;
						break;
					default: return 0;
				}
			break;
			case 5:
				switch(token.at(i)){
					case undefined: return 1;
					default: return 0;
				}
			break;
			case 6:
				switch(token.at(i)){
					default: return 0;
				}
			break;
			case 7:
				switch(token.at(i)){
					case undefined: return 2;
					default: return 0;
				}
			break;
			case 8:
				switch(token.at(i)){
					default: return 0;
				}
			break;
			case 9:
				switch(token.at(i)){
					case 'o':
						i++;
						state = 10;
						break;
					default: return 0;
				}
			break;
			case 10:
				switch(token.at(i)){
					case 'o':
						i++;
						state = 11;
						break;
					default: return 0;
				}
			break;
			case 11:
				switch(token.at(i)){
					case 'd':
						i++;
						state = 12;
						break;
					default: return 0;
				}
			break;
			case 12:
				switch(token.at(i)){
					case 'b':
						i++;
						state = 13;
						break;
					case undefined: return 4;
					default: return 0;
				}
			break;
			case 13:
				switch(token.at(i)){
					case 'y':
						i++;
						state = 14;
						break;
					default: return 0;
				}
			break;
			case 14:
				switch(token.at(i)){
					case 'e':
						i++;
						state = 15;
						break;
					default: return 0;
				}
			break;
			case 15:
				switch(token.at(i)){
					case undefined: return 3;
					default: return 0;
				}
			break;
			case 16:
				switch(token.at(i)){
					default: return 0;
				}
			break;
			case 17:
				switch(token.at(i)){
					default: return 0;
				}
			break;
			case 18:
				switch(token.at(i)){
					case 'o':
						i++;
						state = 19;
						break;
					default: return 0;
				}
			break;
			case 19:
				switch(token.at(i)){
					case 'r':
						i++;
						state = 20;
						break;
					default: return 0;
				}
			break;
			case 20:
				switch(token.at(i)){
					case 'l':
						i++;
						state = 21;
						break;
					case 'd':
						i++;
						state = 24;
						break;
					default: return 0;
				}
			break;
			case 21:
				switch(token.at(i)){
					case 'd':
						i++;
						state = 22;
						break;
					default: return 0;
				}
			break;
			case 22:
				switch(token.at(i)){
					case undefined: return 5;
					default: return 0;
				}
			break;
			case 23:
				switch(token.at(i)){
					default: return 0;
				}
			break;
			case 24:
				switch(token.at(i)){
					case 'l':
						i++;
						state = 25;
						break;
					default: return 0;
				}
			break;
			case 25:
				switch(token.at(i)){
					case 'i':
						i++;
						state = 26;
						break;
					default: return 0;
				}
			break;
			case 26:
				switch(token.at(i)){
					case 's':
						i++;
						state = 27;
						break;
					default: return 0;
				}
			break;
			case 27:
				switch(token.at(i)){
					case 't':
						i++;
						state = 28;
						break;
					default: return 0;
				}
			break;
			case 28:
				switch(token.at(i)){
					case undefined: return 6;
					default: return 0;
				}
			break;
			case 29:
				switch(token.at(i)){
					default: return 0;
				}
			break;
		}
	}
}

With all that, I hope you enjoyed learning the joy of creating a parser generator. Overall this only took me a few hours to write, and it was quite fun to do so, so I really recommend doing it. I have uploaded a gist of the complete code for this parser, so use that for whatever you want.

Posted in Programming | Tagged , , , | 1 Comment

Micro: Brave or Ungoogled Chromium

Recently I was thinking to myself, should I be recommending people Brave browser or Ungoogled Chromium. Myself, I use Firefox, however I acknowledge that most people probably want to stick with Chromium based browsers just because they are familiar, and if they are moving from Chrome, the experience should be more or less the same. That being said however, which Chromium based browser is the one to recommend. Personally, I have been and still recommend Brave just because it is a more complete out of the box experience. While I don’t (and probably never will) fully trust Brave, I can’t deny that their browser is leagues more private than Google’s Chrome. Brave also has out of the box support for extensions and widevine DRM, so you can effectively use Brave as a drop in replacement for Chrome. On the other hand there is Ungoogled Chromium. Ungoogled Chromium is literally the most private browser possible. It is Chromium with all the google forcefully removed, but because of this, it lacks many features like the webstore or widevine. While Brave lets you disable these features, they flat out come disabled on Ungoogled Chromium, and to enable them is a process. As well, the main killer for me to recommending Ungoogled Chromium is its lack of a search engine by default. I have no idea why they chose to make it “No Search” by default, but the majority of people will just load up a browser and expect it to be able to search out of the box. And how would they be able to search to figure out how to set the search engine? To be honest, Ungoogled Chromium is still probably the better browser in terms of privacy, but Brave is what I have to recommend because of its out of the box usability. Expect a blog post in the future about me grappling with being a Firefox user and explaining why Chromium is better in every way…

Posted in Micro Posts | Tagged | 1 Comment

Micro: Nano is an almost perfect text editor

Over the past few weeks, I’ve found myself switching away from Microsoft Word and Google Docs for taking notes, and moving to the humble text file. I now take notes in Microsoft Notepad/Wordpad and my notes take up half the size and use half the ram to view, and contain the same amount of information. Personally I think Notepad is the perfect text editor for well… editing text. It does its job, little extra, and it does it very well. Wordpad is for when you need things like embedded images, or anything plain text cant handle, so a rich text file is used. Wordpad is more like diet word, but still manages to be lighter weight. Personally I think both editors are great in their own regards, but notepad is literally perfect for its job. Now what about other operating systems… MacOS has TextEdit which is more akin to Wordpad, so I have a hard time counting it as a replacement for Notepad, and Linux has a bunch. The common problem between both MacOS and Linux text editors however is they all seem to do way too much. Now ever since the software minimalism crowd has invaded the text editor space, text editors have slowly become less about editing text, and more for editing code. In my text editor for taking notes, I don’t need syntax highlighting and line numbers, especially if those come at the cost of performance, and I sure as hell don’t need whatever emacs is doing. In my travels for the notepad of Unix however, I have stumbled upon my old friend, nano. Nano is almost perfect in my eyes. It is small, starts up instant, and does its job. There is little extra. While it does support syntax highlighting and line numbers, these do not seem to impact it negatively, and come disabled. Another runner up would be vi (not vim). Anyway, if any of you have a suggestion to add to my search, feel free to drop it below. Please nothing more complicated than Notepad however, I don’t want to be taking notes in vscode.

Posted in Micro Posts | Tagged | Leave a comment

Micro: I want dedicated phones to make a comeback (and you should too)

Recently I bought a Western Electric model 2500MMG from an antique store here in Boston. I had always wanted one for decoration since they are THE phone that people think of when they think of a phone, they are iconic. However other than that, I was not looking to use it. To my amazement, I found they are fully able to be hooked up to a POTS (plain old telephone system) line and work fine in the modern age. Problem is, nobody has a landline anymore, and paying for one is too damn expensive, my apartment doesn’t even have phone lines run to it. However, the fact that this literally indestructible behemoth from 1970 can still work on modern phone lines (granted you have one), but my iPhone 4, literally less than half the age of that other phone, cannot connect to cellular anymore because “3G is too outdated” is absolutely astounding to me. I understand getting rid of old technology when its cost starts outweighing the benefits of keeping it around, but that seems a little excessive, a phone bought around 10 years ago is now completely useless, meanwhile a phone from 50 years ago works fine. Dedicated phones (or a phone protocol) need to make a comeback, just so we can standardize on a system to make calls that isn’t ever evolving. Realistically if I want good sound I would use the internet. I propose bringing back something like 2G which reaches far and wide, and having it be just for calls and SMS, meanwhile data would be carried over 4G, 5G, LTE, or what not. Doing this would allow for older phones to stay connected as… well… phones, while making people have to upgrade if they want the new speedy data stuff. But hey, that’s just my opinion.

Here is an incredibly low quality picture of the phone I just bought
Posted in Micro Posts | Tagged | 1 Comment

My review of every song from Animusic 1

I was going to originally review both Animusic 1 and Animusic 2, but I am way too busy (not to mention separated from my animusic discs, and I refuse to watch the YouTube rips), so I will have to post what I have so far. A complete review and ranking of every song in Animusic 1, a whole month in the making, then delayed for about a month because of moving, then I got lazy… So here it is. Expect Animusic 2 reviews and rankings to come probably around winter, and maybe a full review and ranking comprising both discs around that time as well.

In case you aren’t familiar with Animusic, Animusic is a digital album created by Wayne Lytle and David Crognale. It was designed to be the first of its kind, a full album where every “music video” was computer animated. Animusic 1 came out in 2001 to much critical acclaim. It was heralded for its use of computer visuals and distinct MIDI style of song. Animusic 2 would follow in 2005, completing Animusic for now, as Animusic 3 has yet to be released. If you haven’t I would recommend looking into the commentary tracks for Animusic 1 and 2, as they provide the most information about the creation and reception of Animusic, and they are a great way to spend an afternoon. So without further ado, here’s a review of every song from Animusic 1.

Track 1: Future Retro

Future retro is the first song on the first disk of Animusic, so its the first experience you get to animusic granted you haven’t seen any of the viral clips making it around the internet at the time of its release, and man does it deliver in giving you a taste of what’s to come.

Future retro makes heavy use of what I will call the “synth laser” from here on out. The entire song is done in this 80s rock style, with the synth laser being the most prominent instrument, as well as the most visually spectacular. However, there is also a crazy 3 neck guitar/bass in the center of the scene, which surprisingly is mostly used for accompaniment to the laser. Along side this, there is a drum robot in the back, showing off even more of what’s to come. The song itself uses many of these instruments to create a very interesting vibe. One of the most notable things, I especially noticed it when I was a kid, was the use of the flute segment to break up the more heavy rock segments. This always struck me as an interesting choice, and a cool one at that. Along side the synth laser, green lasers and these choir synth lasers are used, which give that futuristic vibe the title implies. Overall, this song is a really solid start, and a perfect introduction to animusic. Its a song with a style that is familiar, being an 80s style rock song, and features some very interesting imagery. Overall, its biggest shortcoming isn’t anything it does specifically, but what the songs later in the album do. Solid start to a solid album.

Track 2: Stick figures

Best song in the album. Done.

Anyway, this song sums up pretty much everything I love about animusic, and even back when I was a kid, this was my favorite song in Animusic 1 by far. I even remember in school art class making a model of the bells + flute + gong instrument.

The instruments used in Stick Figures shows the full creativity of animusic at work. With the lead fretless bass, apparently called “Mr Stick” (best character by the way) to the large stack of brass horns, to even the massive array of drums, to even a few synth lasers (what would an animusic song be without them).

Just like Future Retro, most of the lead is taken by the synth lasers, however every single instrument is pretty much given time in the spotlight. One interesting thing, halfway through the song, the tone shifts to this slower darker tone, however none of the instruments change, they are just used differently, which allows some instruments which don’t fit the main mood of the song to have some much needed spotlight time. And man, the instruments really carry this song. From the opening with Mr. Stick just setting the mood, to the brass picking up, and eventually the laser taking over and really setting the song into full motion. And as the song goes on, you start to notice other instruments getting gradually added, all of which start to form a more full picture. And by the end, it comes to a satisfying close, with pretty much every instrument being active and harmonizing together into the melody of the song. Overall, I still stand by that this is one of the best, if not the absolute best song of animusic 1.

Track 3: Aqua Harp

Before i begin the review, lets talk about the transition from track 2 to track 3. Usually in an album, artists will try to fade one song into another, for example starting a drum beat which is picked up in the next song. This translates slightly harder to something like animusic since we have to establish which instruments are being played, and starting them already playing robs you of the experience of admiring the creative designs. However since animusic is a visual medium, the songs don’t necessarily have to transition, but the visuals can, and in this situation, the camera pans up to the stars in Stick Figures, which gradually turns into the star painted ceiling in Aqua Harp. A small touch, but I really like it. Anyway, on to the review.

Aqua Harp was always my least favorite song on the animusic 1 disk, but that’s not saying its a bad song. The way I would describe it is “atmospheric”. The scenery of Aqua Harp is very relaxing, with a large harp taking center stage, and also being the only instrument played, with all instruments other than the harp being connected to it. The harp itself is placed in the middle of a pool of water. Through out the song, a water sound can be heard in the background, which really helps with the atmosphere, as Aqua Harp is a really quiet song.

As for the song itself, the song is really slow and relaxing. I disliked it as a kid simply because it wasn’t as fast paced as the rest of the songs on the album, and the visuals weren’t as interesting. However, I can now appreciate the departure from the other styles of the songs. Aqua Harp uses a mix of string instruments, like the harp and cello, along side the flue and chimes. The use of these specific instruments creates a very interesting mood, coupled with the water and visuals, its very relaxing. Personally, while I do still think the song is not my favorite, I can appreciate it a lot more, and I do genuinely enjoy it a lot more too. Just sadly overshadowed by the others in this collection.

Track 4: Drum Machine

Next up we have one of the more interesting style songs. Drum Machine takes places in some machine which uses many different sizes of gears, and uses those gears to play different drums. One nice touch is in the background, the chugging of gears can be heard, and they keep perfect time with the song playing.

Over all, the drums are very cool, and it is very cool seeing all the gears moving. Lighting is also heavily used, mostly when symbols crash, but also when the rack of larger drums is moved down. This all contributes to one of the coolest scenes in animusic.

The song itself makes heavy use of percussion, in fact it only uses percussion. The song can be split up into about 3 sections, when new instruments are introduced, which happens 3 times over the song, the rhythm played on the drums changes to allow the new instruments to shine. Overall its a pretty cool sound. I’m personally not that into drum line songs, so I think most of the other songs overshadow the actual song that Drum Machine plays, however the scenery of it is worth the watch alone.

Track 5: Pipe Dream

Now if you saw any animusic clip, its probably this one. This song went viral on the internet due to its unique scene, and man, is it unique. Its probably my favorite scene of them all. Pipe Dream takes place in some factory, with a bunch of pipes shooting metal balls into instruments to create a sound. The creativity in this is crazy. You can see the level of detail in the pipes snaking around the floor, to the position of the instruments, to even which instruments where chosen. The thing that made this song so magical at the time was the idea that “this _could_ exist.” Hell, I even knew some people who thought it *did* exist. Hell it really *DOES* exist. Thanks Intel.

Anyway, the scene aside, this song is really solid. The opening to this song, with the gradual buildup of the banjo like instrument is awesome, just to have it pass the torch to a smaller, higher pitched banjo, just to then pass the torch to the drums, which might I add are some of the coolest drums in animusic. As well the bells this time being in the form of the bell flower, with chimes that descend from the ceiling. Also as the song goes on, marimba pieces scroll across a track above the drums, which basically take over the melody of the song. All of this creates a very unique song, one that I don’t think could exist on something that wasn’t animated. I still have to say most of the fun of this song comes from watching the balls hit the instruments and eventually find their way back home. And not even to mention, the song itself is really good to boot. Overall one of the most iconic songs of animusic and for good reason.

Track 6: Acoustic Curves

As a kid, is disliked Acoustic Curves a lot. I think it was completely due to the opening riffs, which are kind of annoying to me even today. But after listening to it again I just can’t stop. The main chorus of the song is incredibly catchy, despite not having any lyrics.

The overall scene for this one is very simple compared to the rest of the songs on animusic so far. This one seems to just take place in some wooden void, with wood paneling stretching from the dark depths to whatever the light is coming from. Weirdly enough, as a kid this one always reminded me of my Dad’s office, since all of the furniture in his office had that same wood panel look, and even the same color. Weird how some memories just stick with you like that. Other than the lackluster scene though, the instruments are really well designed, and really cool. The gimmick of this song is that almost all instruments are acoustic as the name implies, and they are played by small hammers that rest near the string being played. This is really creative, and grounded in reality. I really like it personally.

As for the song itself, it has a really cool style of being layered, with new instruments gradually descending from the heavens, ultimately forming the complete song towards the end, before gracefully deconstructing. This style is always something I’ve loved, so I’m not really sure why I didn’t like this as a kid. The instruments played are also really cool. I’m not a really big fan of the first two “guitar” like things, but once the bass and drums get into the mix, the song really takes off. I really like (as a bass player) their inclusion of a slap and pop. This lets the bass play more of a slap bass style, which sounds incredibly good. Its also cool to see things modeled like a sustain damper which gets turned on when the song really starts to take off. Overall Acoustic Curves is really solid, I really like it. Now if it could only get out of my damn head.

Track 7: Harmonic Voltage

I remember always disliking Harmonic Voltage as a kid as well because it meant that the movie was over… However I really like it now. In fact, just like Acousitc Curves, its now completely stuck in my head. For some reason these old melodies just come back to me and don’t leave.

As a kid I was obsessed with technology infrastructure for some reason, and I really liked the design of Harmonic Voltage, looking like it was power lines and radio towers, with this cool laser stuff shooting off of it. The center of the stage has a power pylon which is the source of the guitar sounds, with the synth guitar being purple, and the guitar solo guitar being more of a green. Under the pylon is a set of drums along with a synth bass. Overall its pretty cool to look at. Surrounding the pylon is a set of radio antennas and pylons that look like they supply or catch the voltage of the center pylon. There are also these cool little antennas with blue lights that make a cool dropping tone.

As for the song itself, It has a very cool sound. It has a more hybrid rock sound, sort of like an 80s rock song, but mixed with more of an early 2000s electric synth music sound. I particularly love the electric sound that is portrayed with the lasers. I also always liked the green rings that make that cool dropping sound as a kid. The guitar solo being played on the central pole was also a really cool touch.

Anyway, fade to credits. And that’s animusic 1. What an absolutely solid end to an absolutely solid album.

Animusic 1 rankings

  1. Stick Figures
  2. Pipe Dream
  3. Future Retro
  4. Acoustic Curves
  5. Harmonic Voltage
  6. Drum Machine
  7. Aqua Harp

To be honest, Animusic 1 is completely solid. There is not a single song that falls flat, and as well, there is not a single song that feels like it wasn’t take to the absolute maximum with creative potential. Such a solid album.

Posted in Misc | Tagged , , | 1 Comment

Micro: web design is getting out of hand…

I have to use a website called “Cognella” for a textbook at my university. It gives you one of those standard cookie prompts. Which allows you to enable or disable cookies, pretty standard right..? Well when you click “disable”, it logs you out immediately, and when you log back in you just get the same message to enable or disable cookies. So disabling cookies is the equivalent of hitting “I’m not 18” on a porn site. I’ve heard of them just being placebo, but never just outright refusing to serve you unless you consent to their tracking… great trend we are starting up guys. Guess they’re technically GDPR compliant. Turns out never mind, they’re fucking not!

Posted in Micro Posts | Tagged | 3 Comments

Working on a new text editor…

So, as I’ve been teasing (for like 2 years at this point…) I am working on a text editor. Originally it was going to be based in the terminal, and using the Aquila virtual machine, then using Blæst, finally using Crow and not in the terminal. So here are some things I learned.

Keep it simple stupid

First of all, make everything easy on yourself if possible. It’s not always a good idea to reinvent the wheel. Case in point is the text editor interface itself. For so long, I was hung up on how the interface should work. Usually I figure this stuff out and start work, but for the obvious reason of “hey a gui library is pretty freakin huge” I really wasn’t able to get any work done on the project. Especially too since the more I stalled it, the more ideas I got. So eventually it turned from “let’s have it in the terminal” to “let’s have a library to create guis that seamlessly convert from the terminal to literally any ui toolkit and seamlessly integrate into the system they are running on. Needless to say, eventually it just became “what if the text editor was actually an operating system”, and magically that’s where I stopped. So for one, know your limits and keep within them. Now the editor is being written in Qt 6, mostly just because Qt in my experience has the best cross platform ability, and it is really easy to theme from within an application itself. But maybe Qt wasn’t the best option…

Do NOT use Qt

So this might or might not come as a surprise, but I really hate Qt. Always have and always will. The main reason I dislike Qt just mostly has to do with it’s weird licensing problems. Like “is Qt really free software”? If questions like that have to be asked, you probably shouldn’t be using the software in free software projects. Pretty big coming from a guy who uses Mac OS now, but hey, software freedom is something I still really care about, and I want my text editor to be enjoyed and used by all, so picking a UI that was FOSS was an important thing for me. So what do I mean exactly for “is Qt really free”, well for one, now you have to download their (probably proprietary) Qt installer, which requires that you make a Qt account. If you want to have an offline installer, or god forbid just download the headers and libraries, you need to pay for enterprise to do so. So you have two options: embrace freedom by proprietary software, or empty your wallet. If you can, build Qt yourself, or get builds from your distribution or operating system, I just needed mainline Qt so I could make sure it works with what most people will probably try building with… Big mistake.

Make sure things you say are “embeddable” are actually embeddable

Is it a coincidence that a whole boat load of changes came to crow the minute I picked the text editor job back up? Crow got a whole lot of things, including CMake support (hmmm… doesn’t Qt use CMake…) and in general just refining the structure of how things are stored and accessed to allow for crow to be built much easier into a shared or static library for use in other platforms. Eventually when I start making AIs and robots in crow (when I finally make the move away from the dreaded JavaScript abomination), you’ll probably see a multitude of fixes and changes in those as well. Funny how that works.

Just don’t make a text editor in 2022

Now this one may seem anticlimactic, but just don’t do it. Text editors are a dime a dozen now, and chances are you can pick up and maintain one that is exactly what you’d like and maybe more with less time commitment than doing it from scratch. Now I say this with compilers, that there is a great deal to learn from making a text editor, but to be honest, you can create far more useful applications, such as a rich text viewer or chat client, and use the same skills a text editor would use, and maybe even expand on them. Personally I have hated writing a text editor, but I’m doing it for completion at this point. I’ve said I’m going to do this for years now, and I’m damn well going to do it.

Posted in Programming | Tagged , , | Leave a comment

Just moved to Boston

If you’re wondering why there have been no new posts lately, I just moved to Boston. Still getting a lot of stuff setup here, and had to leave a lot of my development hardware behind, but hey, everything is progressing well with Crow (formerly colang). A release candidate for release 1 should be coming within this month.

Anyway, be on the lookout for more posts soon. Side note: WordPress has a surprisingly nice mobile app, I wrote this entire blog post from my phone while waiting for the T, pretty sick.

Posted in Meta Posts | Leave a comment

Switching to Apple

So, for pretty much all my life I’ve used Windows computers, and ever since 2016 pretty much used Linux full time. I used Linux as far back as 2011, with Ubuntu 11.10 being my first distro, however 2016 was when I truly hit my Linux stride. Since then, the standard UNIX-y way of doing things has become permanently ingrained in how I work. Before switching to Linux, I used Visual Studio and Code::Blocks, and after I primarily used the command line. I also switched to using debuggers like gdb which I found much easier to script and run batch tests, and also switched to using programs like git for version control, which was always really clunky to use on Windows. Basically, using Linux taught me that Windows is a terrible development environment for basically anyone, and especially if you intend on making cross platform applications.

Fast forward to now. I’ve been using Linux in some capacity for over a decade at this point, and I still really like it. Coming from Ubuntu 11.10, we were still using Sys-V Init back then, can you believe that. And if Wi-Fi worked out of the box, you had basically just won the lottery jackpot. I still very much like Linux, and like the direction Linux is going. But with all of that being said, I decided that the time was right to try out Apple and their MacOS. Soon, I am moving to a new apartment, and one problem with that is I will be forced to severely downsize what I own. One unfortunate reality is I can’t bring my massive computer setup with me, it is just simply too large. I really needed to get a laptop, and while I was looking at buying a thinkpad (like I already own and use for school), I decided to spend the extra $1000 and buy an M1 pro Macbook Pro 14 inch.

My first impressions of the computer were very good. The screen particularly blew me away. Usually I tend to be the kind of person who spouts things like “Screen doesn’t matter” and “If I want a high resolution screen I’d buy a TV”, however, I work a lot with CJK Language, or Chinese, Japanese, and Korean. CJK languages use very fine symbols, which when rendered at lower font resolutions makes them pretty much unreadable, or at the very least heavily pixelated. Thanks to Apple somehow cramming something like a 2k display into a 14 inch laptop, CJK fonts are incredibly clear, and I can already feel myself never being able to go back to even just a 1080p screen for CJK. Along side the screen, everything felt really snappy. Animations lasted just long enough to be known, but not too long to feel sluggish. Everything seemed to run pretty fast. Overall the thing I was most surprised by was the lack of screen tearing and other Linux-y things I come to expect with the UNIX-y base. I unfortunately had to switch from GNOME/Wayland back to MATE/X.org recently as Debian broke the sid GNOME packages. Wayland was really nice, but ever since the breakage, I have been struggling to get MATE to run without screen tearing without making the entire desktop lag horribly (thanks picom). Overall though, from a visual perspective, MacOS blew me away.

Another unexpected win from MacOS was customization. I had pretty much always been told (by people who don’t themselves own Macs or use MacOS) that Apple locks everything down, so you experience the operating system the way they intended. And while this is true of things like the overall application theme, or the general feel of the desktop and OS, this is not the case for the applications included. I was very angry that Finder kept opening the “Recents” menu when I would open it. To open the Home folder, I would have to navigate to the menu and physically click “Go > Home Folder”, which was a massive pain, especially when I would then have to navigate into further folders from my Home folder. I thought this was going to be the moment I became one of those cynical Apple users where I convince myself that my purchase was justified and “I just have to live with these few extra steps”. Didn’t help as well that I could not for the life of me find any way to set Finder to default to the Home folder anywhere on DuckDuckGo, so I thought I was completely out of luck. However after just deciding to check the preferences page, I found not only could I set Finder to open to the Home folder, but I could add the Home folder to the side bar, and even add the hard drive shortcut to the desktop like in OSX of old. To be honest, I had been trained by general consensus that Apple preferences do basically nothing, but to my surprise, I found everything I had wanted. Considering you cant even set this on GNOME (at least without touching dconf), that’s incredible. Along with this as well, I was pleasantly surprised to find I could exclude the terminal from all the security checks that MacOS does to applications running. Normally this would be totally advised against, since it completely undermines security, but for the terminal, I am mostly only running applications I built from source, and thusly audited, so doing this stopped the annoying “Do you trust this application” popups which I also saw non Mac users complaining about.

So, if you have had no experience with Apple, I would say go out to the nearest Apple store and give it a try. Or you can emulate it on Linux using OSX-KVM if you don’t want to go out or buy anything. I was very surprised with how good Mac OS was in my experience, as well as Apple hardware. Does it justify the price? That’s up to everyone to decide. However I am very happy with my purchase at least at this time. I will make sure to update if anything changes with my opinion on it. Also just a side not, Apple gives some pretty great discounts for students, and they can’t really even prove that you are a student, so if you look young you can probably pull one off.

Anyway, I also bought an iPhone SE 2020 recently as well, but that’s an entirely different story for another day. I’ll probably write another blog post about it (once I’m done with my super massive blog project I’ve been working on for a week at this point). So stay tuned for that.

Posted in Programming | Tagged , | Leave a comment

Back to MATE

So… Debian pushed out a broken update to GNOME, so now I’m back to using MATE. And likewise, I’m back to using xorg. Being honest, I haven’t had such a bad time switching back, I may end up staying with MATE for a little while now. I have always like GNOME 2, so MATE isn’t a desktop I hate, but I do like the looks of the newer GNOME as well, particularly with libadwaita. So… welcome to Linux I guess, but hey, MATE isn’t a terrible fate to be suck with. To think I could be stuck using i3 for a while… horrifying…

Posted in Linux | Tagged | Leave a comment