this post was submitted on 06 Jul 2023
78 points (100.0% liked)
Programming
17668 readers
179 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 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Overall I agree with what the author says, though I have a few further thoughts:
These two arguments contradict each other and together are an argument for static typing, not against. Which just shows how weak these arguments are.
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.
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.
I don’t understand how types could be time consuming.
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.
I never understood this argument. If your function is supposed to take an int, then parse your string before calling it?
There are reasons you might want to, such as you are constructing something that has a few different ways to create it. Like maybe a date, can parse it from a string, pass in each bit as a separate argument, take in a Unix timestamp.
A lot of languages encourage this with constructors as you can often only have one.
IMO it is far better to just have different functions for each type you want to build something from like how it is done in rust.
But when you come from a language that encourages the opposite it can seem clunky to have to define separate functions for each. And it can take a while to accept the different way of working.