473,748 Members | 6,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prothon gets Major Facelift in Vers 0.1.0 [Prothon]

There is a new release of Prothon that I think is worth mentioning here.
Prothon version 0.1.0 has changed almost beyond recognition compared to what
was discussed here before. For example: the "Perl-like" symbols are gone
and the "self" keyword is back, replacing the period. Prothon has gotten
more "python-like", simpler, and more powerful, all at the same time.

There is a new tutorial that covers Prothon completely without assuming any
knowledge of Python or any other language. The Prothon/Python differences
page now has links to the relevant section of this tutorial.
See http://prothon.org.

Some of these differences are:

Locals and globals are gone and replaced by a simple scheme that allows you
to access any local or external variable from inside a block or function
scope by name. You may also modify any existing variable outside of the
current scope by simply prepending "outer" to the variable name as in
"outer.x = 1". You can even do this "outer access" when the variable is in
a function that has quit running, giving you "closures" with no need for a
special syntax.

There is a new powerful self-binding method syntax that gives you the
ability to explicitly specify the "self" to bind to a function call with
"obj.func{self} (args)". This allows the full power of message-passing to be
used without compromising the simplicity of function calling. This powerful
and general scheme also solves the problem of calling methods when there is
no such thing as a class to define what a method is. Intelligent defaults
for {self} allow most method calls to be the intuiitive and simple form
obj.call().

The "with" keyword now just creates a new local scope instead of another
"self" which was so confusing before. So "self" is now the simple meaning
of the instance object inside a method as it is in Python.

There is a new "object" keyword which works almost identically to the
"class" keyword, yet also works as a general object creation and
initialization statement. It combines object creation and the "with"
statement.
Jul 18 '05 #1
25 1839
One thing that might attract me from Python to Prothon is if it had
proper private medthods - i.e. not just name mangling like __myDef
which can be overridden using _myClass__myDef (as the interpreter
does).

Proper encapsulation is needed before the C++ brigade will take
P[y/ro]thon seriously as an OO language, oh and a machinecode compiler
;-)
Jul 18 '05 #2
simo wrote:
One thing that might attract me from Python to Prothon is if it had
proper private medthods - i.e. not just name mangling like __myDef
which can be overridden using _myClass__myDef (as the interpreter
does).

Proper encapsulation is needed before the C++ brigade will take
P[y/ro]thon seriously as an OO language, oh and a machinecode compiler
;-)

PROthon should implement {...} as optional block-beg and end marks.

# Original PROthon code (uses indentation)
def abc(_x):
if _x ...:
do_1()
do_2()
do_3()
Could become

#!/usr/bin/pROthon
#pragma(C_STYLE _BLOCK=1) # <- Valid within this file/module scope

def abc(_x):
{
if _x ...:
{
do_1()
do_2()
}
do_3()
}

----------------------------------------

The lack of "class" type and direct creation and use of objects is very
handy for "Prototype-based Programming" (that's PROthon)

Who said OO-programming must have a class type ?

// moma
http:/www.futuredeskt op.org
Jul 18 '05 #3
On Sun, 2004-05-23 at 21:46 +0000, Neil Hodgson wrote:
gabor:
hmmm...i understand that you can cast away const,
but what about...

class C
{
private x;
};
Technique 1:

class D {
public:
int x;
};

C c;
(reinterpret_ca st<D*>(&c))->x = 1;

Technique 2:

#define private public
#include <C_definition.h >
#undef private

C c;
c.x = 1;

thanks...very interesting.
In both of these it is obvious that the encapsulation rules are being
broken which is exactly the same situation as when someone uses the mangled
name in Python. I have used technique 2 in production code where a library
could not be altered and access to private methods was required.


look...i am not asking for a way in python to COMPLETELY RESTRICT the
access to a variable... i hint is enough... now...if i know correctly
that means that i have to prefix my wanto-to-be-private variables with a
"_"... that restriction would be enough for me. my problem is with the
syntax. i HATE anything that even remotely resembles perl/hungarian
notation. why cannot i do it somehow as we create static-methods ....

class C:
def __init__(self):
self.lenght = 5
self.lenght =private(self.l ength)

or something like it.

the point is:
i only want to WRITE that the variable is private once...
i don't want to deal with _prefixed variables in my whole code...

this is imho of course

gabor
Jul 18 '05 #4
On Sun, 2004-05-23 at 15:04 -0700, Mark Hahn wrote:
Does any Python user have a story of regret of using an object's attribute
when they should not have and encapsulation would have saved their butts?


not exactly...

i don't need restriction, only a hint...

if i look thru some java code, i immediately see what variables/methods
should/can i access... it's not the same for python...

for example at work where i use java, there are classes that have
10-15methods, but only 4public ones... it immediately gets simplier to
understand/use the class
gabor
Jul 18 '05 #5
Ryan Paul wrote:
On Sat, 22 May 2004 22:53:01 -0700, simo wrote:

(snip)
Proper encapsulation is needed before the C++ brigade will take
P[y/ro]thon seriously as an OO language, oh and a machinecode compiler
;-)


(snip)
I dont understand why everybody seems to want a machinecode compiler. It
wont make a high-level, dynamically typed language run any faster.
Err... You might want to check some Common Lisp implementations .
--SegPhault

Note that here it should read 'sigfault' !-)

Bruno

Jul 18 '05 #6
>>>>> "Ryan" == Ryan Paul <se*******@sbcg lobal.net> writes:

Ryan> check out ruby. It is very similar to python, but one of the
Ryan> many benefits it has over python, is ability to distinguish
Ryan> 'real' private, public, and protected
Ryan> variables/methods. Ruby does not allow multiple inheritance,
Ryan> and

Python has private methods too:

class C:
def stuff(self):
_privatestuff(s elf,2)
print "val is",self.val

def _privatestuff(s elf, arg):
self.val = arg

Though I would expect the people that read/use my code to understand
that if I prepended a _ on attribute name, they would have the brain
to not use it as a part of the "official" API. If they absolutely need
to use something private (it happens - world has seen several badly
designed APIs), they can. At least they don't need to resort to
various horrible hacks to do it.

I tend to think that emphasizing private/protected access restrictions
is an artifact of not understanding modern programming realities and
dynamics properly. School teaches access labels as an essential
feature of OO (encapsulation) , and it takes some real world experience
implementing something of lasting value *fast* to unlearn it.

Ryan> it supports a very powerful mixin system- it's OO mechanisms
Ryan> and syntax generally seem better than pythons.

Not to mention that it's much closer to Smalltalk. And it's much
better than Perl too. Python OO is a hack! It's an add-on, not
built-in like in Ruby!

etc, ad infinitum.

Inter-newsgroup advocacy efforts are rather pointless and mostly serve
to create yet more flamewars. Ruby and Python are within the same 10%
productivity-wise (which one is winning depends on the programmer),
but Python is massively more mature and popular (e.g. going to be
shipping with Nokia S60 smartphones RSN hopefully [1]). You do the
math.

[1] http://www.guardian.co.uk/online/sto...182803,00.html

Ryan> I dont understand why everybody seems to want a machinecode
Ryan> compiler. It wont make a high-level, dynamically typed
Ryan> language run any faster.

It could make the language run much faster.

--
Ville Vainio http://tinyurl.com/2prnb
Jul 18 '05 #7

"gabor" <ga***@z10n.net > wrote
Does any Python user have a story of regret of using an object's attribute when they should not have and encapsulation would have saved their
butts?
not exactly...

i don't need restriction, only a hint...

if i look thru some java code, i immediately see what variables/methods
should/can i access... it's not the same for python...

for example at work where i use java, there are classes that have
10-15methods, but only 4public ones... it immediately gets simplier to
understand/use the class


I sounds to me like you want a better documentation solution, not an
encapsulation solution. Now that is something I agree with 100% and have
near the top of the list in Prothon. I personally think docs are a weak
point in Python.
Jul 18 '05 #8
On Mon, 2004-05-24 at 18:10, Mark Hahn wrote:
"gabor" <ga***@z10n.net > wrote
Does any Python user have a story of regret of using an object's attribute when they should not have and encapsulation would have saved their

butts?

not exactly...

i don't need restriction, only a hint...

if i look thru some java code, i immediately see what variables/methods
should/can i access... it's not the same for python...

for example at work where i use java, there are classes that have
10-15methods, but only 4public ones... it immediately gets simplier to
understand/use the class


I sounds to me like you want a better documentation solution, not an
encapsulation solution. Now that is something I agree with 100% and have
near the top of the list in Prothon. I personally think docs are a weak
point in Python.


documentation is fine.... the more the better...

but the argument that
more-docs-should-be-enough-because-you-can-document-which-functions-are-private
reminds me a little of the
but-you-can-write-object-oriented-code-in-assembler....

or that you-can-write-object-oriented-code-in-c...

yes, you can implement the needed mechanism in every language, but it's
not always fun....
:)

gabor
Jul 18 '05 #9

"gabor" <ga***@z10n.net > wrote
yes, you can implement the needed mechanism in every language, but it's
not always fun....


We'll just have to make sure it's fun in Prothon. Maybe you'll have to
elaborate a little more on what you think is fun encapsulation documentation
and what isn't.

I myself think that putting underbars in front of every var like _var is not
fun. Do you agree?

I also don't think declaring all vars as in "private var" is fun either, do
you? If I did, I'd be using C++.

So to me, documenting the public vars makes the most sense. They need some
explaining anyway. So now the only question is, what is a fun and painless
way to document public vars. It would be nice if it had these properties:

1) There should be some reward or lack of punishment for actually doing the
documentation. I was thinking that Prothon could have some cool doc tool
that programmers would want to use that would choke and refuse to finish
without proper doc definitions. Maybe the interpreter itself could even
give warnings.

2) The doc syntax should be painless, friendly, and intelligent enough so
human-added stuff is minimal.

Any ideas in this area would be greatly welcomed. Implementing a half-baked
scheme would be as good as no scheme because it wouldn't be used.
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1400
by: Mark Hahn | last post by:
I would like to announce a new interpreted object-oriented language very closely based on Python, that is Prototype-based, like Self (http://research.sun.com/research/self/language.html) instead of class-based like Python. I have named the language Prothon, short for PROtotype pyTHON. You can check it out at http://prothon.org. The prototype scheme makes object oriented computing very simple and complicated things like meta-classes...
0
1311
by: Mark Hahn | last post by:
Ben Collins and I have developed a new interpreted object-oriented language very closely based on Python, that is Prototype-based, like Self (http://research.sun.com/research/self/language.html) instead of class-based like Python. I have named the language Prothon, short for PROtotype pyTHON. You can check it out at http://prothon.org. The prototype scheme makes object oriented computing very simple and complicated things like...
145
6338
by: David MacQuigg | last post by:
Playing with Prothon today, I am fascinated by the idea of eliminating classes in Python. I'm trying to figure out what fundamental benefit there is to having classes. Is all this complexity unecessary? Here is an example of a Python class with all three types of methods (instance, static, and class methods). # Example from Ch.23, p.381-2 of Learning Python, 2nd ed. class Multi:
27
2011
by: Michele Simionato | last post by:
> Hello, my name is Skip and I am metaclass-unaware. I've been programming in > Python for about ten years and I have yet to write a metaclass. At first I > thought it was just that metaclasses were new to the language, but now as > more and more people use them and proclaim their widespread benefits, I have > come to realize that through years of abuse my brain has become addicted to > classic classes. I began using Python since...
21
1875
by: Mark Hahn | last post by:
We're proud to say that Prothon has grown out of the indent space/tab flame war stage and has moved on to more serious discussions. We've decided to allow space-based indents and tab-based indents but not in the same file. We are also adding some improvements in the area of line continuations (see the algorithm at the end of the message). Since there were zillions of messages here on c.l.py about spaces vs. tabs and Guido has said he...
28
3302
by: David MacQuigg | last post by:
I'm concerned that with all the focus on obj$func binding, &closures, and other not-so-pretty details of Prothon, that we are missing what is really good - the simplification of classes. There are a number of aspects to this simplification, but for me the unification of methods and functions is the biggest benefit. All methods look like functions (which students already understand). Prototypes (classes) look like modules. This will...
22
2237
by: Paul Prescod | last post by:
I think that in this case, Python is demonstrably better than Prothon. C:\temp\prothon\Prothon>python ActivePython 2.3.2 Build 232 (ActiveState Corp.) based on Python 2.3.2 (#49, Nov 13 2003, 10:34:54) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print 2**65 36893488147419103232
49
2621
by: Mark Hahn | last post by:
As we are addressing the "warts" in Python to be fixed in Prothon, we have come upon the mutable default parameter problem. For those unfamiliar with the problem, it can be seen in this Prothon code sample where newbies expect the two function calls below to both print : def f( list= ): print list.append!(1) f() # prints
20
1808
by: Mark Hahn | last post by:
Prothon is pleased to announce another major release of the language, version 0.1.2, build 710 at http://prothon.org. This release adds many new features and demonstrates the level of maturity that Prothon has reached. The next release after this one in approximately a month will be the first release to incorporate the final set of frozen Prothon 1.0 language features and will be the Alpha release. You can see the set of features still...
0
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.