this post was submitted on 06 Jul 2023
0 points (NaN% liked)

Programming

16975 readers
1288 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
top 10 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 1 year ago (1 children)

Overall I agree with what the author says, though I have a few further thoughts:

One might argue that writing types are time consuming, and the bugs are not an issue when programmer can cover those cases with automated tests.

These two arguments contradict each other and together are an argument for static typing, not against. Which just shows how weak these arguments are.

but a more powerful type of inference that can actually infer the whole type of a function by analyzing the body of the function.

This bit I am not convinced by. Inferring the API of a function from its body makes it harder to see breaking changes when you refactor the body. It can be useful for internal private helpers, but IMO public APIs should be explicit about their signature.

Functional Programming

I would go one step further here. It should support OOP and procedural paradigms as well. No single programming paradigm is best suited to all problems. Sometimes a mixed approach is best. Any language that heavily leans oneway at the expense of the others limits itself to the problems it can best solve. I do admit the far too many languages lean too much towards OOP at the expense of functional style.

So it is easy to push for a functional style over OOP in new languages. But I would be weary of purely functional language as well.

[–] [email protected] 0 points 1 year ago (1 children)

I don’t understand how types could be time consuming.

[–] [email protected] 1 points 1 year ago

Some things are very easy to do in loosly typed languages - just as letting a function take a string or int, and then parsing that string into an int if a string was passed in. In a loosly typed language you can just call something like if typeof(input) but in a strongly typed language you often need a lot more boiler plate and extra wrapper types to say the function can only take an int or string - for instance in rust you might need to wrap them in a enum first or some how create a trait and implement that for each types.

This is quite a bit of extra upfront cost some of the time that really rubs people that are used to loosly typed languages the wrong way. So they think it is slow to work with types. But what they never seem to count is the countless hours you save knowing that when you read a value from something and pass it to a function that wants only an int, that the value is an int and you dont end up getting 2 + "2" = "22" and other suprising bugs in your program. Which results in less time debugging and writing tests for weird cases the compiler does not allow.

But all that extra time if often not counted as that is dissociated from the original problem at hand. And they are already used to this cost - people often notice a new cost, but don't notice a possibly bigger saving else where.

[–] [email protected] 0 points 1 year ago* (last edited 1 year ago) (1 children)

Python is basically (IMO) C/C++ made easy.

Billions of libraries, works on even obscure hardware, simple syntax, no compiling(it's behinde the scene and just like always works) or linking etc. etc. etc.

Edit: this implies that C/C++ is the best language ever of course. Let the flame wars begin!

[–] [email protected] 0 points 1 year ago (1 children)

Wow I pretty much disagree with everything you said haha. E.g. packaging/venv in python is absolute hell compared to something like cargo/crates in Rust. Try to manage a large project in python and you'll likely revise your answer (if you actually know all the nice alternatives out there...)

[–] [email protected] 0 points 1 year ago (1 children)

In my experience managing a large project comes down to having a consistent process/standards and enough experienced engineers in that language. Remove that and every single language leads to abominations.

[–] [email protected] 1 points 1 year ago

I agree, that having a consistent process and good engineers is definitely most important, but a language itself definitely can guide you in the right direction. I think ironically Rust and C++ are good vice versa examples (unrelated to their target area, which happens to be the same (systems programming)), C++ has zillion ways to program in, finding the right and best way is definitely no easy task and requires massive experience in all kinds of paradigms, while Rust generally promotes you to do things in one/the "right" (IMHO) way, otherwise the borrow-checker annoys you all the time.

[–] [email protected] 0 points 1 year ago (1 children)

With regards to immutability and pure functions, I don't really care where the language falls on the scale the author defined so long as there is a way to easily express deeply immutable objects and pure functions. There are a ton of benefits of those two things and a lot of optimizations and assumptions that can be made with them. So I don't really care if everything is immutable by default but just being able to tell the compiler/runtime "Hey listen, this thing won't change ever, got it? So go crazy with passing it to threads and stuff" or "This function will 100% definitely return the same value if given the same input so if it takes a long time you can cache the result if you're able to." both seem very appealing.

[–] [email protected] -1 points 1 year ago

Hey listen, this thing won’t change ever, got it? So go crazy with passing it to threads and stuff

I don't really care about that - none of the code I write is compute bound anyway. The CPU is generally twiddling it's thumbs idle for millions of cycles with occasional brief moments of activity when the SSD finally responds to the read operation that was requested an eternity ago. Or worse, it might be waiting on a network request.

I want immutability so I can, for example, make a copy of it and know my copy will always be the same as the original. In other words I want to be able to do my own caching/etc (possibly to avoid SSD access).

[–] [email protected] -1 points 1 year ago