auto isn’t dynamic typing it’s just type inference.
I’m aware, but one of the big arguments I’ve heard about dynamic typing is “I don’t know which type it has when I read the code”. Well, auto looks just like var in that regard.
Lambdas are just a way of defining methods in place. It has nothing to do with callbacks.
In computer programming, a callback is a function that is stored as data (a reference) and designed to be called by another function – often back to the original abstraction layer.
This is exactly what lambdas are often used for in C++.
It really isn’t. Neither in C# nor in Java. They are just syntactic sugar to avoid redundant type specifications. I mean things like Foo foo = new Foo();. Who gets confused with that?
Why do you think IDEs are able to tell which type a variable is?
Even C# takes a step further and allows developer to omit the constructor with their target-typed new expressions. No one is whining about dynamic types just because the language let’s you instantiate an object with Foo foo = new();.
The problem with dynamic typing is you can’t always figure out what the type is even with investigation as it can be lots of things based on what is passed or returned. It also allows incorrect values to be passed.
People will indeed make that readability argument but if the type is not obvious and important to understanding the code then it likely shouldn’t be used there.
I wouldn’t call bad readability a loaded gun really. Your dev tools will hopefully make it pretty easy to learn the type. It should be a minor inconvenience at best.
I wouldn’t call bad readability a loaded gun really.
Bad readability is a problem cause by the developer, not the language. Anyone can crank out unreadable symbol soup in any language, if that’s what they want/can deliver.
Blaming the programming language for the programmer’s incompetence is very telling, so telling there’s even a saying: A bad workman always blames his tools.
auto isn’t dynamic typing it’s just type inference. It still has a fixed type you just don’t have to write it. Like var in C#.
Lambdas are just a way of defining methods in place. It has nothing to do with callbacks.
But you’re spot on for memory safety. Managing it yourself is risky and if it can be managed at zero cost it seems stupid not to.
I’m aware, but one of the big arguments I’ve heard about dynamic typing is “I don’t know which type it has when I read the code”. Well, auto looks just like var in that regard.
Callback definition from wikipedia:
This is exactly what lambdas are often used for in C++.
Anti Commercial-AI license
It really isn’t. Neither in C# nor in Java. They are just syntactic sugar to avoid redundant type specifications. I mean things like
Foo foo = new Foo();
. Who gets confused with that?Why do you think IDEs are able to tell which type a variable is?
Even C# takes a step further and allows developer to omit the constructor with their target-typed new expressions. No one is whining about dynamic types just because the language let’s you instantiate an object with
Foo foo = new();
.The problem with dynamic typing is you can’t always figure out what the type is even with investigation as it can be lots of things based on what is passed or returned. It also allows incorrect values to be passed.
People will indeed make that readability argument but if the type is not obvious and important to understanding the code then it likely shouldn’t be used there.
Keyword being “shouldn’t”. C++ doesn’t care about that, it just hands you the loaded gun.
Anti Commercial-AI license
I wouldn’t call bad readability a loaded gun really. Your dev tools will hopefully make it pretty easy to learn the type. It should be a minor inconvenience at best.
Bad readability is a problem cause by the developer, not the language. Anyone can crank out unreadable symbol soup in any language, if that’s what they want/can deliver.
Blaming the programming language for the programmer’s incompetence is very telling, so telling there’s even a saying: A bad workman always blames his tools.