News for hackers. Stuff that matters.
Re:Beads: Computer language and toolchain by ithkuil on Thursday May 27, 2021 @05:00PM (#27308476)
> I don't see how "special rules of arithmetic and a robust mathematical model" makes it "extremely difficult to have a serious malfunction."

The only way would be to have arbitrary precision integers by default and thus no overflows ever. (IIRC smalltalk was something like that, but it was long time ago since I used it, so I'm not sure)

Re:Beads: Computer language and toolchain by rst on Thursday May 27, 2021 @05:50PM (#27309010)
Integer types in current versions of Ruby and Python both have arbitrary precision (as is also true for lots of other languages these days). That's not enough to make either intrinsically bug-free...
Re:Beads: Computer language and toolchain by ithkuil on Friday May 28, 2021 @06:52AM (#27313851)
python does have bignum integer, but there are subtle things, like if you divide an integer with an integer you get a float, where you do lose precision:

>>>(100000000000000000000000000000000000000000000000000/2+1) % 2 == 0

True

if you want to get an integer you have to use the relatively recent "//" operator:

>>> (100000000000000000000000000000000000000000000000000//2+1) % 2 == 1

True

in smalltalk you'd get a Rational or something like that.

Re:Beads: Computer language and toolchain by deckard1 on Thursday May 27, 2021 @05:49PM (#27309000)
bignum as the default integer is quite common in lots of languages[1]. Notably, Lisp, Scheme, Erlang, Python.

Scheme is a bit interesting in that they have a "numeric tower", which contains rationals and even complex numbers (implementations were free to implement a subset of this tower, at least as far as R5RS, not sure today)

[1] https://en.wikipedia.org/wiki/List_of_arbitrary-precision_ar...

Re:Beads: Computer language and toolchain by travv0 on Thursday May 27, 2021 @06:30PM (#27309394)
Just to elaborate a bit, in CL, numbers are FIXNUMs by default but are promoted to BIGNUMs if needed. CL also has rational and complex numbers, which it probably got from Scheme but I'm not familiar with that history.
Re:Beads: Computer language and toolchain by magicmouse on Saturday May 29, 2021 @02:08PM (#27327067)
Excel achieves its robustness (and it hardly ever crashes) by protecting the user against arithmetic errors, and circular reasoning. Excel doesn't offer infinite precision arithmetic, that is rarely needed in practice.

Null pointers are something that plagues Java, which are primarily caused by having some computation out of sequence. By using the State-Action-Model pattern, most of Beads code will be devoted to rendering the model on the screen, and that one-way transfer of information can be made very robust, provided you have a closed arithmetic, which it does.

Re:Beads: Computer language and toolchain by stonewareslord on Friday May 28, 2021 @05:33PM (#27320793)
That's definitely one way to solve the issue, but I wouldn't say it's the only way.

In Rust, you can configure Clippy to ban the usage of +-*/ and require explicit behavior of each calculation. For example, 10u8.checked_add(10) returns an Option<> (similar to Maybe in Haskell) so you can handle overflows. You can also use 1u8.saturating_sub(100) which will not allow wraparound but values will saturate at the max/min.