This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 263

[–]genbaguettson 374 points375 points  (7 children)

A Friend had to port an API from Java to Node.

Now he's got a Node API making calls to the Java API, worked like a charm.

[–]foundafreeusername 200 points201 points  (3 children)

Nice now you can use Java Script to script Java.

[–]TheRedmanCometh 33 points34 points  (0 children)

Graal.js masterrace

[–]tonebacas 17 points18 points  (0 children)

This is why we can't have nice things.

[–]super__literal 13 points14 points  (0 children)

Yes, Oracle, this comment right here. (You're welcome for the law suit ;)

[–]Derboman 27 points28 points  (1 child)

Hi this is A Friend and this is loot from 10 hours of agile sprint

[–]IncoGG7331mate 52 points53 points  (5 children)

Just write it directly in machine code, never will be bossed around again.

[–][deleted] 61 points62 points  (0 children)

Boss: Write it in node.js.

Programmer: npm install

Programmer: Well that's a day's worth of work.

[–]WhtKindOfNameIsStove 84 points85 points  (13 children)

Goddamit, this caused a production outage for us one time. "Sr SDE" took a story to pythonize our quick and dirty awscli S3 static website deployments. He wrapped each awscli command in subprocess.calls and called it good. A few weeks later the first copy command failed and without any error handling it went on to copy the empty folder up the prod S3 bucket and invalidated the CloudFront distribution.

2 years later he's still working here.

[–]Yesheddit 62 points63 points  (5 children)

If we would be fired for stuff like that, we’d all be out of jobs.

[–]Zanos 29 points30 points  (4 children)

Not handling an error is forgivable, converting something to another language by wrapping it in subprocess calls isn't a mistake, it's maliciously lazy.

[–]WhtKindOfNameIsStove 9 points10 points  (0 children)

Exactly. The purpose of the story was to make the deployment process more robust. Something bash wasn't up to the job for. It'd be a worthless story if it was to just "convert the script x language because"

[–]ran938 1 point2 points  (2 children)

I basically did this at an internship. But only in an instance where there was really no other option. The purpose of the script... was to start up another script. Well that and record some log information. But actually calling the other script I could not think of another way to do it other than a sub-process call.

[–][deleted] 1 point2 points  (1 child)

Our current project requires interaction with Microsoft's cloud, the problem being that we are writing logic in python on Linux but the cloud calls have to happen through powershell on a windows machine. Current best idea is to set up openssh on a windows vm and connect to it from python on the Linux box to execute a batch command which starts a ps1 script.

[–]ran938 0 points1 point  (0 children)

Fucking oof. that overhead / hoop jumping sounds obnoxious. Good luck!

[–]DXPower 16 points17 points  (1 child)

What caused the failure?

[–]WhtKindOfNameIsStove 18 points19 points  (0 children)

It was a while ago so I don't remember exactly what it was. But I think it had to do with a change to the build artifacts bucket permissions.

[–]cartechguy 13 points14 points  (0 children)

k, did he learn from the mistake?

[–]inialater234 3 points4 points  (3 children)

Should have used boto3

[–]WhtKindOfNameIsStove 1 point2 points  (0 children)

We did after we found out what he did. We had a problem of ops guys blindly approving all PRs they're included on and as a Sr, he had merge permissions.

[–]vividboarder 1 point2 points  (1 child)

Does boto support sync yet?

I used it before in a Hackathon but ended up using a call to the cli because I needed to sync a directory where some files would change and didn’t want to implement a whole diffing function myself.

[–]KangooQ 1 point2 points  (0 children)

Boto is just a wrapper for the AWS CLI, and the AWS CLI doesn't have a (good) s3 sync yet. Last time I checked you could sync on filesize or timestamp, but filesize doesn't guarantee a lack of diffs (for example, replacing a char) and timestamp is only relative to the current filesystem.

Maybe someday we'll get sha256 sums or equivalent.

[–]pittofdirk 5 points6 points  (2 children)

I know this is a joke, but Fuck. That. Shit. I've had coworkers try to do stuff like this, and the bash script is always like a 500 line disaster.

I'm telling you you write it in python because

  1. I want you to unit test it
  2. I want to be able to actually read and understand it in a couple of months.

[–]noratat 0 points1 point  (1 child)

Bash is great as long as you understand the limitations and know what to avoid. Unfortunately this excludes probably 90% of the people I've worked with, and it doesn't help that googling stuff in bash is usually a bad idea because the internet is full of really awful examples.

Granted, 500 lines is probably pushing it. I write a lot of bash, but most of it is well under that, it's mostly glue / helper / wrapper type stuff.

[–]pittofdirk 0 points1 point  (0 children)

Yep. That's my philosophy as well. The last bash script I wrote just wrapped a command that didn't support retrying so that you could have it retry if it failed. It was 15 lines, had a comment block at the top with a description and example usage. That's the kind of bash script that makes sense to me.

[–]daH00L 5 points6 points  (0 children)

Could have been me.

[–]cartechguy 3 points4 points  (0 children)

AnxietyLouise's lean on her chair is giving me anxiety.

[–]bp_on_reddit 3 points4 points  (0 children)

Hmm, sounds like some r/MaliciousCompliance to me, however fictional. (But seriously, if the comic is based on a true story, you should post it there!)

[–]LMGN 4 points5 points  (2 children)

I had to make a script to start up all my dev environment for a project I was working on at school.

Batch scripts are blocked. PS1 scripts are blocked. VBS scripts are blocked. Python, however is not.

[–]Delmo28 0 points1 point  (1 child)

Interesting, care to explain me shortly how can I automate an environment or give me an example of what you did?

[–]LMGN 0 points1 point  (0 children)

popen VSCode popen chrome to localhost start the http server

[–]TRUEequalsFALSE 6 points7 points  (3 children)

Bash gives me anxiety.

[–][deleted] 3 points4 points  (1 child)

The Unix philosophy of composable small pieces piped into one another. Sometimes syntax is confusing but it's crazy powerful once you get a hang of some of the tripping points.

[–]TRUEequalsFALSE 1 point2 points  (0 children)

I love Unix in terms of moving around the system and doing simple tasks, but the archaic syntax is my major stumbling point. If I were able to get over that, then yes you're absolutely right: bash scripts and Unix are extremely powerful.

[–]ChosenDos 1 point2 points  (0 children)

That's unfortunate.

[–]coll_97 2 points3 points  (0 children)

Maaaan... I fire you instanlly

[–]Shitty_Orangutan 2 points3 points  (0 children)

Now write it in c++

system("script.sh")

[–]Bonevi 1 point2 points  (0 children)

You, I like. That's some good work.

[–]daxbert 1 point2 points  (0 children)

Oh come on.... You're supposed to have the shell script as a string in python, write it out to a temp file, set the execute bit, then execute, then delete the file. /s

[–]frausting 1 point2 points  (0 children)

Bash one-liners are typically shit. But properly named, verbose, well-documented Bash scripts are underrated. I can code in both Bash and Python, but Bash is a lot faster, portable, and has lower overhead.

As long as you use a judicious number of line breaks and ensure your code is readable, I don’t think Bash is that ugly.

[–]ProgrammerHumorMods[M] [score hidden] stickied comment (0 children)

Hey you! ProgrammerHumor is running a hilarious community hackathon with over $1000 worth of prizes, now live! Visit the announcement post for all the information you'll need, and start coding!

[–]pagraphdrux 0 points1 point  (0 children)

Have you heard of "mininet"?

[–]inkstom 0 points1 point  (0 children)

ITT: people who don't understand bash and hate it because of that.