HNHacker News
TopNewBestAskShowJobs

ilyash

247 karma · joined April 16, 2016

Software, operations, management.

Author of Next Generation Shell.

submissionscomments
ilyash··on Ask HN: What projects are you working on this weekend?
This weekend, like any other time when it's possible, I'm continuing to work on Next Generation Shell. It is a fully-fledged programming language for the DevOps-y niche (the one which was once dominated by Perl). The language contains domain specific facilities such as convenient running of external programs and data manipulation.

https://ngs-lang.org/

ilyash··on Oil 0.10.0 – Can Unix Shell Error Handling Be Fixed Once and for All?
Better ergonomics of error handling is one of the many reasons the author is working on the new shell, Oil. More at https://www.oilshell.org/blog/2018/01/28.html

I am working on another one, Next Generation Shell. We agree on the problem, including that error handling in bash is subpar.

> good programming requires foreseeing and handling errors

I have many small scripts that don't care about errors. Continuing execution in presence of errors is definitely not desirable in these instances, termination is. Ignoring errors is the wrong default for a language, I completely agree with Andy (the author) here. That's why bash has "set -euo pipefail" afterthought. Unfortunately it can't be made the default because of compatibility. Additionally, it has its own quirks.

In general, when judging decades old technologies, I do this check: if somebody was inventing the thing today, what would be the reaction? For bash, many choices made then would be unacceptable today. We know better now. Error handling is one of these choices.

Another related not stellar thing is the exit code of a Unix process. It was supposed to be enough to convey the status of a program. Non-zero is not always an error (think "test" or "grep"), making generic error handling not possible.

These are the decisions that we are paying for.

ilyash··on The temptation of writing shell scripts, illustrated
I guess that's what's called "for humans".

Thanks!

ilyash··on Hush, a modern shell scripting language
Prepared a comparison to Next Generation Shell here:

https://github.com/ngs-lang/ngs/wiki/Hush-vs-NGS

On one hand we are on it since 2013 so there is "more" but I would actually like to highlight the difference in OOP and functional approaches: types, inheritance, multiple dispatch.

ilyash··on Zq: An easier and faster alternative to jq
In Next Generation Shell (author here), it is not as ergonomic (yet?) but on the other hand it's a fully fledged no-nonsense programming language... and I claim quite a readable.

good_data = fetch("openlibrary.json").docs.filter({"author_name": Arr, "publish_year":Arr})

good_data.map({{"title": A.title, "author_name": A.author_name[0], "publish_year": A.publish_year[0]}}).group("author_name").mapv(len).sortv((>=)).limit(3)

ilyash··on Zq: An easier and faster alternative to jq
While we are at it, I have a list of JSON tools for command line here - https://ilya-sher.org/2018/04/10/list-of-json-tools-for-comm...
ilyash··on Zq: An easier and faster alternative to jq
.. or you can try Next Generation Shell (author here):

fetch("cars.json").filter({"color": "red"})

# or

echo(fetch("cars.json").filter({"color": "red"}))

ilyash··on Hush, a modern shell scripting language
Hi. Author of Next Generation Shell. I share the line of thought with Hush. But then we have arrived at different solutions. Small comparison here - https://www.reddit.com/r/ProgrammingLanguages/comments/ubwiz...

In my probably biased view, NGS is even more domain specific (handling of exit codes, syntax for running+parsing, etc) and more concise.

ilyash··on The temptation of writing shell scripts, illustrated
Thank you! I was thinking to add some code snippets on the website. Other projects do that and I think it gives you the "feel" pretty quickly.
ilyash··on The temptation of writing shell scripts, illustrated
Thanks!
ilyash··on The temptation of writing shell scripts, illustrated
It is now the niche of Next Generation Shell. Totally not humble and biased opinion... maybe. I'm the author. You are very welcome to make your own judgement - https://ngs-lang.org/
ilyash··on Clojure isn’t for me (2020)
Next Generation Shell: "hold my beer"

    F fuckoff(x) "lol"
    echo(5.fuckoff())
    echo("Hello World".fuckoff())
ilyash··on I'm tired of Google's business products
Yep. Worked for us when the issue got quite a bit of attention.

Details - https://ilya-sher.org/2018/03/23/google-deleted-our-g-suite/

ilyash··on The ordering operators
Thank you!

For scripting, it is significantly better than bash (at least for most of the cases that I have).

The interactive part is not implemented yet but it is planned to be quite different from the dominant decades old approach. The plan is at https://github.com/ngs-lang/ngs/wiki/UI-Design

ilyash··on The ordering operators
For comparison, in Next Generation Shell, the above would be solved as follows:

    version_ok = version.split(".").map(Int) >= [3, 6, 8]
ilyash··on Show HN: Warp, a Rust-based terminal
Hello. Author of Next Generation Shell here. Good to see the attempt to fix the shitty user experience that is decades old.

More NGS perspective on the UI - https://github.com/ngs-lang/ngs/wiki/UI-Design

ilyash··on Pure Bash Bible – A collection of pure bash alternatives to external processes
Nice... but how you fix the way something fundamental as the way `if` works in bash? Each `if` is a bomb. `if grep -q ...;then ...;else ...;fi`. Two branches for three possible exit codes. Given a long script and big amount of output, you will miss the error message such as "file not found" and the execution will peacefully continue into the else branch.

Things like the above motivated me to create Next Generation Shell.

Edit: hint - yes branch, no branch, exception.

More about motivation: https://ilya-sher.org/2020/10/31/bash-or-python-the-square-p...

Project: https://github.com/ngs-lang/ngs

ilyash··on Jo – a shell command to create JSON (2016)
Depending on your exact needs, you might also want to try Next Generation Shell. It's a fully featured programming language for the DevOps-y stuff with convenient "print JSON" switch so "ngs -pj YOUR_EXPR" evaluates the expression, serializes the result as JSON and prints it.

Disclosure: I'm the author

Project link: https://github.com/ngs-lang/ngs

Enjoy!

ilyash··on Rails is not written in Ruby
Previously posted - https://news.ycombinator.com/item?id=30194136
ilyash··on I got foiled by PHP's deceptive Frankenstein “dictionary or list” ARR (cont)
Yep. In Next Generation Shell for example. At the time that the language was created, around 2013, it was clear to me (author of the language) that ordered traversal is beneficial and outweighs the downsides (memory usage).
ilyash··on Grep one-liners as CI tasks
Interesting to see how nobody cares about exit code 2. Modify your grep command to have syntax error and you will always think you have all the translations.

Edit: ah.. forgot the whole point.. In Next Generation Shell (author here) this doesn't happen: ngs -e '$(grep ...).not()' does right thing. grep exit code 0 becomes 1, 1 becomes 0, 2 becomes 240 (exception)

ilyash··on You shouldn't parse the output of ls(1)
Hi. Author of Next Generation Shell here. Totally agree. Also UI of the shell is stuck and ignores pretty much everything that happened in last decades.

Here is my plan for the UI: https://github.com/ngs-lang/ngs/wiki/UI-Design

Edit: but I do try to keep interoperability with existing bullshit.

ilyash··on Ask HN: What is your favorite programming language and why?
"Why I have no favorite programming language"

https://ilya-sher.org/2017/10/10/why-i-have-no-favorite-prog...

ilyash··on Unix Shell Programming: The Next 50 Years
> As a daily shell user, I want a shell that uses even less resources

Why is this important consideration for you? What's the use case?

ilyash··on Rails 7 Released
> It’s extremely convenient for shell scripting (basically anywhere I might have used Perl in the past).

Exactly the uses cases that I want to "steal" from Python, Ruby, Perl, etc.

Not because Next Generation Shell is "better" but because it's focused on the use cases - https://github.com/ngs-lang/ngs/wiki/Use-Cases ... while still being a "real" programming language.

ilyash··on Cheating at a company group activity using Unix tools
> No "proper programming language" is capable of ergonomically piping between programs.

Solved. https://github.com/ngs-lang/ngs

I'm the author. Frustrated with exactly this situation I created Next Generation Shell. It's a "proper programming language" on one hand but domain-specific for "DevOps"y scripting on another. So sane syntax, data structures, error handling, multiple dispatch on one hand but also syntax for running external programs, pipes and redirects.

You are welcome!

ilyash··on NGS – Next Generation Shell
Here is a bit of history which might shed some light on the decision.

First and very partial implementation - JavaScript. It was a prototype which I knew I will be throwing away... and I did.

Second attempt, also very partial - Lisp. I used SBCL. Skipping the details here but the result was as follows: got stuck with two different unrelated issues. I did not know would I be stuck with additional issues even if I somehow solve these two.

Third attempt - found a language in which I will never be stuck unable to solve something. C. Also, looked around: bash, Python, Ruby - they are all C. At the time I thought I might be "borrowing" some code from. It didn't happen. I did look though.

Edit: unexpectedly a huge chunk of work, which is garbage collection, was already done for me. C has garbage collection! It is a library - https://en.wikipedia.org/wiki/Boehm_garbage_collector

ilyash··on NGS – Next Generation Shell
Hi!

Author here.

> This seems to be more a simple programming language than a shell.

Currently it's only a programming language. The interactive part will be implemented in the NGS language itself.

> simple programming language

Since simple is relative: NGS is simpler than Java and more complex than awk I would say. NGS has exceptions, types with inheritance, multiple dispatch, guards (additional conditions to invoke a method), basic functional programming support, patterns, (new, in progress) facility for deeply nested data manipulation, automatic parsing of command line arguments when invoking the optional main(), threads, domain-specific syntax and facilities for running external programs and file manipulation.

Simplicity is one of the language goals but not over expressive power.

> A shell is first and foremost a UI, only secondarily a scripting language...

I'm having hard time to agree or disagree. There is a lot of interactive usage but there are also a lot of scripts in bash. When I see the scripts I wish bash was "more of a programming language".

> foremost a UI

... where surprisingly little innovation happened over the last decades. It's like in the movies when there is an object in the center of the screen and the whole world is rapidly changing around it. That object is the shell. My plans for UI are at https://github.com/ngs-lang/ngs/wiki/UI-Design .

> easily take a series of commands you'd do manually and put them in a script

You can do it in NGS and even in this simplest use case it will be better than bash - in case of an error the execution will stop (like with -e in bash) and NGS will print stack trace (which I don't know how to do in bash and not sure it can be done in a sane manner).

Edit: $a will expand to exactly one argument (as opposed to zero or more), rm -rf "$mydir/" will throw exception if mydir is undefined. Typical things which are expected from modern programming languages.

NGS uses small subset of syntax from bash so running external programs in the simple forms looks the same.

ilyash··on NGS – Next Generation Shell
Hello!

Author here. AMA here or in Discord - https://discord.gg/6VqgcpM

ilyash··on Common shell script mistakes (2008)
Comparing shamelessly to my own Next Generation Shell, puting aside the completely insane syntax matters that nobody today would do or accept (such as $x expanding to zero or more arguments).

cleaning up temp files

Use TmpFile. It is automatically removed when the script exits.

stopping automatically on error

As in many other modern languages, NGS has exceptions and prints stack trace when they are not handled. Nothing special is required from the programmer.

echoing errors

Use built in error("my message") function. Alternatively, use exit("my message") to print the error and exit, the exit code defaults to 1 but can provided. Tired of seeing bash scripts starting with definition of warn(), debug(), error(), etc functions. These are part of standard library in NGS.

You are welcome to check out the Next Generation Shell project.

https://github.com/ngs-lang/ngs

← PreviousPage 2 of 5Next →