All posts tagged compilers

The release of Kotlin 1.1 brings many welcome improvements to the language: val properties with custom getters can take full advantage of type inference and inlining; they introduced the T.also { it -> } extension method, which is to T.apply {} what T.let { it -> } is to {}; and data classes can inherit from interfaces and base classes, just to name a few. But the two biggest changes are full support for JavaScript as a compilation target (possibly a huge deal, if you’re a full stack dev and reluctantly work with JavaScript), and coroutines(!!!).

Continue Reading

If you’re like me, you’ve grudgingly put up with Java for years, for the sake of getting things done on Android. With Kotlin picking up steam as a viable, modern alternative, things are looking much better for all of us. Whenever possible, I do all my Android work in Kotlin.

To reap the fullest benefits of Kotlin, though, we can’t just fall back on old habits; it’s very easy to write code in a familiar Java style. In fact, allowing this was a design goal of Kotlin, to make it easier to transition between languages. But the real power and beauty of Kotlin is where it differs from Java, sometimes drastically. Let’s take a look at some examples of code patterns I’ve run across in production code, and different ways we can improve upon them.

Continue Reading

Just over two weeks ago I released :Firth pre-alpha1 into the wild. It had progressed to the point where it was starting to be able to do what I’d intended it for–implement small DSLs with relatively little code. It was fairly small, simple, and fast, in the grand scheme of things. Writing code in :Firth was a joy, the syntax was clean and easy to understand, and I was generally happy with what I’d built. So I cut a release, made a little announcement, and waited to see what people thought.

Their feedback? The response was overwhelmingly positive. I did get some technical notes and observations, though: it’s too big, too complicated, and it’s totally incomprehensible.

Ouch. Confusion about how it works and how to read the code is mostly a a cultural issue. To Forth veterans, the REPL with the “ok” prompt should be perfectly mundane and familiar. The idiosyncratic : colon definition syntax ; and reverse-polish notation take some getting used to, but they aren’t especially difficult except insofar as they’re so different from pretty much all mainstream languages.

Continue Reading

So what is :Firth? It’s a programming language. It’s a compiler-interpreter implemented (currently) in Lua. It’s performant, portable, embeddable, stack-based, extensible, and self-modifying. It’s free and open source. It’s more of a compiler construction toolkit for defining DSLs, than a programming language as we normally think about them.

What :Firth definitely is not is FORTH. I describe it as Forth-like, because it shares many idioms and mechanisms with Forth. ANS Forth is definitely the #1 influence on the design of the language and implementation thereof. But, I’ve diverged from that starting place, sometimes dramatically. These differences emerge when I just want to get something working as fast as possible, when I decide to do things differently for technical reasons or personal preference, or when I just can’t be chuffed to look up how Forth does something (or DPANS is too opaque for a relative outsider).

Continue Reading