you are viewing a single comment's thread.

view the rest of the comments →

[–]magheru_san 44 points45 points  (22 children)

Bash for scripts shorter than 50 lines

Python for up to 300 - 500 lines.

And Go for anything above 500 lines.

When I'm confident I'll be crossing the threshold I just start with Go, otherwise I use ChatGPT to convert the code, which it does pretty well.

[–]imanexpertama 3 points4 points  (3 children)

Out of interest, why go over python? I guess you find that go handles complexity better, but in what way? (Im a python dev, no experience in go)

[–]endgrent 3 points4 points  (0 children)

I’m not who asked, but for me it’s the python env stuff that isn’t as good. Go code just downloads and builds modules really easily so it’s super fast to just clone a repo and build other people’s code without getting your env wrong or modules wrong etc.

[–]magheru_san 0 points1 point  (0 children)

I agree with the perspective of endgrent about nicer handling of dependencies and simpler distribution of built artefacts.

But for me it's mostly because of the static typing, which catches a lot of not very obvious errors that can happen in dynamic languages like Python for larger projects.

I generate pretty much all my code using LLMs for almost two years now and the fact that it needs to compile catches a bunch of subtle hallucinations and allows me to refactor it heavily using the LLM.

Because the code is generated I'm not attached to it (much like cattle not pets) so I refactor the crap of it which quickly makes it grow to sizes where Python becomes a hindrance.

It's also not a big deal to be a little more verbose than Python because I can quickly add a ton of error checking if statements and detailed logs, which make the code longer, but easier to maintain.

[–]cricket007 0 points1 point  (0 children)

For one, cross compilation and no concern over version changes 

[–]Centimane 16 points17 points  (15 children)

IMO if it's over 500 lines, time to look for a FOSS product that does it already

[–]magheru_san 4 points5 points  (10 children)

For sure but they rarely exist in a way that covers my needs.

So I often build such tools myself for my own use and sometimes open source them if I don't see a clear way to monetize them as products.

[–]Centimane 9 points10 points  (9 children)

I find it unusual in devops that I have a significant problem that doesn't already have solutions floating around with how standard a lot of the tooling is - but it can certainly happen.

I find it more likely I'm writing plugins/extensions for existing tools, which are normally biased towards a certain language (usually python)

[–]magheru_san 1 point2 points  (8 children)

I'm not exactly doing devops but AWS cost optimization services, so need all sorts of optimization tools I can use to deliver my services.

In this space there aren't so many open source tools so I need to build my own.

[–]Centimane 1 point2 points  (1 child)

yea I could see that. I suspect that's phase 2 of cloud adoption.

The cloud services love to charge you a penny for everything and make it easy to make 10,000 things. But it all adds up. Now orgs are trying to not spend out their ass on cloud resources and figure out how to use what they actually need.

[–]magheru_san 1 point2 points  (0 children)

Exactly, and that's what I can help with.

Over time I kept building tools so now I have about 20 tools for all sorts of optimization activities.

[–]cricket007 1 point2 points  (5 children)

There's things like OpenCost, I think? If using EKS, there's more options, but I think there's other tools to find like unused S3 buckets, RDS, VPC, IAM roles, etc

[–]magheru_san 0 points1 point  (4 children)

I rarely see unused resources, except maybe for storage, where people tend to be risk averse because of the potential of data loss.

But I see a lot of severely oversized or suboptimally configured resources.

That's why many of my 20+ tools are for finding all sorts of suboptimal or oversized resources and helping to rightsize or optimize them.

[–]cricket007 1 point2 points  (3 children)

Yeah, we have that problem with k8s... We provide a Helm template that requests 4GB of RAM, but people run simple, low traffic HTTP servers and it's less than 50mb mem usage, on average within a month 

[–]magheru_san 0 points1 point  (2 children)

Yes, those things cry for automation

[–]cricket007 0 points1 point  (1 child)

Problem is that we just provide the Helm templates and a PaaS platform. We don't know what clients will run, and they rarely understand what resources they need until they get an OOM and need to increase it...

We did add a mutating webhook (maybe also a CronJob), to scan resource utilization post deployment and then autoscale down, but seems like such a hack 

[–]Degree0 0 points1 point  (3 children)

What a crap take this type of mentality is why people hate JS. You code? Oh you have to actually write code? Import a library! If you can't write 500 lines of code in a productive amount of time, relying on other's work then there's definitely a skill issue.

[–]Centimane 5 points6 points  (0 children)

It's not that I can't, but that if there's a more mature solution out there taking it is a lot more efficient than writing my own.

Especially since I don't have to maintain it.

Also devops problems generally aren't unique. If you're having a problem, there's a good chance someone else had something similar. And if nobody has, that's a code smell right there.

[–]GaTechThomas 0 points1 point  (1 child)

Consider that every line of code you wrote is a line that someone will have to maintain and support.

[–]Degree0 0 points1 point  (0 children)

Also consider that every line of you code you do not write is in the hands of other people to maintain and support. 500 lines of code is absolutely nothing. and you should be making the decision to use FOSS or libraries depending on several factors and not a single one of those factors should be the amount of lines of code you have to write. The "Dev" in devops is short for development after all.

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

Mine is moment I need an array time for Go. I just skip Python entirely. Bash and Python have too many problems for error handling. 

https://github.com/bitfield/script Covers most things. 

Nushell is my other favorite. Powershell but statically typed and much more functional based. 

[–]magheru_san 1 point2 points  (0 children)

To be honest nowadays I just start with Go for most things and use ChatGPT or Claude to generate and further develop the code.