odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.17k stars 550 forks source link

The second thing that I miss in Odin is Operator Overloading. And that make me confused. #2728

Closed joaocarvalhoopen closed 11 months ago

joaocarvalhoopen commented 11 months ago

Hello,

I really like the design of Odin, and it's design decision, it's simplicity and elegance, but I must not be seeing something in Odin, because in my brain is confused, it's not making sense that Odin is used for high performance computing and that gingerBill is a Physicist and uses it for high performance mathematical computation of real time fire, smoke and water special effect simulations in the CPU and GPU and Odin doesn't have Operator Overloading for any user structure of custom math ?!??!??!!?

I'm I missing something?

This two realities seem worlds apart, so I must be missing or not understanding something?

Can please someone help to clarify my mind?

Thank you very much.

The very best regards, João Carvalho

drmargarido commented 11 months ago

There is no operator overloading, but there is support for array programming with vector and matrix math operations on the base language itself. Link

joaocarvalhoopen commented 11 months ago

Hello, thank you drmargarido for the fast reply,

I have read the array programming section and the Matrix section of seen the matrix and array operation overloading, but the is steel one aspect that is not compatible of using Odin in language operator overloading and that is this citation that I put here from the manual:

" Currently, matrices are limited to a maximum of 16 elements (rows*columns), and a minimum of 1 element. This is because matrices are stored as values (not a reference type), and thus operations on them will be stored on the stack. Restricting the maximum element count minimizes the possibility of stack overflows. "

There should be support for unlimited size of matrix's of any type of data, ex: f32, f64, f128, complex32 and complex64, complex 128.

I'm thinking about scientific data calculations or processing and not only computer graphical matrix transformations.

Thank you very much,

Best regards, João Carvalho

laytan commented 11 months ago

From the FAQ:

Why does Odin not have operator overloading? #

The design goals of Odin were explicitness and simplicity. Operator overloading is very easily abused and can be used to do many magical things. A procedure is clearer and more explicit.

Array programming is available in Odin; this removes some of the need for operator overloading when creating mathematical libraries.

Kelimion commented 11 months ago

There should be support for unlimited size of matrix's of any type of data, ex: f32, f64, f128, complex32 and complex64, complex 128.

Why? The number one scientific language (Python) doesn't have it without resorting to a third-party package. On what theory then should Odin have it as a base type?