this post was submitted on 18 Nov 2024
14 points (71.9% liked)

Programming

17450 readers
82 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
all 11 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 6 hours ago* (last edited 6 hours ago)

Seems like a Ruby issue and suggested improvement? Using keyword arguments does feel like introducing a type of typing.

In C# I use records for simple, naturally behaving types, I can define explicit and implicit cast operators, so I have to choice between requiring explicit casts or not (because they make sense to require or are not necessary). I can use var to define a variable without specifying a type, and it is deducted from what it gets assigned - but is still that specific type and gives me type safety.

In Rust, as far as I understand anyway, traits define shared behavior. In Go interface implementations are implicit rather than explicit. With these, there's even less of a need of elaborate explicit typing like the post argues/gives an example of.


In general, I've never had considerable effort or annoyance implementing or using typing. And I know what it's good for; explicitness, and in consequence, predictability, certainty, increased maintainability, and reduced issues and confusions. If following references or refactoring becomes unpredictable or high effort, it'd be quite annoying.

When I'm coding JavaScript adding JSDoc so the typing information gets passed along is quite cumbersome. Without it, the IDE does not give intellisense/auto-completion or argument type matching. JavaScript is better with it, I consider it worth it with IDE support, but it is quite cumbersome. (I try to evade TypeScript compiler/tooling overhead.)

A programming language can offer extensive auto-deduction while using strong typing. With appropriate conversions in place, it will only report conflicts and where it was intended to.


I'm thinking of where I enjoyed dynamic natures, which I certainly have. But I don't think that's a matter of typing. It's a matter of programming language interfacing to typing. If in PHP or JS I make a change, hit F5, and get an error, that's not any better than the IDE already showing it beforehand. And for the most part, I can program the same way with or without typing.

Man, this became a long text.

[–] [email protected] 15 points 1 day ago* (last edited 1 day ago) (3 children)

Instead of just doing what I want to do, I'm stuck either doing plumbing work to hold my values and pass them around, or I'm casting things back and forth where I know things are correct but the compiler doesn't.

I hate this attitude.

Instead of doing what you want to do? Dude, unless you’re a hobbyist, you’re being paid to do what your company wants you to do; i.e., it’s not about what you want.

Stuck doing plumbing work? Yeah, nobody likes plumbing, but we all know it’s necessary. When you’ve got your proverbial shit backing up onto your floor because you cheaped out on plumbing, cry to me then.

If you’re casting things back and forth, you’re doing it wrong. Spend a day or two and build yourself a solid, consistent foundation, plan ahead, and you won’t be casting things back and forth.

And no, you obviously don’t know better than your compiler, you arrogant sack of sh…

Anyway, get over yourself already and just do your damn job better.

[–] [email protected] -4 points 22 hours ago* (last edited 22 hours ago) (1 children)

How many billion dollar companies were built on dynamically typed languages? Do you think that companies/bosses/investors care about the compiler warnings or whether you can deliver/iterate faster than the competition?

nobody likes plumbing, but we all know it’s necessary.

Is it, really? Are we all working on mission critical software? We are living in a world where people are launching usable applications with nothing but the prompt to an LLM, ffs, and you are there trying to convince yourself that pleasing the Hindley-Milner gods is fundamental requirement in order to deliver anything?

Good engineering is about understanding design constraints and knowing where to choose in a myriad of trade-offs. It's frankly weird to think that such an absolute, reductionist view like yours got so much support here.

[–] [email protected] 6 points 13 hours ago (1 children)

I care about types not just because I like having stronger confidence in my own software, but because, as a user, bugs are really annoying, and yes, I'm confident that stronger type systems could have caught bugs I've seen in the wild as a user.

[–] [email protected] -1 points 12 hours ago (1 children)

I don't really want to be talking past each other. The point I am refuting is that even if type-safety can help reduce the amount of bugs shipped, this is not the only metric that matters to measure the value of the software being developed.

bugs are really annoying

And being late or never delivering out of fear of shipping buggy code is even worse.

Some years ago, I worked on a crypto project that was financed via an ICO. This meant that whatever money the company was going to get was already in their hands, and their only job was to make sure they could prove they've done a best effort to deliver what was promised to investors.

Because of these incentives, the engineers were more concerned about covering their asses regarding bugs than to actually get the software out in the hands of users. The implementation was in python, and to the team it was easier to justify spending time on getting 100% mypy coverage than to get things in hands of users to see the value of what we promised to deliver.

In the end, by the time the team managed to deliver, the code was super well-tested, there were 0 mypy warnings and absolutely zero interest from other people in adopting our tool because other competitors have launched a whole year before them.

[–] [email protected] 3 points 9 hours ago (1 children)

I understand what you're saying, but I want to do whatever I can to promote the shift in attitudes that's already happening across the industry.

And being late or never delivering out of fear of shipping buggy code is even worse.

From a business perspective, yes, usually true. But shipping buggy software can also harm your company's reputation. I doubt that this has been researched enough yet to be quantifiable, but it's easy to think of companies who were well known for shipping bugs (Microsoft, CD Projekt Red) and eventually suffered in one way or another for it. In both of those cases, you're probably right; Windows was good enough in the 90s to dominate the desktop market, and Cyberpunk 2077 was enough of a technical marvel (for those who had the hardware to experience it) that it probably bolstered the studio's reputation more than harmed it. But could Microsoft have weathered the transition to mobile OSes better if it hadn't left so many consumers yearning for more reliable software? And is Microsoft not partly to blame for the general public just expecting computers to be generally flaky and unreliable?

Imagine if OSes in the 90s crashed as rarely as desktop OSes today. Imagine if desktop OSes today crashed as rarely as mobile OSes today. Imagine if mobile OSes crashed rarely enough that the average consumer never experienced it. Wouldn't that be a better state of things overall?

[–] [email protected] -1 points 8 hours ago* (last edited 8 hours ago)

Imagine if OSes in the 90s crashed as rarely as desktop OSes today. Imagine if desktop OSes today crashed as rarely as mobile OSes today. Imagine if mobile OSes crashed rarely enough that the average consumer never experienced it. Wouldn’t that be a better state of things overall?

Depends. What is the cost to get there? Will that sacrifice openness? Will that sacrifice portability? Will that require ossified structures that will make development of new applications more difficult?

Look, the article is talking from the perspective of someone who is developing web apps in Ruby. Performance is not a huge concern. Processes being crash-proof are not a concern. You know what is the concern? To be able to validate ideas and have something that bring customers willing to pay real money to solve their real problems.

For his scenario, forcing to define everything up front is a hindrance, not a benefit. And having GP screaming at it like this for having this opinion is beyond ridiculous.

[–] [email protected] 8 points 23 hours ago

I mean I agree but you don’t have to be a dick about it

[–] [email protected] 8 points 1 day ago

Types aren't unit tests. Unit tests only test a discrete set of inputs and outputs for correctness, and can miss cases that aren't tested for.

In sound type systems, they are closer to formal verification. The compiler guarantees the properties you expect of the type hold.

As for the rest of the article, do what works best for you in your projects, but if I need to work with you, I'm going to ask for types. I need to know what types the interface expects to receive. Names are not enough. Document them, use type hints, whatever, just put them somewhere because I'm not psychic and I don't know what you thought about when writing the function.

[–] [email protected] 36 points 1 day ago

I don’t get the hatred for types, they have saved my ass so many times and saved so many headaches exactly like what the article describes. I used to write a lot of ruby and after getting decent at typescript I can’t go back.

It’s not just ceremony, types ensure some level of logical consistency in your app. They reduce how much of the world you need to keep in your head at one time, and they allow you to express your intent far more robustly than comments and naming can. I love rust’s approach of making invalid state not even representable.