Sky – an Elm-inspired language that compiles to Go

github.com

97 points

whalesalad

5 hours ago


23 comments

__natty__ 6 minutes ago

I would love to see Java inspired language compiled to Go. I really like Go portability and standard library and Java... verbosity. I prefer explicit names, types and all the syntax around that. Graalvm is not an answer for me because as far as I'm aware it doesn't support cross-compile.

melodyogonna 2 hours ago

That's two new languages compiling to Go making HN frontpage in as many days. It seems people like everything about Go except the language itself. Me? I like everything about Go including the language, these transpiled languages are interesting though.

But I keep wondering if they could integrate at a lower-level than the source code. Like how JVM languages integrate at the bytecode level, or LLVM languages at the LLVM level

  • MichaelNolan 2 hours ago

    > But I keep wondering if they could integrate at a lower-level than the source code.

    I’m sure they could, but targeting go source code has the benefit of giving early adopters an escape hatch. If it targeted LLVM directly, I would never consider using this at work since the risk of it being abandoned is too high. But since it targets go source, I would perhaps consider it for some low importance projects at work.

  • onlyrealcuzzo 28 minutes ago

    What was the other one?

    I'm working on a language that transpiles to Zig with a custom Go-like runtime (and no garbage collector, Rust-style Affine movement instead).

    Sky seems quite cool, as it's additive to Go in interesting ways.

    I originally considered keeping the GC and just transpiling to Go so I didn't need to write a Runtime.

    Go rules! It really does. But I HATE writing/reading Go.

    So I'm glad more people are doing this!

  • ksec an hour ago

    If we think of Go as different kind of C, then having Go as a compiled target seems to make sense as C is a compiled target.

1-more 25 minutes ago

I will add this to my list of Elm-inspired tools that call to mind Brian Eno's quip about the first Velvet Underground album: "I think everyone who bought one of those 30,000 copies started a band!" With Elm it feels like it's 1% of Elm users creating a language.

https://quoteinvestigator.com/2016/03/01/velvet/

harikb 16 minutes ago

Somewhat unrelated to the language itself:

> The compiler bootstraps through 3+ generations of self-compilation.

I guess it applies to any language compiler, but f you are self-hosting, you will naturally release binary packages. Please make sure you have enough support behind the project to setup secure build pipeline. As a user, we will never be able to see something even one nesting-level up.

onlyrealcuzzo 21 minutes ago

First - awesome job. Congrats. Self hosting is an accomplishment!

But I'm curious to get your thoughts on the process in hindsight.

I understand why it's valuable: to cast a wide net in catching bugs and give a good signal that your language is generally "ready".

I'm working on a similar language, but worried about going down the self-hosting path, as I think it'd slow me down rather than speed me up.

How did it work for you?

zem 3 hours ago

at first glance this looks amazing! basically provides everything I have ever wanted in a full stack language. looking forward to experimenting with it.

edit: looking through the docs/examples some more, it looks like javascript interop is fairly clunky, both because it relies on string concatenation to embed fragments of javascript, and because the string concatenation syntax is not great (and the formatter makes it even worse - see the example at https://github.com/anzellai/sky/blob/main/examples/13-skysho...)

I would encourage you to at the least add multiline strings with interpolation support, and ideally add a small compiler for html literals.

skybrian 3 hours ago

Functional languages have some good and some bad features and there's no reason to copy them all. For example, you don't need to have a Hindley-Milner type system (bidirectional is better) or currying just because it's a functional language.

  • troupo an hour ago

    We need more pragmatic languages. E.g. Erlang and Elixir are functional, but eschew all the things FP purists advocate for (complex type systems, purity, currying by default etc.)

    • zem 19 minutes ago

      ocaml has a complex type system but it's also very pragmatic in that it doesn't force you into any one paradigm, you can do whatever works best in a given situation. (scala arguably goes further in the "do whatever you want" direction but it also dials the complexity way up)

      • troupo 7 minutes ago

        Yes! Completely forgot about OCaml because I only spent a couple of months with it

redoh 2 hours ago

Elm's type system and architecture are genuinely pleasant to work with, so seeing those ideas ported to a Go compilation target is interesting. You get the safety and expressiveness of Elm but end up with a Go binary you can deploy anywhere. I wonder how the error messages compare, since that was always one of Elm's strongest features.

submain an hour ago

Great work :). Go doesn't have TCO. That means functional languages (no for loops) could blow up the stack. How did you solve that?

  • kubb an hour ago

    You can just compile any tail recursive function to a function with a loop and no recursion.

    • 1-more 29 minutes ago

      This is in fact how Elm does it! Tail call recursion compiles to a while loop.

    • adamwk 39 minutes ago

      [dead]

tasuki 2 hours ago

A bit too bleeding edge for me, but it does look super nice (ie exactly like Elm).

riclib 3 hours ago

Can’t wait to play with it. Great design!