Show HN: Building a Programming Language for Myself

asadawadia1 pts0 comments

Teak - A Kotlin-inspired language that runs on Node.js

About

Writing

Consulting

Music

Api

Previous post<br>Next post<br>Back to top<br>Share post

1. Introduction<br>2. The language<br>3. How to run it<br>4. Standard library<br>5. Try it

Introduction<br>I really enjoy programming in Kotlin but it can be a bit of a chore to get started with the initial project setup boilerplate like Intellij and Maven + pom.xml file. In fact, it has been such a persistent issue that I have a whole boilerplate repo setup to insta-clone and get started. You can read more about it here

I wanted Kotlin but with no build step, no dependencies to manage, no project structure required, don’t even need a main(). When insiration strikes, I wanted something that allows you to try out an idea quickly without all the ceremony. Initially I was trying to mimic bhai lang as a DSL in Kotlin but then I started thinking why a DSL and why in Kotlin? Why can’t I just write my own lexer, parser, and interpreter combo and have the exact syntax I want. With AI assisted development becoming common, I decided to vibe code a language with the exact semantics and syntax that I wanted.

Teak lets you focus on what you’re building, the core idea, not the tooling around it.

The language<br>Teak is to Kotlin what Crystal is to Ruby. It takes in some parts of Golang as well and mixes them in certain areas. If you have used Kotlin before the syntax will feel familiar.

10<br>11<br>12<br>13<br>14<br>15<br>16<br>// hello.tk<br>println("Hello from Teak!")

data class User(name, score)

val users = mutableListOf(<br>User("Ada", 95), User("Grace", 88), User("Linus", 92)

val top = users<br>.filter { it.score > 90 }<br>.sortedByDescending { it.score }

top.forEach { println("${it.name}: ${it.score}") }<br>// Ada: 95<br>// Linus: 92

Key features:

Data classes for simple data holders

Default parameters on functions

Functional operations on lists and maps (map, filter, fold, etc.)

Functions are a first class citizen with convenient lambdas

Built in http server and client

Can import and use any npm package

How to run it<br>After installing via npm (npm i @teaklang/teak), you get two commands:

teak file.tk - runs a Teak script directly

teakc file.tk - compiles Teak to JavaScript (outputs to stdout)

The dev loop then becomes:

Get an idea

Write your .tk file

Run teak your-file.tk

See the output

Standard library<br>Teak comes with a standard library for scripting:

File system operations (read/write files, walk directories)

HTTP client (get, post, download)

JSON parsing and serialization

Collections with functional operations (list, map, set)

Concurrency primitives (go {} for goroutine-like concurrency, channels)

Math and string utilities

An HTTP server library is built directly in to the language

10<br>11<br>12<br>val server = HttpServer(3000)

server.get("/") {<br>it.html("Hello from Teak!")

server.get("/users/:id") {<br>val id = it.params.get("id")<br>it.json(mutableMapOf("userId" to id))

server.start()

Try it<br>Install: npm i @teaklang/teak<br>Docs: https://teak-lang.aawadia.dev/<br>Examples: https://github.com/asad-awadia/teak-lang/tree/main/examples

About

Writing

Consulting

Music

Api

1. Introduction<br>2. The language<br>3. How to run it<br>4. Standard library<br>5. Try it

Menu<br>TOC<br>Share<br>Top

teak language kotlin file server library

Related Articles