dwyl / learn-elixir

:droplet: Learn the Elixir programming language to build functional, fast, scalable and maintainable web applications!
1.6k stars 107 forks source link

Create a Livebook sub repo? #194

Open ndrean opened 1 year ago

ndrean commented 1 year ago

I am looking for a place for this.

For example, a Livebook is a good place to play with data visualisation. This repo is a good guide: https://book.elixir4datascience.com/3-dataviz.html#content

ndrean commented 1 year ago

I liked the idea of a "Run in Livebook" button to explore libraries:

https://www.youtube.com/watch?v=0wg5S91fam at 21'45

nelsonic commented 1 year ago

https://www.youtube.com/watch?v=0wg5S91fam 404 😢

image
ndrean commented 1 year ago

On youtube: "A Blueprint for Intuitive Internal Elixir Ecosystems | Ryan Young | ElixirConf EU 2022" Trying again??

Screenshot 2023-01-03 at 16 36 18

So how do you do such a button? Is it a link ? <a href="an-url-where-a-livebook-is???/>, or it runs a command livebook server <some-file> on your computer?

Part of this talk is here: https://dashbit.co/blog/mix-hex-registry-build

Screenshot 2023-01-03 at 16 22 35

ndrean commented 1 year ago

This guy seems to be an expert:

https://github.com/jonatanklosko/notebooks/tree/main/examples

nelsonic commented 1 year ago

Keen to do this for https://github.com/dwyl/learn-elixir 💭

ndrean commented 1 year ago

"Run in livebook" button: see https://livebook.dev/badge

Screenshot 2023-01-05 at 13 09 18 Screenshot 2023-01-07 at 18 15 35
ndrean commented 1 year ago

One step further: create smart cells (aka create your own JS front-end):

ElixirConf 2022 - Stephen Ball - Livebook smart cells are amazing

Screenshot 2023-01-09 at 11 23 31

ndrean commented 1 year ago

Keen to do this for https://github.com/dwyl/learn-elixir 💭

I almost did it, but needs to be polished, especially choosing between using the terminal with IEX or exclusively using the Livebook. The pb is that you can't define a module in a cell and then come back later to it. There are some repetitions when you add step-by-step functions in a module as you need it all. You can index the versions of the module but it may need lengthy explanations. Not sure. Then running tests in Livebook is not obvious but I think I made it. Finally, I can't copy-paste or load the code of my livebook to fly.io because it doesn't compile. I only used basic packages. So I can't just put "run in livebook". If I code directly in a fly.io livebook, then I can't use doctest because the version is not up-to-date .....

A little plus. I played with the factorial and was surprised to discover that the "spawn" version outperforms the others pretty quickly. I think the plot I made below helps to visualize why concurrency is interesting when you run heavy computations.

visualization (8)

nelsonic commented 1 year ago

Very cool. 👌

ndrean commented 1 year ago

https://github.com/dwyl/learn-elixir-on-livebok/blob/main/learn-elixir-on-livebook.livemd

The solution to run it seems...hacky but works :)

Please feel free to criticize, or modify it in any way