rahil627
I’ve been out of the computer world for ages. During those ages, I’ve got a bunch of ideas. I’ve chosen Phoenix/Elixir (over Flutter/Dart/Google) to prototype most of 'em quickly.
Although the core apps will be written using/in Phoenix/Elixir, I still find myself running to ruby for small scripts, cli apps, 'n such for more personal, smaller thingies, most of which ai does for me. After having gone through configuring every LSP (the “ruby” vs extension turned out to be the oldest; shopify’s extension for some reason wasn’t listed [dat archlinux life] and gave me troubles; solargraph works but requires extra steps), I wondered, maybe I should just use elixir for scripting everything too? In contrast, Elixir’s LSP worked perfectly on the first try. ![]()
does elixir make sense for small scripts? or does the functional-ness make it feel clunky or overkill? since there’s iex, I’m guessing there’s already an interpreter..
it makes sense to invest in one language/library, not two…
having made some tiny games (<3 haxe), I feel comfort in any non-functional object-oriented lang, but perhaps over-time, I’ll be able to think functionally and use elixir for scripting too?..
is everyone here writing their little everyday scripts in elixir? Were there times one even had to reach for ruby?
just wondering…
–
https://github.com/wojtekmach/mix_install_examples/tree/main
- this repo in particular is what won me over to Phoenix, as it comprises of minimalistic examples of frameworks (<50loc Phoenix app!)
(note: flaming not intentional, i want to love ruby too!
)
Trending in Discussions
Other Trending Topics
Chat & Discussions>Discussions
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First 10 of 22 Posts
D4no0
The only important thing to keep in mind when running these scripts (mainly with escript) is the fact that there is always a quite substantial delay when it starts, because it always spins a new VM instance.
Running them by hand should make no difference, however if you plan on using them in some automated fashion, this becomes a bottleneck very fast.
rahil627
ahhhh, right. a very interesting factor… yeah i guess that’s why scripting/interpreted langs make sense for devops sorta stuff! hmmm..
D4no0
This is not a interpretation issue per-say, because
.exsfiles are also interpreted, but more of a performance problem of the VM when starting up.From my understanding the penalty comes from the fact that application supervision tree starts all processes synchronously, this is a great feature for developers, because you don’t have to think about race conditions, but the price is performance.
At the same time I might be wrong and it is just something that will be fixed in the future, currently it doesn’t have a wide impact because most of the elixir applications work as long-running daemons.
dimitarvp
Scripting doesn’t have anything to do with it, Ruby and Python have bootstrapping time that I find unacceptable as well as Erlang’s / Elixir’s. They all need time to get going.
For scripting I use bash / zsh if it’s something quick / one-off, or reach for Golang if I suspect I’ll use the tool regularly and need logic that bash / zsh make difficult to code (and sadly they have a lot of foot guns).
It’s “per se” btw.
Many of us would wet their pants if the BEAM has CLI parameters that would allow it to boot much faster (maybe at the cost of initializing apps slower? no idea), trust me. There was a discussion some months ago about it and there were various options listed even by core Erlang maintainers but none of them truly helped.
D4no0
I think it would be nice, however I think this is not the right tool for CLI applications, at least not in the fashion of run this command and close.
I’ve had this problem before on a project, and what I ended up doing is to switch the strategy to a long-running process, that basically receives input and generates the output without closing the process, but of course there are many potential problems with this approach.
dimitarvp
Yes, but only because of the slow boot time. If that got addressed then suddenly will be more than adequate for CLI apps, there are libraries making it easier too.
Eh. At this point it’s probably best to just rewrite it. Good for you that you made it work but we both know that it’s best to use the tools to their strengths and not try to bend them.
D4no0
I think one of the solutions we can employ that will work currently would be to have a runtime started and run the scripts in the fashion livebook does, solves the problem and doesn’t require expensive and hard work from VM maintainers.
In that case it was not possible, the CLI was just a wrapper for a custom binary parsing library that we had to use on another project that was written in node, and it was easier from the perspective of infrastructure to ship it as a CLI and not as another service.
smathy
IMHO other tools definitely have better options for the sorts of scripts I find myself writing, although I tend to reach for sed, awk or sh (and occasionally perl) rather than ruby. By the time a script approaches something more like an ETL then I’m going to be writing a mix task, although nowadays I’ll be seriously considering livebook.
derek-zhou
Depends on what you know. If you know Ruby well, I see no point to switch to Elixir for that. I still use Perl for simple scripting:
AndyL
I’ve experienced two problems with elixir scripting 1) slow startup time 2) lack of ‘getch’. If neither of these matter to you, then Elixir is great for scripting! Check out Ratatouille a very nice TUI toolkit for Elixir.