Fortran (Was: The "does Python have variables?" debate)
Mark H Harris
harrismh777 at gmail.com
Sun May 11 14:54:31 EDT 2014
On 5/11/14 12:05 PM, Alain Ketterlin wrote:
>> Julia is Matlab and R, Python, Lisp, Scheme; all rolled together on
>> steroids. Its amazing as a dynamic language, and its fast, like
>> lightning fast as well as multiprocessing (parallel processing) at its
>> core. Its astounding, really.
>
> Hmmm...
>
>> Its number concept is unified,
>
> What exactly is unified? There is no implicit promotion between
> primitive types and BigInt/Float.
The built-in math functions (extensive, by the way) just work, and they
work consistently the way you might expect across types. Consider sqrt():
> julia> sqrt(-1+0im)
> 0.0 + 1.0im
> julia> sqrt(complex(-1))
> 0.0 + 1.0im
> julia> sqrt(2)
> 1.4142135623730951
>julia> sqrt(2.0)
> 1.4142135623730951
> julia> sqrt(BigFloat(2.0))
>1.414213562373095048801688724209698078569671875376948073176679737990732478462102
>e+00 with 256 bits of precision
>julia> with_bigfloat_precision(1024) do
> sqrt(BigFloat(2.0))
> end
>1.414213562373095048801688724209698078569671875376948073176679737990732478462107
>03885038753432764157273501384623091229702492483605585073721264412149709993583141
>32226659275055927557999505011527820605714701095599716059702745345968620147285174
>18640889198609552329230484308714321450839762603627995251407989687253402e+00 >with 1024 bits of precision
You'll notice that I did not need to import anything to use sqrt(), and
sqrt() takes all types and does something meaningful with them.
The following code will produce over 100,000 digits of π (pi) in less
than 2 seconds on a low-end processor, like my mac mini dual core 2Ghz:
>julia> prec=524288
>524288
>julia> with_bigfloat_precision(prec) do
> println(atan(BigFloat(1)/5)*16 - atan(BigFloat(1)/239)*4)
> end
The scientific and transcendental functions (built-ins) just work. The
coder sets the precision in floating point bits, and the functions just
work --- at that precision. Nothing needs to be imported, and special
functions are not necessary. The maths are unified, and they are fast;
yet, the coder has the flexibility and ease of python coding, with a
very useful repl.
But, like lisp, Julia's internal structures are lists, so, it can create
and modify its own code on-the-fly. Unicode characters above code point
\u00A0 can be used as symbols, and constants ARE their unicode characters:
>julia> sin(π/4)
> 0.7071067811865475
>julia> cos(π/4)
> 0.7071067811865476
>julia> sin(BigFloat(π/4))
> 7.0710678118654750275194295621751674626154323953749278952436611913748
> 20215180412e-01 with 256 bits of precision
marcus
More information about the Python-list
mailing list