1. 17
  1.  

  2. 7

    This is my first post of (hopefully) many documenting the process of building a new JVM language. I initially just wrote a couple comments on the “What are you doing this week” threads, but decided to make a proper blog with the encouragement of @feoh and @andyc.

    1. 1

      A side note: your blog doesn’t seem to have a rss stream, at least not that I can find. It’d be helpful to follow updates :)

      1. 3

        It should be exposed from the Home and Blog pages, the RSS icon shows up for me on Firefox when I’m on those pages. Here’s the direct link: https://blog.pentlander.com/feed/?type=rss

    2. 4

      Easily express high level, type-safe logic - Writing Sasquach code should feel like writing a a dynamic language with a type annotations only required on functions declarations. Support for ad-hoc polymorphism is a must.

      For anyone like me who’s not heard of ad-hoc polymorphism, it’s basically what I’d always heard as function/operator overloading:

      https://en.wikipedia.org/wiki/Ad_hoc_polymorphism

      Very cool @pentlander I look forward to seeing some sample syntax! :)

      1. 3

        Yeah more explanation there would have been useful here. I basically think of it as being able to implement interfaces for objects you don’t own. E.g. you have an external class Foo and you want to serialize it but it doesn’t implement the Serializable interface. Instead of needing to create a wrapper around Foo that implements Serializable, you write code that tells the compiler that Foo now implements Serializable. Rust has this in the form of traits, also know as typeclasses in other languages. Sasquach will likely use modular implicit instead.

      2. 4

        Very cool project! Looking forward to reading your posts about the experience of building it.

        Given your comments on other languages, you might want to give Swift a try. It’s strongly typed, supports ad-hoc polymorphisms, has enums with associated types very similar to ML family of languages, immutable value types, automatic reference counting for reference types, generics, protocols (similar to traits), a very lightweight syntax with type inference and in beta 5.5 they added a concurrency language features like async/await and actors.

        1. 4

          Ah yeah I’ve been meaning to give Swift a shot. I think that when I took a look, the compile times were bad and Linux support wasn’t great. I’m also curious how the library ecosystem is now.

        2. 2

          Always nice to see more people build programming languages. I will say this: be prepared to change a lot of your assumptions, implementation, etc 1-2 years from now. As you start working on the language you’ll likely find certain ideas won’t work anymore, or you realise you just prefer to replace one particular feature with something else :)

          1. 1

            That’s partially why I wanted to write the goals upfront and not include many specifics in this post. The language syntax and semantics will evolve as I build things out, but the goals should be relatively static.

          2. 2

            What do you think of Clojure?

            1. 2

              It has very similar pros and cons as Elixir in my mind. Maybe a bit better with ecosystem and a bit worse with concurrency.

            2. 2

              2 questions:

              • Have you taken look on Gleam? It has few of the properties you want.
              • If you liked Elixir, then why not target BEAM instead of JVM?
              1. 2
                • Yes I’ve been following the development of Gleam and I’m excited to see where it goes. The main difference is that I’m currently thinking about using row polymorphism and union types rather than named structs and variant types. I’m not 100% sure if this is better in practice, but I’m gonna give it a shot.
                • As I mentioned in the post, I am very familiar with Java, whereas I have only built a single Phoenix project with Elixir. This project is partially a learning exercise, so I’d rather focus on the JVM since it could also be useful with my day job.
              2. 2

                Sounds fun! And I like your goals. Have you considered using the Truffle JVM framework to implement it? Then you only need to implement an interpreter for your AST and you get a state of the art specialised JIT compiler and AOT compilation for free, without needing to touch Java bytecode.

                1. 2

                  Yeah I looked at Truffle a while ago, it seems really nice. It does conflict with my goal of being on the latest version of the JVM. I’d like to integrate with Valhalla and Loom asap, and the Graal VM seems to lag behind.

                  Since this is partially a JVM learning exercise, I feel like I wouldn’t benefit as much from using Truffle. However for building an actual language, it seems amazing. I’ll definitely look into it in the future as an alternative backend.

                  1. 2

                    Yep, makes sense. I still don’t understand why they removed the JVMCI interface from standard JVMs which meant you could use Graal on any JVM >= 9.

                    You might also be interested in a language someone else is writing on the JVM, though with different goals. They also happen to be the author of the Hotspot compiler (Cliff Click): https://github.com/cliffclick/aa

                    1. 1

                      Wow that looks super interesting, I starred it and will dive into the code later. Thanks for sharing!

                      1. 1

                        I’ve just double checked about JVMCI and it seems they didn’t remove the interface, just the Graal implementation, which makes much more sense. So one can in fact still use Graal and Truffle on any standard JVM >=9.

                        https://openjdk.java.net/jeps/410

                2. 1

                  It looks quite interesting, and I would share many of the list goals if I was to do the same. However I’m surprised by this:

                  Easy to reason about state - This one I’m a bit fuzzy about. My current thinking is to keep the language purely functional, with mutations only occurring with with Java interop.

                  It seems like it clashes with the criticism of Scala as a language where people write libraries as if it were Haskell. A pragmatic, looks-like-scripting static language should be impure imho. The modern tradeoff would be an effect system but that’s a lot of complexity :-).

                  I hope you post more as you go. Do you intend to have a LSP server, not just a jetbrains plugin, when it comes to IDE support?

                  1. 2

                    Yeah looking back, I didn’t mean actually mean purely functional. I imagine the programming style to be similar to Ocaml and Elixir, where almost all of the data is immutable and side effects can occur wherever. I’m still trying to decide if keeping state via recursion is a good idea, but that’s how Ocaml and Elixir do it so that’s my current plan. I’ve also read a lot about effects, specifically extensible effects, but I agree that’s a lot of complexity and will likely not do that.

                    I definitely plan to, I’ll just have to figure out a cadence to post at. I might do that, though I personally much prefer intellij as an IDE and will make that my priority. The compiler will be structured in such a way that LSP support should be easy to implement .

                  2. 1

                    Looks great, best of luck! I kind of hate to be that guy but I know I’d want someone to say it to me - before you get really stuck in, just in case it’s not on purpose and you care about such things, Sasquatch is normally spelled with a ‘t’ :-)

                    1. 1

                      Heh, I realized this almost immediately after creating the Java scaffolding project. I kept the misspelling because I figured it might end up being more searchable than the correctly spelled word. On the other hand, search engines just think it’s a misspelling ¯_(ツ)_/¯

                    2. 1

                      Apologies if this is off-topic: are you aware that “Sasquach” doesn’t appear to be the traditional spelling of the word?

                      It seems that it’s usually spelled “Sasquatch” (with a “t”). Google asks “did you mean sasquatch?”; Wikipedia only uses “Sasquatch”, etc…

                      Obviously the name and spelling are your decision alone, and it doesn’t matter what Google suggests :)