Server side problem

#1

I have a BIG problem, and I want feedback from the community :

I’m trying to do a graphql server with websockets push and to do so I went the ruby way (I was doing ruby before elm). But the performance is not great and I have this problem where ruby wants to map database lines to objects and objects to arrays of records to send them to the browser when what I want is just requesting lists of records, mapping on them, and sending them to the client through websockets. So I went Crystal, but the type system in Crystal is undergone, and it’s basically impossible to type the returns of functions, and implicit is beloved here so you get weird compiler issues.

So : I need a way to communicate with Redis on the backend to store and retrieve my data, and a way to send to the client a record, and a way to do some side effects.

The options are :
Haskell
OCaml
FSharp
Closure
Rust
Purescript
Elixir
elm (I know it’s not written for that case, but I don’t see any other simple language that doesn’t allow objects) ?

What would you do ?

#2

I had a similar background, so I will say Elixir/Rust I think elixir + fenix because the elm + ruby experience will help you, in the other hand rust is also well known because of the compiler messages, so again you will be in a familiar environment.

#3

I have built GraphQL servers in Rust and OCaml using


Both are great but immature options. Rust is more mature here (except subscriptions) and has better documentation. I really like how these two languages fit with GraphQL. E.g. their type systems enforce that your graphql end points actually return what you say in the schema.

Websockets is used only for the subscriptions part, right? I haven’t touched subscriptions with these, so can’t comment much. The ocaml package seems to support them.

1 Like
#4

What Ruby library do you use? It sounds more like a library issue than a language one. Maybe there are others libraries without this issue?

#5

I don’t know the fine languages you listed above so… my choices are limited. :slight_smile:

Elixir+Absinthe is what I’ve used so far but I ended up using regular POST calls for the queries and mutations that I needed, not websockets. Absinthe is nice, it introduces a little bit of type safety to Elixir as the schema will fail to compile if the types don’t match.

2 Likes
#6

Elixir might not have the type safety of the other languages you listed, but it may pair well for your use case. The syntax is somewhat familiar given your Ruby background. And you’d likely get a big performance upgrade.

  • Absinthe for GraphQL
  • Phoenix Channels for your WebSocket needs
  • Redix for Redis (although maybe Ecto is enough given the performance improvements you’d be getting?)

The source code for Level is a really nice example courtesy of @derrickreimer and takes a similar approach with Elixir and Elm and GraphQL.

closed #7

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.