Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: What will scientific computing in Perl 6 look like?

by moritz (Cardinal)
on Jul 14, 2008 at 11:52 UTC ( #697451=note: print w/replies, xml ) Need Help??

in reply to What will scientific computing in Perl 6 look like?

First of all there's currently a Google Summer of Code project in the run that implements a simple to use NCI (native call interface), to make it easier to call C functions from parrot.

Secondly please remember that Perl 6 is designed for the utmost amount of flexibility, so it's very easy to have a nice syntax for new features, like natural arithmetic operators for vector and matrix operations.

Perl 6 comes with low-level data types (like int32 and uint32) and arrays with pre-defined shapes (see S09 for more details, there's also a section on PDL support. In conjunction with the optional static type declaration there's no reason why native Perl 6 number crunching should be any slower than C.

So to summarize, from the specification point of view the future looks very bright. But currently speed isn't the primary concern, so I don't expect the first versions of Perl 6 to be very fast.

But there's much more room for optimization for Perl 6 than for Perl 5 - on the language level as well as on the VM level (for one thing parrot does JIT already, perl 5 doesn't, and is not likely to do in near future).


A few more thoughts on concurrency: Perl 6 avoids some pitfalls that made concurrency rather hard in Perl 5, like the huge number of global variables. Stuff that was global in Perl 5 (like $_, $!, $1, $2, ...) is now mostly solved with contextual variables (lexically scoped variables that may change their value in an outer block), and the language design was done from ground off with concurrency in mind (or at least in the back of TimToady's mind).

Implementations are free (and encouraged) to autothread meta operators, so this:

my @a1 = 1, 2, 3, 4, 5; my @a2 = 9, 8, 7, 6, 5; my @item_wise_sum = @a1 >>+<< @a2; my $sum = [+] @item_wise_sum;

is likely to happen in parallel without the programmer even noticing.

By the way complex numbers are natively supported in Perl 6.

So I think that both in terms of speed and syntax Perl 6 will be an improvement over Perl 5 (in the realm of sci. computing at least; don't want to start the overall discussion again), but it still needs much work to get there.

Replies are listed 'Best First'.
Re^2: What will scientific computing in Perl 6 look like?
by jettero (Monsignor) on Jul 14, 2008 at 12:14 UTC

    By the way complex numbers are natively supported in Perl 6.

    Can you construct arbitrary vector spaces (e.g., the quadratics) or are the complex numbers a special case?

    UPDATE: I think abstract algebra starts at the undergrad level. Also, wow, perl6 is like a whole new language.


      Complex numbers are special cased, in that they are explicitly specced. While numerics aren't a weak spot in Perl 6, they aren't exactly the most powerful area either (Larry keeps telling us on #perl6 that he doesn't do higher mathematics ;-)

      But it's quite easy to define your own data types and the associated operations:

      # suppose you inherit from List to implement your vector: class MyVector is List { sub infix:<+>(MyVector @self, MyVector @other) is export { return @self + @other; } # adding a scalar: sub infix:<+>(MyVector @self, Num $other) is export { return @self + $other } }

      No more hassle of overloading literal constants in the source, since multi method dispatch takes care of it all.

        I simply don't believe that multi method dispatch takes care of it all when it comes to different number systems. While Perl 6 offers a lot of features, to the best of my knowledge The Structure of Computer Programming is still correct when it says "Developing a useful, general framework for expressing the relations among different types of entities (what philosophers call ``ontology'') seems intractably difficult. The main difference between the confusion that existed ten years ago and the confusion that exists now is that now a variety of inadequate ontological theories have been embodied in a plethora of correspondingly inadequate programming languages. For example, much of the complexity of object-oriented programming languages -- and the subtle and confusing differences among contemporary object-oriented languages -- centers on the treatment of generic operations on interrelated types."

        That is not to say that Perl 6 is not an improvement. It is. It just isn't a solution.

        Don't you need to use the multi keyword on those subs?
      Can you construct arbitrary vector spaces (e.g., the quadratics) or are the complex numbers a special case?

      I personally believe that this is slightly nonsense, since vector spaces are "simply" vector spaces, while the complex numbers can be described in a variety of different algebraic structures: they're a field, a two dimensional real algebra, a one dimensional complex algebra, etc. Now, I'm sure that binary field operations will be supported for complex numbers: thus whether arbitrary vector spaces will be supported or not, it won't be a matter of "special case."

      If you can't understand the incipit, then please check the IPB Campaign.
        It isn't nonsense at all. Subspaces, fields, and vector spaces are all interrelated. The complex numbers are a vector space and the quadratics are a subspace of them. I was hoping that instead of just complex numbers, you could use the special type for all sorts of vector math, tensors, quadratics, values with units attached. Why make complex numbers the special case? Why not have two tuples or n-tuples that know about co-efficients so you can do all kinds of interesting algebra in the same way you can use complex numbers.

        All you have to do to make this really really flexible is allow users to change the value of that sqrt(-1) co-efficient(s) and change the length of the vector/sum/value. Tada.

        UPDATE: Yes, well, I believe the quadratics are a 2-dimensional vector space and a field of reals. It happens to be a subspace of the complexes, so maybe it doesn't matter, but I fail to see why there couldn't be an interface to use the complex number system for more.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://697451]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2017-02-24 23:05 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (364 votes). Check out past polls.