News for hackers. Stuff that matters.
Re:Bakeware – Compile Elixir applications into single execut... by abhijat on Thursday September 17, 2020 @08:32AM (#24503803)
Has anyone used elixir for building command line tools? It seems like this would be very useful for distributing them.
Re:Bakeware – Compile Elixir applications into single execut... by nickjj on Thursday September 17, 2020 @08:54AM (#24503984)
The readme file in the repo mentions a ~500ms start up time. Maybe it's just me, but I wouldn't want to wait half a second for a tool to start running. For context most popular Unix tools start up in 1-2ms.
Re:Bakeware – Compile Elixir applications into single execut... by pzmarzly on Thursday September 17, 2020 @10:33AM (#24505100)
On my PC:

  time node -e "console.log('a')" # 0.377 total
  time ruby -e "p 'aaa'" # 0.084 total
  time python3 -c "print('a')" # 0.020 total
  time elixir -e "IO.puts 'a'" # 0.117 total
  time _build/prod/rel/bakeware/simple_script Hi # 0.205 total without zstd, 0.212 with
Another question is which language loads modules the fastest (afaik Ruby is kind of slow when it comes to `require`).
Re:Bakeware – Compile Elixir applications into single execut... by YorickPeterse on Thursday September 17, 2020 @10:52AM (#24505321)
> Another question is which language loads modules the fastest (afaik Ruby is kind of slow when it comes to `require`).

I think both Python and Ruby loosely follow a similar model. The difference is that IIRC Python caches bytecode files, while Ruby compiles them from scratch every time. Not sure how big of a performance impact that has, especially for simple cases like this.

And just to toot my own horn, using Inko (https://inko-lang.org/), I get:

    inko /tmp/test.inko # 0.470 total
Note that this invokes the horribly slow Ruby compiler currently in use. If you invoke the VM directly on the compiled bytecode, it only takes about 10 milliseconds to run. Using the `master` branch:

    vm/target/release/ivm /home/yorickpeterse/.cache/inko/bytecode/release/43/38021ddc9a3449ace13288a2fac894d1d3e2aaa.ibi # 0.008.8 total
In this case all modules (including the standard library) are included in the bytecode file, meaning no disk IO is necessary, and modules can be parsed in parallel.

This is something dynamic languages like Ruby and Python can't do, as loading modules is something that can be done anywhere at any time, so you have to process them one by one.

Re:Bakeware – Compile Elixir applications into single execut... by johnisgood on Friday September 18, 2020 @12:17AM (#24512950)
Perl's startup time is pretty good.
Re:Bakeware – Compile Elixir applications into single execut... by vendiddy on Thursday September 17, 2020 @02:19PM (#24508132)
I wouldn't use Elixir for short lived cli commands because of startup time. For that I'd probably turn to Go or Rust.

However for distributing long running server apps--where Elixir shines--I'm happy with this start-up time.

Re:Bakeware – Compile Elixir applications into single execut... by zorbash on Thursday September 17, 2020 @08:49AM (#24503933)
I have and blogged about it here

https://zorbash.com/post/building-command-line-applications-...

I'll give bakeware a go and probably update the post with the results.

Re:Bakeware – Compile Elixir applications into single execut... by freedomben on Thursday September 17, 2020 @10:13AM (#24504856)
I've used it to write CLI tools for myself and found it to be great for medium to large tools. Small tools it's still much faster and easier to grab Ruby (assuming a quick bash script isn't appropriate).

But yeah distribution is mostly a pain. I use the escript method but it's far from perfect. I'm excited about Bakeware and plan to try it.

Re:Bakeware – Compile Elixir applications into single execut... by brightball on Thursday September 17, 2020 @10:15AM (#24504870)
I've always felt like the ideal way to use Elixir for command line tooling would be to have some way to let a pipe feed into a new BEAM process from an already running application.