Gemini client devlog 1: Parsing gemtext
I'm completely new to JavaScript, so I figured I'd familiarize myself with the easier task of parsing gemtext and converting gmi documents to HTML.
This feels like a very backwards thing to do.
Solderpunk: Hey y'all the web is bloated and HTML is a mess and JavaScript sucks so I invented gemini:// and gemtext to provide a minimal and sane alternative
me: cool I'll use JavaScript to turn it back into HTML
I kinda understand why seemingly no one has released something like this before. But, hey, given my goal of making a KaiOS browser, I don't really have much of an option, and a lot of people have done very similar things in order to proxy gemini content in HTML pages served on HTTP.
But that's beside the point. I build something in JavaScript and it works.
The gemtext format is straightforward enough that I barely had to think about the algorithm and could focus on how to write it. Yet I had a real thing to work towards that allowed me to do that, not just an artificial exercise as is often the case when getting familiar with a new language.
In the end, I have a parser that handle every bit of the spec, I squashed a few bugs on some edge cases and I don't believe there are any left, and I'm not as afraid as before at tackling the harder bits such as implementing the protocol.
I plan on releasing the code under a free license soon, but in the meantime I asked for a review on Code Review StackExchange (but didn't get an answer yet), so if you're interested you can have a peek at my code there.
Code review request on StackExchange
So far, I sort of get why JS has a bad reputations, but in an attempt to stay positive, I'll list what I did like programming in JavaScript:
- Basically nothing needed to get started. Any text editor and web browser are enough to run your code
- Integration with the DOM. I feel that a tool can only be affordable by anyone to use (beside other programmers) if it has a GUI, but GUIs are a pain in the ass to make. With JS, just slap a basic HTML page and you have a basic but usable GUI. It's incredibly satisfying to work that way and see your code in action.
- Awesome documentation. Those people at Mozilla making MDN deserve a hug.
- Great debugging tools. I heard people complain that Firefox is low-tier for it's debugging tools, but I don't have Chrome and found FF developer tools to be great. Complete and works out of the box and easy to use, far ahead of basically any other tool I have used.
- Love the object flexibility and syntax, it makes it very easy to work with.
- Seamless regex integration makes it quite comfortable working with strings.
In conclusion, JS is OK and I have a parser, yay! Now I just need to build a protocol library, a URL parser, a nice HTML/CSS wrapper, a settings system... Lots of fun times to come!
/devlog/