News for hackers. Stuff that matters.
Re:Common Lisp: Numbers by mmoez on Friday June 14, 2019 @11:16AM (#20183666)
It is worth noting that most scripting languages today are still restricted by 64-bit integers and IEEE floating points limitations.

Python and Ruby are probably the only popular ones that ship by default with unlimited precision integers.

For arbitrary precision reals in Python, there is mpmath http://mpmath.org/ . There is also the standard decimal module which "provides support for fast correctly-rounded decimal floating point arithmetic" : https://docs.python.org/3/library/decimal.html

Re:Common Lisp: Numbers by ddragon on Friday June 14, 2019 @02:24PM (#20185367)
Julia (as a "scripting" language for scientific purposes) also supports them natively, but defaults to normal int/float for performance reasons, which might create some gotchas for people who use the language but are not programmers.

https://docs.julialang.org/en/v1/manual/integers-and-floatin...

If I remember correctly, Elixir uses arbitrary precision integers by default, though I'm not sure about float.

Re:Common Lisp: Numbers by threwawasy1228 on Friday June 14, 2019 @12:13PM (#20184149)
I think Haskell allows for arbitrary-precision with the Integer type. It is limited only by the available memory in the machine.
Re:Common Lisp: Numbers by divs1210 on Friday June 14, 2019 @12:27PM (#20184264)
Even though the term 'scripting language' is very loosely defined, I don't think Haskell qualifies as one.
Re:Common Lisp: Numbers by ky3 on Friday June 14, 2019 @12:37PM (#20184340)
Haskell has shell hash-bang scripting capabilities just like Python and Ruby do. See

https://stackoverflow.com/questions/8676331/how-to-run-a-has...

Re:Common Lisp: Numbers by kazinator on Friday June 14, 2019 @01:16PM (#20184682)
Re:Common Lisp: Numbers by ky3 on Friday June 14, 2019 @02:33PM (#20185438)
True, but the difference between C and Haskell hash-bangs is that GHC Haskell provides an interpreter.

GCC hash-bang is still an edit-compile-link-debug cycle. Just like with Python and Ruby, Haskell hash-bang accelerates the cycle by jettisoning the compile and linking steps.

Re:Common Lisp: Numbers by kazinator on Friday June 14, 2019 @02:43PM (#20185532)
The Rosetta examples show a solution that only compiles the C file if it has not been previously compiled, or if it has a newer modification timestamp than the executable.
Re:Common Lisp: Numbers by ky3 on Friday June 14, 2019 @02:58PM (#20185699)
Doesn't the (necessarily loose) coupling of executables with source files create its own challenges? Or does it track the object file too, in which case we have 3 files, not 1, to manage simultaneously?

The benefit of scripts is that each file is a self-contained single source of truth.

Re:Common Lisp: Numbers by kazinator on Friday June 14, 2019 @03:04PM (#20185741)
In the case of one .c file, there doesn't have to be an object file; you can go straight to executable "cc prog.c -o prog".

Python implements a caching scheme for .pyc files; maybe it's not a scripting language ...

If I were to venture an opinion on why C (in its usual implementations) is not a scripting language it would be:

- no interactive prompt (REPL).

- no reloading of code (other than clumsy, fragile, platform-specific shared lib mechanisms).

- no execution of "top level forms": a program's entry point is a specific function (main on hosted implementations). When, e.g., Lisp code is compiled, the effect of loading the compiled file is still the same as of the source file: the top-level forms (now in a compiled form) are executed one by one. (What's a "script"? A file with instructions to be run one by one.)

- no late binding; in fact, no program at all, unless all external references are satisfied. Scripting languages can run code that contains references to unknown global variables, or calls to unknown functions. These can be loaded late.

Re:Common Lisp: Numbers by TeMPOraL on Friday June 14, 2019 @05:44PM (#20186900)
> When, e.g., Lisp code is compiled, the effect of loading the compiled file is still the same as of the source file: the top-level forms (now in a compiled form) are executed one by one. (What's a "script"? A file with instructions to be run one by one.)

Fun fact: the SBCL implementation of Common Lisp actually adds a shebang to its compiled, binary Lisp files, so you can compile your Lisp script and then execute it from the shell.

Re:Common Lisp: Numbers by kazinator on Friday June 14, 2019 @07:57PM (#20187625)
My TXR Lisp adds a shebang to the compiled file, if the source file has one.

  $ cat > foo.tl
  #!/usr/bin/txr
  (pprinl "hello")
  $ txr -e '(compile-file "foo")'
  hello
  $ cat foo.tlo
  #!/usr/bin/txr
  (5 0 nil)
  ((2 3 #b'0200012400000004 02000010' #("hello") #(usr:pprinl)))
If the source file doesn't have a hash bang line, the one isn't output.

You'd think SBCL wouldn't need this sort of thing since it compiles to native code?

Re:Common Lisp: Numbers by kazinator on Saturday June 15, 2019 @01:37AM (#20188535)
I just improved this tonight. If the original program is unsuffixed, and so its hash bang line uses the --lisp option to say "treat this as Lisp source" that option is translated to --compiled, so that if the compiled file is also unsuffixed, it will be properly treated as compiled.
Re:Common Lisp: Numbers by m4r35n357 on Friday June 14, 2019 @11:40AM (#20183863)
For MP work in Python, gmpy2 - https://pypi.org/project/gmpy2/ comes with a much better selection of MP functions, backed by MPFR, MPC.

Also, the buit-in Decimal class is horribly slow by comparison to gmpy2.

Re:Common Lisp: Numbers by baruchel on Friday June 14, 2019 @01:02PM (#20184536)
Purpose of the Decimal module is not really arbitrary precision computation but rather exact computation on decimal numbers wherever it matters (financial arithmetic, etc.). This module should never be used for scientific purposes.
Re:Common Lisp: Numbers by fdej on Friday June 14, 2019 @12:32PM (#20184299)
Also (shameless self-promotion) python-flint! http://fredrikj.net/python-flint/
Re:Common Lisp: Numbers by nikofeyn on Friday June 14, 2019 @01:54PM (#20185064)
> Python and Ruby are probably the only popular ones that ship by default with unlimited precision integers.

racket has exact numbers of unlimited size.

https://docs.racket-lang.org/reference/numbers.html

Re:Common Lisp: Numbers by 292355744930110 on Friday June 14, 2019 @11:41AM (#20183873)
In Go "Numeric constants represent exact values of arbitrary precision"

https://golang.org/ref/spec#Constants

Re:Common Lisp: Numbers by divs1210 on Friday June 14, 2019 @12:29PM (#20184279)
I don't think Go qualifies as a 'scripting language', even though the term is very loosely defined.
Re:Common Lisp: Numbers by 292355744930110 on Friday June 14, 2019 @01:07PM (#20184600)
I missed the part about scripting languages. Is LISP a scripting language?
Re:Common Lisp: Numbers by kazinator on Friday June 14, 2019 @02:26PM (#20185384)
Yes.

1. Most Lisp dialects, including Scheme and ANSI Lisp, have interactive modes for evaluating expressions.

2. Most Lisp dialects have a mode of processing files in the same manner: reading individual forms and evaluating them immediately. I.e. it is not necessary to translate files into objects that have to be linked to produce an executable program.

Re:Common Lisp: Numbers by munificent on Friday June 14, 2019 @12:33PM (#20184306)
This is only true for values calculated at compile time. Once the result is stored in a variable it is converted to a fixed-size representation. All runtime calculations and results are fixed size.
Re:Common Lisp: Numbers by hajile on Friday June 14, 2019 @03:11PM (#20185807)
BigInt works in Firefox, Chrome, Opera, and upcoming Edge at the moment. Safari preview also has at least partial support.