Thread #108655591
File: Untitled.png (5 KB)
5 KB PNG
why don't people like coding in bash anymore? it's so cvmfy
40 RepliesView Thread
>>
>>
I coded large projects in it. It feels really cool and edgy, but once you need to revisit it years later, when you look at the code, even well structured, it's pretty rubbish. In retrospect, I would rather write stuff in Go.
>>
File: 1759871912124984.webm (2 MB)
2 MB WEBM
>>108655591
xatnys tihs
>>
>>
>>
>>
>>
>>
>>
>>
>>108655591
I've started to write most of my new scripts in nushell. I love types and functional-ish programming, but LLMs are pretty bad at it.
Bash has so many warts that I always have to look up again if I haven't used it for more than a few months, but again, llms solve this.
>>
>>
>>
>>
>>
>>
>>
>>108657347
I was thinking about nushell, but murex has somethig called "typed pipelines," that goes a lot farther than structured data in tables.~ » runtime --marshallers
[
"*",
"bool",
"columns",
"csv",
"float",
"generic",
"hcl",
"int",
"json",
"jsonc",
"jsonl",
"md",
"null",
"num",
"path",
"paths",
"qs",
"str",
"string",
"toml",
"xml",
"yaml"
]
>>
>>
>>108657358
>>108657390
can you expand? I couldn't really find anything concrete about it in the docs but I've been vaguely annoyed about everything being a table in nushell in the past so this might be interesting to me
>>
>>108657411
You'll basically have to dig up example code or ask an ai, but json, yml, etc, are converted into maps and can be treated as such within the scripting language, including substituent types like bools, ints, and floats. So you can update the map with a script and spit it back out as json. Or load up json from whatever source and use it as a data structure in your script, basically directly, because it's a map, or in bash terms, an associative array.
>>
>>
>>108657489
I think I understand. It automatically serializes to json for external commands, while also providing a more imperative syntax?
this nushell codelet data = ($datastr | from json)
$data | select key1 | update subkey1 { |k| k + 1 } | to json | sed 's/a/b' | from json
would just be somewhat like the following in murex?
[codex]
$datastr[key1][subkey1] += 1
let result = $datastr | sed 's/a/b'
>>
>>108657599
Something like that.
From https://github.com/lmorg/murex/blob/master/examples/inline-sql.mx #!/usr/bin/env murex
#
# This example uses SQL to filter output from a POSIX command
ps aux | select USER, PID, COMMAND where USER = `foo` order by PID ASC | head -n10
/#
Outputs:
USER PID COMMAND
foo 943 /usr/lib/systemd/systemd --user
foo 944 (sd-pam)
foo 954 /usr/bin/kwalletd5 --pam-login 6 8
foo 955 /usr/bin/startplasma-x11
foo 960 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
foo 987 /usr/lib/baloo_file
foo 991 /usr/lib/xdg-desktop-portal
foo 1004 /usr/lib/xdg-document-portal
foo 1008 /usr/lib/xdg-permission-store
#/
https://github.com/lmorg/murex/blob/master/examples/dictionary-api.mx #!/usr/bin/env murex
words = list.join('%20' @PARAMS)
open https://api.dictionaryapi.dev/api/v2/entries/en/$(words) \
-> foreach {
-> [ meanings ] -> foreach meaning {
-> [ definitions ] -> foreach def {
$definitions <~ %[ {
partOfSpeech: $meaning.partOfSpeech
meaning: $def.definition
} ]
}
}
}
$definitions
>>
>>108657717
that second one is total trash. imagine writing that out from left to right with no newlines in the command line. even jq gets annoying as fuck when you need to go back and forth adding parentheses. doing sql and complex set theory in my head is a chore too.
>>108657599
this just looks like powershell. also way too verbose for the shell compared to jq. all of these always end up looking like basedlangs instead of what you'd use in the shell.
>>
>>
>>
>>108655591
I'm not a big fan of bash but I haven't seen anything better (python is disgusting)
>>108655661# that's why you leave comments above blocks
>>
>>108655591
Because it's designed first as an interactive shell which leads to friction and gotchas the more you try to do anything serious. Perl was created to address these shortcomings and then various modern scripting languages have replaced perl in that niche by being more sane.
>>
>>108658896
>all of these always end up looking like basedlangs instead of what you'd use in the shell.
agreed, I still prefer bash for interactive usage. I use it for scripts once I need to deal with structured data, even arrays, or when I start writing stuff likegenerator | while read x { ... }
properly shellchecked bash is also very verbose but looks more like gibberish
>>108657717
it definitely looks like its more concise than nushell in many areas, and some of this flexibility might help sometimes (though stuff like defining variables inside a deeply nested chain looks like a double edged sword for me wrt. readability). I guess I have to try it out to get a feel for it, hopefully LLMs can help a bit
Do you know whether it can do streaming processing? that's a big disadvantage of nushell for some workloads
>>
File: 1771268938335399.png (31.9 KB)
31.9 KB PNG
>>108657353
tsmt
>>
>>
>>
>>
>>108655591
bash is certainly a language, i won't call it good but not bad either, in terms of quickly cobbling something together is more "ergonomic" than python for the stuff where you are just using system utils and leveraging existing command line programs.
that said once you need to reach for arrays it is a sign that you should either switch to a different language or rethink how your program works.
that said lately i've been writing more posix shell than bash, not out of the need to be an insufferable hipster cu "i don't use them bash features" but rather for the small utils i'm cobbling in posix shell to be more portable without having to reach for something like C, ada or go as even the most complex thing i'm building i feel would only exponentially balloon in complexity if i were to reach for something lower level than shell and if i didn't care about portability so much bash would not offer massive benefits to barely any benefit at all as code would be just as extensive with the usage of bashisms probably producing less readable code, not that reaching for bashisms DO inherently produce less readable code but the way many a scripters use bashisms do tend to that...
>>
>>
>>
>>
>>108666687
shell scripts are readable, even if they are poorly written in an obscure dialect there will be some script out there in the internet that makes use of the same features but is actually well written and commented so it can be used as a sort of rosetta stone to translate the worse dialectic script.
the same doesn't happen with perl, perl by nature is horribly dialectic with more ways to do things than c++ has ways to shotgun your foot off, all those ways equally as bad and unreadable, to the point that while C and C++ have competitions about writing obfuscated software, perl has competitions about writing the most unobfuscated sotfware, and over 80% of the submitted code doesn't even qualify as unobfuscated enough to enter the competitions...