World Library  
Flag as Inappropriate
Email this Article
 

ParaSail (programming language)

ParaSail
Paradigm(s) compiled, concurrent, imperative, structured, object-oriented
Designed by S. Tucker Taft
Developer AdaCore
Appeared in 2009
Preview release Revision 5.2 of alpha release 0.5 / 19 February 2014 (2014-02-19)
Typing discipline strong, static
Major implementations pslc
Influenced by Modula, Ada, Pascal, ML
OS Linux, Mac OS X, MS Windows
Filename extension(s) .psi .psl .psn
Website .org.parasail-langwww

ParaSail, Parallel Specification and Implementation Language, is an object-oriented parallel programming language. The design and ongoing implementation of ParaSail is described in a blog and on its official website.

ParaSail uses a pointer-free programming model, where objects can grow and shrink, and value semantics are used for assignment. There is no global garbage collected heap. Region-based storage management is used throughout. Types can be recursive, so long as the recursive components are declared as optional. There are no global variables, no parameter aliasing, and all subexpressions of an expression can be evaluated in parallel. Assertions, preconditions, postconditions, class invariants, etc., are part of the standard syntax, using a Hoare-like notation. Any possible race conditions are detected at compile time.

The initial design of ParaSail was started in September 2009 by S. Tucker Taft.

A prototype implementation of the ParaSail compiler and virtual machine is available. Work stealing is used for scheduling ParaSail's light-weight threads. The latest version can be downloaded from the ParaSail website.

Contents

  • Goals 1
  • Description 2
  • Examples 3
  • 4 Articles
  • External links 5

Goals

ParaSail goals:

  • Pervasive, safe support for implicit and explicit parallelism.
  • Compile-time enforcement of assertions, preconditions, postconditions, and class invariants.
  • Efficient, pointer-free region-based storage management.
  • Familiar class-and-interface-based object-oriented programming model.

Description

The syntax of ParaSail is reminiscent of Modula, but with a class-and-interface-based object-oriented programming model more reminiscent of Java or C#.

More recently the parallel constructs of ParaSail have been adapted for other syntaxes, to produce Java-like, Python-like, and Ada-like parallel languages, dubbed, respectively, Javallel, Parython, and Sparkel (named after the SPARK subset of Ada on which it is based). Compilers and interpreters for these languages are included with the ParaSail implementation (see http://www.parasail-lang.org).

Examples

The following is a Hello world program in ParaSail:

func Hello_World(var IO) is
    IO.Println("Hello, World");
end func Hello_World;

The following is an interface to a basic map module:

interface BMap; Element_Type is Assignable<>> is
    op "[]"() -> BMap;  // Create an empty map

    func Insert(var BMap; Key : Key_Type; Value : Element_Type);
    func Find(BMap; Key : Key_Type) -> optional Element_Type;
    func Delete(var BMap; Key : Key_Type);
    func Count(BMap) -> Univ_Integer;
end interface BMap;

Here is a possible implementation of this map module, using a binary tree:

class BMap is
    interface Binary_Node<> is
      // A simple "concrete" binary node module
        var Left : optional Binary_Node;
        var Right : optional Binary_Node;
        const Key : Key_Type;
        var Value : optional Element_Type;  // null means deleted
    end interface Binary_Node;
    var Tree : optional Binary_Node;
    var Count := 0;
  exports
    op "[]"() -> BMap is  // Create an empty map
        return (Tree => null, Count => 0);
    end op "[]";
    func Insert(var BMap; Key : Key_Type; Value : Element_Type) is
      // Search for Key, overwrite if found, insert new node if not
        for M => BMap.Tree loop
            if M is null then
                // Not already in the map; add it
                M := (Key => Key, Value => Value, Left => null, Right => null);
                BMap.Count += 1;
            else
               case Key =? M.Key of
                 [#less] =>
                   continue loop with M.Left;
                 [#greater] =>
                   continue loop with M.Right;
                 [#equal] =>
                   // Key is already in the map;
                   // bump count if Value was null;
                   if M.Value is null then
                       BMap.Count += 1;
                   end if;
                   // in any case overwrite the Value field
                   M.Value := Value;
                   return;
               end case;
            end if;
        end loop;
    end func Insert;
    func Find(BMap; Key : Key_Type) -> optional Element_Type is
      // Search for Key, return associated Value if present, or null otherwise
        for M => BMap.Tree while M not null loop
            case Key =? M.Key of
              [#less] =>
                continue loop with M.Left;
              [#greater] =>
                continue loop with M.Right;
              [#equal] =>
                // Found it; return the value
                return M.Value;
            end case;
        end loop;
        // Not found in BMap
        return null;
    end func Find;
    func Delete(var BMap; Key : Key_Type) is
      // Search for Key; delete associated node if found
        for M => BMap.Tree while M not null loop
            case Key =? M.Key of
              [#less] =>
                continue loop with M.Left;
              [#greater] =>
                continue loop with M.Right;
              [#equal] =>
                // Found it; if at most one subtree is non-null, overwrite
                // it; otherwise, set its value field to null
                // (to avoid a more complex re-balancing).
                if M.Left is null then
                    // Move right subtree into M
                    M <== M.Right;
                elsif M.Right is null then
                    // Move left subtree into M
                    M <== M.Left;
                else
                    // Cannot immediately reclaim node;
                    // set value field to null instead.
                    M.Value := null;
                end if;
                // Decrement count
                BMap.Count -= 1;
            end case;
        end loop;
        // Not found in the map
    end func Delete;
    func Count(BMap) -> Univ_Integer is
      // Return count of number of items in map
        return BMap.Count;
    end func Count;
end class BMap;

Here is a simple test program for the BMap module:

import PSL::Core::Random;
import BMap;
func Test_BMap(Num : Univ_Integer; Seed : Univ_Integer) is
    // Test the Binary-Tree-based Map
    var Ran : Random := Start(Seed);  // Start a random-number sequence

    // Declare a map from integers to strings
    var M : BMap Univ_Integer, Element_Type => Univ_String>;

    M := [];  // Initialize the map to the empty map

    for I in 1..Num*2 forward loop  // Add elements to the map
        const Key := Next(Ran) mod Num + 1;
        const Val := "Val" | To_String(I);
        Println("About to insert " | Key | " => " | Val);
        Insert(M, Key, Val);
    end loop;
    Println("Count = " | Count(M));

    for I in 1..Num loop // Search for elements in the map
        const Key := Next(Ran) mod Num + 1;
        Println("Looking for " | Key | ", found " | Find(M, Key));
    end loop;

    for I in 1..Num/3 loop  // Delete some elements from the map
        const Key := Next(Ran) mod Num + 1;
        Println("About to delete " | Key);
        Delete(M, Key);
    end loop;
    Println("Count = " | Count(M));

    for I in 1..Num forward loop  // Search again for elements in the map
        Println("Looking for " | I | ", found " | Find(M, I));
    end loop;

end func Test_BMap;

Articles

Articles on ParaSail have appeared in various forums:

  • Graham-Rowe, Duncan (28 July 2011). "New Language for Programming in Parallel". Technology Review (MIT). 
  • Clarke, Peter (28 July 2011). "SofCheck preps ParaSail parallel language". EETimes (UBM Electronics). 
  • Taft, S. Tucker (9 June 2012). "ParaSail: Less is more with multicore". EETimes (UBM Electronics). 
  • Selwood, Dick (18 July 2012). "Does the World Need a New Programming Language?". EEJournal (techfocus media, inc.). 

External links

  • Official website
  • Blog of design and implementation process
  • ParaSail language newsgroup
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 


Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.