<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Andraž Bajt's blog</title><link>/</link><description>Recent content on Andraž Bajt's blog</description><generator>Hugo</generator><language>en-us</language><copyright>Andraz Bajt</copyright><lastBuildDate>Wed, 10 Dec 2025 00:00:00 +0000</lastBuildDate><atom:link href="/index.xml" rel="self" type="application/rss+xml"/><item><title>How I use AI to help me prepare talks</title><link>/blog/2025-12-10-ai-talks/</link><pubDate>Wed, 10 Dec 2025 00:00:00 +0000</pubDate><guid>/blog/2025-12-10-ai-talks/</guid><description>&lt;p&gt;I&amp;rsquo;ve recently changed my workflow for preparing talks. I prepared 3 with this approach so far and I&amp;rsquo;m quite happy with the process so I decided to document it.&lt;/p&gt;
&lt;h1 id="inspired-by-gary"&gt;Inspired by Gary&lt;/h1&gt;
&lt;p&gt;I love Gary Bernhard&amp;rsquo;s &lt;a href="https://www.deconstructconf.com/blog/how-to-prepare-a-talk"&gt;How to prepare a talk&lt;/a&gt;. But it&amp;rsquo;s a lot!&lt;/p&gt;
&lt;p&gt;tl;dr: improvise a bunch of times and the structure will crystallize. As a bonus you&amp;rsquo;ve now practiced a lot and are well prepared now.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve tried this but it&amp;rsquo;s hard to find time (well, motivation really) to spend that much time on initial ad-lib runs. So I tried my own twist.&lt;/p&gt;</description></item><item><title>GraphQL ❤️ SQLite</title><link>/blog/2023-05-06-graphql-sqlite/</link><pubDate>Sat, 06 May 2023 13:20:31 +0200</pubDate><guid>/blog/2023-05-06-graphql-sqlite/</guid><description>&lt;p&gt;If you&amp;rsquo;ve done anything nontrivial with GraphQL you&amp;rsquo;re probably familiar with
how &amp;ldquo;N+1 select problem&amp;rdquo; sneaks up on you. If not, this is how &lt;a href="https://gqlgen.com/reference/dataloaders/"&gt;gqlgen
docs&lt;/a&gt; explain it:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Imagine your graph has query that lists todos…&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code class="language-graphql" data-lang="graphql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;query&lt;/span&gt; { &lt;span style="color:#a6e22e"&gt;todos&lt;/span&gt; { user { name } } }
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;blockquote&gt;
&lt;p&gt;and the todo.user resolver reads the User from a database…&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt; 1
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt; 2
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt; 3
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt; 4
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt; 5
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt; 6
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt; 7
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt; 8
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt; 9
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;10
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;11
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;12
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;13
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;14
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;15
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;16
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;17
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;func&lt;/span&gt; (&lt;span style="color:#a6e22e"&gt;r&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;todoResolver&lt;/span&gt;) &lt;span style="color:#a6e22e"&gt;User&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;ctx&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;context&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;Context&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;obj&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;model&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;Todo&lt;/span&gt;) (&lt;span style="color:#f92672"&gt;*&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;model&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;User&lt;/span&gt;, &lt;span style="color:#66d9ef"&gt;error&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	&lt;span style="color:#a6e22e"&gt;res&lt;/span&gt; &lt;span style="color:#f92672"&gt;:=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;db&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;LogAndQuery&lt;/span&gt;(
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;		&lt;span style="color:#a6e22e"&gt;r&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;Conn&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;		&lt;span style="color:#e6db74"&gt;&amp;#34;SELECT id, name FROM users WHERE id = ?&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;		&lt;span style="color:#a6e22e"&gt;obj&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;UserID&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	&lt;span style="color:#66d9ef"&gt;defer&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;res&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;Close&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; !&lt;span style="color:#a6e22e"&gt;res&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;Next&lt;/span&gt;() {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;		&lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;nil&lt;/span&gt;, &lt;span style="color:#66d9ef"&gt;nil&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	&lt;span style="color:#66d9ef"&gt;var&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;user&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;model&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;User&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;err&lt;/span&gt; &lt;span style="color:#f92672"&gt;:=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;res&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;Scan&lt;/span&gt;(&lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;user&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;ID&lt;/span&gt;, &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;user&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;Name&lt;/span&gt;); &lt;span style="color:#a6e22e"&gt;err&lt;/span&gt; &lt;span style="color:#f92672"&gt;!=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;nil&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;		panic(&lt;span style="color:#a6e22e"&gt;err&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	&lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;user&lt;/span&gt;, &lt;span style="color:#66d9ef"&gt;nil&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;blockquote&gt;
&lt;p&gt;The query executor will call the Query.Todos resolver which does a select *
from todo and returns N todos. If the nested User is selected, the above
UserRaw resolver will run a separate query for each user, resulting in N+1
database queries. e.g.&lt;/p&gt;</description></item><item><title>(Re)Learning AWK with ChatGPT</title><link>/blog/2023-03-31-awk-chatgpt/</link><pubDate>Fri, 31 Mar 2023 16:12:00 +0200</pubDate><guid>/blog/2023-03-31-awk-chatgpt/</guid><description>&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/AWK"&gt;awk&lt;/a&gt; is the Swiss army knife of the command
line. If you have a text-shaped problem then awk can probably be a solution.
&lt;a href="https://www.youtube.com/watch?v=Sg4U4r_AgJU"&gt;Here’s&lt;/a&gt; a fabulous talk by Brian
Kernighan (the k in awk) on why this may be the case.&lt;/p&gt;
&lt;p&gt;But it’s also a tool that I use just rarely enough that I keep forgetting
details. So everytime I reach for awk it’s a painful experience of not
remembering and having to cobble together 3 different StackOverflow answers to
get something resembling the script I want. Only to then realize I’ve been
“holding it wrong” and there’s a better approach 🤦.&lt;/p&gt;</description></item><item><title>Hypermedia driven micro frontends</title><link>/posts/2022-06-29-hypermedia-driven-micro-frontends/</link><pubDate>Wed, 29 Jun 2022 00:00:00 +0000</pubDate><guid>/posts/2022-06-29-hypermedia-driven-micro-frontends/</guid><description>&lt;p&gt;Micro frontends? Huh?&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;extending the microservice idea to frontend development
&amp;ndash; &lt;a href="https://micro-frontends.org/"&gt;https://micro-frontends.org/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;or: how to scale frontend development once you have too many engineers and they start stepping on each other&amp;rsquo;s toes. Assuming of course your frontend is an SPA (&lt;a href="https://grugbrain.dev/"&gt;grug&lt;/a&gt; might have something to say about both points).&lt;/p&gt;
&lt;p&gt;But of course splitting an SPA into multiple smaller applications and having it all play together brings along a ton of additional complexity. Just like splitting a monolith into micro services &amp;#x1f609;.&lt;/p&gt;</description></item><item><title>How I fell in love with low-js</title><link>/posts/2022-01-28-low-js/</link><pubDate>Fri, 28 Jan 2022 00:00:00 +0000</pubDate><guid>/posts/2022-01-28-low-js/</guid><description>&lt;p&gt;About 5 years ago I was working on a project written in style still common for today:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;python backend serving a REST API (public btw)&lt;/li&gt;
&lt;li&gt;SPA using framework-of-the day&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And it was horrible. Not to mention that the framework-of-the-day did not actually take off and we ended up using something very fringe - there were real performance and complexity problems. And to this day I believe all our problems stemmed from the base architecture. There were just too many layers, each contributing overhead. Both in execution speed (aka &amp;ldquo;app is slow&amp;rdquo;) and development speed (&amp;ldquo;our velocity is too low&amp;rdquo;).&lt;/p&gt;</description></item><item><title>Tailwind CSS vs Pico CSS</title><link>/posts/2022-01-18-tailwind-vs-pico/</link><pubDate>Tue, 18 Jan 2022 00:00:00 +0000</pubDate><guid>/posts/2022-01-18-tailwind-vs-pico/</guid><description>&lt;p&gt;tl;dr it&amp;rsquo;s a tradeoff so it depends.&lt;/p&gt;
&lt;p&gt;With that out of the ways let&amp;rsquo;s start with the fact that this is not an article about technical merits and which is best. It about my experience and my beliefs about which kinds of projects are a good fit for which tool.&lt;/p&gt;
&lt;p&gt;So what did I do? I have a (useless) pet project I keep fiddling with to try out new things. At one point I decided my eyes hurt and I want to make the frontend a bit prettier. It is paramount to explain that I have indeed been living under a rock for a few years and haven&amp;rsquo;t really touched any CSS. So I first did some exploration to see what has the world moved on to.&lt;/p&gt;</description></item><item><title>Speed is a feature; thoughts on modern web performance</title><link>/posts/2021-12-29-speed-is-a-feature/</link><pubDate>Wed, 29 Dec 2021 00:00:00 +0000</pubDate><guid>/posts/2021-12-29-speed-is-a-feature/</guid><description>&lt;p&gt;I&amp;rsquo;m pretty sure that as computers got faster they got slower. As chips got
faster the software slowed down. I&amp;rsquo;m acutely aware that we do much more now but
just the user interfaces really have no reason for slowing down.&lt;/p&gt;
&lt;p&gt;Why do I care? Because a fast web is a delight to browse. A fast app is a
delight to use. The tool feels like an extension of your body. Where as a
sluggish tool get&amp;rsquo;s in the way. Feels like you&amp;rsquo;re battling it instead of using
it. This is one of the main reasons I still prefer vim over more &amp;ldquo;modern&amp;rdquo; IDEs.&lt;/p&gt;</description></item><item><title>Trying Out Remix</title><link>/posts/2021-12-19-trying-out-remix/</link><pubDate>Sun, 19 Dec 2021 00:00:00 +0000</pubDate><guid>/posts/2021-12-19-trying-out-remix/</guid><description>&lt;p&gt;I came across &lt;a href="https://blog.cloudflare.com/remix-on-cloudflare-pages/"&gt;Supporting Remix with full stack Cloudflare Pages&lt;/a&gt; on Cloudflare blog (yes
I&amp;rsquo;m a CF fan) and &lt;a href="https://remix.run"&gt;Remix&lt;/a&gt; piqued my interest. Mostly because
it addresses my concerns with &amp;ldquo;modern&amp;rdquo; web development: the wiring boilerplate
is mostly gone, there is no 100 file setup to get a workable dev environment. And
of course because it&amp;rsquo;s outside my comfort zone - so maybe I&amp;rsquo;ll learn something.&lt;/p&gt;
&lt;h1 id="getting-started"&gt;Getting started&lt;/h1&gt;
&lt;p&gt;There&amp;rsquo;s a code example right on the home page but I&amp;rsquo;m having hard time building
a mental model from just that. Luckily there is also a bit &lt;a href="https://remix.run/docs/en/v1/tutorials/blog"&gt;Get started&lt;/a&gt; button which takes me to a tutorial. Great, let&amp;rsquo;s follow that.&lt;/p&gt;</description></item><item><title>Running amd64 docker images with Podman on Apple Silicon (M1)</title><link>/posts/2021-09-12-podman-m1-amd64/</link><pubDate>Sun, 12 Sep 2021 00:00:00 +0000</pubDate><guid>/posts/2021-09-12-podman-m1-amd64/</guid><description>&lt;p&gt;&lt;strong&gt;tl;dr&lt;/strong&gt; it works, scroll though and look for the code snippets&lt;/p&gt;
&lt;p&gt;You might have heard about Docker (the company) changing the terms of use which effectively requires enterprise users to pay up. While I personally think that paying for critical infrastructure that supports your business is a good idea there was a considerable backlash among engineers and &amp;ldquo;alternative to docker&amp;rdquo; was the common them on HN front page for a few days.&lt;/p&gt;</description></item><item><title>Trying out Prometheus</title><link>/posts/2021-06-27-trying-out-prometheus/</link><pubDate>Sun, 27 Jun 2021 00:00:00 +0000</pubDate><guid>/posts/2021-06-27-trying-out-prometheus/</guid><description>&lt;p&gt;This time I&amp;rsquo;m trying out a monitoring solution: &lt;a href="https://prometheus.io/"&gt;Prometheus&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;All I know about it so far:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;pull based, server scrapes /metrics on workloads, human readable format&lt;/li&gt;
&lt;li&gt;scales well because of this&lt;/li&gt;
&lt;li&gt;popular in kuberetes space&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let&amp;rsquo;s try running the &lt;a href="https://hub.docker.com/r/prom/prometheus/"&gt;docker iamge&lt;/a&gt;
based on the README.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run --rm -it -p9090:9090 prom/prometheus:main
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;&lt;img src="/images/prometheus/1.webp" alt="prometheus dashboard"&gt;&lt;/p&gt;
&lt;p&gt;We&amp;rsquo;ve got lift off! And it&amp;rsquo;s monitoring itself right out the gate:&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/prometheus/2.webp" alt="prometheus monitoring itself"&gt;&lt;/p&gt;</description></item><item><title>Trying out Microk8s</title><link>/posts/2021-04-15-trying-microk8s/</link><pubDate>Thu, 15 Apr 2021 00:00:00 +0000</pubDate><guid>/posts/2021-04-15-trying-microk8s/</guid><description>&lt;p&gt;In another &amp;ldquo;running kuberets&amp;rdquo; flavoured post I&amp;rsquo;ll be trying out
&lt;a href="https://microk8s.io/"&gt;microk8s&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;High availability K8s.
Low-ops, minimal production Kubernetes,
for devs, cloud, clusters, workstations, Edge and IoT.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In the past I&amp;rsquo;ve been using &lt;a href="https://k3s.io/"&gt;k3s&lt;/a&gt; for small (mostly single
node) &amp;ldquo;clusters&amp;rdquo;. The pitch is very similar. The few differences I can point
out now are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;microk8s is a bit heavier - I don&amp;rsquo;t think it will run on 1G vps, let&amp;rsquo;s try it
out&lt;/li&gt;
&lt;li&gt;microk8s has a better HA story - definately want to try this out&lt;/li&gt;
&lt;li&gt;k3s comes as a single &amp;ldquo;run everywhere&amp;rdquo; binary whereas microk8s requires
&lt;a href="https://snapcraft.io/docs/installing-snapd"&gt;snap&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id="setting-up"&gt;Setting up&lt;/h1&gt;
&lt;p&gt;I&amp;rsquo;ll be using &lt;a href="https://www.hetzner.com/cloud"&gt;Hetzner Cloud&lt;/a&gt; to provision a few
small VMs for my laboratory. But I&amp;rsquo;ll start with a single one.&lt;/p&gt;</description></item><item><title>Trying out Rancher</title><link>/posts/2021-04-14-trying-out-rancher/</link><pubDate>Wed, 14 Apr 2021 00:00:00 +0000</pubDate><guid>/posts/2021-04-14-trying-out-rancher/</guid><description>&lt;p&gt;This time it&amp;rsquo;s a bit different: this post has very little code and a lot of
screenshots as I was primarily working with a GUI.&lt;/p&gt;
&lt;p&gt;Reading about (and working with) &lt;a href="https://k3s.io/"&gt;K3s&lt;/a&gt; is almost impossible to
not hear about &lt;a href="https://rancher.com/"&gt;Rancher&lt;/a&gt; - the company behind K3s. But
what had me slightly confused is their primary product: &lt;a href="https://rancher.com/products/rancher/"&gt;Rancher (the
software)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The web page says&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Managed Kubernetes Cluster Operations&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;but that doesn&amp;rsquo;t really tell me much. Neither do their presentations. So what
better way to get a feel for it than taking it for a spin :) (there is some
enterprise offerings but the base product is free).&lt;/p&gt;</description></item><item><title>Trying out Okteto Cloud</title><link>/posts/2021-02-27-trying-out-okteto-cloud/</link><pubDate>Sat, 27 Feb 2021 00:00:00 +0000</pubDate><guid>/posts/2021-02-27-trying-out-okteto-cloud/</guid><description>&lt;p&gt;This is a part two of &lt;a href="/posts/2021-02-22-trying-out-okteto-cli/"&gt;Trying out Okteto&lt;/a&gt;.
I&amp;rsquo;ll be trying out &lt;a href="https://okteto.com/"&gt;okteto.com&lt;/a&gt; - &amp;ldquo;The Kubernetes development platform&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;At a first glance it looks like a hosted kubernetes solution + the CLI tool I
already tested + some bells and whistles. Let&amp;rsquo;s find out what those are.&lt;/p&gt;
&lt;h1 id="first-impressions"&gt;First impressions&lt;/h1&gt;
&lt;p&gt;Login with github. Boom I&amp;rsquo;m in, no extra sign up required. Big thumbs up.&lt;/p&gt;
&lt;p&gt;Looks like I got a managed namespace with 8G ram, 4cpus and 5G storage. Quite
generous for a free plan.&lt;/p&gt;</description></item><item><title>Trying out Okteto (CLI)</title><link>/posts/2021-02-22-trying-out-okteto-cli/</link><pubDate>Mon, 22 Feb 2021 00:00:00 +0000</pubDate><guid>/posts/2021-02-22-trying-out-okteto-cli/</guid><description>&lt;p&gt;Today I&amp;rsquo;ll be giving &lt;a href="https://github.com/okteto/okteto"&gt;Okteto&lt;/a&gt; a spin. From the docs&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Okteto: Tool to Develop Applications on Kubernetes&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Or my personal pitch:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Okteto delivers on the &amp;ldquo;my other computer is the cloud&amp;rdquo; trope&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;What does this mean? First of all: there is a distinction between&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Okteto Cloud &amp;amp; Okteto Enterprise: this is a server side solution that provides
managed k8s namespaces, CD and other bells and whistles - will look into this
in the future&lt;/li&gt;
&lt;li&gt;okteto - the tool: open source client to work with Okteto Cloud &amp;amp; Okteto
Enterprise - but the core functionality works with any k8s cluster. This is the
tool I&amp;rsquo;m trying out today.&lt;/li&gt;
&lt;li&gt;Okteto - the company (behind all of this)&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id="how-it-works"&gt;How it works&lt;/h1&gt;
&lt;p&gt;From the docs:&lt;/p&gt;</description></item><item><title>Trying out Buffalo</title><link>/posts/2021-02-07-trying-out-buffalo/</link><pubDate>Sun, 07 Feb 2021 00:00:00 +0000</pubDate><guid>/posts/2021-02-07-trying-out-buffalo/</guid><description>&lt;p&gt;I&amp;rsquo;m trying out a new concept: my &amp;ldquo;I should check this out&amp;rdquo; list of tools and technologies has grown quite a bit so I got
the idea that I could do short write ups of my experimentation and first impressions to give myself motivation to try
these things out. Will see how this turns out, hopefully this will turn out a series :)&lt;/p&gt;
&lt;p&gt;Today I&amp;rsquo;ll be trying out &lt;a href="https://gobuffalo.io/en/"&gt;Buffalo&lt;/a&gt; - a Go web framework. I believe this one distinguishes
itself by focusing on developer productivity - a kind of &amp;ldquo;Rails for Go&amp;rdquo;. But apparently it&amp;rsquo;s mostly some glue and
tooling around a bunch of other established libraries. I very much like this approach. And yes, I agree that &amp;ldquo;just use
standard library&amp;rdquo; is not (always) the right approach. Sometimes you just want to bootstrap a small project quickly.&lt;/p&gt;</description></item><item><title>Attaching your local machine to a Kubernetes cluster</title><link>/posts/2020-10-17-attach-to-k8s/</link><pubDate>Sat, 17 Oct 2020 00:00:00 +0000</pubDate><guid>/posts/2020-10-17-attach-to-k8s/</guid><description>&lt;p&gt;Why on earth would you want to do that?! You may have a legitimate reason like
pooling spare compute capacity. Oooooor you&amp;rsquo;re just goofing around in order to
understand things. Like me.&lt;/p&gt;
&lt;p&gt;Specifically I was playing with &lt;a href="https://www.telepresence.io/"&gt;telepresence&lt;/a&gt; (a
&amp;ldquo;VPN into the cluster&amp;rdquo;) and a had an idea: why not just run a part of the
cluster locally. Then you can interact with the containers and containers can
interact with your host (host port, host path etc), no magic required.&lt;/p&gt;</description></item><item><title>Surprising ease of gaming on Linux in 2020</title><link>/posts/2020-06-07-linux-gaming/</link><pubDate>Sun, 07 Jun 2020 00:00:00 +0000</pubDate><guid>/posts/2020-06-07-linux-gaming/</guid><description>&lt;p&gt;During the quarantine my hobbies (and I imagine many others&amp;rsquo;) shifted to more
indoors ones - possibly sedentary. Among other things I also started gaming
after a hiatus of many years.&lt;/p&gt;
&lt;p&gt;But as you can probably imagine gaming on a 13&amp;quot; laptop with integrated graphics
is not the most gratifying of experiences. So I got myself a desktop with a
proper graphics card.&lt;/p&gt;
&lt;p&gt;And now comes the interesting part: since all the games I originally planned on
playing have Linux support I decided to skip buying a copy of Windows and copy
my laptop &lt;a href="https://nixos.org/"&gt;NixOS&lt;/a&gt; config and extend it as needed. Basically
I wanted to do some tinkering again.&lt;/p&gt;</description></item><item><title>Rename rebase with git</title><link>/posts/2020-04-20-rebase-rename/</link><pubDate>Mon, 20 Apr 2020 00:00:00 +0000</pubDate><guid>/posts/2020-04-20-rebase-rename/</guid><description>&lt;p&gt;Want to perform a &lt;code&gt;git rebase&lt;/code&gt; in which you rename a file without pesky
conflicts?&lt;/p&gt;
&lt;p&gt;tl;dr&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;1
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git filter-branch -f --tree-filter &lt;span style="color:#e6db74"&gt;&amp;#34;git mv ORIGINAL_FILE_NAME NEW_FILE_NAME || true&amp;#34;&lt;/span&gt; -- &lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;git merge-base origin/master HEAD&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;..HEAD
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git rebase origin/master
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Ever wanted to rename a file you created/modified in a pull request but also
wanted to keep the pristine history you worked hard for? Well tough luck you
can either push a new commit to rename it (and keep old commits with the old
file name) or resolve a bunch of pointless conflicts. There must be a better
way&amp;hellip;&lt;/p&gt;</description></item><item><title>Moving to Hugo</title><link>/posts/2020-01-15-hugo/</link><pubDate>Wed, 15 Jan 2020 00:00:00 +0000</pubDate><guid>/posts/2020-01-15-hugo/</guid><description>&lt;p&gt;If you&amp;rsquo;ve been here before you might notice the site looks different. Indeed I
moved my content to yet another platform (first it was blogspot -&amp;gt; hakyll).&lt;/p&gt;
&lt;p&gt;I wanted to publish something but I ran into issues: my toolchain did not work.
See, I&amp;rsquo;ve been doing less Haskell on my machine lately and negligence led into
my setup rotting (as I did upgrade my machine quite a bit). Truth be told the
infrastructure was not designed to last the test of time. Anyways after a few
rounds of debugging I once decided to finally give up my complicated custom
setup and move to something off-the-shelf so I can focus on writing.&lt;/p&gt;</description></item><item><title>Linear time sorting</title><link>/posts/2018-05-25-linear-time-sorting/</link><pubDate>Fri, 25 May 2018 00:00:00 +0000</pubDate><guid>/posts/2018-05-25-linear-time-sorting/</guid><description>&lt;p&gt;Did you know that you can sort data in time linear with respect to the lenght
of said data? Some people dismiss linear time sorts because they&amp;rsquo;ve learned
that &lt;code&gt;n log n&lt;/code&gt; is the bottom bound for sorting an arbitrary input.&lt;/p&gt;
&lt;h1 id="but-n-log-n-is-optimal"&gt;But &lt;em&gt;n log n&lt;/em&gt; is optimal!?&lt;/h1&gt;
&lt;p&gt;Let&amp;rsquo;s even sketch out a proof. Any function that sorts an array of elements
will in fact figure out a permutation of elements into a sorted order. Even if
your algorithm does not work in terms of permutations it can be viewed as a
black box that computes a permutation.&lt;/p&gt;</description></item><item><title>Integrating Jira into Google Sheets</title><link>/posts/2018-01-25-jira-gsheet/</link><pubDate>Thu, 25 Jan 2018 00:00:00 +0000</pubDate><guid>/posts/2018-01-25-jira-gsheet/</guid><description>&lt;p&gt;So I got a (recurring) task to compile some stats from Jira. You now, some
filtering and agregation. Possibly a pivot table and a chart. Sounds like a
perfect task for spreadsheets. But Jira doesn&amp;rsquo;t have spreadsheets - at least
without addons, but that is not an options for me.&lt;/p&gt;
&lt;p&gt;So I decided to use Google Sheets. And figure out a way to automatically fetch
data from Jira because there&amp;rsquo;s no way in hell I&amp;rsquo;m doing that manually every
time. Turns out there are some scripts you are supposed to paste into sheets and
give them all the permissions. But I don&amp;rsquo;t trust that, not without properly
reviewing the thousands of lines of code.&lt;/p&gt;</description></item><item><title>NixOS install &amp; labor pains</title><link>/posts/2018-01-24-nixos-install-pains/</link><pubDate>Wed, 24 Jan 2018 00:00:00 +0000</pubDate><guid>/posts/2018-01-24-nixos-install-pains/</guid><description>&lt;h1 id="the-back-story"&gt;The Back Story&lt;/h1&gt;
&lt;p&gt;My first foray into world of Linux happened with Red Hat Linux 6 (original, not
the enterprise one). It was magical but it didn&amp;rsquo;t stick. See, I was a kid who
liked video games. So it was back to Windows until I finally got serious about
programming and discovered I the development environment on Linux. So I
formatted my hard drive and installed Ubuntu. I quickly learned absorbed
information and slowly got bored. When Unity came out it was time to switch. I
dabbled a bit with Mint but ultimately landed on ArchLinux. I really like the
&lt;em&gt;RTFM or GTFO&lt;/em&gt; philosophy of Arch because it means you learn stuff and you
learn it quickly. Because you just have to. Oh, and there is great
documentation. And everything was great. Until I borked my system doing an
upgrade or some other system package operation. A few times. Btrfs to the
rescue! But there must be a better way. (I was doing manual snapshots of the
root filesystem before any potentially destructive operation.&lt;/p&gt;</description></item><item><title>Implementing apply on tuples in Scala</title><link>/posts/2017-09-01-scala-tuple-apply/</link><pubDate>Fri, 01 Sep 2017 00:00:00 +0000</pubDate><guid>/posts/2017-09-01-scala-tuple-apply/</guid><description>&lt;p&gt;One of the first things you learn as a newcomer to Scala is the difference
between a list and a tuple: a list must be homogeneous but a tuple can be
heterogeneous. That is all elements of a list must have the same types but a
tuple can contain things of different types.&lt;/p&gt;
&lt;p&gt;A direct consequence of this is that a list can define a by-index accessor and
a tuple cannot. You can use &lt;code&gt;list(3)&lt;/code&gt; but you can&amp;rsquo;t do &lt;code&gt;tuple(3)&lt;/code&gt; - you need to
do &lt;code&gt;tuple._4&lt;/code&gt; (and there is that pesky off-by-one).&lt;/p&gt;</description></item><item><title>Dockerless Services (with Nix)</title><link>/posts/2017-08-30-dockerless-services/</link><pubDate>Wed, 30 Aug 2017 00:00:00 +0000</pubDate><guid>/posts/2017-08-30-dockerless-services/</guid><description>&lt;p&gt;So you want an &amp;ldquo;isolated&amp;rdquo; MySQL &amp;ldquo;service&amp;rdquo; but don&amp;rsquo;t want to (or are not able
to) run Docker/rkt/LXC/whatever?&lt;/p&gt;
&lt;p&gt;Here are the tl;dr steps:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;1
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;2
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;3
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;4
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;5
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;6
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;7
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;8
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;9
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd /tmp
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir mysql-1
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd mysql-1
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nix-shell -p mysql
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mysql_install_db --datadir&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;pwd&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mysqld --datadir&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;pwd&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt; --socket&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;pwd&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;/socket &amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mysqladmin -uroot -h127.0.0.1 password &amp;lt;REDACTED&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mysql -uroot -p&amp;lt;REDACTED&amp;gt; -h127.0.0.1
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;...
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2 id="why"&gt;Why?&lt;/h2&gt;
&lt;p&gt;My motivation for this was running a database on a machine with a specially
tuned kernel that did not support containers.&lt;/p&gt;</description></item><item><title>TDD-ing a toy sized project</title><link>/posts/2016-09-21-toy-sized-tdd/</link><pubDate>Wed, 21 Sep 2016 00:00:00 +0000</pubDate><guid>/posts/2016-09-21-toy-sized-tdd/</guid><description>&lt;p&gt;Just recently I was porting a toy sized parser combinator library (a proof of
concept) from Haskell to Python. You know, for educational purposes. It turns
out I&amp;rsquo;m not smart enough to keep the complicated types (and explicit laziness)
in my head even for such a small project. So my solution was to do TDD. To
clarify: I wanted to test happy paths through my functions to make sure at
least types fit together.&lt;/p&gt;</description></item><item><title>Repairing a corrupt Git repo using a clone</title><link>/posts/2016-02-24-git-repair/</link><pubDate>Wed, 24 Feb 2016 00:00:00 +0000</pubDate><guid>/posts/2016-02-24-git-repair/</guid><description>&lt;p&gt;Quite recently I managed to make myself a corrupt git repository due to a file system failure.
See, git stores everything in content addressable blobs - the file name of something is it&amp;rsquo;s hash. Which lends itself nicely to checking repository integrity - it keeps out malicious attackers as well as my file system problems.&lt;/p&gt;
&lt;p&gt;I already hear you saying: Why not just make a new clone, git is distributed anyway?
Well, I wasn&amp;rsquo;t diligent enough to push everything. I had local commits that were quite important, so I spent some time fixing it.&lt;/p&gt;</description></item><item><title>Lazy unary numbers</title><link>/posts/2015-05-03-unary-numbers/</link><pubDate>Sun, 03 May 2015 00:00:00 +0000</pubDate><guid>/posts/2015-05-03-unary-numbers/</guid><description>&lt;p&gt;We are used to encoding numbers on computers in binary. Binary is the &amp;ldquo;simplest&amp;rdquo; base that yields logarithmic length though it &lt;a href="http://web.williams.edu/Mathematics/sjmiller/public_html/105Sp10/addcomments/Hayes_ThirdBase.htm"&gt;may not be optimal&lt;/a&gt;. But can we do simpler? How about unary?&lt;/p&gt;
&lt;p&gt;Unary is often used with Turing machines where we don&amp;rsquo;t care for efficiency and I will assume this same stance. Let&amp;rsquo;s forget about efficiency and explore what can unary numbers do that binary can&amp;rsquo;t. Specifically lazy unary numbers as otherwise the systems are equivalent. I&amp;rsquo;ll be using Haskell as it is lazy by default and thus a good fit.&lt;/p&gt;</description></item><item><title>Cheap tagged types in Scala</title><link>/posts/2015-05-02-tagged-types/</link><pubDate>Sat, 02 May 2015 00:00:00 +0000</pubDate><guid>/posts/2015-05-02-tagged-types/</guid><description>&lt;p&gt;Sometimes you want to distinguish between different types that have the same underlying representation. For example both &lt;code&gt;UserId&lt;/code&gt; and &lt;code&gt;ProductId&lt;/code&gt; could be represented by &lt;code&gt;Long&lt;/code&gt;. The usual solution is to introduce wrappers in order to make the distinction safe.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;1
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code class="language-scala" data-lang="scala"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;case&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;UserId&lt;/span&gt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;id&lt;span style="color:#66d9ef"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;Long&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;case&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;ProductId&lt;/span&gt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;id&lt;span style="color:#66d9ef"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;Long&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;But this introduces runtime overhead of boxing and unboxing over and over which may add up in some cases. Luckily Scala 2.10 introduced value classes. We can ensure no runtime overhead by extending &lt;code&gt;AnyVal&lt;/code&gt; (this can only be done with classes with one field).&lt;/p&gt;</description></item><item><title>Approaches to designing a Haskell API</title><link>/posts/2014-10-05-haskell-apis/</link><pubDate>Sun, 05 Oct 2014 00:00:00 +0000</pubDate><guid>/posts/2014-10-05-haskell-apis/</guid><description>&lt;p&gt;Recently I&amp;rsquo;ve been thinking about the design of programming interfaces, especially in Haskell. But don&amp;rsquo;t let the title misguide you; this is not supposed to be a tutorial or a guide but simply an showcase of different styles. Feel free to tell me I&amp;rsquo;m wrong or missed something.&lt;/p&gt;
&lt;h2 id="the-problem"&gt;The problem&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s say we are writing an interface to RESTful web service. Our goal is to create type safe functions and descriptive models but all in all easy to use.&lt;/p&gt;</description></item><item><title>Static linking with GHC on ArchLinux</title><link>/posts/2014-05-03-ghc-arch-static/</link><pubDate>Sat, 03 May 2014 00:00:00 +0000</pubDate><guid>/posts/2014-05-03-ghc-arch-static/</guid><description>&lt;p&gt;There are many reasons why to prefer dynamic linking to static but I&amp;rsquo;ll not go through them. Sometimes you just want static linking, period. In my case it was to show that &lt;a href="http://golang.org/"&gt;Go&lt;/a&gt;&amp;rsquo;s static executables without dependencies are not something special and other languages can do it as good as well - Haskell included.
My compiler of choice is GHC and I&amp;rsquo;m running ArchLinux. More on why this is important later.&lt;/p&gt;</description></item><item><title>Coroutines for free</title><link>/posts/2014-04-14-free-coroutines/</link><pubDate>Mon, 14 Apr 2014 00:00:00 +0000</pubDate><guid>/posts/2014-04-14-free-coroutines/</guid><description>&lt;h3 id="motivation"&gt;Motivation&lt;/h3&gt;
&lt;p&gt;My first run-in with coroutines was with Python&amp;rsquo;s generators.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;1
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;2
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;3
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;4
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;5
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;ints&lt;/span&gt;():
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; i &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;while&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;yield&lt;/span&gt; i
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; i &lt;span style="color:#f92672"&gt;+=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;This is a function that never returns. Instead it runs in an infinite loop over all natural numbers. But it &lt;em&gt;yield&lt;/em&gt;s every number. This means it actually stops and &amp;ldquo;returns&amp;rdquo; the number to the caller but is available for more execution. Kind-of like implementing an &lt;code&gt;Iterator&lt;/code&gt; but the control flow is reversed. Now you don&amp;rsquo;t produce a value on demand but rather you run and output values at will while the runtime system stops and resumes you.&lt;/p&gt;</description></item><item><title>Practical Future[Option[A]] in Scala</title><link>/posts/2014-03-07-practical-future-option/</link><pubDate>Fri, 07 Mar 2014 00:00:00 +0000</pubDate><guid>/posts/2014-03-07-practical-future-option/</guid><description>&lt;h3 id="motivation"&gt;Motivation&lt;/h3&gt;
&lt;p&gt;In real world concurrent code you often come across the &lt;code&gt;Future[Option[A]]&lt;/code&gt; type(where &lt;code&gt;A&lt;/code&gt; is usually some concrete type). And then you need to compose these things. This is not straightforward in Scala.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;ve done some Haskell just &lt;code&gt;import scalaz._&lt;/code&gt; and you can skip the rest of this article. Scalaz library defines a monad typeclass(and many others) that formally specifies what it means to be a monad(not &amp;ldquo;has a flatMap-ish thingy&amp;rdquo;). Then it&amp;rsquo;s easy to build abstractions upon this.&lt;/p&gt;</description></item><item><title>Comparing Haskell Web Frameworks</title><link>/posts/2014-02-23-haskell-web/</link><pubDate>Sun, 23 Feb 2014 00:00:00 +0000</pubDate><guid>/posts/2014-02-23-haskell-web/</guid><description>&lt;h2 id="intro"&gt;Intro&lt;/h2&gt;
&lt;p&gt;Lately I got sucked into Haskell. When I first saw it it looked like it might be a bit impractical for real-life projects but this prejudice faded away slowly. Now I&amp;rsquo;m at the point where I have an idea for a web application and I&amp;rsquo;d like to do it in Haskell. After a quick search I found many frameworks and libraries that I might use. So I decided to do some exploration and implement a bunch of stuff with different technologies. This way I don&amp;rsquo;t have to believe others and I can decide for myself what feels right to me.&lt;/p&gt;</description></item><item><title>Product and sum types (Go and Haskell)</title><link>/posts/2014-02-17-product-and-sum-types/</link><pubDate>Mon, 17 Feb 2014 00:00:00 +0000</pubDate><guid>/posts/2014-02-17-product-and-sum-types/</guid><description>&lt;p&gt;Let&amp;rsquo;s take a look at Go-language functions. They let you return more than one result. Like in&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;1
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;2
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;func&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;foo&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;n&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt;) (&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt;, &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;n&lt;/span&gt;&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;n&lt;/span&gt;&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;This function &lt;code&gt;foo&lt;/code&gt; returns two numbers. But does it really? Pairs(and tuples in general) aren&amp;rsquo;t a first class citizen in Go. Yes you can return them from function and you can even return a result of a function that returns the same signature as you but then you must immediately bind each result to separate variable.&lt;/p&gt;</description></item><item><title>Hakyll</title><link>/posts/2014-01-08-hakyll/</link><pubDate>Wed, 08 Jan 2014 00:00:00 +0000</pubDate><guid>/posts/2014-01-08-hakyll/</guid><description>&lt;p&gt;Hello there. I think I&amp;rsquo;m gonna resurrect this blog as I feel like writing again.
I kinda have a general dislike for PHP and don&amp;rsquo;t like Wordpress. I tried mucking about with Github Pages, but I&amp;rsquo;m not a fan of Jekyll either. And then I forgot about this.&lt;/p&gt;
&lt;h3 id="haskell"&gt;Haskell&lt;/h3&gt;
&lt;p&gt;A few weeks ago I rediscovered Haskell. I tried learning it once before but gave up. And insisted in Scala. This time I believe I got past the hardest part of the learning curve. And it&amp;rsquo;s been awesome! I learned so much, even bought and start reading a book on abstract algebra. But most importantly, I&amp;rsquo;ve written some software. Nothing fancy. Some &lt;a href="http://projecteuler.net/"&gt;Project Euler&lt;/a&gt; problems and some homeworks. But I got a feel for the language and I love it.&lt;/p&gt;</description></item><item><title>Virtual machine in C++</title><link>/posts/2013-10-18-virtual-machine-cpp/</link><pubDate>Fri, 18 Oct 2013 00:00:00 +0000</pubDate><guid>/posts/2013-10-18-virtual-machine-cpp/</guid><description>&lt;p&gt;This is not a tutorial. This post
is a flashback I had today. It might be a bit fiction as my memory about
events tends to be fuzzy at times. But I promise it at least resembles
the real story.
I was in &lt;a href="http://en.wikipedia.org/wiki/Elementary_school" title="Elementary school"&gt;elementary
school&lt;/a&gt;
and just found out about programming and was learning about c++. After
reading &amp;ldquo;&lt;a href="http://en.wikipedia.org/wiki/C%2B%2B" title="C++"&gt;C++&lt;/a&gt; na kolenih&amp;rdquo;
by Goran Bervar I was empowered by knowledge and tried to do all sorts
of projects. Mostly in console. Stuff like subtitle format converter -
&lt;a href="http://en.wikipedia.org/wiki/Not_Invented_Here" title="Not Invented Here"&gt;NIH
syndrome&lt;/a&gt;.
I was a bit frustrated because I couldn&amp;rsquo;t find any books about windows
programming in the library. Yes, library was may primary source of
information, because
my &lt;a href="http://en.wikipedia.org/wiki/English_language" title="English language"&gt;English&lt;/a&gt; was
not nearly good enough for technical stuff.
I might add here I worked on
&lt;a href="http://www.microsoft.com/WINDOWS" title="Windows"&gt;Windows&lt;/a&gt; 98(and later XP)
with &lt;a href="http://www.bloodshed.net%2c/" title="Dev-C++"&gt;DevC++&lt;/a&gt;. I found out about
&lt;a href="http://www.microsoft.com/visualstudio/en-us" title="Microsoft Visual Studio"&gt;Visual
Studio&lt;/a&gt;
in a few years and did some Windows development.
I digressed a bit. Then came the most optimistic idea. A &lt;a href="http://www.symantec.com/theme.jsp?themeid=protect-virtual-environments" title="Virtual machine"&gt;virtual
machine&lt;/a&gt;.
Something quite high level(instruction to print) an eventually an
assembler. I now realize I was always &lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;into language
stuff&lt;/a&gt;.
So a designed a &lt;a href="http://en.wikipedia.org/wiki/Machine_code" title="Machine code"&gt;machine
language&lt;/a&gt; with
just enough instructions to do &lt;a href="http://en.wikipedia.org/wiki/Hello_world_program" title="Hello world program"&gt;Hello
World&lt;/a&gt;,
that is PRINT and END.&lt;/p&gt;</description></item><item><title>Setting up for better Scala development on Android</title><link>/posts/2013-09-04-better-scala-android/</link><pubDate>Wed, 04 Sep 2013 00:00:00 +0000</pubDate><guid>/posts/2013-09-04-better-scala-android/</guid><description>&lt;p&gt;&lt;img src="http://www.crunchbase.com/assets/images/resized/0001/4601/14601v1-max-450x450.png" alt=""&gt;&lt;/p&gt;
&lt;p&gt;I did &lt;a href="/posts/2012-10-22-scala-android"&gt;a tutorial how to set up
everything using
IntelliJ&lt;/a&gt;
a while ago. I still think &lt;a href="http://www.jetbrains.com/idea/" title="IntelliJ IDEA"&gt;IntelliJ
IDEA&lt;/a&gt; is awesome and you
should use it(it has a free and open version) but I&amp;rsquo;ve found a better
way. No more clicking around in wizards&amp;hellip;it&amp;rsquo;s config file time. Relax -
it&amp;rsquo;s quite simple. I recommend installing the Typesafe-stack. It gives
you the two tools listed below in nice packaged form with updates. And
that&amp;rsquo;s about it. I&amp;rsquo;m quite fond of package managers =&amp;gt; one place to
update everything.&lt;/p&gt;</description></item><item><title>750 words</title><link>/posts/2013-01-27-750-words/</link><pubDate>Sun, 27 Jan 2013 00:00:00 +0000</pubDate><guid>/posts/2013-01-27-750-words/</guid><description>&lt;p&gt;&lt;a href="http://www.flickr.com/photos/12584908@N08/3293117576"&gt;&lt;img src="http://farm4.static.flickr.com/3447/3293117576_05f43d8305_m.jpg" alt="Writing" title="Writing"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This week I felt the impulse
to express myself multiple times. I felt like
&lt;a href="http://en.wikipedia.org/wiki/Writing" title="Writing"&gt;writing&lt;/a&gt;. Being a bit
sentimental I opened up a notepad I got from my girlfriend as a birthday
present and began a brain dump. A &lt;a href="http://en.wikipedia.org/wiki/Stream_of_consciousness_%28narrative_mode%29" title="Stream of consciousness (narrative mode)"&gt;stream
of consciousness&lt;/a&gt;.
But my handwriting is painfully slow. This means I had time to do
reformatting and rewording in my mind. Sot this was &lt;strong&gt;definitely not&lt;/strong&gt; a
brain dump. I wasn&amp;rsquo;t expressing my thoughts directly but rather doing
some writing - I don&amp;rsquo;t know how to put this subtle(but important)
difference better. And after 2 small(&amp;lt; A5 format) pages I gave up. I
kinda wanna keep a journal  but this is too much work for too little
return.&lt;/p&gt;</description></item><item><title>Chaining implicit conversion in scala</title><link>/posts/2013-01-27-chaining-implicits/</link><pubDate>Sun, 27 Jan 2013 00:00:00 +0000</pubDate><guid>/posts/2013-01-27-chaining-implicits/</guid><description>&lt;p&gt;Today I was hanging
in the
#&lt;a href="http://www.scala-lang.org/" title="Scala (programming language)"&gt;scala&lt;/a&gt;
&lt;a href="http://en.wikipedia.org/wiki/Internet_Relay_Chat" title="Internet Relay Chat"&gt;IRC
channel&lt;/a&gt;
and somebody came along(forgot the nick, sorry) and asked about some
&lt;a href="http://en.wikipedia.org/wiki/Compilation_error" title="Compilation error"&gt;compilation
error&lt;/a&gt;.
I deduced he was trying to chain implicit conversions. And this doesn&amp;rsquo;t
work. Else compilation would take forever and would also compile some
wrong code by inserting long strings of implicits. But then somebody
else responded(I think nick started with d) and gave a solution to
implicit chaining. But I&amp;rsquo;m not giving it away yet, you&amp;rsquo;ll have to read a
bit more.&lt;/p&gt;</description></item><item><title>Generic singletons through dependent method types</title><link>/posts/2013-01-27-generic-singletons/</link><pubDate>Sun, 27 Jan 2013 00:00:00 +0000</pubDate><guid>/posts/2013-01-27-generic-singletons/</guid><description>&lt;p&gt;Ever
tried to write a
&lt;a href="http://en.wikipedia.org/wiki/Generic_programming" title="Generic programming"&gt;generic&lt;/a&gt;
singleton? It&amp;rsquo;s an oxymoron of a sort. But sometimes my brain dreams up
funny concepts to solve the problem at hand. Sadly I cannot remember
what I wanted to use them for. Anyway I think I just made all the
&lt;a href="http://en.wikipedia.org/wiki/Method_%28computer_programming%29" title="Method (computer programming)"&gt;methods&lt;/a&gt;
generic and solved it this way. But this doesn&amp;rsquo;t really express the
notion of one entity that&amp;rsquo;s agnostic to type of the parameters. With
generic methods you get a bunch of disconnected units - at least that&amp;rsquo;s
the picture in my head.&lt;/p&gt;</description></item><item><title>Monadic IO with ScalaZ</title><link>/posts/2013-01-27-monadic-io/</link><pubDate>Sun, 27 Jan 2013 00:00:00 +0000</pubDate><guid>/posts/2013-01-27-monadic-io/</guid><description>&lt;p&gt;I just recently scratched the
surface with &lt;a href="http://code.google.com/p/scalaz/"&gt;scalaz&lt;/a&gt;. Think of it as
an additional standard library for scala that&amp;rsquo;s
&lt;a href="http://en.wikipedia.org/wiki/Functional_programming" title="Functional programming"&gt;FP&lt;/a&gt;
oriented. It provides a bunch of &lt;a href="http://en.wikipedia.org/wiki/Type_class" title="Type class"&gt;type
classes&lt;/a&gt;,
instances for pretty much everything, some fancy data types, pimps(Pimp
My Library) for standard library collections, actor implementation and
probably some stuff I&amp;rsquo;m not aware of. I could really use a &amp;ldquo;map of
scalaz&amp;rdquo; - but I&amp;rsquo;ll probably dive into source and scaladoc anyway. One
fancy feature that&amp;rsquo;s not noted on their&lt;a href="http://code.google.com/p/scalaz/"&gt;Google Code
page&lt;/a&gt; is
&lt;a href="http://en.wikipedia.org/wiki/Io_%28programming_language%29" title="Io (programming language)"&gt;IO&lt;/a&gt;
monad implementation.&lt;/p&gt;</description></item><item><title>Null-coalescing(??) in scala</title><link>/posts/2013-01-27-null-coalescing/</link><pubDate>Sun, 27 Jan 2013 00:00:00 +0000</pubDate><guid>/posts/2013-01-27-null-coalescing/</guid><description>&lt;p&gt;I was doing my homework
today(yes I am aware I should be enjoying myself on 30th December) and had some problems
with &lt;a href="http://en.wikipedia.org/wiki/Concatenation" title="Concatenation"&gt;concatenating&lt;/a&gt; possibly
null strings in
&lt;a href="http://en.wikipedia.org/wiki/Language_Integrated_Query" title="Language Integrated Query"&gt;LINQ&lt;/a&gt;.
Quick trip to
&lt;a href="http://stackoverflow.com/" title="Stack Overflow"&gt;StackOverflow&lt;/a&gt; and I find
out
&lt;a href="http://msdn2.microsoft.com/en-us/vcsharp/aa336809.aspx" title="C Sharp (programming language)"&gt;C#&lt;/a&gt;
has some funky operators that solve this in a (sort-of) clean way.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code class="language-csharp" data-lang="csharp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;var&lt;/span&gt; outputString = input1 ?? &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#34;&lt;/span&gt; + input2 ?? &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;I like &lt;a href="http://en.wikipedia.org/wiki/Type_inference" title="Type inference"&gt;type
inference&lt;/a&gt;
so I use var&amp;rsquo;s extensively - please don&amp;rsquo;t judge me. What this does is
concatenate input1 and input2 substituting null values with &lt;a href="http://en.wikipedia.org/wiki/Empty_string" title="Empty string"&gt;empty
string&lt;/a&gt;. In
scala you would write something like&lt;/p&gt;</description></item><item><title>Union types in scala</title><link>/posts/2013-01-27-union-types/</link><pubDate>Sun, 27 Jan 2013 00:00:00 +0000</pubDate><guid>/posts/2013-01-27-union-types/</guid><description>&lt;p&gt;I&amp;rsquo;ve done some research  a while
ago on union types and found a nice &lt;a href="http://www.chuusai.com/2011/06/09/scala-union-types-curry-howard/"&gt;implementation by Miles
Sabin&lt;/a&gt; but
it only works for declaring types of function parameters. And you can
also do this with with &lt;a href="http://en.wikipedia.org/wiki/Type_class" title="Type class"&gt;type
classes&lt;/a&gt;. What do
I mean with &amp;ldquo;only function parameters&amp;rdquo;? In &amp;ldquo;everything is a function&amp;rdquo;
kind of view there are three places to put types&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;function parameters&lt;/li&gt;
&lt;li&gt;value(val or let binding in haskell and the like)&lt;/li&gt;
&lt;li&gt;function &lt;a href="http://en.wikipedia.org/wiki/Return_type" title="Return type"&gt;return
type&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Even though Miles&amp;rsquo; encoding with &lt;a href="http://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspondence" title="Curry–Howard correspondence"&gt;Curry-Howard
isomorphism&lt;/a&gt;
is ingenious it only applies to point 1. Let&amp;rsquo;s fix that! Oh yeah you
could also use Either but that adds up boilerplate(even with implicits!)
and packing. And I want my union types unboxed.&lt;/p&gt;</description></item><item><title>Cool Monday - Exploration of dynamic db acces from scala</title><link>/posts/2012-12-10-dynamic-db/</link><pubDate>Mon, 10 Dec 2012 00:00:00 +0000</pubDate><guid>/posts/2012-12-10-dynamic-db/</guid><description>&lt;p&gt;I use &lt;a href="http://www.scala-lang.org/" title="Scala (programming language)"&gt;scala&lt;/a&gt; on
&lt;a href="http://www.t-mobile.com/shop/phones/?capcode=AGE" title="Android phones"&gt;Android&lt;/a&gt;
and I don&amp;rsquo;t like the integrated database
&lt;a href="http://en.wikipedia.org/wiki/Application_programming_interface" title="Application programming interface"&gt;API&lt;/a&gt;.
It&amp;rsquo;s very verbose and very stateful. I had written my own
&lt;a href="http://en.wikipedia.org/wiki/Object-relational_mapping" title="Object-relational mapping"&gt;ORM&lt;/a&gt;(&lt;a href="http://en.wikipedia.org/wiki/Data_access_object" title="Data access object"&gt;DAO&lt;/a&gt;
would be a more appropriate tag) a while back, before I used scala but
it&amp;rsquo;s not enough anymore. So now I&amp;rsquo;m on a quest for a better database
API. My dream is something small that handles schema for me and is
&lt;a href="http://en.wikipedia.org/wiki/Type_safety" title="Type safety"&gt;type-safe&lt;/a&gt;. A
nice
&lt;a href="http://en.wikipedia.org/wiki/Digital_subscriber_line" title="Digital subscriber line"&gt;DSL&lt;/a&gt;
that is converted to
&lt;a href="http://www.iso.org/iso/catalogue_detail.htm?csnumber=45498" title="SQL"&gt;SQL&lt;/a&gt;
at &lt;a href="http://en.wikipedia.org/wiki/Compile_time" title="Compile time"&gt;compile
time&lt;/a&gt;  and
does code generation. So it&amp;rsquo;s fast like hand writing everything. But
reduces code footprint by an order of magnitude(at least).
&lt;a href="http://www.scala-lang.org/" title="Scala (programming language)"&gt;Scala&lt;/a&gt;
&lt;a href="http://slick.typesafe.com/"&gt;SLICK&lt;/a&gt; looks promising. It fits most
requirements. But it&amp;rsquo;s kinda big for android projects(you need scala
library too!) and has not yet hit a stable version so I wouldn&amp;rsquo;t be
comfortable shipping it. Will definitely give it a thorough test when
scala 2.10 is stable and SLICK is released. Oh, and it needs a third
party &lt;a href="http://en.wikipedia.org/wiki/JDBC_driver" title="JDBC driver"&gt;JDBC
 driver&lt;/a&gt; for
Android. This is another level of abstraction and therefore another
source of slowness. I contemplated writing my own clone targeted at
Android but   never came around to actually doing it(yet!). It seems
like a herculean task for single developer working in spare time.&lt;/p&gt;</description></item><item><title>Homework - functional style (outer sorting)</title><link>/posts/2012-12-04-hw-functional/</link><pubDate>Tue, 04 Dec 2012 00:00:00 +0000</pubDate><guid>/posts/2012-12-04-hw-functional/</guid><description>&lt;p&gt;I&amp;rsquo;m attending
Algorithms and data structures class this semester. Material it self is
quite interesting and one TA is pretty cool too. But I don&amp;rsquo;t like
professor(makes whole experience very much worse) and I believe
homeworks could be much better. Oh, and we didn&amp;rsquo;t even mention
functional approach&amp;hellip;you know
&lt;a href="http://haskell.org/" title="Haskell (programming language)"&gt;Haskell&lt;/a&gt;,
&lt;a href="http://www.scala-lang.org/" title="Scala (programming language)"&gt;Scala&lt;/a&gt; and
the like. All we do is imperative, C-style code in Java. Enough ranting.
This is how it saw the bright side.&lt;/p&gt;</description></item><item><title>Cool Monday - Functional compilers and atoms</title><link>/posts/2012-11-26-functional-compilers/</link><pubDate>Mon, 26 Nov 2012 00:00:00 +0000</pubDate><guid>/posts/2012-11-26-functional-compilers/</guid><description>&lt;p&gt;I&amp;rsquo;ve seen
&lt;a href="http://skillsmatter.com/podcast/scala/functional-compilers-from-cfg-to-exe/ac-5896"&gt;this great
talk&lt;/a&gt;
by Daniel Spiewak on Functional
&lt;a href="http://en.wikipedia.org/wiki/Compiler" title="Compiler"&gt;Compilers&lt;/a&gt;. He talks
about lexical and &lt;a href="http://en.wikipedia.org/wiki/Compiler" title="Compiler"&gt;semantic
analysis&lt;/a&gt;
in particular.
First, problems with traditional
&lt;a href="http://en.wikipedia.org/wiki/Lexical_analysis" title="Lexical analysis"&gt;lexing&lt;/a&gt;
with scanner. You can only have regular tokens or you have do do some
dirty hacking and
&lt;a href="http://en.wikipedia.org/wiki/Stack_trace" title="Stack trace"&gt;backtrace&lt;/a&gt; the
scanner therefore losing linearity. And you can solve this with
&lt;a href="http://en.wikipedia.org/wiki/Scannerless_parsing" title="Scannerless parsing"&gt;scannerless
parsing&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;putting &lt;a href="http://en.wikipedia.org/wiki/Regular_expression" title="Regular expression"&gt;regular
expressions&lt;/a&gt;
into your grammar. In fact this approach seems simpler to me, as the
&lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;only proper parser I&amp;rsquo;ve
done&lt;/a&gt;
works this way. But this is not the interesting part.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="semantic-analysis"&gt;Semantic analysis&lt;/h3&gt;
&lt;p&gt;This is where fun kicks in. After you parse the &lt;a href="http://en.wikipedia.org/wiki/Source_code" title="Source code"&gt;source
code&lt;/a&gt; into an
&lt;a href="http://en.wikipedia.org/wiki/Abstract_syntax_tree" title="Abstract syntax tree"&gt;AST&lt;/a&gt;
you need to do a bunch of operations on it. Naming, typing(even
optimization in later phases). If I want to stay functional(which
usually I do) my instinct tells me to do recursive traversal and rewrite
the tree. And that&amp;rsquo;s exactly what my language does. But there is one
huge problem. AST is not a tree. It&amp;rsquo;s huge misnomer. AST is just a
&lt;a href="http://en.wikipedia.org/wiki/Spanning_tree" title="Spanning tree"&gt;spanning
tree&lt;/a&gt; in the
program graph. See, when you add stuff like let expressions, or
types(what I&amp;rsquo;m doing currently) you get problems&lt;/p&gt;</description></item><item><title>Nomadic programming</title><link>/posts/2012-11-23-nomadic-programming/</link><pubDate>Fri, 23 Nov 2012 00:00:00 +0000</pubDate><guid>/posts/2012-11-23-nomadic-programming/</guid><description>&lt;p&gt;DISCLAIMER: This is about my opinion.
And may or may not contain some boasting. And is also a bit of a brain
dump.&lt;/p&gt;
&lt;p&gt;Yep, this is not a typo. Not monadic but
&lt;a href="http://en.wikipedia.org/wiki/Nomad" title="Nomad"&gt;nomadic&lt;/a&gt;. Although monads
are cool too.
A few days ago the
&lt;a href="http://en.wikipedia.org/wiki/Chief_technology_officer" title="Chief technology officer"&gt;CTO&lt;/a&gt;
of a company I work for said it&amp;rsquo;s time to specialize. He was talking
about my career. Offering me a few things to try and then pick one. But
this got me thinking.
Today another CTO told me that I&amp;rsquo;m &amp;ldquo;essentially a good dev&amp;rdquo; and that
chosen
&lt;a href="http://en.wikipedia.org/wiki/Computer_software" title="Computer software"&gt;software&lt;/a&gt;
stack doesn&amp;rsquo;t matter. And I agree. (&lt;a href="http://www.kalzumeus.com/2011/10/28/dont-call-yourself-a-programmer/"&gt;Patrick does
too&lt;/a&gt;).&lt;/p&gt;</description></item><item><title>Cool Monday - CERC and my trip to Krakow</title><link>/posts/2012-11-19-cerc/</link><pubDate>Mon, 19 Nov 2012 00:00:00 +0000</pubDate><guid>/posts/2012-11-19-cerc/</guid><description>&lt;p&gt;This week&amp;rsquo;s post is a bit different. Well very different. My team
qualified for &lt;a href="http://icpc.baylor.edu/public/worldMap/1317"&gt;CERC ICPC&lt;/a&gt;(european programming
contest) and that means a trip to &lt;a href="http://maps.google.com/maps?ll=50.0613888889,19.9383333333&amp;amp;spn=0.1,0.1&amp;amp;q=50.0613888889,19.9383333333%20(Krak%C3%B3w)&amp;amp;t=h" title="Kraków"&gt;Krakow,
Poland&lt;/a&gt;.
I plan on writing this in a journal style. A bit every day.&lt;/p&gt;
&lt;h3 id="friday-11-am"&gt;Friday, 11. am&lt;/h3&gt;
&lt;p&gt;I got up at 6. to check news and read a bit before departing. And of
course to charge my laptop and phone to 100% batter for the long trip.
Then a 10 minute walk across
&lt;a href="http://maps.google.com/maps?ll=46.0555555556,14.5083333333&amp;amp;spn=0.1,0.1&amp;amp;q=46.0555555556,14.5083333333%20(Ljubljana)&amp;amp;t=h" title="Ljubljana"&gt;Ljubljana&lt;/a&gt;(quite
cold outside) and bus left at 7.15am. Yes, we&amp;rsquo;re riding a bus. And we
will be riding this bus for quite some time. Approximately 12 hours
total! I guess it would be cheaper to buy plane tickets for low end
jet-line than renting a bus(and two drivers) for whole weekend. Not to
mention faster. Twelve hours!!&lt;/p&gt;</description></item><item><title>Why Linux will never win the desktop</title><link>/posts/2012-11-17-y-u-no-linux/</link><pubDate>Sat, 17 Nov 2012 00:00:00 +0000</pubDate><guid>/posts/2012-11-17-y-u-no-linux/</guid><description>&lt;p&gt;Don&amp;rsquo;t get me wrong, I&amp;rsquo;m a huge linux fan. I use it on all my
machines(even my phone,
&lt;a href="http://www.t-mobile.com/shop/phones/?capcode=AGE" title="Android phones"&gt;Android&lt;/a&gt;
is basically linux) and even converted my sister and a few friends. But
if you don&amp;rsquo;t convert somebody, chance they&amp;rsquo;ll try a new operating system
is slim to none. Only geeks like me install funky stuff as their primary
software just to try it.
But the major problem lies somewhere else. &lt;strong&gt;People hate making
choices.&lt;/strong&gt; And linux is all about cohice. It gives you power and you
choose what you&amp;rsquo;ll do with it. And it starts with selecting selecting
distribution.&lt;/p&gt;</description></item><item><title>Cool Monday - Scala Macros</title><link>/posts/2012-11-12-scala-macros/</link><pubDate>Mon, 12 Nov 2012 00:00:00 +0000</pubDate><guid>/posts/2012-11-12-scala-macros/</guid><description>&lt;p&gt;&lt;a href="http://commons.wikipedia.org/wiki/File%3AGarden_flower_.jpg"&gt;&lt;img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Garden_flower_.jpg/300px-Garden_flower_.jpg" alt="Garden flower"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For me the highlight of this week was discovering Bootstrap. I heard of
it before but never looked into it. Probably because I wasn&amp;rsquo;t doing web
stuff. The thing is bloody awesome. Back on topic.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.scala-lang.org/" title="Scala (programming language)"&gt;Scala&lt;/a&gt; 2.10
RC2 was released this Friday. Considering 2.9 had 3 RC releases, 2.10
final is probably quite near. And it brings some awesome features. One2
of them are
&lt;a href="http://en.wikipedia.org/wiki/Macro_%28computer_science%29" title="Macro (computer science)"&gt;macros&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Cool Monday - Hindley-Milner on a dynamic language</title><link>/posts/2012-11-05-hindley-milner/</link><pubDate>Mon, 05 Nov 2012 00:00:00 +0000</pubDate><guid>/posts/2012-11-05-hindley-milner/</guid><description>&lt;p&gt;So I&amp;rsquo;m getting into type theory. Slowly. Note to self: read a proper
book on this topic. I&amp;rsquo;m getting familiar with it through some practical
applications. Namely scala and haskell. &lt;/p&gt;
&lt;p&gt;That same &lt;a href="/posts/2012-10-29-design-patterns-bullshit"&gt;discussion about design
patterns&lt;/a&gt; also
included dynamic vs &lt;a href="http://en.wikipedia.org/wiki/Type_system" title="Type system"&gt;static
typing&lt;/a&gt;. And I
asked twitter about it. &lt;a href="https://twitter.com/HairyFotr"&gt;HairyFotr&lt;/a&gt; linked
this &lt;a href="http://screencasts.chariotsolutions.com/uncovering-the-unknown-principles-of-type-inference-"&gt;amazing talk about type
inference&lt;/a&gt;
to me. Basically there are two conclusions to be drawn&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Every static typed language should have at least limited type
&lt;a href="http://en.wikipedia.org/wiki/Inference" title="Inference"&gt;inference&lt;/a&gt;.
It&amp;rsquo;s compiler&amp;rsquo;s job to do so and quite trivial to implement.&lt;/li&gt;
&lt;li&gt;Properly done static typed language provides all features the that
dynamic typed languages can. Safely.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As I&amp;rsquo;m (still) &lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;implementing a
language&lt;/a&gt; that
happens to be dynamic(because I was too lazy to look-up how to do type
checking) second point interests me more. &lt;/p&gt;</description></item><item><title>Hunt for a web framework that works</title><link>/posts/2012-11-02-web-framework/</link><pubDate>Fri, 02 Nov 2012 00:00:00 +0000</pubDate><guid>/posts/2012-11-02-web-framework/</guid><description>&lt;p&gt;I have this personal project I want to do that includes a web
application and I want to learn something. So I&amp;rsquo;m on the hunt for
language, environment and framework.&lt;/p&gt;
&lt;h3 id="other-stuff"&gt;Other stuff&lt;/h3&gt;
&lt;p&gt;I did some &lt;a href="http://www.php.net/" title="PHP"&gt;PHP&lt;/a&gt; a few years back
and definitely don&amp;rsquo;t want to go there anymore. I also did some
&lt;a href="http://msdn.microsoft.com/netframework" title=".NET Framework"&gt;.NET&lt;/a&gt; and it&amp;rsquo;s
even part of curriculum here at FRI. But clicking on wizards in &lt;a href="http://www.microsoft.com/visualstudio/en-us" title="Microsoft Visual Studio"&gt;Visual
Studio&lt;/a&gt;
feels weird to me. Not like development should be done. And I also use
GNU/Linux as my primary(and only)
&lt;a href="http://en.wikipedia.org/wiki/Operating_system" title="Operating system"&gt;OS&lt;/a&gt;,
so that&amp;rsquo;s out of the water. I did read about &lt;a href="http://en.wikipedia.org/wiki/JavaServer_Pages" title="JavaServer Pages"&gt;java server
pages&lt;/a&gt;
and faces and even tried few things out. But luckily I didn&amp;rsquo;t get to do
this project I was preparing for and I didn&amp;rsquo;t need it. It looked ugly
anyway. I did some flirting with
&lt;a href="http://code.google.com/webtoolkit" title="Google Web Toolkit"&gt;GWT&lt;/a&gt;, does that
even count as a web framework? &lt;/p&gt;</description></item><item><title>Cool Monday - HList and Shapeless</title><link>/posts/2012-10-29-hlist-shapeless/</link><pubDate>Mon, 29 Oct 2012 00:00:00 +0000</pubDate><guid>/posts/2012-10-29-hlist-shapeless/</guid><description>&lt;p&gt;HList as in
&lt;a href="http://en.wikipedia.org/wiki/Homogeneity_and_heterogeneity" title="Homogeneity and heterogeneity"&gt;heterogenous&lt;/a&gt;
lists. This means every element is of different type. Yeah sure, just
list List in Java, but that is in no way typesafe. I want compiler to know the
type of every element and stop me if I try to do something silly.&lt;/p&gt;
&lt;h3 id="linked-lists-to-the-rescue"&gt;Linked lists to the rescue&lt;/h3&gt;
&lt;p&gt;So what&amp;rsquo;s a &lt;a href="http://en.wikipedia.org/wiki/Linked_list" title="Linked list"&gt;linked
list&lt;/a&gt; anyway? A
sequence of nodes with pointers to next. And a nice implementation(still
talking
&lt;a href="http://www.oracle.com/technetwork/java/" title="Java (programming language)"&gt;Java&lt;/a&gt;
here) would be generic to allow
&lt;a href="http://en.wikipedia.org/wiki/Type_safety" title="Type safety"&gt;type-safety&lt;/a&gt;
for homogeneous lists. It turns out generics are solution for HLists too.
Just introduce additional &lt;a href="http://en.wikipedia.org/wiki/TypeParameter" title="TypeParameter"&gt;type
parameter&lt;/a&gt;.
Apocalisp has a &lt;a href="http://apocalisp.wordpress.com/2008/10/23/heterogeneous-lists-and-the-limits-of-the-java-type-system/"&gt;great
post&lt;/a&gt;
on implementing them in Java.
Java requires A LOT of &lt;a href="http://en.wikipedia.org/wiki/Type_signature" title="Type signature"&gt;type
annotation&lt;/a&gt;.
It works but it&amp;rsquo;s just painful and it doesn&amp;rsquo;t pay off.&lt;/p&gt;</description></item><item><title>Design patterns are bullshit!</title><link>/posts/2012-10-29-design-patterns-bullshit/</link><pubDate>Mon, 29 Oct 2012 00:00:00 +0000</pubDate><guid>/posts/2012-10-29-design-patterns-bullshit/</guid><description>&lt;p&gt;It all started Monday
morning at college. Professor of &lt;a href="http://en.wikipedia.org/wiki/Information_systems" title="Information systems"&gt;Information
Systems&lt;/a&gt;
was talking about evolution of programming techniques and at the end of
the chain was
&lt;a href="http://en.wikipedia.org/wiki/Object-oriented_programming" title="Object-oriented programming"&gt;OOP&lt;/a&gt;.
The pinnacle of program design. Well, no. Even professor admitted that
OOP failed to deliver. (No word on
&lt;a href="http://en.wikipedia.org/wiki/Functional_programming" title="Functional programming"&gt;FP&lt;/a&gt;
though, I was kinda disappointing). This made me think about problems
of&lt;a href="http://www.oracle.com/technetwork/java/" title="Java (programming language)"&gt;Java&lt;/a&gt;
and the like.
Some hours later I&amp;rsquo;m sitting in cafe Metropol above
&lt;a href="http://maps.google.com/maps?ll=46.056184,14.503798&amp;amp;spn=0.005,0.005&amp;amp;q=46.056184,14.503798%20(Kiberpipa)&amp;amp;t=h" title="Kiberpipa"&gt;Kiberpipa&lt;/a&gt;
having tea with some friends - freshmen from FRI. And one of them asks
me if there is a class on &lt;a href="http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29" title="Design pattern (computer science)"&gt;design
patterns&lt;/a&gt;.
I give a puzzled look and say no and he goes on to explain he&amp;rsquo;s
currently reading &lt;a href="http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29" title="Design pattern (computer science)"&gt;Design
Patterns&lt;/a&gt;
in C#. Apparently an awesome book that teaches you some general
approaches to problems.
But I have quite strong opinions on some topics. And one of them are
design patterns. I believe they are bullshit and I said that. I didn&amp;rsquo;t
read the GoF book and I don&amp;rsquo;t have any intention to do so in near
future. But I&amp;rsquo;m familiar with some patterns. Mostly workarounds for
shortcomings of OOP languages and contrived solutions to non-existent
problems. And I explained this.
Response was to paraphrase: &amp;ldquo;Well, MVC is a great design pattern&amp;rdquo;. But I
argued that it isn&amp;rsquo;t a design pattern at all. Since everybody had a
laptop, a quick wiki search cleared this up. It&amp;rsquo;s an &lt;a href="http://en.wikipedia.org/wiki/Architectural_pattern" title="Architectural pattern"&gt;architectural
pattern&lt;/a&gt;.
Not a design pattern.&lt;/p&gt;</description></item><item><title>Setting up for scala development on Android</title><link>/posts/2012-10-22-scala-android/</link><pubDate>Mon, 22 Oct 2012 00:00:00 +0000</pubDate><guid>/posts/2012-10-22-scala-android/</guid><description>&lt;p&gt;&lt;a href="http://www.crunchbase.com/product/android"&gt;&lt;img src="http://www.crunchbase.com/assets/images/resized/0001/4601/14601v1-max-450x450.png" alt="Image representing Android as depicted in Crun&amp;hellip;"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/File%3AScala_logo.png"&gt;&lt;img src="http://upload.wikimedia.org/wikipedia/en/thumb/8/85/Scala_logo.png/300px-Scala_logo.png" alt="Scala (programming language)"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve been developing for android more than a year now and a few months
in scala. So naturally I wanted to combine the two. But it&amp;rsquo;s not dead
simple. This is kinda a tutorial an a reference if I ever forget how to
do this. It took me a few days to figure it all out. I tried maven, ant
with special config and sbt(I need to learn more about this one) but in
the end I just wanted fast solution integrated into my IDE.&lt;/p&gt;</description></item><item><title>Javascript faster than light! (well C actually)</title><link>/posts/2012-10-21-javascript-ftl/</link><pubDate>Sun, 21 Oct 2012 00:00:00 +0000</pubDate><guid>/posts/2012-10-21-javascript-ftl/</guid><description>&lt;p&gt;&lt;a href="http://www.flickr.com/photos/42149364@N03/6772086623"&gt;&lt;img src="http://farm8.static.flickr.com/7156/6772086623_646ee6ab31_m.jpg" alt="157/365. Acorn - Oak Nut - The Scrat Problem."&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Disclaimer: I never was a fan of js, but I&amp;rsquo;ve come to think it&amp;rsquo;s quite
AWESOME!&lt;/p&gt;
&lt;p&gt;Anyway I &lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;invented my own toy language
scrat&lt;/a&gt;
recently. And I now I want it to go fast and do cool stuff. So I went on
to compile it. Well more appropriate term would be
&amp;ldquo;&lt;a href="http://en.wikipedia.org/wiki/Translation" title="Translation"&gt;translate&lt;/a&gt;&amp;quot;(as
&lt;a href="https://twitter.com/zidarsk8"&gt;zidarsk8&lt;/a&gt; pointed out) since my target is
&lt;a href="http://en.wikipedia.org/wiki/JavaScript" title="JavaScript"&gt;JavaScript&lt;/a&gt;. And
then I use node.js to run it - browser test sometime in the future.
Enough about that, I&amp;rsquo;ll be doing a post when I get everything to run
under js.&lt;/p&gt;</description></item><item><title>Making a programming language Part 7b - using objects</title><link>/posts/2012-10-08-creating-a-language-7b/</link><pubDate>Mon, 08 Oct 2012 00:00:00 +0000</pubDate><guid>/posts/2012-10-08-creating-a-language-7b/</guid><description>&lt;p&gt;&lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;Table of contents&lt;/a&gt;, 
&lt;a href="https://github.com/edofic/scrat-lang"&gt;Whole project on github&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Something like EPIC FAIL occured to me and I &lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;published a post&lt;/a&gt;
containing only half the content I intended to write. So I&amp;rsquo;m doing a
part b.&lt;/p&gt;
&lt;p&gt;My intended usage of objects is something along the lines of&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;objectName.someProperty
objectName.someFunction()
someFunction().someProperty
someObject.someProperty.someFunction().someProperty.someFunction
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Explanation&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;getting a value from an
&lt;a href="http://en.wikipedia.org/wiki/Object_%28computer_science%29" title="Object (computer science)"&gt;object&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;invoking a function contained in an object&lt;/li&gt;
&lt;li&gt;getting a value from returned object of the invoked function&lt;/li&gt;
&lt;li&gt;a bit contrived example. Invoking a function contained inside a
property(object) of an object and then getting a &lt;a href="http://en.wikipedia.org/wiki/Function_%28mathematics%29" title="Function (mathematics)"&gt;function
value&lt;/a&gt;
from a property of the returned value from the first function.
That&amp;rsquo;s a mouthful, just read the damn code instead&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="dot-access"&gt;Dot access&lt;/h3&gt;
&lt;p&gt;So everything bases on those little dots. First my thoughts were
something like &amp;ldquo;you just do expr &amp;lt;- expr | expr.expr&amp;rdquo;. This is just
wrong. At least I should have reversed the order as this leads to
infinite &lt;a href="http://en.wikipedia.org/wiki/Left_recursion" title="Left recursion"&gt;left
recursion&lt;/a&gt;.
Then I might have got away. Then I realized I only need dots after
function calls and simple identifiers. Design choice(if you think it&amp;rsquo;s a
bad one leave a comment). Notice the &amp;ldquo;simple
&lt;a href="http://en.wikipedia.org/wiki/Identifier" title="Identifier"&gt;identifier&lt;/a&gt;&amp;rdquo;.
That&amp;rsquo;s what I did: Renamed identifier to simple identifier and put
something that handles dots under name identifier. And then fixed
everything. &lt;/p&gt;</description></item><item><title>Making a programming language Part 8 - going faster</title><link>/posts/2012-09-29-creating-a-language-8/</link><pubDate>Sat, 29 Sep 2012 00:00:00 +0000</pubDate><guid>/posts/2012-09-29-creating-a-language-8/</guid><description>&lt;p&gt;&lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;Table of contents&lt;/a&gt;, 
&lt;a href="https://github.com/edofic/scrat-lang"&gt;Whole project on github&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;First of all, I wrote some tests for scrat. That was a bit challenging
to get started. How do you test a language? I decided to write a bunch
of programs that exercise and combine different language features. And
then stare into code until I was absolutely sure they are correct.
That&amp;rsquo;s the problem with implementing a new language, nobody can tell you
if your code is correct but your software, but you don&amp;rsquo;t even know if
software is correct.
So I wrote some test programs and
&lt;a href="http://en.wikipedia.org/wiki/Parsing" title="Parsing"&gt;parsed&lt;/a&gt; and evaluated
them in my mind to produce final result. And then I wrote a class using
ScalaTest that generates tests by iterating over the array of these
&lt;a href="http://en.wikipedia.org/wiki/Tuple" title="Tuple"&gt;tuples&lt;/a&gt;. Quite cool, oh and
I also included some descriptions into the tuples. So I get nice output.
I pondered this idea quite some time ago but finally implemented it a
bit after functions and objects.&lt;/p&gt;</description></item><item><title>Making a programming language Part 7a - objects</title><link>/posts/2012-09-27-creating-a-language-7a/</link><pubDate>Thu, 27 Sep 2012 00:00:00 +0000</pubDate><guid>/posts/2012-09-27-creating-a-language-7a/</guid><description>&lt;p&gt;&lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;Table of contents&lt;/a&gt;, 
&lt;a href="https://github.com/edofic/scrat-lang"&gt;Whole project on github&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;My goal in this post is for this to compile&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;func create(n){this}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and a call to it to return a reference to an
&lt;a href="http://en.wikipedia.org/wiki/Object_%28computer_science%29" title="Object (computer science)"&gt;object&lt;/a&gt;
that contains &amp;ldquo;n&amp;rdquo;. Functions are a bit different from the rest of the
language. Not by
&lt;a href="http://en.wikipedia.org/wiki/Implementation" title="Implementation"&gt;implementation&lt;/a&gt;
or usage but by &lt;a href="http://en.wikipedia.org/wiki/Thought" title="Thought"&gt;thought
process&lt;/a&gt; behind
designing them. I actually thought about objects and
&lt;a href="http://en.wikipedia.org/wiki/Function_%28mathematics%29" title="Function (mathematics)"&gt;functions&lt;/a&gt;
before implementing any of them. Considering my implementation of
scopes(which I like) and shadowing I got this great idea that functions,
scopes and objects are just many faces of the same thing. Or &amp;ldquo;could be&amp;rdquo;
many faces of the same thing. Something a bit more powerful than a
function being the &amp;ldquo;thing&amp;rdquo;. Let&amp;rsquo;s see how that works. A function in this
language needs a new &lt;a href="http://en.wikipedia.org/wiki/Local_variable" title="Local variable"&gt;local
scope&lt;/a&gt; for
every execution(not all functions, but this is a simplification because
I don&amp;rsquo;t care about performance, see &lt;a href="/posts/2012-09-25-creating-a-language-6"&gt;previous
post&lt;/a&gt;
for details). New scope. New something. New. Bells should be ringing
right now. I&amp;rsquo;m creating objects. I could just as well pass the reference
to that object. I even have the reference. It&amp;rsquo;s current scope - &amp;ldquo;this&amp;rdquo;
in scala code. So I just need a &lt;a href="http://en.wikipedia.org/wiki/Language_construct" title="Language construct"&gt;language
construct&lt;/a&gt;
to access that. How about &amp;ldquo;this&amp;rdquo;.&lt;/p&gt;</description></item><item><title>Making a programming language Part 6 - functions</title><link>/posts/2012-09-25-creating-a-language-6/</link><pubDate>Tue, 25 Sep 2012 00:00:00 +0000</pubDate><guid>/posts/2012-09-25-creating-a-language-6/</guid><description>&lt;p&gt;&lt;a href="http://commons.wikipedia.org/wiki/File%3AFunction_illustration.svg"&gt;&lt;img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Function_illustration.svg/200px-Function_illustration.svg.png" alt="Illustration of Function (mathematics)."&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;Table of contents&lt;/a&gt;,
&lt;a href="https://github.com/edofic/scrat-lang"&gt;Whole project on github&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Long overdue, I&amp;rsquo;m finally writing about the most interesting part -
&lt;a href="http://en.wikipedia.org/wiki/User-defined_function" title="User-defined function"&gt;user defined functions&lt;/a&gt;.
Objects should be in the next post as they are a natural extension of
what I&amp;rsquo;m about to do. And because I&amp;rsquo;m to lazy to write a post that
long.&lt;/p&gt;
&lt;h3 id="whats-a-function"&gt;What&amp;rsquo;s a function?&lt;/h3&gt;
&lt;p&gt;A function is something that takes parameters and returns a result. And
I&amp;rsquo;m opting for side-effects as this is simpler to get something working
that doing the whole &lt;a href="http://en.wikipedia.org/wiki/Referential_transparency_%28computer_science%29" title="Referential transparency (computer science)"&gt;referential
transparency&lt;/a&gt;
and
&lt;a href="http://en.wikipedia.org/wiki/Io_%28programming_language%29" title="Io (programming language)"&gt;IO&lt;/a&gt;
&lt;a href="http://en.wikipedia.org/wiki/Monad_%28functional_programming%29" title="Monad (functional programming)"&gt;monad(Haskell)&lt;/a&gt;.
Although it would be interesting to have sort of &lt;a href="http://en.wikipedia.org/wiki/Type_system" title="Type system"&gt;dynamically
typed&lt;/a&gt;
&lt;a href="http://haskell.org/" title="Haskell (programming language)"&gt;Haskell&lt;/a&gt;
thingy&amp;hellip;maybe in the future. &lt;/p&gt;</description></item><item><title>Power sets</title><link>/posts/2012-09-21-power-sets/</link><pubDate>Fri, 21 Sep 2012 00:00:00 +0000</pubDate><guid>/posts/2012-09-21-power-sets/</guid><description>&lt;p&gt;It all started out when a friend of mine(&lt;a href="http://naspletu.org/"&gt;check him out&lt;/a&gt;)
told me a story about someone having an
interview at &lt;a href="http://google.com/" title="Google"&gt;Google&lt;/a&gt;. He was &lt;a href="http://en.wikipedia.org/wiki/Live_coding" title="Live coding"&gt;live
coding&lt;/a&gt; and
asked to implement a function that computes a &lt;a href="http://en.wikipedia.org/wiki/Power_set" title="Power set"&gt;power
set&lt;/a&gt; of a given set.
He totaly over-engineered it and after an hour of fiddling came up with
4-liner in python. Ok. Big deal. How hard can it be? I immediately
started to brainstorm a solution of my own(and Matevž helped).
Paraphrased train of thought below.
So what is a power set? Say a power set of set A. It&amp;rsquo;s a set of all
&lt;a href="http://en.wikipedia.org/wiki/Subset" title="Subset"&gt;subsets&lt;/a&gt; of A. It&amp;rsquo;s all
possible combinations of including and excluding single elements. So
it&amp;rsquo;s like applying filters to the original set. Wait a sec, a set of
size n has 2 to the n-th power subsets. It all matches up. N-bit number
are said filters. So you count from 0 to 2^n-1 you enumerate exactly
all the filters and therefore all the subsets. You just calculated the
power set. This took about 30sec in real time. Another minute to sketch
the implementation. You implement set as Lists. Let&amp;rsquo;s say
&lt;a href="http://www.oracle.com/technetwork/java/" title="Java (programming language)"&gt;Java&lt;/a&gt;
is the language of choice. Any reasonable input would be shorter than
64 elements, at least on current machinery. So long can be used as
counter. And now a nested for loop to iterate over elements and
appending them if counter &amp;amp;&amp;amp; (1 &amp;laquo; n). Simple. Won&amp;rsquo;t post the code
since I never wrote it.&lt;/p&gt;</description></item><item><title>Pretty function composition in scala and asynchronous function composition on android</title><link>/posts/2012-09-17-composition/</link><pubDate>Mon, 17 Sep 2012 00:00:00 +0000</pubDate><guid>/posts/2012-09-17-composition/</guid><description>&lt;p&gt;&lt;a href="http://commons.wikipedia.org/wiki/File%3ASurjective_composition.svg"&gt;&lt;img src="http://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Surjective_composition.svg/300px-Surjective_composition.svg.png" alt="Surjective composition: the first function nee&amp;hellip;"&gt;&lt;/a&gt;
Surjective composition: the first function need not be surjective. (Photo credit: &lt;a href="http://commons.wikipedia.org/wiki/File%3ASurjective_composition.svg"&gt;Wikipedia&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;Function composition is a nice way to sequence transformations on data.
For example in a
&lt;a href="http://en.wikipedia.org/wiki/Compiler" title="Compiler"&gt;compiler&lt;/a&gt; you take
your source, &lt;a href="http://en.wikipedia.org/wiki/Parsing" title="Parsing"&gt;parse&lt;/a&gt;,
check, optimize and generate code(in a nutshell). It&amp;rsquo;s a linear series
of transformations -&amp;gt; perfect for &lt;a href="http://en.wikipedia.org/wiki/Function_composition" title="Function composition"&gt;function
composition&lt;/a&gt;
In &lt;a href="http://haskell.org/" title="Haskell (programming language)"&gt;Haskell&lt;/a&gt; you
can use this beautiful
&lt;a href="http://en.wikipedia.org/wiki/Syntax" title="Syntax"&gt;syntax&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code class="language-haskell" data-lang="haskell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;compile&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; codegen &lt;span style="color:#f92672"&gt;.&lt;/span&gt; optimize &lt;span style="color:#f92672"&gt;.&lt;/span&gt;check &lt;span style="color:#f92672"&gt;.&lt;/span&gt; parse
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;leaving out the parameters and noting composition
as &amp;ldquo;.&amp;rdquo; which kinda looks like ° used in math(if you squint a bit). In
scala you could do something like&lt;/p&gt;</description></item><item><title>Making a programming language Part 5 - variables and decisions</title><link>/posts/2012-09-02-creating-a-language-5/</link><pubDate>Sun, 02 Sep 2012 00:00:00 +0000</pubDate><guid>/posts/2012-09-02-creating-a-language-5/</guid><description>&lt;p&gt;&lt;a href="http://commons.wikipedia.org/wiki/File%3AStdstreams-notitle.svg"&gt;&lt;img src="http://upload.wikimedia.org/wikipedia/commons/thumb/7/70/Stdstreams-notitle.svg/300px-Stdstreams-notitle.svg.png" alt="A typical text terminal produces input and dis&amp;hellip;"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;Table of contents&lt;/a&gt;, 
&lt;a href="https://github.com/edofic/scrat-lang"&gt;Whole project on github&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In &lt;a href="/posts/2012-09-01-creating-a-language4"&gt;Part 4&lt;/a&gt; I
managed to create a &lt;a href="http://en.wikipedia.org/wiki/Hello_world_program" title="Hello world program"&gt;Hello World&lt;/a&gt;.
What&amp;rsquo;s the next program after this in every programming tutorial? A
program that asks your name and greets you. Greeter perhaps?&lt;/p&gt;
&lt;p&gt;Reading from &lt;a href="http://en.wikipedia.org/wiki/Standard_streams" title="Standard streams"&gt;standard
input&lt;/a&gt;
in pretty trivial, just wrapping up readLine
&lt;a href="http://en.wikipedia.org/wiki/Function_%28mathematics%29" title="Function (mathematics)"&gt;function&lt;/a&gt;
from scala, see previous post on how this is done. And I called this
function readln.&lt;/p&gt;</description></item><item><title>Making a programming language Part 4 - Hello World</title><link>/posts/2012-09-01-creating-a-language4/</link><pubDate>Sat, 01 Sep 2012 00:00:00 +0000</pubDate><guid>/posts/2012-09-01-creating-a-language4/</guid><description>&lt;p&gt;&lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;Table of
contents&lt;/a&gt;,
&lt;a href="https://github.com/edofic/scrat-lang"&gt;Whole project on github&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;What good is a language if you cannot do a &lt;a href="http://en.wikipedia.org/wiki/Hello_world_program" title="Hello world program"&gt;Hello World
program&lt;/a&gt;.
Every tutorial on every language I ever read has a Hello World in it
somewhere, even if it&amp;rsquo;s a convoluted and sarcastic one.&lt;/p&gt;
&lt;p&gt;So what do I need?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a way to print stuff to console &lt;/li&gt;
&lt;li&gt;strings&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In that order. Since this is more of a math lang for now my first hello
world can just print 1 - arguably the simplest number.&lt;/p&gt;</description></item><item><title>Making a programming language Part 3 - adding features</title><link>/posts/2012-08-31-creating-a-language3/</link><pubDate>Fri, 31 Aug 2012 00:00:00 +0000</pubDate><guid>/posts/2012-08-31-creating-a-language3/</guid><description>&lt;p&gt;&lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;Table of
contents&lt;/a&gt;, 
&lt;a href="https://github.com/edofic/scrat-lang"&gt;Whole project on github&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So now I have a repl that can evaluate stuff like&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(2+3)*(7/2-1)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Not much of a &lt;a href="http://en.wikipedia.org/wiki/Programming_language" title="Programming language"&gt;programming language&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;more like a calculator, and not even a good one. Lets add some
features!&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="constants"&gt;Constants&lt;/h3&gt;
&lt;p&gt;Like pi, e and such. I have to change the grammar to match identifiers too.&lt;/p&gt;
&lt;p&gt;Now I have&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code class="language-scala" data-lang="scala"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;private&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; factor&lt;span style="color:#66d9ef"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;Parser&lt;/span&gt;&lt;span style="color:#f92672"&gt;[&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;Expression&lt;/span&gt;&lt;span style="color:#f92672"&gt;]&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;=&lt;/span&gt; number &lt;span style="color:#f92672"&gt;|&lt;/span&gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;(&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;~&amp;gt;&lt;/span&gt; expr &lt;span style="color:#f92672"&gt;&amp;lt;~&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;)&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;And I change that to&lt;/p&gt;</description></item><item><title>Making a programming language Part 2 - something that kinda works</title><link>/posts/2012-08-30-creating-a-language-2/</link><pubDate>Thu, 30 Aug 2012 00:00:00 +0000</pubDate><guid>/posts/2012-08-30-creating-a-language-2/</guid><description>&lt;p&gt;&lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;Table of contents&lt;/a&gt;,
&lt;a href="https://github.com/edofic/scrat-lang"&gt;Whole project on github&lt;/a&gt;,
&lt;a href="https://github.com/edofic/scrat-lang/tree/blogpost1and2"&gt;relevant version on github&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In the &lt;a href="/posts/2012-08-29-creating-a-language-1"&gt;Part 1&lt;/a&gt; I posted a working
repl(&lt;a href="http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop" title="Read–eval–print loop"&gt;read-eval-print-loop&lt;/a&gt;)
for simple math expressions but I kinda cheated and only explained how I
built the &lt;a href="http://en.wikipedia.org/wiki/Abstract_syntax_tree" title="Abstract syntax tree"&gt;AST&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id="ast-elements"&gt;AST elements&lt;/h3&gt;
&lt;p&gt;Just &lt;a href="http://www.scala-lang.org/" title="Scala (programming language)"&gt;scala&lt;/a&gt; case classes&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;1
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;2
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;3
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;4
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;5
&lt;/span&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;6
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"&gt;&lt;code class="language-scala" data-lang="scala"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;sealed&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;trait&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Expression&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;case&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Number&lt;/span&gt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;n&lt;span style="color:#66d9ef"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;Double&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;extends&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Expression&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;case&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Add&lt;/span&gt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;left&lt;span style="color:#66d9ef"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;Expression&lt;/span&gt;&lt;span style="color:#f92672"&gt;,&lt;/span&gt; right&lt;span style="color:#66d9ef"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;Expression&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;extends&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Expression&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;case&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Subtract&lt;/span&gt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;left&lt;span style="color:#66d9ef"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;Expression&lt;/span&gt;&lt;span style="color:#f92672"&gt;,&lt;/span&gt; right&lt;span style="color:#66d9ef"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;Expression&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;extends&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Expression&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;case&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Multiply&lt;/span&gt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;left&lt;span style="color:#66d9ef"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;Expression&lt;/span&gt;&lt;span style="color:#f92672"&gt;,&lt;/span&gt; right&lt;span style="color:#66d9ef"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;Expression&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;extends&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Expression&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;case&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Divide&lt;/span&gt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;left&lt;span style="color:#66d9ef"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;Expression&lt;/span&gt;&lt;span style="color:#f92672"&gt;,&lt;/span&gt; right&lt;span style="color:#66d9ef"&gt;:&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;Expression&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;extends&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Expression&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h3 id="parser-combinators-revisited"&gt;&lt;a href="http://en.wikipedia.org/wiki/Parser_combinator" title="Parser combinator"&gt;Parser combinators&lt;/a&gt; revisited&lt;/h3&gt;
&lt;p&gt;I use power of scala library to cheat a bit and do lexing and
&lt;a href="http://en.wikipedia.org/wiki/Parsing" title="Parsing"&gt;parsing&lt;/a&gt; in one
step.Basic parser combinators from scala api documentation, everything
you need to define productions in your grammar.&lt;/p&gt;</description></item><item><title>Making a programming language Part 1 - how to start</title><link>/posts/2012-08-29-creating-a-language-1/</link><pubDate>Wed, 29 Aug 2012 00:00:00 +0000</pubDate><guid>/posts/2012-08-29-creating-a-language-1/</guid><description>&lt;h3 id="table-of-contents"&gt;Table of contents&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Part 1 - how to start (this article)&lt;/li&gt;
&lt;li&gt;&lt;a href="/posts/2012-08-30-creating-a-language-2"&gt;Part 2 - something that kinda works&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/posts/2012-08-31-creating-a-language3"&gt;Part 3 - adding features&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/posts/2012-09-01-creating-a-language4"&gt;Part 4 - Hello World&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/posts/2012-09-02-creating-a-language-5"&gt;Part 5 - variables and decisions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/posts/2012-09-25-creating-a-language-6"&gt;Part 6 - user defined functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/posts/2012-09-27-creating-a-language-7a"&gt;Part 7a - constructors and objects&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/posts/2012-10-08-creating-a-language-7b"&gt;Part 7b - using objects&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/posts/2012-09-29-creating-a-language-8"&gt;Part 8 - going faster&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="source-version-for-this-post"&gt;&lt;a href="https://github.com/edofic/scrat-lang/tree/blogpost1and2"&gt;Source version for this post&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Lately I gained some interest in &lt;a href="http://en.wikipedia.org/wiki/Programming_language" title="Programming language"&gt;programming
languages&lt;/a&gt;
and &lt;a href="http://en.wikipedia.org/wiki/Compiler" title="Compiler"&gt;compilers&lt;/a&gt;. Those
seem like quite some daunting monsters - just consider the amount of
different features and more importantly, the vast infinity of possible
programs.So where to start? I have a course about compilers at my
college, but I have to wait another year to enroll into that. So welcome
&lt;a href="https://www.coursera.org/course/compilers"&gt;Coursera&lt;/a&gt;. It&amp;rsquo;s currently
available only in self-study but that&amp;rsquo;s enough for me. I should mention
the &lt;a href="http://www.amazon.com/Compilers-Principles-Techniques-Alfred-Aho/dp/0201100886%3FSubscriptionId%3D0G81C5DAZ03ZR9WH9X82%26tag%3Dzem-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0201100886" title="Compilers: Principles, Techniques, and Tools"&gt;Dragon
Book&lt;/a&gt;,
but I didn&amp;rsquo;t read that(yet) so I can&amp;rsquo;t comment. Compiler is basicaly
&lt;code&gt;lexer -&amp;gt; parser -&amp;gt; optimiser -&amp;gt; code generator&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>About me</title><link>/about/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/about/</guid><description>&lt;p&gt;My name is Andraz and I work as a software engineer. Sometimes writing code
(mostly Go) but mostly telling others what and how to write. But more
importantly I&amp;rsquo;m a curious human. And when I feel like it I write about my
explorations here on this blog.&lt;/p&gt;
&lt;p&gt;In my free time I&amp;rsquo;m often playing around with various statically-typed
functional programming &amp;ldquo;things&amp;rdquo;. But work has also led me in the direction of
distributed systems and low latency which both turned out of great interest as
well.&lt;/p&gt;</description></item></channel></rss>