brainlid

brainlid

ThinkingElixir Discussion: Mental models for your Elixir and LiveView code

In ThinkingElixir Podcast episode #40, we talked about the mental models we use when we think about writing our Elixir code or when thinking about our Elixir system. We also covered how we approach writing our LiveView code.

This topic is a public discussion place where we’d like to hear from you! What works for you? Did you make the mistake of trying to do it just the way you would in React? What tips work for you? How do you approach it now? Did any of our discussion help or resonate with you?

The LiveView discussion starts at 31:20.

First Post!

a8t

a8t

Broken link?

Most Liked

brainlid

brainlid

Thanks for the questions! We released an episode that wasn’t an interview, but instead a discussion around “the mental models we use for writing Elixir code” and a related topic of “the ways we think about and approach LiveView”. The goal was two things:

  1. Find a place where we could have community engagement.
  2. Direct people to ElixirForum as a place where they could engage with the larger Elixir community.

My alternatives for community engagement are a Thinking Elixir Discord or Slack, but that would be a community silo and I wanted people coming to Elixir to find and engage at ElixirForum. If this isn’t the right forum or approach, I understand. Is there a better way to go about that? One that would work better for your vision of what ElixirForum is and should be?

soup

soup

Slightly off topic, but since this episode mentioned tailwind’s JIT, in my short experience, you need to patch the default webpack.config.js with this (at the very bottom):

.concat(devMode ? [
  new HardSourceWebpackPlugin(),
  new HardSourceWebpackPlugin.ExcludeModulePlugin([
    {
        // HardSource works with mini-css-extract-plugin but due to how
        // mini-css emits assets, assets are not emitted on repeated builds with
        // mini-css and hard-source together. Ignoring the mini-css loader
        // modules, but not the other css loader modules, excludes the modules
        // that mini-css needs rebuilt to output assets every time.
        test: /mini-css-extract-plugin[\\/]dist[\\/]loader/,
    },
])
] : [])

and follow the tailwindcssjit install instructions as normal.

Not sure if it’s worth phx PR or not, might have unforeseen consequences.

PS: JIT is totally worth it. No more long waits if you change css files.

I think the patch above is all you actually need but a really scrappy working repo is here GitHub - rktjmp/phx-tailwindcssjit: How to setup Phoenix Framework and TailwindCSS-JIT · GitHub to compare configs with if someone has trouble.

AndyL

AndyL

For me, this is one of your most valuable episodes. Prompted me to go back and listen to the Sasa Jurik interview. Now my schemas are all organized within their own boundry - a flatter organization that I think will be easier to maintain over time.

Last Post!

Sebb

Sebb

I finally had time to listen to the episode.

I really liked the workbench metaphor. I try to recapitulate as I understood it:

  • a couple of workbenches each with a set of tools (modules)
  • on them binders with some sheets of paper (functions)
  • little pixies running from bench to bench (processes)
  • carrying blocks of wood (data)

The pixie’s duty is to transform the block of wood into something useful, say she wants to create a shiny wooden ball. I think she needs some instructions how to do that.
She gets those from a gremlin (coordinator) sitting on a shiny throne at the boundary of the workshop.

# instructions for pixie 4711 issued by gremlin 0815
block_of_wood
|> WoodturningBench.shape_to_ball
|> WoodturningBench.polish

That’s easy, we can have thousands of pixies doing that in parallel (not really, but they are so fast, that it seems like it) and we can have the fairies of the QA division follow the same instructions. And we know, if they are happy with their result, we’ll be happy with what the pixies do in production.

So everything is good. Until the ogres at management decide, that revenue has to be increased. The orks at marketing have the solution: Lets sell not just shiny balls, but red shiny balls.

The gremlins add

...
|> Paintshop.paint(:red)

to the instructions. Everything still works well and revenue increases as the customers are enthusiastic about the red shiny balls. But not for long. The paint peels of from the balls and customers are furious and demand refunds. So we need a quick solution. Its easy. We just have to add a primer.

...
|> Paintshop.add_primer
|> Paintshop.paint(:red)

But wait, the fairies at QA notice that the shininess has decreased. Someone reads the instructions of the primer. It has to dry for an hour! So now the pixies have to grow some gremlin ears: after they applied the primer they tell another gremlin to wake them after an hour, so that they then can apply the paint. First tests with this approach in :dev are promising, but the QA division is not happy. They are not allowed such long running jobs. The ogres decide to increase revenue even more by reorganizing (dissipate) QA. The product is perfect and shiny, no complaining fairies anymore, so they lived happily ever after with ever growing revenue … NOT (some fatal flaw creeped in and the whole workshop got bankrupt.)

Where Next?

Popular in Discussions Top

scouten
I’m looking for a host for the server part of a small (personal) side project that I’m working on. It’s currently written in Node.js and ...
New
und0ck3d
Hello everyone! A few days ago I’ve created a topic here about how people were creating CMSs with Elixir and Phoenix. I’ve been studying...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
wmnnd
The Go vs Elixir thread got me thinking: Would it be too hard to implement a simple mechanism for creating Go-style static app binaries f...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
Fl4m3Ph03n1x
Background This question comes mainly from my ignorance. Today is Black Friday, one of my favorite days of the year to buy books. One boo...
New
mmmrrr
Just saw that dhh announced https://hotwire.dev/ Is it just me or is this essentially live view? :smiley: Although I like the “iFrame-e...
New

Other popular topics Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement