Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Presto
Nov 22, 2002

Keep calm and Harry on.

QuarkJets posted:

If you're writing a shell function then you should stop and do something else, I mean that in the biggest way, maybe become a forest ranger or something
You joke but one of my lab partners in college switched his major from CompEng to Forestry.

In retrospect he was right.

Adbot
ADBOT LOVES YOU

Trapick
Apr 17, 2006

bash scripts rule, they're a great choice for a ton of things, just don't use them for everything.

If it can be done in 40 lines of bash that'll be so much easier to manage than python or something.

repiv
Aug 13, 2009

https://twitter.com/elementnumber46/status/1643613896526184448

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
markdown sucks and I wish to destroy it

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Hammerite posted:

markdown sucks and I wish to destroy it

Yeah asciidoc is better in every way. Including in that it's a defined thing.

Toshimo
Aug 23, 2012

He's outta line...

But he's right!
https://twitter.com/zacbowden/status/1643594814120656897

Macichne Leainig
Jul 26, 2012

by VG
Man I can't find this drat string, might as well just sed the whole codebase

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
shellcheck makes shell an infinitely more usable programming language. It's still a weird language that works differently from every other mainstream language these days, but shellcheck catches most of the common ways to write something that doesn't do what you think it's going to do.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with

Grimey Drawer
I'm not suggesting this is necessarily efficient, but I've almost moved entirely to just writing all my 'scripts' in .Net. I have a project template I just spin up. C# is way more pleasant to write in, and you actually have the ability to extend it into something more robust later if you want.

Like I said, I'm not defending this as an efficiency play, but it is way more enjoyable to work in then PS / cmd / shell / etc.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


It is technically possible to write all your shell scripts in R, but if I saw someone did that I'd probably just quit.

Vanadium
Jan 8, 2005

Like I acknowledge that bash scripts can be awful and terrifying in a lot of respects, but really, I place the blame with literally every other programming language for ceding the "plumbing together a bunch of random garbage with as minimal a notation as possible for the happy path" space to stuff like bash.

Presto
Nov 22, 2002

Keep calm and Harry on.
Minimal notation? Bash scripts generally look like you loaded a shotgun with punctuation and fired it at the screen.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Are you thinking of APL?

Vanadium
Jan 8, 2005

Okay maybe happy path isn't the right words. I mean when your script just does a bunch of stuff maybe with a minimal loop and you don't have to worry about safely passing user input around or handling errors. Sure there's probably a few pipes and stray semicolons, but you're still under budget from not needing most commas and curly braces and parentheses.

Like most programming languages aren't interested in competing with how concise curl https://example.org or even curl -sSf https://example.org | jq .lol is, they immediately make you think about stuff like explicitly creating an http client that pools connections, whether you're streaming the response body, what data type represents it, how to handle errors at different layers, etc, which is probably good but it's still slightly inconvenient for me in the moment so whoops here's another 100 lines bash script that started as a 3-commands pipeline that I had to run repeatedly for some reason. I wish there were good languages out there vying for me as a customer specifically.

Vanadium fucked around with this message at 23:23 on Apr 5, 2023

Polio Vax Scene
Apr 5, 2009




owns

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Considered as programming languages, Unix shells are DSLs for running commands. The problem is that they all suck at that, for a couple reasons. The first is that they’re focused on making things really easy to do instead of really easy to do correctly, so they do poo poo like swallow errors by default and muddy lists and strings in ways that programmers have to explicitly protect against. The second is that they’re a very 1970s style of language with a bunch of hyper-terse builtin operations with poor discoverability and frequently odd semantics, and if you need something slightly different, good luck composing it out of what’s there.

Kazinsal
Dec 13, 2011


all shells should work like router command lines where every command, switch, and parameter is fluidly autocompleted and switches can be discovered immediately by typing a question mark

Vanadium
Jan 8, 2005

rjmccall posted:

Considered as programming languages, Unix shells are DSLs for running commands. The problem is that they all suck at that, for a couple reasons. The first is that they’re focused on making things really easy to do instead of really easy to do correctly, so they do poo poo like swallow errors by default and muddy lists and strings in ways that programmers have to explicitly protect against.

Yeah, that's right of course. I think these are tradeoffs, shells made lovely tradeoffs because it was a different time, but everybody else doesn't even try to get anywhere near the conciseness of a shell pipeline. Maybe the Haskell people do in isolated cases but it's immediately impossibly convoluted by all the higher order types and that sort of thing.

quote:

The second is that they’re a very 1970s style of language with a bunch of hyper-terse builtin operations with poor discoverability and frequently odd semantics, and if you need something slightly different, good luck composing it out of what’s there.

Ehh, how much discoverability do you need for a shell? Ideally there wouldn't be that much to discover, you'd download a cheatsheet that gives you intuition for basic, common stuff and leaves you with vocabulary to look up fancier stuff in a man page if you can't stackoverflow it for whatever reason. You'd probably use the shell all the time so you'd internalize the important stuff really soon.

imo people give terseness too much poo poo. Yeah, nobody wants to read a perl script that got golfed to hell, but, like, assuming for a moment that we're talking about a hypothetical language where people really thought through the fundamental design to encompass basic use cases without being limited by them, having an idiomatic/built-in hyper-terse way to denote the basic table-stakes operations that you do all the time just removes cognitive load. Code is more readable if there's less of it! My ceterum censeo is basically that the perl people were on to something and the PLT people turning their back on them was basically criminally negligent.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
I mean, the terse things I object to in shells is the crap like all the operators you can do after the variable name in a ${} expansion, which is just unreadable gibberish that only a real sicko would have learned by heart.

Vanadium
Jan 8, 2005

Okay, yeah, I have to look up unset ${!AWS_*} every time because I refused to type out AWS_SECRET_ACCESS_KEY etc.

Raymond T. Racing
Jun 11, 2019

Kazinsal posted:

all shells should work like router command lines where every command, switch, and parameter is fluidly autocompleted and switches can be discovered immediately by typing a question mark

fish has best autocomplete, just smash tab and auto complete practically everything

brap
Aug 23, 2004

Grimey Drawer

Vanadium posted:

Okay, yeah, I have to look up unset ${!AWS_*} every time because I refused to type out AWS_SECRET_ACCESS_KEY etc.

Go directly to jail

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.
There'd be a lot more programming languages used as shell scripts if you could execute them from the command-line like Python. Just replace Powershell with "dotnet myscript.cs" already.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
I've got to admit the new c# syntax where you can just leave out the main method has me doing this

Cold on a Cob
Feb 6, 2006

i've seen so much, i'm going blind
and i'm brain dead virtually

College Slice

Canine Blues Arooo posted:

I'm not suggesting this is necessarily efficient, but I've almost moved entirely to just writing all my 'scripts' in .Net. I have a project template I just spin up. C# is way more pleasant to write in, and you actually have the ability to extend it into something more robust later if you want.

Like I said, I'm not defending this as an efficiency play, but it is way more enjoyable to work in then PS / cmd / shell / etc.

Not sure if it would help with this or not but I found a decent c# REPL I've been playing with very recently. I haven't bothered with c# REPLs in the past but this one seems pretty good. There's also dotnet-script but I've never used it.

I've also replaced some hairy scripts with c# utilities but I stopped during the early .net core releases where things just kept changing a lot. Now that things are relatively stable I may do it again though.

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003
i wrote a pure posix sh csv parser once, just to prove i could do it

more falafel please
Feb 26, 2005

forums poster

DELETE CASCADE posted:

i wrote a pure posix sh csv parser once, just to prove i could do it

I wrote a (toy) lisp interpreter in smalltalk once but you don't see me braggin

Actually, yeah you do, that kicked rear end

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
The real horror is letting this thread die due to inactivity.

QuarkJets
Sep 8, 2008

Sorry but I think we fixed software development, all of the code is good now

Toshimo
Aug 23, 2012

He's outta line...

But he's right!

Volmarias posted:

The real horror is letting this thread die due to inactivity.

This post could have been an email.

God of Mischief
Oct 22, 2010

QuarkJets posted:

Sorry but I think we fixed software development, all of the code is good now

Does that mean my repositories have been properly purged with cleansing fire? Because I don't know what else could fix them.

I would blow Dane Cook
Dec 26, 2008
We had the tabs vs spaces argument at work.

QuarkJets
Sep 8, 2008

did you win

I would blow Dane Cook
Dec 26, 2008
I stayed well away.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

I would blow Dane Cook posted:

I stayed well away.
How far? 4 or 8?

Falcon2001
Oct 10, 2004

Eat your hamburgers, Apollo.
Pillbug

QuarkJets posted:

Sorry but I think we fixed software development, all of the code is good now

I'm still employed so this is unfortunately not true.

Beef
Jul 26, 2004
I went into a video call expecting a tabs vs spaces discussion when I raised the issue of the baffling seemingly random C code style on a project I'm working on. Sometimes there would be a space between the function name and arglist, sometimes where wouldn't. There are occasional superfluous space after an open brace, which my emacs setups paints in angry red, that I would have to sweep up using whitespace-cleanup before commits.


It turned out every extra space has it's purpose and it is beautiful.

`foo ()` vs `foo()` allows grep to distinguish between definitions and call sites.

The superfluous space is a marker for a codegen tool that inserts markers for code coverage testing using gcov.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Beef posted:

I went into a video call expecting a tabs vs spaces discussion when I raised the issue of the baffling seemingly random C code style on a project I'm working on. Sometimes there would be a space between the function name and arglist, sometimes where wouldn't. There are occasional superfluous space after an open brace, which my emacs setups paints in angry red, that I would have to sweep up using whitespace-cleanup before commits.


It turned out every extra space has it's purpose and it is beautiful.

`foo ()` vs `foo()` allows grep to distinguish between definitions and call sites.

The superfluous space is a marker for a codegen tool that inserts markers for code coverage testing using gcov.

Definitely the right thread for this post. Beauty is in the eyes of a beholder.

Beef
Jul 26, 2004
I'm still afraid to ask why there's an extra space in front of semicolons.

Adbot
ADBOT LOVES YOU

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Beef posted:

I'm still afraid to ask why there's an extra space in front of semicolons.

They said. It's for an out-of-band code generator.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply