4 ms·
I think your comment is covered in the FAQ: https://flix.dev/faq/ https://flix.dev/faq/ > Can we just stop building new programming languages? We build new p
by jorkadeen 6y ago
I think your comment is covered in the FAQ:
https://flix.dev/faq/ https://flix.dev/faq/
> Can we just stop building new programming languages?
We build new programming languages and we do research on programming languages because we want to offer developers better tools to write programs. We want tools that make it simpler, safer, and faster to write correct programs. We want tools that increase productivity and that aid in program maintenance.
The situation is not unlike why we would want better airplanes, better houses, or better surgical instruments.
(I am one of the authors of Flix)
- xupybd 6y agoCan you elaborate on this? >We are planning to define division by zero as yielding zero Is there a non mathematical reason for that choice?
- jorkadeen 6y agoThe alternatives are: - Division must be impure (because it can throw an exception, crash the program, etc.) - Division must be partial - i.e. return Option[Int]. Both seem worse compared to defining division by zero as zero. Coq, Lean, and Pony do the same. https://github.com/ponylang/pony-tutorial/blob/master/content/gotchas/divide-by-zero.md https://github.com/ponylang/pony-tutorial/blob/master/conten...
- coldtea 6y agoWhy is the Option[Int] "worse"?
- lock-free 6y agoWhy not NaN for floating point division and INT_MAX for integer division? When you write code that may divide by zero you need to check the result afterwards (and in truly defensive programming that is every time you divide numbers). 0 is not a great choice because it doesn't necessarily mean you divided by zero - in floating point, dividing by a sufficiently large number or when working with the status register set to flush denormals to zero then normal division can result in 0. For integer division, any fraction will result in 0. No valid division can result in NaN or INT_MAX.
- wice 6y agoThese are not the only alternatives. E.g.: - introduce a non-zero number type, define division as Number/NonZeroNumber -> Number, and provide a simple, non-verbose way to convert a Number into NonZeroNumber (with default value in case of zero, and/or direct assignment after a non-zero-check) - optionally introduce an unsafe division operator that takes two Numbers and returns Option[Number]