What Language Should I Learn After Rust?

Polar opposites as languages in so many ways, sure. But opposites can attract! I've been playing around in a couple of areas lately where Rust and Javascript ( or in reality Typescript) work really nicely together.

There's Tauri, which scaffolds a Rust app with a browser-based front-end written in the js/ts framework of your choice.

And then there's Deno's Fresh, a young but very pleasantly simple js/ts framework. It integrates simply with their wasmbuild tool to make it pitifully easy to call between Rust and the Fresh front-end.

Both of these appear to make it pretty straightforward to write a core app in Rust for essential speed & robustness, and then take advantage of the breadth of web technologies, and the loose flexible nature of javascript, to put together a UI (I make only the modest claim "appear to" because I'm in an early phase of trying both as UIs for a Rust library I'm working on; and I'm very much a Rust beginner)

Others have already mentioned lots of good ideas, so I'll just write what I did after learning Rust.

I chose to pick up Elm, which is a functional compiles-to-javascript language for the frontend. I am (unluckily given its prevalence) not a fan of javascript, and I was looking for a language that would get me some of Rust's niceties in the frontend. Elm happened to fit the bill, featuring things such as

enums with exhaustive pattern matching
type MyEnum
    = FirstVariant { someData : String, moreData : Int }
    | SecondVariant Int
    | ThirdVariant


isFirstVariant : MyEnum -> Bool
isFirstVariant myEnum =
    case myEnum of
        FirstVariant _ ->
            True

        ThirdVariant ->
            False
-- MISSING PATTERNS ------- src/Main.elm

This `case` does not have branches for all possibilities:

12|>    case myEnum of
13|>        FirstVariant _ ->
14|>            True
15|>
16|>        ThirdVariant ->
17|>            False

Missing possibilities include:

    SecondVariant _

I would have to crash if I saw one of those. Add branches for them!

Hint: If you want to write the code for each branch later, use `Debug.todo` as a
placeholder. Read <https://elm-lang.org/0.19.1/missing-patterns> for more
guidance on this workflow.


not having to deal with nulls

There's no null in Elm, instead things that may-or-may-not-be are expressed with Maybe, which is identical to Rust's Option

type Maybe a
    = Just a
    | Nothing
a sound type system

Here's my least favorite thing about typescript:

const array: Array<number> = [0, 1, 2, 3];
const coolNumber: number = array[100];
console.log(stringifier(coolNumber))

function stringifier(num: number): String {
    // I can trust that num is really a number thanks to typescript!
    // ...right?
    return num.toString()
}
Uncaught TypeError: Cannot read properties of undefined (reading 'toString')

Then you might want to consider Elixir. It's a pleasant enough language to write in and learn, but its great appeal lies in the ecosystem. The BEAM VM and associated OTP libraries provide a unique and practical approach to writing distributed applications. It's also easy to integrate with Rust binaries. Its Phoenix web framework is broadly liked by developers who have tried it.

If you would like to target the JVM, someone above mentioned kotlin, which is a nice language, but you could also take a look at clojure.

Do it! Writing a compiler in Rust a lot of fun, speaking from experience (far from being an expert though). I assume that for an experienced programmer like you, parsing is not the most interesting part, so you can save a lot of time by using nom and nom_locate crates (it's also super fast). The real fun begins with code generation, so you might want to use the algorithm in this paper to generate your custom IR in SSA form.

As for @Bora , I would suggest learning a bit of Scheme, just to experience how nice metaprogramming can be if you reduce the language down to the most basic bits. A bit of Haskell wouldn't hurt too: at first, you'll suffer from total lack of mutable state, but then you'll enjoy total lack of heisenbugs.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.