My First Impressions of Gleam By Michael Lynch, June 22, 2025 — 19-minute read --- Overview Michael Lynch explores Gleam, a young statically-typed functional language inspired by Elixir, as a candidate for his new programming language to learn. He shares candid insights from his first few hours using Gleam through a hands-on project: parsing AOL Instant Messenger (AIM) plaintext logs. --- Project: Parsing Old AIM Logs AIM logs vary in formats (XML, HTML, plaintext). Lynch focuses on plaintext logs for initial parsing: He previously attempted universal AIM log parsing in Python 2.7 but gave up due to boredom. Parsing logs suits Gleam because simple formats can be tackled first while learning the language gradually. Functional languages are reputedly good for parsing but Lynch has not fully understood why, so this is an opportunity to learn. --- Programmer Background 20 years programming experience. Not deeply familiar with language design or functional programming; closest experience is JavaScript. Proficient in Go and Python. --- Key Observations and Experiences Using Gleam Parsing Command-Line Arguments No built-in standard library support. Found third-party argv package simpler than the more complex glint package. Example code: Running gleam run ~/whatever works as expected. gleam build Behavior Compiles the project but does not produce a standalone executable. Output artifacts are BEAM bytecode files for the Erlang VM in build/dev/erlang/logparser/ebin/. No clear documentation on executable creation; running code via gleam run preferred. Writing a Simple Parser - Challenges Initial test expects parsing plaintext logs into just chat messages: ["hi", "hey whats up"]. Gleam lacks typical programming constructs such as: if statements loops return keyword list index access Parsed input by splitting string on newline (\n) to a list. Iterating Over Lists Without Loops Used list.map to apply a function (parseline) over each line. Pattern matching used for processing: Output produces empty strings for session metadata, leaves message lines intact. Extracting the Message Content Input line: [18:55] Me: hey whats up Goal: extract text after sender’s name, e.g., hey whats up. Used string.splitonce(line, on: ": ") which returns a Result type (Ok or Error). Pattern matching to extract message: Returned empty string for lines not matching. Filtering Out Empty Strings Used list.filter with predicate !string.isempty(s) to remove empty strings from the final list. Using Result Type Instead of Sentinel Values Improved by returning Result(String, Nil) where error represents no message line. Parsing function now returns Error(Nil) on metadata lines instead of "". Final step uses result.values to extract all successful lines, filtering errors. --- Gleam Language Features Liked Pipeline syntax (|>): clear and concise chaining of function calls. Example-centric docs: lots of usage examples in official documentation. Built-in unused code warnings: warns about unused variables/functions/imports but doesn't error, aiding debugging. todo keyword: allows compiling incomplete or