# Do you have an opinion/advice on functional backends technologies?

**URL:** <https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095>\
**Category:** Request Feedback\
**Created:** [March 13, 2021, 7:34am UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095 "2021-03-13T07:34:45Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![rupert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/rupert/32/1775_2.png) [@rupert](https://discourse.elm-lang.org/u/rupert)\
**Post date:** [March 16, 2021, 9:02pm UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/21 "2021-03-16T21:02:05Z")

</div>

> [@berend](#):
>
> I wouldn’t have a clue how to do that in Elm, except through Msgs, and not sure that would improve understandability/readability.

By defining all the side effects as `Procedure`s, and then chaining them together with `Procedure.andThen`:

[https://package.elm-lang.org/packages/brian-watkins/elm-procedure/1.1.0/Procedure#andThen](https://package.elm-lang.org/packages/brian-watkins/elm-procedure/1.1.0/Procedure#andThen)

This is basically Task ports. 🙂

I think also this is closer to IO Monads in Haskell?

---

<div class="post-metadata">

**Author:** ![stoft](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/stoft/32/753_2.png) [@stoft](https://discourse.elm-lang.org/u/stoft)\
**Post date:** [March 17, 2021, 8:08am UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/22 "2021-03-17T08:08:06Z")

</div>

At work we currently have a combo of Elm + F# + Hasura/GraphQL (and some other stuff as well but that’s legacy for you). We have been moving over to F# from TypeScript on the backend for almost 2 years and now the majority of our code is F#. IDE-wise experience is fairly good, but mixed, people tend towards JetBrains Rider over VSCode Ionide (even though that works too). GraphQL gives you shared types in Elm. F# gives you type providers.

If I could pick something else it would be that mature statically typed BEAM language that does not yet exist. 🙂 (be it Alpaca, Caramel, Whatsapp’s yet unreleased thingy, Hamler or Gleam. Elchemy seems pretty dead in the water tbh)

---

<div class="post-metadata">

**Author:** ![choonkeat](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/choonkeat/32/1555_2.png) [@choonkeat](https://discourse.elm-lang.org/u/choonkeat)\
**Post date:** [March 17, 2021, 11:59am UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/23 "2021-03-17T11:59:11Z")

</div>

> [@rupert](#):
>
> so far I have only used it with a no-SQL database, DynamoDB. At some point I would like to look into what serverless SQL database offering are available on AWS (I’m hoping for a pay-on-demand Postgres), and then figure out how to do SQL in Elm to make use of that.

I was also on lambda + dynamodb (Http.task) with [choonkeat/elm-fullstack](https://package.elm-lang.org/packages/choonkeat/elm-fullstack/latest)

But recently our startup is using elm-fullstack with Postgres (through Hasura), so we get to keep our `Http.task` chaining.

> [@rupert](#):
>
> I think Elm has some potential as a cloud language, more so than as a general purpose back-end language. So-called ‘Lambda’ functions on AWS interact with the rest of the AWS environment almost exclusively over HTTP - which means that the familiar `elm/http` package is already available to work with them.

my thoughts exactly. lambda function environments doesn’t have traditional server side affordances, but then with elm you don’t have those apis anyways, so you’re not missing out lol

---

<div class="post-metadata">

**Author:** ![rupert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/rupert/32/1775_2.png) [@rupert](https://discourse.elm-lang.org/u/rupert)\
**Post date:** [March 17, 2021, 1:49pm UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/24 "2021-03-17T13:49:10Z")

</div>

> [@choonkeat](#):
>
> I was also on lambda + dynamodb (Http.task) with [choonkeat/elm-fullstack](https://package.elm-lang.org/packages/choonkeat/elm-fullstack/latest)

Do you have any example code using this? Would love to see how it looks with `Task` chaining.

---

<div class="post-metadata">

**Author:** ![tkuriyama](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/tkuriyama/32/3930_2.png) [@tkuriyama](https://discourse.elm-lang.org/u/tkuriyama)\
**Post date:** [March 17, 2021, 2:39pm UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/25 "2021-03-17T14:39:18Z")

</div>

Thanks for starting this thread – it would be great to see further developments in this area (particularly as it pertains to Elm integration).

I played around with an Em + Haskell [`servant`](https://docs.servant.dev/en/stable/) with [`servant-elm`](https://hackage.haskell.org/package/servant-elm) + Haskell `persistent` backend for SQL ([from the Yesod folks](https://www.yesodweb.com/book/persistent)) stack last year.

Similar to some of the things mentioned above, I wanted to try to write data and API definitions once, and have that serve as the basis for:

- automatically creating the SQL backend with type-safe bindings (I used Sqlite, but `persistent` works with Postgres among others)
- automatically generating the Elm decoders on the front end

It works as a proof of concept (the various Hello Server examples in [this repo](https://github.com/tkuriyama/spacemonkey) are fairly straightforward, to get a taste). A few caveats:

- Even with simple data definitions, I had to write some custom generators for Elm code (if there was a way to do this more directly in `servant-elm` or underlying `elm-bridge`, I couldn’t work it out from the docs ☹ )
- The monadic state gets a bit complex (at least for my intermediate Haskell level – the composition of monads for server + storage is hard to follow beyond basic usage)
- `servant` is not hard to get started with (much easier than Yesod, I gather), but its state of support seems suspect, with a backlog of issues and PRs piling up; and things like cookies are not supported out of the box, though folks have written modules for it

---

<div class="post-metadata">

**Author:** ![wondible](https://avatars.discourse-cdn.com/v4/letter/w/e9c0ed/32.png) [@wondible](https://discourse.elm-lang.org/u/wondible)\
**Post date:** [March 18, 2021, 1:08pm UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/26 "2021-03-18T13:08:35Z")

</div>

> [@rupert](#):
>
> So-called ‘Lambda’ functions on AWS interact with the rest of the AWS environment almost exclusively over HTTP - which means that the familiar `elm/http` package is already available to work with them.

Really? And here I wrote my own http look-alike; I guess I must have never actually tried the default package.

---

<div class="post-metadata">

**Author:** ![rupert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/rupert/32/1775_2.png) [@rupert](https://discourse.elm-lang.org/u/rupert)\
**Post date:** [March 18, 2021, 3:55pm UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/27 "2021-03-18T15:55:49Z")

</div>

You need to have an XMLHttpRequest implementation to work with [http 2.0.0](https://package.elm-lang.org/packages/elm/http/latest/) on the server side. Such as this:

> <https://github.com/the-sett/elm-serverless/blob/4.0.0/src-bridge/xmlhttprequest.js>

---

<div class="post-metadata">

**Author:** ![benjamin-thomas](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/benjamin-thomas/32/3869_2.png) [@benjamin-thomas](https://discourse.elm-lang.org/u/benjamin-thomas)\
**Post date:** [March 20, 2021, 6:11am UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/28 "2021-03-20T06:11:42Z")

</div>

Busy week, sorry for not getting back sooner.

Thanks all for the valuable feedback, I’ve got many avenues to explore now.

I’ve been mainly doing research since creating this post, not much coding yet. So no specific questions related to previous replies yet.

So as I said, I like the idea of a language constraining what one could do, not allowing or making difficult to shoot oneself in the foot. And, although I’m barely scratching the surface, I can feel this is what Elm will give me…to be continued 😉

Backend wise, I’ve been thinking there is another option I hadn’t considered: just applying functional programming concepts! (doh!)

I feel this requires quite a bit of discipline though, one could also translate that to just “be a better programmer”.

Anyhow, here’s an interesting video demonstrating this concept in a **practical** way: [https://youtu.be/kPLGftyQ5ho](https://youtu.be/kPLGftyQ5ho)

That’s JavaScript, and the applied concept is “functional core, imperative shell”.

Having first class functions, it feels pretty natural in js. I anticipate this technique will feel a little clunky in Java or Ruby but still doable (not considering performance issues though). Throwing typescript into the mix could turn out to be interesting refactoring/tooling wise, I’ll have to try it.

Staying on the topic of a functional backend, from what I gathered, the Elixir community seems to be much much more active than any other. There’s a ton of resources available.

Interestingly, I stumbled upon this video where the speaker applied a similar technique to the one mentioned above: isolating a statically typed functional core component, implemented with the Gleam language (which looks lovely) on a Phoenix/Elixir/LiveView backend : [https://youtu.be/UCIcJBM\_YDw](https://youtu.be/UCIcJBM_YDw)

Si maybe just having a little more discipline is what I’m looking for, not sure yet.

Having so much resources available means I’ll probably dig into the Erlang/Elixir ecosystem next. Kinda makes sens for my use case and background. Also considering the perspective of a better BEAM language, which looks like it could happen.

For completeness, I didn’t mention that I started integrating the sorbet gradual static type checker to my ruby code base. Definitely helps and glad this project exists. But it’s quite a lot of work to this after the fact, much better to consider static typing from the get go. And tooling is a little rough.

Anyways a little of topic again 😉

Please do keep posting suggestions if you have any though. I’m also interested in feedback on experiences with switching technologies, etc.

Purescript didn’t get a mention and looks like it could be an interesting option with a nodejs backend. Has anyone dabbled with it?

---

<div class="post-metadata">

**Author:** ![benjamin-thomas](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/benjamin-thomas/32/3869_2.png) [@benjamin-thomas](https://discourse.elm-lang.org/u/benjamin-thomas)\
**Post date:** [March 20, 2021, 7:02am UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/29 "2021-03-20T07:02:43Z")

</div>

Here’s also an **excellent** talk from a Clojure programmer, demonstrating how to apply FP principles to a js code base: [https://youtu.be/vK1DazRK\_a0](https://youtu.be/vK1DazRK_a0)

It was this video that triggered my realization mentioned in my previous post, but couldn’t find it anymore.

I’m posting it for reference, definitely will try to apply this knowledge.

I found the highlighting and isolating of mutations to be an eye opener.

Hope it’ll be useful to others too.

---

<div class="post-metadata">

**Author:** ![choonkeat](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/choonkeat/32/1555_2.png) [@choonkeat](https://discourse.elm-lang.org/u/choonkeat)\
**Post date:** [March 20, 2021, 7:29am UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/30 "2021-03-20T07:29:06Z")

</div>

> [@rupert](#):
>
> Do you have any example code using this? Would love to see how it looks with `Task` chainin

Redacted a bunch but should work as example

First, requests from our SPA arrive as a [lamdera-style `MsgFromClient`](https://dashboard.lamdera.app/features), which I immediately ship off to a function elsewhere to detail.

```elm
updateFromClient : RequestContext -> Time.Posix -> MsgFromClient -> ServerState -> ( ServerState, Task String MsgFromServer )
updateFromClient ctx now clientMsg serverState =
    case clientMsg of
        ForgotPassword email ->
            ( serverState, HandleClient.forgotPassword serverState.hasuraClient now email )
 
        ... ->

```

I can do what I need and as long as I end up with `Task String MsgFromServer` all is good.

```elm
forgotPassword : Client -> Time.Posix -> String -> Task String MsgFromServer
forgotPassword hasuraClient now email =
    let
        sendForgotPasswordEmail recipient =
            let
                mailBody = ...
            in
            -- wraps `AWS.SES.unsignedRequest` + `AWS.signRequest`
            Server.Email.sendEmail awsConfig mailBody

        recoveryToken =
            ...
    in
    HasuraAPI.CreateRecoveryToken.createRecoveryToken { email = email, recoveryToken = recoveryToken }
        |> Server.HasuraAPI.do client now -- Task that updated DB with recovery token + return the affected user
        |> Task.andThen sendForgotPasswordEmail -- Task that construct mailBody for user and deliver
        |> Task.map (always (ToastSuccess "Reset password" "Check your email for the password reset link."))
        -- in this case, we're not interested in success payload, just let client know to show success message

```

---

<div class="post-metadata">

**Author:** ![choonkeat](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/choonkeat/32/1555_2.png) [@choonkeat](https://discourse.elm-lang.org/u/choonkeat)\
**Post date:** [March 20, 2021, 9:03am UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/31 "2021-03-20T09:03:59Z")

</div>

> [@benjamin-thomas](#):
>
> I like the idea of a language constraining what one could do, not allowing or making difficult to shoot oneself in the foot. And, although I’m barely scratching the surface, I can feel this is what Elm will give me

Yes indeed 👍

> [@benjamin-thomas](#):
>
> I’ve been thinking there is another option I hadn’t considered: just applying functional programming concepts! (doh!)

I actually have a slide for this lol [https://speakerdeck.com/choonkeat/life-without-footguns-part-1?slide=9](https://speakerdeck.com/choonkeat/life-without-footguns-part-1?slide=9)

---

<div class="post-metadata">

**Author:** ![pdamoc](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/pdamoc/32/36_2.png) [@pdamoc](https://discourse.elm-lang.org/u/pdamoc)\
**Post date:** [March 20, 2021, 9:44am UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/32 "2021-03-20T09:44:06Z")

</div>

Elixir is my favorite language for backend.  
The needs of the backend are very different from the needs of the frontend. In the backend you need the kind of concurrency and scalability that BEAM provides.

> [@benjamin-thomas](#):
>
> Imperative code did seem more appealing to me at first because I thought it made more sens to stay close what a CPU would do rather than introducing a huge layer of indirection.

You want the layers of indirection because you want to focus on solving your problems not the problems you have created for yourself because of poor management of resources.

At a minimum, you would want to program in a memory managed language, preferable one that also has the concurrency handled for you.

My suggestion is to take a look at [RealWorld backends](https://github.com/gothinkster/realworld#backends). Download the implementations with the technologies that look interesting to you. Read through the source code (it’s only about 1k LOC for most).

There are no solutions, only tradeoffs. Each technology stack makes different tradeoffs. You need to take a good look at them and decide which of the tradeoffs you like more.

---

<div class="post-metadata">

**Author:** ![malaire](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@malaire](https://discourse.elm-lang.org/u/malaire)\
**Post date:** [March 20, 2021, 10:20am UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/33 "2021-03-20T10:20:50Z")

</div>

I tried BEAM and Elixir some time ago but rejected it because of its huge RAM consumption for small programs. With default settings even trivial “Hello World” consumes 60 MB RAM. I’ve read that if you know settings really well you can get it down to around 20 MB, but less than that is not possible.

Those numbers are far too high for me. (Rust is now my backend choice.)

---

<div class="post-metadata">

**Author:** ![pdamoc](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/pdamoc/32/36_2.png) [@pdamoc](https://discourse.elm-lang.org/u/pdamoc)\
**Post date:** [March 20, 2021, 10:57am UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/34 "2021-03-20T10:57:46Z")

</div>

> [@malaire](#):
>
> Those numbers are far too high for me.

This is why I said that there are no solutions, only tradeoffs. If you need the webapp to run in as little ram as possible and this is the most important thing to you, of course you would choose a language that allows you as much control over resources as you need.

---

<div class="post-metadata">

**Author:** ![MarkHamburg](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@MarkHamburg](https://discourse.elm-lang.org/u/MarkHamburg)\
**Post date:** [March 20, 2021, 3:20pm UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/35 "2021-03-20T15:20:16Z")

</div>

Full resource “paranoia” — not always a bad thing — could lead one to unikernels and ML. But that’s a bit extreme.

---

<div class="post-metadata">

**Author:** ![ckjaer](https://avatars.discourse-cdn.com/v4/letter/c/e99b99/32.png) [@ckjaer](https://discourse.elm-lang.org/u/ckjaer)\
**Post date:** [March 20, 2021, 5:47pm UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/36 "2021-03-20T17:47:27Z")

</div>

Where I work we use Scala for our backend. It is a language that crosses different paradigms, but using a functional programming library like Cats gives a relatively pain-free experience with a good “if it compiles then it works”-feeling.

Good libraries for building a functional backend might be [http4s](https://http4s.org/) and [doobie](https://tpolecat.github.io/doobie/). If GraphQL is your thing then Sangria is really mature. We use it together with elm-graphql for great happiness.

---

<div class="post-metadata">

**Author:** ![benjamin-thomas](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/benjamin-thomas/32/3869_2.png) [@benjamin-thomas](https://discourse.elm-lang.org/u/benjamin-thomas)\
**Post date:** [March 23, 2021, 6:15am UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/37 "2021-03-23T06:15:53Z")

</div>

> [@choonkeat](#):
>
> I actually have a slide for this

I had a good laugh looking at your slides. I sens I’m following a similar path as you, I like the boulder analogy 🙂

> [@pdamoc](#):
>
> The needs of the backend are very different from the needs of the frontend

Yes and no IMO. By that I mean that I don’t see any reason why a language couldn’t in theory cover the frontend + backend. I feel we split technologies because of practical reasons and history.

> [@pdamoc](#):
>
> My suggestion is to take a look at [RealWorld backends](https://github.com/gothinkster/realworld#backends)

Thanks, great suggestion. I had completely forgotten about that project.

> [@pdamoc](#):
>
> There are no solutions, only tradeoffs

Sure I agree 🙂 I’m not looking for a solution. Any problem can be tackled in any language at the end of the day. Rather, I feel annoyed with what I know on the backend side. In the same way that I felt annoyed with frontend technologies, until I stumbled once again on Elm (I had a look at it 2-3 years ago). Of course this is very early opinion for me, and as I tried to explain, this language really seems to click with my frame of mind. So I thought maybe other Elm programmers went through the same process and would have an opinion on the matter.

> [@malaire](#):
>
> I tried BEAM and Elixir some time ago but rejected it because of its huge RAM consumption for small programs. With default settings even trivial “Hello World” consumes 60 MB RAM.

I suppose this is due to the VM. Java technologies have the same problem. There’s probably a tipping point where the RAM consumption becomes worth it and the benefits of the platform outweigh the downside of wasteful resources.

> [@ckjaer](#):
>
> Where I work we use Scala for our backend. It is a language that crosses different paradigms, but using a functional programming library like Cats gives a relatively pain-free experience with a good “if it compiles then it works”-feeling.
> 
> Good libraries for building a functional backend might be [http4s](https://http4s.org/) and [doobie](https://tpolecat.github.io/doobie/)

Thanks for the suggestion, I’ll look into it. Scala looks rather tough to learn though, because of it’s multi-paradigm approach (many ways of doing things). If I understand things correctly, Kotlin is quite close to it in terms of features and functionality.

* * *

For the record I stumbled upon another project today, having the objective to bring a statically typed language for the BEAM (based on Ocaml): [https://caramel.run/](https://caramel.run/)

Not anything production ready but I can see there’s definitely a push in that community to have a statically typed language, interesting…

---

<div class="post-metadata">

**Author:** ![pdamoc](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/pdamoc/32/36_2.png) [@pdamoc](https://discourse.elm-lang.org/u/pdamoc)\
**Post date:** [March 23, 2021, 7:05am UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/38 "2021-03-23T07:05:20Z")

</div>

> [@benjamin-thomas](#):
>
> I don’t see any reason why a language couldn’t in theory cover the frontend + backend.

The backend needs a very good concurrency story. Frontend… not so much. But I agree, a language could cover both and there is a huge advantage to this.

---

<div class="post-metadata">

**Author:** ![cbrake](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/cbrake/32/438_2.png) [@cbrake](https://discourse.elm-lang.org/u/cbrake)\
**Post date:** [March 23, 2021, 6:23pm UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/39 "2021-03-23T18:23:40Z")

</div>

I’m liking Go:

[http://bec-systems.com/site/1625/why-are-go-applications-so-reliable](http://bec-systems.com/site/1625/why-are-go-applications-so-reliable)

I’ve [used Go+Elm](https://github.com/simpleiot/simpleiot) a lot in the last couple years, and it feels pretty natural. The language values (ex simplicity) and tooling [matter a lot](https://docs.simpleiot.org/go/vision/#technology-choices) – Elm and Go have a lot in common there.

Go defies most conventional thinking when it comes to programming languages and does [not fit in neat little boxes](https://npf.io/2014/10/why-everyone-hates-go/), but in practice it seems to work well.

Deployment for Go apps is generally [very simple](https://community.tmpdir.org/t/do-you-really-need-docker-with-go/241)

Everyone has their values/priorities, so it is nice we have so many options for programming languages! It really comes down to what is important to you.

---

<div class="post-metadata">

**Author:** ![benjamin-thomas](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/benjamin-thomas/32/3869_2.png) [@benjamin-thomas](https://discourse.elm-lang.org/u/benjamin-thomas)\
**Post date:** [March 24, 2021, 7:16am UTC](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095/40 "2021-03-24T07:16:00Z")

</div>

I love go, it’s a superb technology! I used it on a couple of projects and indeed it is rock solid. I feel that if the problem domain is well understood, then it’s a great fit.

However, I often don’t know what I’m building, I’m discovering along the way. And golang never felt great to me for exploration. So for that reason, I never felt good about using it for web dev either.

I’ve gotta say that my web apps have a small user base, but the business complexity is high, the domain is big.

Here is what bothered me at the time (code below was me fooling around, trying to get a feel of things, so warning code is very messy in some places).

Most golang programmers don’t feel the urge to consolidate knowledge into a common framework, thus rely upon golang’s stdlib. As a result, one can waste time trying to solve problems that have been solved many moons ago in other ecosystems.

Here’s an example, have a look at this code: [golang-crud-example/main.go at 82cbcd5a047cffab071d3e7193c37ebb8d716ed0 · benjamin-thomas/golang-crud-example · GitHub](https://github.com/benjamin-thomas/golang-crud-example/blob/82cbcd5a047cffab071d3e7193c37ebb8d716ed0/main.go#L264)

I was annoyed having to convert incoming HTTP strings params to ints. So I had the idea of [creating an intKeyProvider function](https://github.com/benjamin-thomas/golang-crud-example/blob/82cbcd5a047cffab071d3e7193c37ebb8d716ed0/main.go#L199) that would wrap around the [the showCountry function](https://github.com/benjamin-thomas/golang-crud-example/blob/82cbcd5a047cffab071d3e7193c37ebb8d716ed0/countriesHandlers.go#L38).

Seemed to make sens, it would be a useful abstraction and would remove a lot of uneccesarry work. At the time I was used to ruby where the incoming params are already converted (after routing) for the programmer (which is just practical).

In the end, there was a lot of stuff similar to this, so it felt like re-inventing the wheel so I decided to just drop the idea of using golang for web dev.

Here’s the equivalent java/spring version: [spring\_address\_book/CountryController.java at master · benjamin-thomas/spring\_address\_book · GitHub](https://github.com/benjamin-thomas/spring_address_book/blob/master/src/main/java/invalid/bt/spring_address_book/controllers/CountryController.java#L62)

It’s a solved problem, one has to learn the abstraction of the framework that’s all. From where I stand, I don’t anticipate all the problems I’m gonna face so I can appreciate if some of the work is already done for me.

As I said at the top of the post, SQL felt like a drag with golang (my apps are very database driven, like most business apps I would imagine).

Have a look here: [golang-crud-example/countriesCRUD.go at 82cbcd5a047cffab071d3e7193c37ebb8d716ed0 · benjamin-thomas/golang-crud-example · GitHub](https://github.com/benjamin-thomas/golang-crud-example/blob/82cbcd5a047cffab071d3e7193c37ebb8d716ed0/countriesCRUD.go#L41)

Here, the programmer has to remember to check for a possible error (triggered by the SQL library) after iterating on rows. I hate stuff like that, it’s so easy to forget. And in practice, I found there’s quite a lot of similar gotchas which I’m not fond of.

At the time, I remembered looking at rust, where not checking an error is made impossible, so that made me even less interested in the language (at least for my typical use case).

So to sum up, I’m context switching a lot, and can’t fit my main code base into my head. So that’s why I’m looking at other things. I want my tool to guide me along the way, scream at me if I forget something 😉

So golang doesn’t look too good for me with that constraint.

Note: I’m aware of [Buffalo](https://gobuffalo.io/en), but not compelling enough for me comming from a rails background. In fact I really dislike all the string injection here: [Querying · Buffalo](https://gobuffalo.io/en/docs/db/querying)

The golang/sql solution that appealed to me the most at the time was: [GitHub - Masterminds/squirrel: Fluent SQL generation for golang](https://github.com/Masterminds/squirrel)

Java side, I think [JOOQ](https://www.jooq.org/) is one of the most appealing options to me: change something db related, and everything breaks at compile time (which is what I want).

There was actually another library which I found that was even better but can’t remember its name, the concept is the same though.

So I know I’m going all over the place. All that to say I’m looking at a combination of great tooling at the language and library level but I also want constraints. The kind of good constraint I’m feeling from writing elm code, this is what pushed me to write this post. And I think I’d like to find that on the backend.

Thanks for your feedback though, I’m all ears if the golang ecosystem changed since I last looked at it 🙂

[Previous page](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095.md?page=1)

[Next page](https://discourse.elm-lang.org/t/do-you-have-an-opinion-advice-on-functional-backends-technologies/7095.md?page=3)
