Author Topic: what would you use to replace Bash for scripting?  (Read 54572 times)

0 Members and 2 Guests are viewing this topic.

Offline gnif

  • Administrator
  • *****
  • Posts: 1939
  • Country: au
  • Views and opinions are my own
Re: what would you use to replace Bash for scripting?
« Reply #125 on: June 22, 2023, 05:39:36 pm »
While I get your point and I personally do not like restoring to `system`, `popen`, etc. Sometimes it's well worth doing so even if it's possible to achieve what you want in your own application using native library calls, etc.

The plethora of applications that invoke `ffmpeg` or `vlc` are perfect examples of this, implementing it directly is tricky and time consuming. What about programs that check on your system status for monitoring like Zabbix/Nagios, etc. These all invoke command line tools to determine the status of applications. Tools like Puppet & Saltstack for system configuration and deployment extensively make use of shell commands.

Or, lets turn to PHP. Until gd2 became common place everyone used `imagemagik` via system commands to manipulate images. Want to recursively chown a directory in PHP with specific access permissions? sure you can write a function to do that, or just use `exec('chown -R u=rw,g=rw,o=r,a+X ' . escapshellarg($path), $out, $errcode);` Which is easier/faster and considered more reliable?

Just because you can re-implement something in your application to do it directly doesn't always make it the right or wisest choice.
« Last Edit: June 22, 2023, 05:51:47 pm by gnif »
 

Offline MMMarco

  • Regular Contributor
  • *
  • Posts: 69
  • Country: ch
  • Hobbyist. ⚠️ Opinionated
Re: what would you use to replace Bash for scripting?
« Reply #126 on: June 22, 2023, 06:08:53 pm »
While I get your point and I personally do not like restoring to `system`, `popen`, etc. Sometimes it's well worth doing so even if it's possible to achieve what you want in your own application using native library calls, etc.

The plethora of applications that invoke `ffmpeg` or `vlc` are perfect examples of this, implementing it directly is tricky and time consuming.

That's why I said:

... , where you usually don't interact with other programs (awk, sed etc.) directly. ...

... nobody uses the shell / external commands in JavaScript if they don't have to. ...


I'm not sure if ffmpeg has native API bindings in nodejs, PHP etc. but in the case of ffmpeg the case is pretty clear: you don't want to reimplement it.

In other cases, which have been provided by brucehoult the case is clear: you don't want to invoke sed if you can use the native RegEx engine. It's just ridiculous.  :palm:

Just because you can re-implement something in your application to do it directly doesn't always make it the right or wisest choice.
No, but using the shell for basic operations like "delete this directory" or "copy this directory" is pretty lame  :-DD :-DD and will make you look like a joke to experienced high level programmers  ;D ;D

You should default to using native APIs, then resort to external commands / the shell. Not the other way around  :palm: :palm:

All in all, brucehoult's lack of experience in higher level language is clearly showing, which is fine.

Quote
Which is fine, but it makes your scripting opinions irrelevant in this thread.
Just be a little more careful when dismissing other people's opinion  :-DD

 :-/O
« Last Edit: June 22, 2023, 06:17:44 pm by MMMarco »
27 year old Software Engineer (mostly JavaScript) from Switzerland with a taste for low level stuff like electronics 😊

 

Offline gnif

  • Administrator
  • *****
  • Posts: 1939
  • Country: au
  • Views and opinions are my own
Re: what would you use to replace Bash for scripting?
« Reply #127 on: June 22, 2023, 06:20:53 pm »
In other cases, which have been provided by brucehoult the case is clear: you don't want to invoke sed if you can use the native RegEx engine. It's just ridiculous.  :palm:

Not really, it depends on what you're doing. Try using your native RegEx engine on a huge file for example, you now suddenly need to deal with reading the file as a stream as loading the entire file into RAM would be a huge waste of resources. The complexity of what you're implementing suddenly goes up and it may not be worth the time/effort or cost to implement all the edge case error handing, etc.

Just because you can re-implement something in your application to do it directly doesn't always make it the right or wisest choice.
No, but using the shell for basic operations like "delete this directory" or "copy this directory" is pretty lame  :-DD :-DD

Not when you're dealing with a huge directory structure and you're coming from a scripted language where it's infinitely faster to use `rm` or `cp`. Again it depends on your use case, you might even want to take advantage of `rsync` to avoid unnecessary copying of files where possible. And lets say you write a recursive `rm`, did you remember to check for symbolic links that might take you to `/`? There are a lot of edge cases these tools cover that protect you (https://github.com/coreutils/coreutils/blob/master/src/remove.c - 35 years old and still getting tweaks today, latest patch was June this year, vs your recursive rm function... hrmm).

You should default to using native APIs, then resort to external commands / the shell. Not the other way around  :palm: :palm:

All in all, brucehoult's lack of experience in higher level language is clearly showing, which is fine.

You are showing a lack of experience in general system administration tasks on huge datasets and files along with the task of making something that is maintainable by other system admins that may not have your "prowess" in the languages you are using. The right tool for the right job. There is no "order" to things as you put it, assuming so and dismissing these other options as a developer is asinine and just ties your hands unnecessarily.

Quote
Which is fine, but it makes your scripting opinions irrelevant in this thread.
Just be a little more careful when dismissing other people's opinion  :-DD

 :-/O

You do realise you're coming across as super arrogant and hostile here which is why you're getting this kind of reaction from others.
« Last Edit: June 22, 2023, 06:38:56 pm by gnif »
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17876
  • Country: fr
Re: what would you use to replace Bash for scripting?
« Reply #128 on: June 22, 2023, 07:55:16 pm »
I started looking for a way to program the same application in Python and I have found that it is necessary to replicate the operation of standard unix tools like "file", "find", "wc", "grep", etc.

Uh? These are all individual programs. You can call them from Bash, but otherwise from any other scripting language that allows executing external programs, which both Lua and Python can.

Bash doesn't do anything else than spawning processes for any command you ask it to execute and that's something you can do in many languages.
The only thing that may be more or less difficult in other languages is directly piping one executable to another - that would be something to check.
For Python, this is where to start: https://docs.python.org/3/library/subprocess.html

I am familiar with the subprocess lib. I have used it frequently to call some external tools like ImageMagick that sometimes seem to me better than the corresponding Python library (PIL / Pillow).

That's nice to know.

But calling an external program is usually more messy, slower and harder to communicate with than using the language's own tools.

That's what Bash does.
Holy crap, as I said the whole topic was about replacing Bash with another scripting language.
It wasn't about rewriting the whole Linux/Unix ecosystem from scratch.

Of course you can write directly in a given language without resorting to executing outside processes.
That was not the topic at all.
 

Offline MMMarco

  • Regular Contributor
  • *
  • Posts: 69
  • Country: ch
  • Hobbyist. ⚠️ Opinionated
Re: what would you use to replace Bash for scripting?
« Reply #129 on: June 22, 2023, 08:14:00 pm »
Not really, it depends on what you're doing. Try using your native RegEx engine on a huge file for example, you now suddenly need to deal with reading the file as a stream as loading the entire file into RAM would be a huge waste of resources. The complexity of what you're implementing suddenly goes up and it may not be worth the time/effort or cost to implement all the edge case error handing, etc.

No, not "not really" it doesn't matter what you're doing in the grand scheme of things.

you now suddenly need to deal with reading the file as a stream as loading the entire file into RAM would be a huge waste of resources. which is exactly what nodejs was designed for. Streams are one of the common ways to process data in nodejs. So what's the argument? This isn't PHP where everything is synchronous (by default) and everything loaded into RAM.

Not when you're dealing with a huge directory structure and you're coming from a scripted language where it's infinitely faster to use `rm` or `cp`. Again it depends on your use case, you might even want to take advantage of `rsync` to avoid unnecessary copying of files where possible.

Which is a pretty specific situation for a discussion about a scripting language. It doesn't apply to the discussion because it's not a general problem. As far as I know, OP hasn't posted any specific needs that they want to be addressed. So the discussion shall remain about general problems, not specific ones [that happen to play into your argument (as it seems)].

You are showing a lack of experience in general system administration tasks on huge datasets and files along with the task of making something that is maintainable by other system admins that may not have your "prowess" in the languages you are using.

I have a lack of experience in general system administration tasks but that doesn't disqualify me from being a part of the discussion.

The right tool for the right job.

I agree.

There is no "order" to things as you put it, assuming so and dismissing these other options as a developer is asinine and just ties your hands unnecessarily.

Oh, yes. Absolutely. There's an order and you are mistaken for thinking that there isn't.


You do realise you're coming across as super arrogant and hostile here which is why you're getting this kind of reaction from others.

Well, I'm kinda used to that. Doesn't surprise me at all to hear.

You call me "super arrogant and hostile" but brucehoult saying:

Quote
Which is fine, but it makes your scripting opinions irrelevant in this thread.

Is totally fine? Look, I don't even want to step on specific things on what others have said.

I'm not offended, not in the slightest.

But I'm surprised to hear that it's somehow ok for someone to dismiss someone's opinion and then getting a "reaction" (so to speak) and that's what you consider "hostile"?

In my defense, you don't get to discredit me without proving you're right.¹ That's how I work, nothing to do with hostility, or arrogance.

It's really sad that so many people fall into the trap of mistaking confidence with arrogance.

I'm not an arrogant person. I have plenty of years of experience in software engineering and if I disagree with someone (like brucehoult) then I'll make my word heard.

It's just not true that you usually call external programs from JavaScript - it's just the way it is. I don't know what else to tell you.
This is also true for other scripting languages such as PHP.

And the reasons are as clear as they can get: it's a messy and slow process - whether you want to believe that or not.

How many people in here do you think have the credentials/experiences to speak about JavaScript? I would like to know.



What I'm telling you comes from experience, not arrogance.



I'm not saying that you shouldn't ever call an external program from a scripting language. What I'm saying is, that this is not how things are usually done in higher level languages. Why? Because the higher level language already provides API for common functionality. You're falling in a similar trap that brucehoult has fallen into. You're showing clear ignorance (not arrogance, but ignorance) to the nodejs / JavaScript Language. That's the whole point, you don't understand how things are done in JavaScript, so how could you possibly argue with someone who knows how it works?? JavaScript has solutions to these problems, you're either too ignorant to know about them, or just too lazy. That's how it is.

If you're using an external program, you better have a good reason for it, otherwise, you're doing things wrong.

Take it from someone who's been programming for over +10 years now.



¹ brucehoult's argument got diminished once I took a look at the implementation of shelljs. Unfortunately for him, it even proved my point. So what exactly do you expect me to do? It should be clear that he's missing the experience to make a meaningful argument in that area when he can't even make a first proper argument. By the way, "Oh, really?" is not a good way of starting your argument.

But whatever, think what you wanna think (people do that all the time anyway *cough* flat-earths). As long as I don't get censored, I'm happy  because everyone reading can form the own opinion - that's what matters to me. (this is also why I sometimes write more, because I like to keep a record of things).
« Last Edit: June 22, 2023, 08:41:04 pm by MMMarco »
27 year old Software Engineer (mostly JavaScript) from Switzerland with a taste for low level stuff like electronics 😊

 

Offline gnif

  • Administrator
  • *****
  • Posts: 1939
  • Country: au
  • Views and opinions are my own
Re: what would you use to replace Bash for scripting?
« Reply #130 on: June 22, 2023, 08:40:20 pm »
you now suddenly need to deal with reading the file as a stream as loading the entire file into RAM would be a huge waste of resources. which is exactly what nodejs was designed for. Streams are one of the common ways to process data in nodejs. So what's the argument?

Great, nodejs handles that, doesn't mean that your statement holds true for other languages/platforms which your statement implied.

Which is a pretty specific situation for a discussion about a scripting language. It doesn't apply to the discussion because it's not a general problem.

Performance is always a general problem and concern and if you're not writing your code to be performant then you should re-assess how you write code. I have seen this exact situation countless times, most often with WordPress plugins that write a directory of files for whatever reason, and they give the user a `purge` feature. This purge when run takes so long it causes the php process to hit the max execution time leaving the job 1/2 done. It's far more general then you think.

I have a lack of experience in general system administration tasks but that doesn't disqualify me from being a part of the discussion.

I never said that it did. I am saying that there is a side to software development that developers often fail to heed/understand. The "it's fast enough for me" or "works well enough for me" and not taking into consideration the performance requirements when the application is scaled up to any kind of level causes no end of sysadmin headaches. Just because it's more "proper" in your eyes doesn't make it the more correct way to do things. 30+ years of sysadmin and software engineering across dozens of languages has taught me this lesson countless times as I like you, try my damnedest to avoid using exec/system/popen if possible.

Oh, yes. Absolutely. There's an order and you are mistaken for thinking that there isn't.

There is an order based on the demands of the application and the time/cost budget involved in the development. There is no fixed constant order as you put it.

You do realise you're coming across as super arrogant and hostile here which is why you're getting this kind of reaction from others.

Well, I'm kinda used to that. Doesn't surprise me at all to hear.

You call me "super arrogant and hostile" but brucehoult saying:

Re-read what I said, I stated you're coming across this way, I did not say you are, or intend to be. But the way you continually use emoticons in your posts, making out that your laughing in peoples faces is doing you a disservice.

It's just not true that you usually call external programs from JavaScript - it's just the way it is. I don't know what else to tell you.
This is also true for other scripting languages such as PHP.

Can't speak for JS myself, but I have seen it done in PHP hundreds of times over the years, in some cases warranted (ie, pre-gd2 as I mentioned earlier), and still done today in some instances where there is a need for doing so (ie: try and do a DNS lookup against a specific DNS server without implementing the DNS protocol from scratch).

And the reasons are as clear as they can get: it's a messy and slow process - whether you want to believe that or not.

It depends on if the overheads of fork/exec outweigh the performance benefits of executing a native binary that is faster then your own implementation.

How many people in here do you think have the credentials/experiences to speak about JavaScript? I would like to know.


What I'm telling you comes from experience, not arrogance.

Again, I didn't say you were arrogant, but your method of writing is coming across this way.

Take it from someone who's been programming for over +10 years now.

Ok son, 30+ here, and I am sure there are others here with far more then even I have.

Edit: omg, just saw your signature image... are we really playing that game?



And I have been pretty much inactive on there for years now. It's not that hard to get tons of rep there.
« Last Edit: June 23, 2023, 04:28:14 am by gnif »
 

Offline MMMarco

  • Regular Contributor
  • *
  • Posts: 69
  • Country: ch
  • Hobbyist. ⚠️ Opinionated
Re: what would you use to replace Bash for scripting?
« Reply #131 on: June 22, 2023, 09:02:35 pm »
Performance is always a general problem and concern and if you're not writing your code to be performant then you should re-assess how you write code.

Hence why you should AVOID spawning processes. In MANY (not all) but in MANY cases the overhead of setting up a new process etc. TAKES SUBSTANTIALLY LONGER than using native APIs.

I have seen this exact situation countless times, most often with WordPress plugins that write a directory of files for whatever reason

Oh c'mon, WordPress? WordPress is a lost cause and a joke  :-DD

This purge when run takes so long it causes the php process to hit the max execution time leaving the job 1/2 done. It's far more general then you think.

PHP's doomed anyway, but that's my opinion.

30+ years of sysadmin and software engineering across dozens of languages has taught me this lesson countless times as I like you, try my damnedest to avoid using exec/system/popen if possible.

So where's the disagreeing part?

Just because it's more "proper" in your eyes doesn't make it the more correct way to do things.

I haven't said anything about "proper" I said it's unusual to do such a thing, not implying that it is improper.

There is an order based on the demands of the application and the time/cost budget involved in the development. There is no fixed constant order as you put it.

Well, I can see where this is coming from. But aren't we talking about someone who wants to switch their personal scripts to a different language?

I get what you mean, in a professional context this is definitely the case, no doubt. But I don't think it applies to "business" outside the job, does it?

I mean, I'm doing an assumption here, but aren't we all enthusiasts of electronics/programming etc. who want to do their best?

Excuse me if this should be taken in a professional context, because then I'm definitely wrong - I can see that.

I just think when you're doing things voluntarily these factors (time/cost budget) don't play a huge role.

It might for some, but not for me. And I'm pretty confident in saying that most hobbyist do it for the fun, not because they're on a "budget" or whatever.

I'm a hobbyist (as my profile signature tells you), I've worked professionally as a Software Engineer, but I don't think I want to go back into that hell  :scared: 😂

Re-read what I said, I stated you're coming across this way, I did not say you are, or intend to be. But the way you continually use emoticons in your posts, making out that your laughing in peoples faces is doing you a disservice.

I'm sorry, I just find some of these statements to be ridiculous and I have no shame of hiding that. It's not meant in a demeaning way, I just want to show people when I'm not taking them seriously - that's all.

Ok son, 30+ here, and I am sure there are others here with far more then even I have.

Doesn't mean you have the knowledge  :P I know, I'm probably going into dangerous terrority here but just because doing things for +30 years doesn't mean you know better than someone who did it for less time  :-DD Technology has quite improved, and nowadays, it's actually a disadvantage because younger (myself excluded) people actually do better because they got to learn technologies that were impossible back in the time - I don't think this trend ends here. Plus, nowadays it's much easier to get to learning resource than it was 20 years ago. Not a personal attack, just saying, experience is not everything.

And please, could you not call me "Son"?

Off-topic: Man, quoting people here in the forum is a real pain :S

Edit: omg, just saw your signature image... are we really playing that game?

I don't play games, but it's NICE to see that you do  :-DD :-DD get lost.
27 year old Software Engineer (mostly JavaScript) from Switzerland with a taste for low level stuff like electronics 😊

 

Offline gnif

  • Administrator
  • *****
  • Posts: 1939
  • Country: au
  • Views and opinions are my own
Re: what would you use to replace Bash for scripting?
« Reply #132 on: June 22, 2023, 09:19:35 pm »
Doesn't mean you have the knowledge  :P I know, I'm probably going into dangerous terrority here but just because doing things for +30 years doesn't mean you know better than someone who did it for less time  :-DD Technology has quite improved, and nowadays, it's actually a disadvantage because younger (myself excluded) people actually do better because they got to learn technologies that were impossible back in the time - I don't think this trend ends here. Plus, nowadays it's much easier to get to learning resource than it was 20 years ago. Not a personal attack, just saying, experience is not everything.

The younger generation that were not exposed to the low level details of how the computer architecture actually functions usually end up writing bad/poor code that we then spend inordinate amounts of time trying to fix. And while I agree entirely that experience is not everything, it is a far better teacher then just reading. Even still I make full use of the learning tools I have available and work on projects most would dream of being a part of. These days most of my free time is spent on the Looking Glass project which is cutting edge technology that I made possible.

Your prior post spoke in such a way to state that your 10+ years of development experience means we should just trust your word as gospel. All it did in my eyes was show me how much you still need to grow as a person and why I called you "son". Which btw, is not an insult

Quote
In American English, it is acceptable and common that an older man calls a man his junior, "son"—even if the younger man is not the older man's child (or related to him in any way). Used by an elder person as a form of address for a boy or young man

You publish your age, and your experience in this field, that by definition makes you my junior.

Edit:

That said, I am done, think what you like, but please stop acting like you know better then everyone else. Speaking down to others by laughing at them with the emotes as you did is only going to result in threads like this repeating over and over again.
« Last Edit: June 22, 2023, 09:26:25 pm by gnif »
 
The following users thanked this post: MK14

Offline MMMarco

  • Regular Contributor
  • *
  • Posts: 69
  • Country: ch
  • Hobbyist. ⚠️ Opinionated
Re: what would you use to replace Bash for scripting?
« Reply #133 on: June 22, 2023, 09:28:37 pm »
Your prior post spoke in such a way to state that your 10+ years of development experience means we should just trust your word as gospel.

No, that wasn't the intent and I wouldn't advocate for such a lunacy. Nobody's words should be taken as gospel.

What I was trying to do was to give my word some credibility, since it seems like people think I don't know what I'm talking about.

All it did in my eyes was show me how much you still need to grow as a person and why I called you "son".

Well, good for you then. I can see how I need to grow as a person, especially from someone who takes the bait and think I'm playing games like a little child - I'm not. You fell for it, and now ... I think (actually) lesser of you, because I'm indeed not playing games.

YOU assuming I am, really tells a lot more about you than me ANYWAY we're going HUGELY off-topic and I will leave it AT THAT.

All it did in my eyes was show me how much you still need to grow as a person and why I called you "son". Which btw, is not an insult.

You don't get to call me "Son" because your not my dad, simple as that. Nothing to do with being offended or whatever.

OP: sorry for getting into "DRAMA"  :-DD I'll keep my mouth shut.

I'll refrain from using the laughing emoticons to my closing statement to this discussion.

That said, I am done, think what you like, but please stop acting like you know better then everyone else.

I will (think what I like) and I will act to know better until there's someone who can prove me wrong. Nobody's on this thread so far convinced me otherwise. You have a problem with that? Fine. It's your problem then.
« Last Edit: June 22, 2023, 09:32:44 pm by MMMarco »
27 year old Software Engineer (mostly JavaScript) from Switzerland with a taste for low level stuff like electronics 😊

 

Offline gnif

  • Administrator
  • *****
  • Posts: 1939
  • Country: au
  • Views and opinions are my own
Re: what would you use to replace Bash for scripting?
« Reply #134 on: June 22, 2023, 09:32:46 pm »
Well, good for you then. I can see how I need to grow as a person, especially from someone who takes the bait and think I'm playing games like a little child - I'm not. You fell for it, and now ... I think (actually) lesser of you, because I'm indeed not playing games.

Ok... so trolling, a bannable offence. Careful now
 
The following users thanked this post: MMMarco

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: what would you use to replace Bash for scripting?
« Reply #135 on: June 23, 2023, 12:41:29 am »
Oh, really?

Code: [Select]
var shell = require('shelljs');

if (!shell.which('git')) {
  shell.echo('Sorry, this script requires git');
  shell.exit(1);
}

// Copy files to release dir
shell.rm('-rf', 'out/Release');
shell.cp('-R', 'stuff/', 'out/Release');

// Replace macros in each .js file
shell.cd('lib');
shell.ls('*.js').forEach(function (file) {
  shell.sed('-i', 'BUILD_VERSION', 'v0.1.2', file);
  shell.sed('-i', /^.*REMOVE_THIS_LINE.*$/, '', file);
  shell.sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, shell.cat('macro.js'), file);
});
shell.cd('..');

// Run external tool synchronously
if (shell.exec('git commit -am "Auto-commit"').code !== 0) {
  shell.echo('Error: Git commit failed');
  shell.exit(1);
}

Yes, really. shelljs does not use the shell, it has a misleading library name and you fell for it.  :-DD

shelljs is just a wrapper around native JavaScript APIs like the fs module etc.

For example, shell.sed does indeed NOT call the sed binary but instead emulates the expected behaviour with native JavaScript.

*Some* of them. Just like busybox emulates many of the same programs. Nothing wrong with that.

Bash itself emulates/reimplements some commands that are available as external programs in /bin or /usr/bin (and which you can use instead if you invoke them with the full path).

Do you think shelljs emulates that call to git?

Because that's a big "nope".
« Last Edit: June 23, 2023, 01:20:36 am by brucehoult »
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: what would you use to replace Bash for scripting?
« Reply #136 on: June 23, 2023, 01:09:58 am »
Take it from someone who's been programming for over +10 years now.

Ok son, 30+ here, and I am sure there are others here with far more then even I have.

A 27 year old lording it over everyone because he has 10+ years programming experience? Meaning he's starting counting from somewhere in the middle of high school.

Laughable, isn't it?

Fuck me. I was programming an Apple ][ in Pascal and machine code and wrote my own Forth on it in 1980. And programmed TI and HP calculators before that. I was using LISP on a VAX in 1982. I've heard that's a high level language. I've worked at Mozilla improving the Javascript JIT in FireFox -- when MMMarco was 13. But, yeah, I've got no experience in Javascript. I've won multiple prizes in the ICFP (International Conference on Functional Programming) 72 hour programming contest, using the high level language "Dylan". But apparently I don't have any experience in high level languages.

I could go on, but I won't.
 
The following users thanked this post: gnif, MK14, Nominal Animal

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8361
  • Country: fi
    • My home page and email address
Re: what would you use to replace Bash for scripting?
« Reply #137 on: June 23, 2023, 08:45:10 am »
I could go on, but I won't.
I for one trust your real world experience, even if I sometimes disagree, and (inadvertently!) apparently annoy you.

Note: not the opinion, but the way brucehoult often explains the basis of their opinion based on practical experience.  Sometimes it takes a bit of prodding, which seems to annoy some members here.  I love it, because that way I can trust, but also test and verify.  Reality beats theory, and experience has utility and value, but reproducibility and verifiability is king.

Me, I have a rather spread-out professional history; ridiculous, really.  (As in, I would be sceptical if someone claimed a similar one, it's just so.. unlikely.  It's just random chances in life, though.)  I don't have the kind of spear-tip experience as say brucehoult has, as I am more of a generalist and synthesist, relying on the width/spread of my practical experience to give hints and guidance.  My education is in computational materials physics, but I've also taught a couple courses at uni (basic it courses and web stuff, back around the turn of the century), and ran my own IT company for a few years (profitably, but completely unsuitable to my personality).  I am analytical to the core, which requires me to try and explain the reasons for my opinions instead of stating them as fact, or relying on myself or my background to be any kind of authority.  I often have wrong opinions myself!  My scientific background has taught me provability and reproducibility trumps opinions or beliefs, and even previous experience.  Otherwise, our sciences would not – could not – progress at all.

I love hanging out here, reading the discussions where experienced people in their own fields explain why and how projects can be made better.
It just annoys me to no end when people confuse opinions with facts (≃ experimentally verifiable details and results).  Sometimes when I prod into it, into the reasons behind the opinions, people see it as questioning their experience, but it isn't that, it is just inquisitiviness and trying to get to the reasoning behind the things at hand.

Even in the programming threads, I often learn more, because the stock of human knowledge about our tools well exceeds what a single person can learn in a lifetime of personal experience.  I will never know enough; my education is never complete.  Many times, when someone poses an interesting question, I have no idea what the answer is, but I happen to know how to find out, so do that, and show the results and how I did it.  I used to do that at stackoverflow and math.stackexchange.com, but their social rules became impossible for me to follow.  (Not ideologically; it is literally too much work for me to keep track of the social rules there.  Plus, fundamentally, popularity does not guarantee or even correlate reliably with correctness, so the entire voting up good answers is a popularity game only.  Social gaming.)

On the electronics front, although I do have some formal education in it, I am still a newbie hobbyist after a decade or so.  I do try to help others with e.g. suggested schematics and even boards, but I make sure they're aware I'm only a hobbyist and not experienced in the practical electronics side.  Heck, BGA packages still scare me away.  There is nothing wrong, nothing demeaning, nothing belittling in admitting one is still learning.  Many seem to feel so, but to me, it just means someone is willing to take the effort to learn, and listen to suggestions and criticism, which is a HUGE positive in my mind, because that attitude works.  Pride, and believing one already knows everything worth knowing, does not work in practice.

I openly admit I'm still addicted to problem solving: finding verifiable, effective, robust solutions to tasks that are considered impossible or too difficult.

Finally, I am fully aware that I am way, way too verbose with my walls-of-text responses.  Apologies; I am working on it.
 
The following users thanked this post: paulca

Offline paulca

  • Super Contributor
  • ***
  • Posts: 6643
  • Country: gb
Re: what would you use to replace Bash for scripting?
« Reply #138 on: June 23, 2023, 09:58:16 am »
Of course, if your "software engineers" believe only monolithic and fully proprietary applications are the only sensible way to construct applications, they will never accept that or say using user-specified external programs or scripts to work on that user's data.  After all, all data belongs to the application, not the user, eh?

We aren't even on the same page mate.  I don't disagree with you either.  It's just old hat and mostly what the entire 'enterprise software industry' has been moving away from at rapid pace.

If I go on a call right now with a customer to talk about a solution.  For a fact.  I am NOT going to recommend a kernel bound, native C++ application set and scripts, pipes, sockets and devs.  Why?  Because I sure as hell don't want to maintain it, or make the support teams suffer the same.

C++ developers are like hens teeth and their business application development rate is pathetically slow.  So the industry moves to where there are developers.  Java, Python, even things like Go!  The places you will still find C, C++ is in the low-level, high speed components in the likes of stock exchanges and realtime marketdata processing systems like Algos.

On "target platform".  It's very seldom I will develop an application with a target of a bare OS.  Extremely unlikely actually.  At very least it will be targetting a pre-determined landing environment provided as a service AND running in some form of virtual machine or container.  These days its more likely to be Dockerized at build time, encrypted and stored in a repo, then deployed by someone else onto a logical pod in a multi-zone international cluster.

Most applications are stateless.  Most applications amount to micro-services.  Persistence is handled in many different ways, but very, very, very rarely files or even "OS level" filesystems.  Transient state, distribution, IPC et. al. is handled in some form of middleware.  Deployments are full automated, applications can be scaled elastically on demand.  Version rollout and rollback etc. etc.

Even when I was developing kernel bound "RHEL5" applications such as the Mexico Equities Exchange (BMV) Common Customer Gateways which where rated for 20k messages per second, per session, 20 sessions 20uS max latency, the deployments, configuration and maintaince was "platform" based.  The customer took our build, applied their own configs via a dynamic configuration platform and then man handled the binaries onto "pre-canned image based" hosts and started them via remote process management agents, like AutoSys, Tidal etc.

Again.  When you have one person writing, testing, deploying an application you are not experiencing what modern software engineering is all about.  It's all about running away from the model you describe, due to it being unmaintainable and unscalable.

I'm not saving you can run a system completely script free.  It's that Application development has completely separated itself from such fragile and mundane tasks as reinstalling an OS every ''''ing day and fiddling with cryptic spehegetti devops scripts.  Instead we heir devops people to do that while writing systems to avoid needing them either.

Have an application processing 100k requests per second and it's struggling?  Click'ity click, now you have 1000 edge nodes running hte application in 14 different regions.  Demand has suddenly stopped?  Would be expensive to maintain all those OS's and scripts.  Click'ity click BOOM!  900 of them are deleted out of existence a matter of seconds later.

I should be obvious I am not a front-end developer.  I have written one or two GUIs, but they are so... brittle and slow to develop, WUIs or webUIs being much faster are more common and due to that one type of service I have written a lot is an API front end for said WebUIs.  Often REST, Kafka etc.

EDIT: As to how I feel about the criticism.  The important point is... you don't pay my salary. ;)

I am also 10% trolling.  You know that right.  I'm basically standing up a model enterprise 2020+ architecture at the bleeding edge of massively scaled enterprise applications running on some of the biggest clusters and data centres in the world against your 1960s Unix modular 'native binary coupled' architecture.

It's not fair to compare them really.   We also do use Linux at the core of 99% of the systems when you peel back all the layers you eventually come to a linux kernel running in a supervisor somewhere.  Those OS's need developing.  Yes there are scripts involved there.  However, even Linux itself has been moving away from that model over the past decade or so.
« Last Edit: June 23, 2023, 10:12:30 am by paulca »
"What could possibly go wrong?"
Current Open Projects:  68000 Self Build computer + OS.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8361
  • Country: fi
    • My home page and email address
Re: what would you use to replace Bash for scripting?
« Reply #139 on: June 23, 2023, 12:41:04 pm »
If I go on a call right now with a customer to talk about a solution.  For a fact.  I am NOT going to recommend a kernel bound, native C++ application set and scripts, pipes, sockets and devs.  Why?  Because I sure as hell don't want to maintain it, or make the support teams suffer the same.
Now you're mixing technical choices with business reasoning.  Your business is not the only business out there, you know.

I'm not saving you can run a system completely script free.
But that is exactly what this entire thread is about: systems that DiTBho is working on, have very strict reliability requirements, and has found the necessary interface glue between the system's applications and services to be a weak point, requiring something better (easier to maintain, debug, and verify/validate to required standards).

Just because you wouldn't be able to make a buck doing things that way, does not mean it is not a perfectly valid business niche for someone else.

EDIT: As to how I feel about the criticism.  The important point is... you don't pay my salary. ;)
I have walked the business path, and decided it is not for me, because I do not want to be ruled by financial concerns, to evaluate solutions based on their costs.

That does mean I am much better suited for research, for developing new technologies that others may later adapt to solutions that lead to profitable business, but without people like me kicking the butt of the "just throw more developers and hardware at it, and it'll work out" crowd, you'd drown in unreliable shit within a generation.  It has happened before, it will happen again.

I am also 10% trolling.  You know that right.  I'm basically standing up a model enterprise 2020+ architecture at the bleeding edge of massively scaled enterprise applications running on some of the biggest clusters and data centres in the world against your 1960s Unix modular 'native binary coupled' architecture.
Do you realize, at all, that you are trolling exactly the people who have developed and still develop the underlying transports and mechanisms that makes your lofty business possible in the first place?

However, even Linux itself has been moving away from that model over the past decade or so.
And the developments like systemd that you think are making it better suited for your use cases, are in reality moving it away.

Fifteen years ago, I set up a small test cluster (on a few unused old desktops), and did some experimentation on ksplice (live-patching), kernel-assisted userspace checkpoint-restore (for hot reconfiguration of cluster nodes to avoid stopping long-running distributed tasks), and various imaging approaches to speed up compute node reinstallation.  This worked, but since it wasn't done elsewhere, it was too much to ask from the other sysadmins, and was rejected from wider use.

Today, dbus interconnections are a source of single point failures, which makes userspace checkpoint-restore unfeasible.  Auto-reconnection of the connections without additional userspace code is just not possible.  Systemd itself is one huge risk of single point failure, and has revealed years-long security holes, because its developer base is tiny and insulated from the rest of the development.  Using it makes your systems fragile, because any unexpected failure of a service daemon can destabilize the systemd daemons and cause the system to become unoperable.  It is very difficult to track down the exact cause, because such cases only reveal the services that failed, and the logs never point to systemd as being the cause, unless you check (whether its service daemons still operate correctly, or are in an inoperable state), which basically nobody does.  This, and its viral subsumption of unrelated services, is what drives the hatred towards systemd, not some silly "we want to keep things like they were in the 1960s".

And unless you pay, no more live patching either: you will be rebooting your nodes for kernel updates.  You'll need to reboot anyway when systemd is updated, so who cares, right?

I have a view further in the future than you do.  You think it means I'm "stuck in 1960s".  No, I just want to produce something better, without repeating past mistakes and the oh so popular "this is new, so it has to be better!" belief by most youngsters.  We've seen too many of these come and fail already to get excited by every single new and shiny thing.

In many threads, I've described how I believe distributed and parallel computing will be the way forward, but our current programming languages just don't have the proper abstractions that would facilitate that effectively in practice.  Sure, there are all kinds of CS theories out there, experimental and academic languages, and some even backed by huge corporations, but they are almost all the same-old, same-old; nothing that transported back two decades would surprise developers at all compared to the advances in hardware capabilities.  I know, because I just cannot help myself and keep an occasional eye at ACM and elsewhere.

I hope you realize you have been arguing a business case against exactly the people who make your business possible in the first place.  It is unlikely, though, because people who rely on complex abstractions to get their work done, often lose the ability to understand the reality behind the abstractions.  Perhaps you are an exception, but I doubt it; your arguments are all just based on your own opinions and experience, with nothing verifiable or testable in them, which indicates you're not actually that interested in the factual reality beyond your business needs.

Which is fine, really, except I'm not interested in interacting with such people at all.  I want to keep doing the grass-roots level that hopefully will help/lead to a true step forward, ending the programming language stagnation I've seen cripple software development for the last quarter century.  It has been papered over by the huge advances in computing capacity, but that just makes it wasteful.  With the current laughably bad reliability and security record, we need, and deserve, something better.  It may not make business sense to try to do that, but that is the kind of change I'd like to be part of in this world.
 
The following users thanked this post: SiliconWizard

Offline MMMarco

  • Regular Contributor
  • *
  • Posts: 69
  • Country: ch
  • Hobbyist. ⚠️ Opinionated
Re: what would you use to replace Bash for scripting?
« Reply #140 on: June 23, 2023, 03:00:27 pm »
Do you think shelljs emulates that call to git?

Because that's a big "nope".

That's literally the ONLY thing that shelljs ISN'T EMULATING - clear that you would jump onto that.

A 27 year old lording it over everyone because he has 10+ years programming experience? Meaning he's starting counting from somewhere in the middle of high school.

I'm not lording over anything, if anything, you're lording over me. You're wrong - I (somewhat) proved that you're wrong and it is you, who cannot deal with that. Sure, you might be a very experienced assembly/low level/C++ whatever programmer, but that doesn't make you a good JavaScript Developer.

I assume that you're not, because "calling external programs" is not something USUAL you do in JavaScript - that's the whole point of my argument, and always has been.

You said my opinions were irrelevant, because "scripting" would involve calling external programs.

Which is not true and why I disagree. That's the whole argument right there.

I don't know about you, but if you're telling a person (in person) that their opinion is "irrelevant" you better prepare for a fight if you got someone in front of you who's proud and passionate about the topic at hand. You provoked this whole mess.

Your one and only argument "shelljs" is laughable because it takes seconds to disprove your whole argument.

I really don't know what you think I should do?

You fucked up, own up to it  ;)

Fuck me. I was programming an Apple ][ in Pascal and machine code and wrote my own Forth on it in 1980. And programmed TI and HP calculators before that. I was using LISP on a VAX in 1982. I've heard that's a high level language. I've worked at Mozilla improving the Javascript JIT in FireFox -- when MMMarco was 13.

 :-DD yeah I get it, you're a "big dog" doesn't mean you have the experience in JavaScript.

But, yeah, I've got no experience in Javascript.

I bet you don't.

But apparently I don't have any experience in high level languages.

Yes, you don't. Get over it.
« Last Edit: June 23, 2023, 04:28:24 pm by MMMarco »
27 year old Software Engineer (mostly JavaScript) from Switzerland with a taste for low level stuff like electronics 😊

 

Offline gnif

  • Administrator
  • *****
  • Posts: 1939
  • Country: au
  • Views and opinions are my own
Re: what would you use to replace Bash for scripting?
« Reply #141 on: June 23, 2023, 04:29:37 pm »
:-DD yeah I get it, you're a "big dog" doesn't mean you have the experience in JavaScript.

 :palm:

I've worked at Mozilla improving the Javascript JIT in FireFox -- when MMMarco was 13

But apparently I don't have any experience in high level languages.

Yes, you don't. Get over it.

 :palm:

I've won multiple prizes in the ICFP (International Conference on Functional Programming) 72 hour programming contest, using the high level language "Dylan"

@MMMarco I warned you against trolling, and you continued, you're done here. Take a two week break. Hopefully when you return you have learned to show some respect towards others and take the time to actually read what people are saying before responding in such an asinine way.
« Last Edit: June 23, 2023, 04:44:42 pm by gnif »
 
The following users thanked this post: MK14

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: what would you use to replace Bash for scripting?
« Reply #142 on: June 24, 2023, 12:55:10 am »
Do you think shelljs emulates that call to git?

Because that's a big "nope".

That's literally the ONLY thing that shelljs ISN'T EMULATING - clear that you would jump onto that.

The git call was the entire point of the example I posted. The other stuff was just for context, showing it was a real example, not just something I was making  up on the spot.

I just spent 18 months working as a JS dev at a small NZ web-based startup "TIME" listed in their "100 Most Influential Companies of 2022" (in the world).

The RISC-V world is exploding right now in a way it wasn't two years ago, so I'm jumping back into that now.
 

Online helius

  • Super Contributor
  • ***
  • Posts: 3849
  • Country: us
Re: what would you use to replace Bash for scripting?
« Reply #143 on: June 24, 2023, 01:33:52 am »
bash is feeling rather long in the tooth and has implemented a number of questionable decisions (including one that led to an exploit named "shellshock": it automatically executed code found in environment variables). But the concept of the Unix shell doesn't begin and end with bash. Zsh is a lot more modern for example. And there is Scsh!
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17876
  • Country: fr
Re: what would you use to replace Bash for scripting?
« Reply #144 on: June 24, 2023, 01:42:31 am »
bash is feeling rather long in the tooth and has implemented a number of questionable decisions (including one that led to an exploit named "shellshock": it automatically executed code found in environment variables). But the concept of the Unix shell doesn't begin and end with bash. Zsh is a lot more modern for example. And there is Scsh!

Interestingly both Bash and Zsh were released at about the same time.
I don't know much details about Zsh. What does it offer that Bash doesn't?

I think the OP was looking for a scripting language a bit more elaborate than just a "shell". But maybe Zsh is? In all cases, you're right in pointing out that there are alternative shells out there.
The thing is, many Linux tools rely on Bash - like 'autotools' (can it run with anything else?).
Which, btw, means that if you're using a scripting language, you may still need to have Bash available to execute some existing tools.

So a question: can you use autotools say with Zsh?
 

Online helius

  • Super Contributor
  • ***
  • Posts: 3849
  • Country: us
Re: what would you use to replace Bash for scripting?
« Reply #145 on: June 24, 2023, 02:29:25 am »
There are a lot of small differences, making a comparison list would be pretty hard (although no doubt someone on the Internet has already tried; I have not looked). In general the philosophy of Zsh is not to be quite as constrained by compatibility with older shells. Bash on the other hand (as you can sort of tell from its name: "Bourne-Again Shell") is required to be compatible with Bourne shell scripts as in many systems it is linked to /bin/sh.
Some of the interesting features are nested substitutions, process plumbing, dynamic directory names, catch and throw, evaluation hooks, and precompiled batch files.
About autotools, I do not know for sure. It may have bashisms.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17876
  • Country: fr
Re: what would you use to replace Bash for scripting?
« Reply #146 on: June 24, 2023, 02:36:48 am »
I think I've found an answer to this: https://www.gnu.org/software/autoconf/manual/autoconf-2.67/autoconf.html
Zsh has a compatibility mode that you need to use for this. So, that should be workable.

The doc says that Mac OS X switched from Zsh to Bash. Would be interesting to know why. Possibly they were running into too many compatibility issues with existing stuff.


 

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1803
  • Country: us
Re: what would you use to replace Bash for scripting?
« Reply #147 on: June 25, 2023, 12:01:25 pm »
MacOS switched back to zsh as the default shell in a later version. I think it was Catalina (10.15, October 2019).
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: what would you use to replace Bash for scripting?
« Reply #148 on: June 25, 2023, 01:29:45 pm »
MacOS switched back to zsh as the default shell in a later version. I think it was Catalina (10.15, October 2019).

This of course is only for new accounts. Old accounts keep their existing settings which, for me, have been bash ever since Rhapsody, which IIRC had tcsh as the default shell.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17876
  • Country: fr
Re: what would you use to replace Bash for scripting?
« Reply #149 on: June 25, 2023, 07:23:11 pm »
MacOS switched back to zsh as the default shell in a later version. I think it was Catalina (10.15, October 2019).

This of course is only for new accounts. Old accounts keep their existing settings which, for me, have been bash ever since Rhapsody, which IIRC had tcsh as the default shell.

Any ideas why they have kept changing?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->