What would make a backend language appealing to you?

Hi! Gleam looks very promising to me!

One thing I love in Elm and I cannot find in another backend language is the built-in Architecture and the very clear and opinionated path between the toy app (with Browser.sandbox) and the fully-fledged application. It made the acculturation less scary for the total beginner I was.

I don’t know how it can transpose to Gleam but it’s definitely a concept that worths an investigation. Picking a language and having to choose between 4-5 frameworks doing too much or not enough is something that repeatedly made me give up my learning effort…

3 Likes

Could you give an example here? :slight_smile:

That’s a really good bit of info, thank you!

Have you tried Ruby’s Rails, Python’s Django or Elixir’s Phoenix? They’re very opinionated and convention based backend web frameworks that for me have fit that TEA-like niche. I would be interested in knowing if there’s something that could be improved from your point of view.

I haven’t found a backend language that I’m happy with. I have tried many languages (Ruby, Python, JS, Rust, Nim, Haskell, Ocaml, Elixir, Go) but I don’t quite like them for different reasons e.g. slow compilation, hard to learn, bad error handling, no/unsound type system, poor tooling, unnecessary complexity, very little documentation, etc.

I have been following Gleam and for me it looks very attractive for building web backends. I would have liked an ML syntax, but no big deal. I have high hopes.

Specific things I would love to see in the near future:

  • A web framework
  • Authentication library
  • JWTs
  • GraphQL server
  • Postgres client
  • Date time library

Thanks

1 Like

Elixir can pattern match on args in function heads, which is something I miss in Elm.

def my_func(%{"foo" => foo}), do: ...
def my_func(%{"bar" => bar}), do: ...

Hello @lpil this isn’t answering your question but is more of a bit of feedback, hopefully helpful. I got interested and went to the link you provided, which is the github page, which in turn links to https://gleam.run/
Scouring through that I was trying to answer the question “is this a pure functional language” and I cannot really do that (quickly) from either of those two places. I was really interested to see how you were going to do, for example, database access. I ended up taking a look at the example-url-shorterner, which has the following:

fn get_link(id) {
  case db.get(id) {
    Ok(link) ->
      Response(200, [], link)

    Error(_) ->
      Response(404, [], html.not_found())
  }
}

So that seems to me as if there are side-effects in the language so it isn’t pure. In addition I looked at the ‘Try’ section of the language tour (https://gleam.run/tour/try.html) and it shows:

case parse_int("123") {
    Error(e) -> io.println("That wasn't an Int")
      Ok(i) -> io.println("We parsed the Int")
}

That looks like it’s definitely an impure language. So I guess I’m suggesting that this information up-front would be handy, perhaps in the ‘Gleam principles’, or even if the ‘Hello Gleam’ program actually printed “hello world” to the screen, that’s what I was expecting when I went to that section, and the fact that it didn’t do that, made me think “oh, maybe it’s a pure language”. I guess I also thought that because you were posting on the Elm discourse and saying “very much inspired by Elm”.

So obviously that’s a pretty minor point, and you cannot have all the language design choices up-front in the main blurb. However, and I mean this as wholly constructive feedback, I’m still kind of lacking the whole point of the language. From the blurb, the whole raison d’etre for the language is simply that you wanted a statically typed language that targets the erlang BEAM. Is that correct? If not, that’s the impression I got. All of the other design choices, are basically “just” your personal preference (again, that’s they way it comes across, I’m not saying that’s the reality). So I suppose in summary, what I’m saying is the website is lacking a ‘vision’. In particular, if that was your goal, explaining why you didn’t re-target an existing functional language would go a long way to explaining the why of Gleam.

Note, I’m specifically saying the ‘website’, I’m not saying your project lacks a vision, just that it isn’t conveyed well on your webpage. At the moment, I’m having a hard time figuring out why I might be interested in Gleam, in particular why might I be interested in Gleam over more mature, funded, supported languages such as F#, Kotlin, or O’Caml which (from what I have understood) are similar in that they are impure strictly evaluated functional languages with static type systems and type inference.

In very marketing terms, what is the unique selling point?

1 Like

We actually used to have an ML syntax a year or two ago! We ended up dropping it to be more familiar to a wider collection of people (which has been a very popular decision). I mildly prefer ML syntax, but whatever makes Gleam more friendly to more people is good by me!

GraphQL is probably quite a way away. I would love a GraphQL server library like the one in OCaml (it’s type safe without any codegen), but we would need a few more fancy type system features first (GADTs for example).

The others are not so far off :slight_smile:

Gleam intends to only have one way of writing any one thing, so we will not support flow control based on multiple function heads as this is duplication of the case expression feature.

The Erlang compiler (and thus the Elixir compiler) actually rewrites multiple function heads into a single function with a case expression, so there’s no practical difference between the two.

I’ve not made any notes on purity as the vast majority of languages are impure. Elm is the only language I can think of that is actually pure (providing you ignore the Debug module, the runtime, and the fact that equality is not total).

To be clear Gleam is a functional language with side effects (like OCaml or Erlang). Later we’ll have a better website, but for now we are focusing on building the language itself.

Thanks for the feedback! You’re the first person to raise this question, so I think it is quite a niche question.

It would be great to be able to always give a clear picture of the language from the get-go, but what questions need to be answers depends on who the reader is. Here’s some questions I have received from people first viewing the language:

  • Are there side effects?
  • Is there a web framework?
  • Does it compile to native?
  • Can I use it in AWS lambda?
  • Does it have higher kinded types?
  • Does it have dependant types?
  • Does it have objects?
  • Does it have Erlang’s maps?
  • Are processes types?
  • Is there mutable state?
  • Can I use it for graphics programming?
  • Are there first class modules?
  • Are there type classes?
  • Can I run it in the browser?
  • Are there macros?
  • What kind of metaprogramming is there?
  • Are there polymorphic variants?
  • Can it compile to Go?
  • Are there row typed records?

And so on! It’s really difficult to answer all these questions without writing a long, boring essay on the home page.

Also, Elm doesn’t answer any questions about side effects or purity on it’s home page either!

Yes, that’s right.

At the moment we’re largely marketing to Erlang + Elixir users, so they have a full understanding of why the BEAM is special and has value, so we don’t attempt to explain that to them. We’ve largely been focusing on explaining why types have value.

Later on we will improve upon this, and have a website with an introduction that is designed to explain the value of the Erlang way to people from other ecosystems.

While the written documentation is lacking here I have given talks to more general audiences, so if you’d be interested in learn more about the philosophy and value of Gleam then it may help a little.

Otherwise I’m extemely happy to answer questions about Gleam and Erlang in general!

Gleam builds on top of Erlang, so it out-classes those languages in terms of durability, scalability, and latency. It is an extremely reliable and performant runtime that makes multi-core and distributed computing comparitively trivial.

Once we have matured I am confident that Gleam will provide a nicer and easier development experience for web application backends than those languages, while also providing superior performance without any specific optimisation required by the user.

1 Like

Are there side effects?
Is there a web framework?
Does it compile to native?
Can I use it in AWS lambda?
Does it have higher kinded types?
Does it have dependant types?
Does it have objects?
Does it have Erlang’s maps?
Are processes types?
Is there mutable state?
Can I use it for graphics programming?
Are there first class modules?
Are there type classes?
Can I run it in the browser?
Are there macros?
What kind of metaprogramming is there?
Are there polymorphic variants?
Can it compile to Go?
Are there row typed records?

I think these would be great questions to answer on the FAQ page!

I don’t think so, they’re not FAQs. Most of them have been answered once, and the frequently asked ones are on the frequently asked questions page.

I don’t think it’s possible to describe a language by listing everything that it is not, better to describe what it does and what it has, which is what we’re doing now with the language tour.

Having said that, if you can find an example of another language answering these questions in a clear way that would be super useful! We could adopt the technique they use for Gleam’s documentation.

I can say that I had these same questions Are there side effects? and Is there mutable state?.
A lot of the other ones I didn’t think to ask but would be curious to know the answer after seeing them.

It depends of course who your target demographic is, but if you’re expecting adoption from Elm users, I imagine at least some of these questions will be frequently asked.

Not off the top of my head but I’ll let you know if I think of anything.

1 Like

A great reflection! Thank you!

I’ve added thse two items to the FAQs page: https://github.com/gleam-lang/website/commit/ca3260b33f87f1217dfbdaf9a251b4fd8b486b91

1 Like

That’s probably correct, it’s a niche question in general, it’s less niche in the context of the Elm discourse of course, but that’s not what your website is intended for.

And you probably have a good reason why you couldn’t write a compiler for, say O’Caml, that targets the BEAM, or rather a new backend. I don’t know enough about the BEAM to know whether or not such a re-targeting makes sense, in particular whether you could then have any reasonable interop.

I’m only asking such questions because it seems as if there is some interesting story/purpose behind Gleam, but the website really makes it appear more like a hobby project consisting of mostly personal preferences, there are many such projects, and whilst they are surely good as learning projects for the authors aren’t really of much interest to anyone else. Don’t feel like you need to respond here, I haven’t even as yet watched the video you posted which likely answers this “question”.

The one of the first versions of Gleam actually was an alternative backend for the OCaml compiler, but I became unhappy with this approach. I think without the ability to really tailor the language to the runtime and the problem space you’ll always have a second-class experience, especially when it comes to interop with the wider ecosystem. It’s very important to me that it it easy to use Gleam with Erlang and Elixir, and that we enrich the wider BEAM ecosystem.

Also I was unhappy with the OCaml documentation and tooling and wanted more control over that too.

Gleam was a learning project in ~2016-2017, but we progressed past that now. The aim is to be a production ready and productive language for backend web and embedded programming, using static types and the BEAM. I’m happy to report that we’re well on the way there, and there’s at least one company running Gleam in production at present. :slight_smile:

The website is certainly quite amateurish and could do with a face-lift. Sadly I’m a lot better at building languages than designing nice looking websites, so I have been putting off this task for now. It will come with time for sure.

1 Like

If only there was some language and community that might be interested in contributing :eyes::eyes::eyes::sweat_smile:

3 Likes

The example is exactly what @paulh mentioned below - pattern matching in function heads. Maybe it is less familiar, but I think it’s a the sort of thing that is optional to learn and, once learned, is a really nice technique.

I was thinking exactly that, would be happy to get involved with others :grinning:

1 Like

I was listening to an interview with Richard Feldman and another guy today morning, I think from a couple weeks ago or so. I realized that the thing I miss most when I work in any language, front or back end, that isn’t Elm is fearless refactoring. I know that when I make a change to my Elm code that 99% of the time everything will just work. I’ve used at least a dozen different language at my jobs and probably another dozen or more in my hobbies, and Elm has been the only language that has given me that confidence.

3 Likes

If anyone would be interested in helping out with anything that would be really cool! Maybe drop by the issue tracker and we can discuss more https://github.com/gleam-lang/gleam/issues

100% with you here! This was why I switched from Erlang to Rust for the Gleam compiler, and it has paid off many times over.

It is the intention to have the same experience in Gleam, and so far I would say we’re doing a pretty good job!

6 Likes

I didn’t want to mean that your language should include a TEA or an MVC-like architecture. I wanted to point out the refreshing idea of the built-in architecture we can find in Elm. I have no opinion regarding the nature of the architecture.

Here’s a recent story that made me realize how cool it is to learn a language and an architecture at the same time.*

I discovered Crystal-lang 3 weeks ago and thought it was interesting. I read the doc and wanted to build something with it. I looked for a web framework and I found this one, this one and this one. Then, I spent 3-4 hours to decide which one was the best for me. I picked lucky. Out of luck-y, Crystal has just been updated to 0.35 and I couldn’t install this web framework. At the end of the day, I had no result and my excitation went down.
I had almost a similar experience with Rust… choice paralyzes is a real thing for me :confused:

For not-yet hegemonic languages such as Gleam, Elm or Crystal I believe endorsing an architecture as part of the language has several advantages:

  • It’s beginner-friendly as you can craft a path with regular rewarding milestones and avoid for many the choice paralyzes I described.
  • User experience is always optimal with no sync-out between the vital libraries and the hosting language.
  • Your brightest early adopters are not in competition with each other from day one to create THE new Django/Phoenix.
  • Libraries are easier to understand as creators will try to fit with the built-in architecture.
  • More importantly, It naturally narrows down the scope of your language so you can compete with majors ones.

And a narrowly-scoped back-end language is really important for me because I don’t want to pay the complexity which comes with the power of doing too many things. Because I’m a beginner and I want to do simple things! like interacting with a database and feed my Elm-app with the same sense of safety I have when I build the client.

*Elm wasn’t born with the TEA. According to the Evan’s Guide this architecture imposed itself organically…

@rupert : Have you tried dark-lang? I believe it is based on a ML syntax and is inspired by Elm. However it’s closed source so not really appealing for me…

2 Likes

I’ve been reading about Elixir lately and it looks like the best language for backend I’ve ever seen, so I intend to move to Elixir as my main backend language.

I don’t like its dynamic typing at all, and my dream backend language would probably be Elixir/Phoenix with static typing and easy interop with Rust/C as needed.

Now onto Gleam. Since Gleam won’t for a long time offer similar functionality as Elixir/Phoenix, its use case for me would be to implement some specific functionality within Elixir/Phoenix project. If Gleam can do some specific part better than Elixir/Phoenix then I would use it.

Some things which affect usability of Gleam:

  • must be simple to use within Elixir/Phoenix project
  • must work with mix instead of using different build tool (rebar3)
  • how it works with other tools like ExUnit, :debugger and :observer
  • syntax highlighting for Sublime Text
  • code formatter

I havn’t tried Gleam yet (still learning Elixir), but I do intend to try Gleam soon and then I can give more specific feedback of any problems or missing features.

1 Like

You may be in luck! Erlang (and thus Gleam, Elixir, etc) have a built in application framework called OTP. All applications on the VM are written in this general framework, and any web frameworks etc are but thin layers on top. It’s well worth checking out, no matter which language is being used :slight_smile:

I believe the company behind Darklang just shut up shop, a real shame :frowning:

We have a mix plugin that makes Gleam easy to use within a mix project. With the next release it’ll be even better as we’re focusing on tooling at the moment.

Full support here, Erlang + Elixir interop is a big focus of Gleam.

I’m not a sublime user so someone from the community will have to provide this one I’m afraid.

We’ve had one of these for some time! I was the person who wrote the first Elixir code formatter, they’re one of my favourite tools <3

2 Likes