Slashdot Mirror


Prothon - A New Prototype-based Language

Ben Collins writes "Prothon is a new industrial-strength, interpreted, prototype-based, object-oriented language that gets rid of classes altogether in the way that the Self language does. It uses the sensible, practical syntax and add-on C module scheme from Python. This major prototype improvement over Python plus many other general improvements make for a clean new revolutionary breakthrough in language development. Prothon is simple to use and yet offers the combined power of Python and Self. Check out the first public pre-alpha release at prothon.org."

9 of 630 comments (clear)

  1. Karma Whoring by froody · · Score: 3, Informative

    Prothon Description:
    This document assumes a working knowledge of Python. Many features are described as differences to Python features. If you are new to Python, a good starting point can be found at www.python.org.

    Comments

    Standard Python comments using the # character work exactly the same in Prothon. Prothon also supports the C comment format of /* and */. This is useful for temporarily blocking out large blocks of code and inserting inline comments.

    # this line is a comment
    x=5 # this is a trailing comment
    if not rlst /*no response*/ or is_too_long:

    Indentation is Tab-Only

    Like Python, Prothon uses indentation to control the block structure of the program instead of block/end or {}. However, Prothon only allows tabs for indentation. Any space in an indent will cause an error. This allows each programmer to set the editor to show the tab width to whatever he pleases and the Python problems of mixed spaces and tabs cannot happen in Prothon. It also allows for minimum typing.

    Line Continuation

    A line can be continued by placing a backslash ( \ ) as the last character of a line as in Python. Also, any tab indent of more than one level deeper than the previous indent level will cause the line to be considered a continuation of the previous line, which is a new feature to Prothon. The automatic continuation of lines in comma separated lists found in Python is not allowed in Prothon because of parsing differences, but usually the auto-continuation from indents alleviates the need for this.

    Note that you can put spaces after tabs when in an auto-continuation. This allows you to line up the continued line for appearance.

    x = 1 + 2 + 3 + 4 + \
    5 + 6 + 7 + 8 + 9 # backslash continuation

    s = "this is a normal line \
    this is a continuation" # backslash works in quotes

    y = long_function_name() +
    another_function_name() # extra indent continuation

    z = function_name(variable_name_1, # this is legal in Prothon because
    variable_name_2) # of extra indents, not commas

    Variable Names and Scope (No more "self variable")

    The syntax for a variable name (label) is the same as Python except that one exclamation mark is allowed at the end and only at the end. This usage should be reserved for functions that modify the object's content in place. This allows a function such as list.sort!() to return the modified list, which was not allowed in Python. One should ALWAYS use this naming convention for in-place modification functions to warn programmers.

    Prothon has a very different concept of self than Python. Any and every object can be "self", whether the code is in a function or not. So the Python tradition of using the variable named "self" does not fit in Prothon. The next section shows how an object becomes the "self". For now just imagine that somehow there is always one special "self" object at any one time.

    Prothon code needs a way to differentiate between local variables, attributes in the self our code is running on, and global variables (in Prothon, globals are attributes of the module running our code). Prothon is introducing a relatively new concept in order to make it very easy to know which of these three types of variable you are referring to. This is the use of character case. Just as Python pioneered the use of white-space (indentation) to control syntax, Prothon is using case to control syntax.

    Local variables always start with a lower-case letter or underbar ( _ ). Global variables always start with an upper-case letter. Attributes in the self object are prefixed by a period ( . ), but the name of the attribute itself can start with any case.

    def .get_hdr(text): # define func "get_hdr" as attribute of self .text = text # attribute "text" loaded from local "text" .hdr = Mime

  2. text of website Prothon by Anonymous Coward · · Score: 3, Informative

    Why a new language?

    Python is a interpreted language with object-oriented features that is practical, powerful, and fun to program at the same time. Over time capabilities have been added to the core Python language, while compatibility with earlier versions has been maintained, and Python has became loaded with features, some quite complex. The metaclass is an example of a recent feature addition. Even Python experts admit that metaclasses are brain-achingly complex.

    Prothon is a fresh new language that gets rid of classes altogether in the same way that Self does and regains the original practical and fun sensibility of Python. This major improvement plus many minor ones make for a clean new revolutionary break in language development. Prothon is quite simple and yet offers the power of Python and Self.

    Prothon is also an industrial-strength alternative to Python and Self. Prothon uses native threads and a 64-bit architecture to maximize performance in applications such as multiple-cpu hosting.
    What is Prothon like?

    See a quick description of the Prothon language.

    Take a look under the hood at how Prothon is implemented.

    Summary of differences from Python.
    Development status?

    As of 3/04 Prothon exists as a pre-alpha interpreter with minimum capabilites, just enough to try out the language.

    Summary of currently implemented functions. Known problems.

    Tested platforms: i386-linux, , sparc-linux, sparc64-linux, i386-Win2K, i386-XP, Dual-Opteron-Win2K

    Target Schedule:

    7/04: Freeze core language specs (keywords, etc.)

    10/04: Release version 0.1
    Download

    Stable (build 115) Source tarball (175 KB)

    Stable (build 115) Windows executable zip file (400 KB)

    Latest (probably broken) SVN access: svn://svn.prothon.org/prothon/trunk

    Latest source view and tarball: http://www.prothon.org/viewcvs/trunk
    How can I contribute?

    (Mailing list)

    For now, the biggest contribution you can make would be adding to the discussion of 0.1 features. Please join the mailing list. Of course helping with the coding effort is always welcome.
    Credits

    Language design & win32 coding: Mark Hahn

    Linux/Unix coding: Ben Collins

  3. Re:Bondage by Just+Some+Guy · · Score: 4, Informative
    I can think of two good reasons:
    1. If you're using indentation for structure, then it's horribly confusing to allow both tabs and spaces. How many spaces is a tab worth? You could add a "tabsize=" variable to the core language, but you have to be able to parse a file before you can start evaluating it, so that would necessarily have to be an ugly hack.
    2. An (old) Python topic-of-heated-discussion was the relative merit of tabs vs. spaces. Setting one as the standard avoids the whole issue and lets everyone get back to work.
    My only gripe is that out of the two choices, they picked the wrong one <ducks>.
    --
    Dewey, what part of this looks like authorities should be involved?
  4. Like school in the summer time by Sloppy · · Score: 4, Informative

    Found a little example code inside the tarball, that shows what they mean by no classes:

    Emp_proto = Object()

    with Emp_proto: .name = ""

    def .__init__(name): .name = name .hello()
    return .

    def .hello():
    print "My name is:", .name

    Emp_proto.hello()
    emp = Emp_proto("Jim")
    emp.hello()

    --
    As copyright owner of this comment, I authorize everyone to defeat any technological measure which limits access to it.
  5. Re:Here we go.... by icklemichael · · Score: 3, Informative

    implementing classes, the OOP approach

    The OOP approach isn't limited to the class based languages. Class based languages have traditionally been more popular. The only recent mainstream prototype based language I can think of is javascript.

    Saying one is better than the other is only ever likely to generate an argument, they're just different.

    Have a look here for the classic paper on the prototype based approach.

  6. Re:Because SQL works by AndyElf · · Score: 3, Informative

    You can use regexp's if you use Postgres.

    --

    --AP
  7. Re:YANISL: Just What We Needed by Hater's+Leaving,+The · · Score: 4, Informative

    Not improved - just as bad:

    "Like Python, Prothon uses indentation ..."

    Oh joy.

    THL.

    --
    Keeping /. cynic density high since the fscking Kwhores/trolls arrived.
  8. A plea to all up-and-coming language designers by alispguru · · Score: 4, Informative
    Before you go off and try to code up the Next Big Thing, please do all of us a favor and learn a little bit about Lisp.

    Don't learn about it from your officemate, or your college instructor, especially if they say they haven't used it in over ten years. You wouldn't believe the opinions of someone who learned C from K&R without upgrading their knowledge, would you?

    Instead, start from places like the ALU web site or Cliki or Paul Graham's Lisp FAQ.

    If you do this right, you will learn that computer languages:

    are not inherently fast or slow - implementations are fast or slow, not languages

    can be both dynamic and have good performance

    can be cross-platform without swallowing POSIX whole

    can have multiple inheritance without damaging your brain

    can be object-oriented without being object-obsessed

    If you like, you can quit as soon as you understand how static scoping and closures work - at least that way you will avoid the primary mistake in pretty much every recent scripting language.

    There is a small risk you will become a SmugLispWeenie by doing this, so be forwarned.

    --

    To a Lisp hacker, XML is S-expressions in drag.
  9. There's another name for Prothon: Python by Lulu+of+the+Lotus-Ea · · Score: 4, Informative

    We already have perfectly good prototype-based programming in Python. Do a search for "metaclass programming in python" for links to my articles on this topic. You can do -everything- with Python metaclasses (which isn't to say you -should-).

    But actually, prototype programming is even simpler:

    new = old.__class__(init, args, here)

    Just what 'old' is is determined at runtime. And if you like, you can poke around at 'obj.__bases__' to futz with inheritence.

    Not having read my _Charming Python_ articles isn't really a sufficient reason to create a new programming language.