ela

Questions

ela, weighed up.

24 questions on how ela compares with the shells and languages you know, what it does well, where it falls short and where it stands.

1

How ela compares

ela beside the shells and languages a script is written in today.

How does ela compare to Bash?

Bash is on every Linux machine, and ela is not. ela is built for the places Bash goes wrong: an unset variable, a failed command the script carries on past, a value split into words, quoting. In ela a typo such as $cahce stops the script with an error at its line, where Bash expands it to nothing and rm -rf $cahce/* becomes rm -rf /*.

How does ela compare to fish?

fish is an interactive shell with a script language of its own that is not POSIX. ela covers the prompt too, with highlighting, Tab completion, history and job control, and adds what scripts need: structs and enums, procs with named arguments, imports, and JSON, YAML and TOML as data.

How does ela compare to Oils and YSH?

YSH, the language of the Oils project, is ela's closest relative: a shell that grows into a language and is strict by default. Oils keeps a path from Bash, and its OSH runs Bash scripts as they are. ela starts clean, with no Bash compatibility, so there is one way to write each thing.

How does ela compare to Nushell?

Nushell passes structured tables through its pipelines. ela keeps Unix text pipelines as they are, and turns text into data where a script asks for it, with json.decode, maps and lists. Someone who knows Bash reads an ela pipeline without learning a new model of pipes.

How does ela compare to PowerShell?

PowerShell passes .NET objects between commands and runs on the .NET runtime. ela is a native program of 3.3 MB with no runtime to install, and the commands it runs are the system's own.

When is Python the better choice?

Python is the better choice for a program that grows past a few hundred lines, and it has a library for almost anything. ela is for the script that mostly runs commands: a command is a line, its output is captured with $( ), and a failure stops the script, with none of subprocess's arguments and flags.

2

What ela does well

The parts of ela a script, and its writer, lean on most.

What is different about ela's errors?

Every error names the rule that was broken and what to write instead. ela --explain 'message' gives any message's rule, the reason for it, a wrong and a right example and the manual section to read, and the build fails when a message has no entry. A person learns the language from them, and so does an AI agent writing a script.

What happens when a command fails?

The script stops at that line, which is what set -euo pipefail attempts in Bash, without its gaps. A yes-or-no question is a condition, if grep -q needle notes.txt. Where a failure is expected, try gives it as a value: err = try make dist gives null, or an Error with the exit code and stderr, and error.is($err, 2) asks for a code. See Error handling.

What tools come with ela?

Each is an option of the one ela binary, beside a few files for editors.

  • --lsp is a language server: errors as you type, hover with the --explain entry, formatting, completion, definitions and colour.
  • Editor files colour a script where no server runs: a TextMate grammar generated from ela, a Vim syntax file, and ela.lang for GtkSourceView editors, KAT800 among them.
  • A plugin for Neovim starts the server and colours the buffer, and --spec editors sets up every other editor.
  • --agent prints the guide for an AI agent, and sets up its skill and the hook that sends its shell commands through ela.
  • --translate bash writes a Bash script as ela, and --report counts what carries over.
  • --lint finds mistakes without running anything.
  • --fmt lays a script out.
  • --explain gives any message's rule, the reason for it, and a wrong and a right example.
  • --spec prints a section of this site's manual.
  • --builtins lists every built-in proc, package proc and shell built-in.
  • --watch runs a script again on every save.
  • --usage shows a run's CPU, memory and disk on the bottom row.
  • --doctor checks the shell's setup.

How do the tutorial and the playground run ela in the browser?

The tutorial and the playground run ela's own interpreter, built from ela's source for WebAssembly by the ela-wasm repository. It runs in a web worker on the page, and nothing is sent to a server. The language works there, with the str, json, toml, csv, table, text, rand, url and time packages. Programs, files, re, yaml and the rest need ela installed: each stops the script at its line with not in the browser: … needs ela on a machine. The module is about 340 KB compressed with gzip. See In a browser page.

How does ela handle secrets?

A script reads a secret from the system keyring with $keyring.NAME instead of keeping it in a file. Error messages mask it, and ela --lint warns when one reaches a command's arguments, where any user of the machine can read it in the process list.

Why does ela work the way it does?

The specification, the messages and the reasons behind them say the same thing. Each rule has its reason written down beside the alternatives that were weighed and rejected, and the Goals page says what the language is for.

Can ela convert my Bash scripts?

Yes. ela --translate bash deploy.sh > deploy.ela writes a Bash or sh script as ela that parses and is laid out as ela --fmt lays it. A line with no ela form stays in place as a # bash: comment, and stderr names it with what to write instead. --report shows the work before you start. The translated script stops at its first failed command, as every ela script does, and the report names each place where Bash would have gone on. Across the 638 postinst maintainer scripts of a Debian-based system, 12,956 of 15,069 lines, 85%, translate as they are.

terminal
€ ela --translate bash --report deploy.shdeploy.sh: 7 lines of code, 6 translated (85%), 1 left for hand left for hand, by form:      1  [ -O ] where ela does otherwise:      3  a failed command deploy.sh:3: bash went on if this failed; ela stops: write try cmd to go ondeploy.sh:4: bash went on if this failed; ela stops: write try cmd to go ondeploy.sh:5: ela has no proc for test -O: write if test -O path, or rewrite it by handdeploy.sh:8: bash went on if this failed; ela stops: write try cmd to go on
3

ela for AI agents

An agent's shell tool running ela, and what it gets from it.

How do I call ela from another shell or an AI agent?

Hand ela the code on stdin in a quoted here-document, ela <<'EOF' … EOF. With the marker quoted, the calling shell passes the code through as written, so ela's quotes and backslashes need no escaping; ela -c '…' breaks at the first ' in the code. ela --lint - --json on the same here-document finds mistakes before anything runs, and ela --explain takes any error ela prints. ela --agent prints the whole guide, and --save writes it as a skill. See Calling ela.

How does the hook keep an agent in ela?

ela --agent --hooks writes a hook that sends each of the agent's shell commands through ela --agent hook before it runs. The hook reads the command with ela's parser: a line of ela goes through, and bash is refused with the same commands written as ela, ready to run. ela --agent commands --json lists every command a script would run, inside procs, with blocks and imported files, so a check of your own, such as "scan before you push", holds even inside a script file or a proc, where a text match can't see. See The hook.

terminal
ela --agent hook: this shell runs ela, and the command is bash: run it as ela, as below ela <<'EOF'cd sitemake ciEOFela --lint - checks it before it runs; ela --agent prints the guide.

Are ela scripts longer than Bash?

Yes, on purpose. The 26 scripts that build and check the project's repositories grew from 4,529 lines in Bash, sh and Python to 7,225 in ela, with path.base($f) in place of ${f##*/} and if $x == "" in place of [[ -z $x ]]. Each line says what it does, so a person can read the hundreds of lines an agent writes.

4

Where ela falls short

What to weigh before writing your next script in ela.

Who uses ela?

No one outside the project yet, and there are no packages from others. ela runs on Linux, and its browser build runs the tutorial and the playground and no more. One person writes it. A language lives on what people build with it, and Bash has a lead of decades.

Why can't a line end in an operator?

Go carries an expression over with the operator at the end of the line, total := price + with tax below it: Go puts a hidden ; after a line that ends in a name, a literal or a closing bracket (the Go spec's Semicolons), so a line that starts with + is an error there. ela is the other way round, because a line of an ela script can be a command: ls * and cd - end in * and - and are complete. Outside brackets, an operator at the end of a line is an error that says what to write, and ; ends a line too, so x = 1 +; is the same error. Arithmetic carries on inside brackets, and and and or at the start of the next line. See Statements and blocks.

total = ($price    + $tax)

Is ela fast?

ela runs a script by walking its syntax tree, with no compiling step. That suits a script whose time goes on the commands it runs. A loop over millions of numbers belongs in a compiled language. See Speed for measurements beside Bash.

Can ela call a web API?

Through curl: out, err = try $(curl -sS $url), then json.decode($out). ela has no HTTP client of its own, and the name http is kept for one, as URLs and HTTP says.

Does ela have lambdas or closures?

No. Where a built-in takes a proc, as table.sort takes a comparator and table.filter a test of a row, a script passes a declared proc by its name: by = newest_first. An error in it then points at the proc, at its own line, and ela --lint follows the call and checks the name and the count of its arguments. The cost is that a script cannot write its own higher-order helpers, a proc that takes a proc, and a short comparator is still a proc, written on one line: proc newest_first(a, b); return $a["when"] > $b["when"]. See Tables.

How much is there to ela?

Beside the language and the shell, ela has packages for PDF documents, charts in the terminal, Markdown, the keyring, JSON, YAML and TOML, CSV for spreadsheets, and tables to sort, filter and page them, and around it a language server and editor files and a build for the browser. That is a wide surface for one project to keep correct.

5

Where ela stands

ela as a design, and ela as something to use.

Is ela a good choice for scripts?

For scripts, ela changes the defaults that make Bash and fish risky: an unset variable is an error, a failure stops the script, and a value is never split into words. It is strict by default as YSH is, and asks less of a Bash user than Nushell does.

Is ela ready to use?

The language, the shell and the manual cover everything on this site, and the tests run on every change. What ela has not had yet is users: its worth shows when people write their own scripts in it.