Is Operator Overloading Really Needed? | Tsoding

preview_player
Показать описание
Tsoding shares his opinion on operator overloading in modern languages.

This channel is not affiliated in any way with the Tsoding Daily channel or any of the three owners of the main Tsoding channel.
Рекомендации по теме
Комментарии
Автор

This video is from the stream where he was trying the C3 programing language which is a C-like language. It do not have operator overloading and has built-in vector types with swizzling.

TsodingHighlights
Автор

Operator overloading is an absolute blessing for scienfic libraries and ml frameworks. One of the reasons python is so popular in ML and AI space. I mean java also has ml libraries, but it is an absolute pain when you have to implement complex algorithms. In python and C++, it is as easy as copying math equations.

fluxter
Автор

I'm a mathematician. No language developer is going to exhaustively handle our mathematical "data types" (algebraic structures). A lot of the time we're dealing with things non-mathematicians wouldn't even call numbers. But it's just as nice to be able to overload operators for those as on vectors and matrices. Just let us extend the language instead of having to fork it or deal with specialized software written 35 years ago.

Not saying every language must have it, but it is a useful feature and some languages should have it.

rupen
Автор

Dude still not tried Odin. And he's talking about Odin 😂

vapandris
Автор

Odin technically not mentioned, but implied.

krisdabrowski
Автор

It's hard to standardize matricies tho. Or to go further - tensors. Should they be stored column-wise or row-wise? Do we support up to 4x4 matricies for graphics people or arbitrarily sized ones for ai people? If latter should they require an allocator? What about the ownership?

Like operator overloading is not ideal but at least you don't have to attempt to solve a one-size-fits-all solution for matricies. If you're making a systems programming language - but you could add numpy matricies to standard js and it'd fit perfectly.

ovi
Автор

Odin showed me that all we really need operator overloading for is composite mathematical types and all we need preprocessor macros for is conditional compilation. It’s people abusing these features in other languages that make them look bad.

taylorallred
Автор

I mean, I do agree. In Julia tough, it all go around this concept... And it works in very understandable way

mattiasamiolo
Автор

Easy solution: if your want to overload +, -, * and /, you have to prove that your type forms a field. /j

mskiptr
Автор

numpy be like
sure who needs operators, mat.add(mat) sounds delicious

asbestos
Автор

Why all the comments are about this odin thing? Have anyone even used it production?

Gruak
Автор

What an IQ 145+ W take.

This makes it trivial to implement assembly vector operations on datatypes that actually need them.

arkeynserhayn
Автор

Half of this comment section is Odin bots

stefanalecu
Автор

Haskell's operators are actually very principled; if you want the same operator to work on two different types, there needs to be a common interface. Haskell has no actual function or operator overloading, just the ability to define new operators.

einargs
Автор

it's more of a Haskell problem than an operator problem, eg Julia has a lot of operators + macros that can locally modify operators but is not nearly as confusing.

Daniel_Zhu_af
Автор

I feel like the value operator overloading can bring heavily outweighs the costs of people misusing it.
I do agree that it should be more restrictive than what C++ allows, but why should I not be able to provide custom equality or comparion (>, >=, < =<) operators for my own types?

mkwpaul
Автор

GingerBill (the creator of odin) said the same thing

aedd
Автор

*clears throat* Ahem... Odin mentioned! :)

Whatthetrash
Автор

imo rust way of using traits for like *everything* is probbably my favorite way of implementing matrix math, plus you cant (or well atleast its hard to) turn that into an implicit nightmare

MCorange
Автор

Operator overloading is a pretty useful imo. Stupid people will always find ways to make everything terrible. We need to educate people instead of removing a cool feature.

CrazyWinner