308 points · by ingve · 4y ago · 95 comments
I have more 'books' on C++, python, SQL, web dev, dart/flutter, clojure, ruby, and more:
I use these for the programming-focused cs courses that I teach instead of having the students buy bloated textbooks. The students prefer them to books (no surprise) and videos (somewhat surprising). The code is searchable and copy/pasteable so the students actually use it.
The tool is free and open.
Congratulations on designing and developing the system, as well as pouring such a high quality content to it.
I can see the code of a book on GitHub[1]. It seems that the data of a single chapter is crushed in a single JS object[2].
Is the chapter data manageable in some text format, or is it only through the GUI presented in the docs[3]?
[1] https://github.com/markm208/exbook.
[2] https://github.com/markm208/exbook/blob/master/chapter1/01/j...
Thanks for posting!
For some reason LiveView has changed between versions, and the documentation isn’t the greatest on explaining why or what to do to remedy it, but its broke my app. I’ve managed to fix the majority of it but then the third party libraries used have not kept up (for authentication of all things). There is so little people using Elixir/Phoenix/LiveView that libraries are often poor quality and maintained by one person or very few people. It makes me miss Django for the batteries included completeness, quality of documentation and eco system.
Phoenix also feels a little bit magical in the way Rails is, and I hated Rails for that. Give me configuration over convention and stop with the damn macros.
I am also not convinced with Elixir as a language, I miss types, I miss C# and Typescripts documentation or the fact they feel well designed, I want something to replace Python as my goto and Elixir just feels like a dead end that happens to have a web framework with some excellent ideas.
So I am currently thinking of rewriting the whole damn thing and leaving Elixir.
I am obviously biased but I would stick around. :) I assume you started with LiveView early on, which means the documentation was sprouting and best practices still evolving.
Nowadays it is still pre-1.0 but much closer to its vision, so you should find better docs on the current practices. We now support components too, which declare each attribute, alongside their docs and types. So assuming you go through the update, I am hoping you will have a good time once it is done. And don’t hesitate to reach out in ElixirForum.com if you have questions.
Regarding types, we are researching types for Elixir: https://elixir-lang.org/blog/2022/10/05/my-future-with-elixi... - this is still years ahead, but I thought I would mention in context.
I'm sure you've been linked these a thousand times, but the docs for Laravel are imo, the gold standard for developer documentation. I love the idea of Hex being a built in solution for documentation, but a hodgepodge short guides supplemented by the Hex docs isn't enough.
I also realize you're not Chris, but I figured it was worth mentioning. I do really like Elixir and hope I can come back to it when these ideas mature a little more!
I really like the promise of Phoenix, it really is one of the most forward thinking projects I have come across - hence continuing using it, though I don't have all the time in the world to invest in it so just jumping in and out can be painful.
Want this project to work though, I have tried commercial products, IOS apps, and nothing matches upto my vision or indeed my old working prototype.
I've felt this about every backend web framework I've encountered, Django included. There's a tension between reducing boiler-plate, and not having directory structures/symbol names/etc. have some implicit order to them. If you want explicitness, don't use a framework and maybe use something like Flask/Werkzeug
> I miss types
Most frameworks have typespecs defined which are enforced by dialyzer, using a much richer type system than most. e.g. Without creating some explicit enum you can make a function signature like:
@spec some_function() :: {:error, :bad_args | :out_of_bounds } | {:ok, SomeStruct.t}
And then you can a caller can just pattern match on that with a 'case' statement, and dialyzer will complain if all paths aren't handled.
> I miss C# and Typescripts documentation
hexdocs.pm is pretty amazing. Elixir as a language encourages documentation and has iterated heavily on its documentation tooling. I love that I can just fire up an iex console and go `h Module.some_command` and I'll get great docs back. And then `@doctests` that both work as inline unit tests as well as low-cost documentation for the library author. I think the incentives to make good documentation are there, and that has inspired the community to document well. And then there's elixirforum.com if I get stuck. In constrast, many times a Django extension has left me wanting in its description about intended behaviours.
>
> I've felt this about every backend web framework I've encountered, Django included. There's a tension between reducing boiler-plate, and not having directory structures/symbol names/etc. have some implicit order to them. If you want explicitness, don't use a framework and maybe use something like Flask/Werkzeug
One of the things I love about phoenix is how little magic there is. Not directed at you, but I agree there is always some amount of "it just works" with a framework but Elixir/Phoenix felt immeasurably more "the code is here" vs "well that particular thing is method_missing'd a few layers down into this which routes into that and then kaboom, here's your entire app."
This is helped by Ecto, which is the perfect mix of helpful and not helpful to me. It gets what I ask for and only what I ask for. It tells me when I've mucked up and generally it feels like a nice API to SQL vs its own thing (and dropping custom SQL is super easy). The data layer is most often the most hidden magic layer in frameworks IMO as routing some HTTP GET to some controller/function/whatever is pretty simple and easy to reckon.
Will be reading the IEx documentation more closely.
Documentation across the elixir ecosystem is pretty good, I find. I am way more comfortable in elixir ecosystem docs over python ecosystem docs.
0.16 to 0.18 has been mostly okay again, but I’ve seen bugs introduced into an app just by adding IDs to HTML elements with a phx-hook on them. This is a problem since heex templates enforce that each hook does have an ID. It’s also strange that a totally new ID never used elsewhere in the app would break existing JS interop, but it does and it’s what I’ll be working on this week so we can continue upgrading…
Not sure what it’s going to be like upgrading to Phoenix 1.7, but I think it’s going to be a major undertaking and unfortunately most my Phoenix-related screencasts will become obsolete. Elixir itself and Ecto have been really stable, though.
This drives me nuts for example: https://guides.rubyonrails.org/layouts_and_rendering.html#re... - ok it's automatically parsing and rendering that template, based on that route and controller and it's less code but less explicit. And it assumes that we have written all the filenames correctly.
If only it were up to us simple devs who actually do the work. But its not. CTOs make the decisions and they bring in tech that "everyone else" is using. That means Java/Node/Python/C#/ and Angular/React is probably 90% of web code out there. I can try fighting the trend and specifically apply to niche tech jobs but its no fun...been doing that with Ruby for awhile until jobs literally dried up where I live. If you live in a remote friendly area (big parts of Europe) you can get by .. but I don't.
Controversially I'm also pleased about breaking changes if it means things get significantly better and there's less legacy to deal with.
All in all a fast-paced ecosystem for a fast-paced world.
I did seriously give it a try with elixir but felt I wouldn't appreciate it without dealing with js first, so it'll be something if I ever outraged with js, but between typescript, nextjs, jsx templates and all the excellent vscode tooling I'm happy. Infact much happier than dealing with Django's black magic.
Junior positions are quite uncommon and seem to require some hustle on the networking side.
Market seems to be cooling a bit for consulting (I do that) as the economy makes companies more careful.
None of the highly motivated Elixir devs I know are struggling to find work. Consulting/contract clients has been trickier lately but not impossible.
Source: I help companies connect with Elixir devs as a specialist recruiter. And I do contracting/consulting.
Feel free to ask questions here or via contact through underjord.io
https://elixir-lang.org/cases.html
Also there's https://elixir-companies.com/en
A friend and I have been trying it for a project and for a NixOS dweller like me it was less than 2 minutes of work. But for her it has been never ending troubles.
Otherwise, Elixir and Phoenix are fantastic! No explicit JavaScript is necessary and that alone sells it for me, but the concurrency story is so easy to grok that I'm amazed nobody else managed to recreate it in so many years..
For running directly on Windows you can simply run the Elixir installer, which will install Erlang and Elixir. After that, I highly recommend using the ElixirLS extension for Visual Studio Code. Note that on Windows, you need to use `iex.bat` and `mix.bat` instead of just `iex` and `mix` when running the commands. For example, `iex.bat -S mix.bat`. (I have it setup where I can leave off `.bat` for `mix`, but I can't remember what I did off the top of my head, if anything, to get that. `iex` conflicts with a PowerShell thing, so `iex.bat` is required.)
The other option is to install WSL2, install Erlang and Elixir there (I recommend using the asdf package manager (https://asdf-vm.com/). Once installed, use the Remote - SSH extension in Visual Studio Code on the Windows side to remote into the WSL2 instance. You could also download an official Elixir Docker container and again use Visual Studio Code (https://code.visualstudio.com/docs/devcontainers/containers).
I’ve made a doc for setting up Windows machines that I’ve been planning to share online but haven’t gotten around to yet. I’ll try to tonight and update this thread with a link.
Tldr; use WSL2 and Ubuntu stable. Use ASDF. Put your app on the Linux part of the filesystem and if your Postgres installation is also on the Linux side, then have bash start it for you.
kvm/Hypervisor support on windows is patchy, but there are a lot of lower performance virtual machines that can work.
I couldn't get Elixir 1.14 to work in September actually and reverted to 1.13.4, maybe I should try again.
But, after installing Elixir and pointing it to the otp 25.0.4 folder.
> elixir -v
> Cannot find file at 'c:\program files\erl-24.0\erts-12.0\bin\erl.exe' c:\program files\erl-24.0\erts-12.0\bin\erl.exe). This usually indicates a missing or moved file.
I install erl-24.0
> elixir -v
> Could not load module C:\Program Files\erl-24.2.2\erts-12.2.1\bin\erlexec.dll.
I install erl-24.2.2
> elixir -v
> {"init terminating in do_boot",{undef,[{elixir,start_cli,[],[]},{init,start_em,1,[{file,"init.erl"},{line,1191}]},{init,do_boot,3,[{file,"init.erl"},{line,889}]}]}} init terminating in do_boot ({undef,[{elixir,start_cli,[],[]},{init,start_em,1,[{_},{_}]},{init,do_boot,3,[{_},{_}]}]})
All the while erl-25.0.4 doesn't seem used (while being in the PATH env), I guess that's the problem but how do you enforce the OTP version?
----
edit:
So I kinda made it work. First I noticed that I had erl-24.0 installed by Chocolatey (which I don't remember using ahah) so I uninstalled that.
To make it clear, I'm on Windows 7 so the problems may come from that, but maybe it will help somebody else.
But then the elixir-websetup.exe (2.2) would not actually complete any longer (while doing so when erl-24 was installed by Chocolatey?), it could not find the actual elixir downloaded installer in C:\<Me>\etc (not the valid user path in Windows 7 but maybe in 10+ ?)
I then used elixir-websetup.exe 2.1 and got almost the same error but this time it complained about "elixir-v1.14.1 (Erlang/OTP 25)-setup.exe" while it actually downloaded "elixir-v1.14.1-setup.exe", which I was able to launch myself and finish the setup.
And voilà, Elixir 1.14.1 ;)
My understanding is that BEAM is designed for long running setups where hot reload of the code makes sense, and reboots are not happening that often thanks to the supervision trees.
But practically speaking how does it work under k8s env? When pod is being destroyed, what happens to all the messages sitting there? Pushing state out of actors is a possibility, but isn’t it ruin the whole idea of stateful actors ?
If you do write a stateful app, and run it in k8s, you can have state handover to a newly created pod. It works pretty well.
As for state handover between pods - what are the keywords to look for ?
A typical Phoenix app spawns one process for every HTTP request, websocket channel, or DB connection, for example. All these things have a lifetime shorter or equal to the pod's.
The VM gives guarantees and tools to ensure one of these process crashing will not affect the others, unless you want it to. For instance, if a request crashes, its memory will be reclaimed, open files will be closed, DB connections will be re-opened, the exit reason will be logged, error metrics incremented, etc. This is possible with no defensive programming like try/catch and so on, because the processes are isolated. For example they don't share memory, so it's always safe to deallocate something if its owner process died.
This gives a two-layer safety net that allows for very reliable apps, where the VM protects you against bugs in your own code, and Kubernetes protects you against bugs in Erlang, or really catastrophic failures. There's a good blog post on this: http://blog.plataformatec.com.br/2019/10/kubernetes-and-the-...
One thing that Elixir does well is handling faults - the relevant chunk of code 'crashes', and then restarts. The restart process does the appropriate recovery of any state. This turns all fault handling into a single code path (the startup path).
This approach also fits with the stateless style - the application should already be designed to start up properly and set up its state from scratch. Yes, in practice you design your application differently for a stateless deploy model, but Elixir helps you a lot in this model just as it does in the other one.
Don't tell me I'll love it because of some programming feature. Make me see why I would love it by showing me how cool it is !
[1] https://news.livebook.dev/whats-new-in-livebook-0.7-2wOPsY
LiveView has changed over time but that’s precisely why it is on a 0.x release cycle. Even then, we do our best to deprecate first whenever possible. But the goal is that established projects have been stable.
In any case, LiveView is nearing 1.0 now, which makes us comfortable enough to promote it as part of the default Phoenix experience.
I think the bigger problem with Elixir is the smallness of its community. There were several libraries that I started using (for example, Gringotts) that were actively developed for a while but then died off and nobody picked up where things were left off. Unfortunately, I am not skilled enough to put forth contributions myself (aside from the occasional bug report). But once LiveView hits 1.0, I think that if the community continues to expand, Elixir has an even brighter future.
Thanks for all your hard work making it possible! :)