English-like Python

T

The Music Guy

Just out of curiousity, have there been any attempts to make a version
of Python that looks like actual English text? I mean, so much of Python
is already based on the English language that it seems like the next
natural step would be to make a programming language which is actually a
spoken one.

For example, the following code...
foo
bar
etc

....might be translated as...
"a path" and does the following:
For every item in the list returned by the operating system's
directory listing of the given path, do the following:
Print the item.foo
bar
etc


Obviously, creating a parser capable of handling such "code" would
require a very good understanding not only of the English language but
also of how ideas expressed in spoken languages are represented in terms
that a computer can understand.

A language like this would, of course, blow a lot of staple coding
coding concepts like "variables," "objects," etc. right out of the
water. I think, however, that it could be done, and wouldn't necessarily
have to be any slower than any other scripting language as any text/code
could be cached as bytecode, just like Python.

I know it's sort of silly but I think something like this would be very
interesting, maybe even useful. ^_^
 
T

Tobias Andersson

The Music Guy skrev:
Just out of curiousity, have there been any attempts to make a version
of Python that looks like actual English text? I mean, so much of Python
is already based on the English language that it seems like the next
natural step would be to make a programming language which is actually a
spoken one.

Take a look at Inform 7. It's not Python but does something
similar to what you are describing:

www.inform-fiction.org

Check out the examples in the tutorial. Some of them are quite
elegant.

HTH /TA
 
A

alex23

Inform 7 has some
interesting ideas, but I think the general problem with English-like
programming language systems is that once you get into the nitty gritty
details, you end up having to know exactly the right things to type,

This has always been my impression of Inform 7. I have a lot of
respect for what they've set out to achieve but English isn't exactly
known for its lack of ambiguity. This is great for literature but not
so helpful for programming.
which ultimately get just as complicated as a more traditional
programming language syntax.

And much more verbose, as well.
 
J

John Roth

This has always been my impression of Inform 7. I have a lot of
respect for what they've set out to achieve but English isn't exactly
known for its lack of ambiguity. This is great for literature but not
so helpful for programming.


And much more verbose, as well.

Since I've used Inform 7 I can say that the syntactic problem isn't
that great: once you get far enough into a project to matter the
specialized constraints just sink in. It's more work to learn, but no
stranger than Python's indentation scheme.

The bigger problem for the comparison is that Inform 7 is a Domain
Specific Language (DSL), not a general purpose language. Not only
that, but the domain is pretty much everyday experience (with a large
dollop of fantasy, of course). All the feedback is that the results
are quite readable to non-programmers. This is why well over half of
the mailing list posts on the authoring mailing list are about Inform
7.

I really don't think that using natural language for a general purpose
programming language is a good idea, for reasons that several other
people have already said. I think it's a great idea for DSLs, at least
in some cases.

The other really major problem is that I don't think anyone really
knows how to process natural language. The direction that natural
language processing has taken in the last 50 years has come up lacking
big-time. It does a good job in a single domain, but try to build
something that crosses domains and nothing works. There isn't a good
alternative in sight

John Roth
 
M

MRAB

[Hit Reply instead of Reply All. Sorry alex23.]
This has always been my impression of Inform 7. I have a lot of
respect for what they've set out to achieve but English isn't exactly
known for its lack of ambiguity. This is great for literature but
not so helpful for programming.


And much more verbose, as well.
I once had to do something in AppleScript. The problem I found was that
it tried so much to resemble English that it wasn't always clear what
was valid!

Programming languages need to look artificial to remind you that the
computers aren't intelligent. Python, for example, is clearly
artificial but with a clear syntax and short (but not too short)
reserved words.
 
S

sturlamolden

I was thinking of this as well when I saw his post. Inform 7 has some
interesting ideas, but I think the general problem with English-like
programming language systems is that once you get into the nitty gritty
details, you end up having to know exactly the right things to type,
which ultimately get just as complicated as a more traditional
programming language syntax. In the big picture I don't think it helps
much. After all, there's a reason that most modern programming
languages don't look like COBOL or AppleScript.

COBOL looks like English to facilitate reading programs, not writing
them. COBOL is for use in places where programs must be read and
verified by possibly computer-illiterate personnel. E.g. in bank and
finance where (at least in some countries) everything must be
supervised and approved by professional accountants. COBOL is still
the dominating language in that domain.
 
A

Aaron Brady

Just out of curiousity, have there been any attempts to make a version
of Python that looks like actual English text? I mean, so much of Python
is already based on the English language that it seems like the next
natural step would be to make a programming language which is actually a
spoken one.

For example, the following code...


foo
bar
etc

...might be translated as...


    "a path" and does the following:
        For every item in the list returned by the operating system's
        directory listing of the given path, do the following:
             Print the item.


foo
bar
etc

Obviously, creating a parser capable of handling such "code" would
require a very good understanding not only of the English language but
also of how ideas expressed in spoken languages are represented in terms
that a computer can understand.

A language like this would, of course, blow a lot of staple coding
coding concepts like "variables," "objects," etc. right out of the
water. I think, however, that it could be done, and wouldn't necessarily
have to be any slower than any other scripting language as any text/code
could be cached as bytecode, just like Python.

I know it's sort of silly but I think something like this would be very
interesting, maybe even useful. ^_^

I'm actually moderately interested in this idea. I was pursuing it a
while back, but didn't find anyone else interested. You want to avoid
requiring an understanding, since English syntax doesn't always
guarantee its semantics. Even a trivial transformation from non-
delimited English can cause an AmbiguityException.

The basics started like this:

'a= open "file1.py"' --> 'a= open( "file1.py" )'

'''
a= nat_list()
append 0 to a
append 1 to a
sort a
'''
-->
'''
a= nat_list()
a.append( 0 )
a.append( 1 )
a.sort()
'''

However, as you can see, 'open a' can map to both 'a.open()' and 'open
( a )'. If 'open' is both a method on 'a', and a callable defined in
current scope, the expression is ambiguous and raises an
AmbiguityException.

If you're willing to constrain yourself to a subset of English which
the language will understand, you open a lot of doors; that is, if you
will accept a 'more natural Python' instead of 'true natural Python'.
 
K

Kay Schluehr

Just out of curiousity, have there been any attempts to make a version
of Python that looks like actual English text?

No, but I've once written a Python dialect that uses German text. Just
look at how amazing this result is !!! But be warned it requires
knowledge of the German language.

http://www.fiber-space.de/EasyExtend/doc/teuton/teuton.htm

I mean, so much of Python
is already based on the English language that it seems like the next
natural step would be to make a programming language which is actually a
spoken one.

As you know Python 3.0 has full unicode support. Python 4.0 will be
surely written in Mandarin or Hindi.
For example, the following code...


foo
bar
etc

...might be translated as...


    "a path" and does the following:
        For every item in the list returned by the operating system's
        directory listing of the given path, do the following:
             Print the item.


foo
bar
etc

Obviously, creating a parser capable of handling such "code" would
require a very good understanding not only of the English language but
also of how ideas expressed in spoken languages are represented in terms
that a computer can understand.

Yep. Resolving ambiguities in natural languages is actually an open
research topic. Moving from Python to a language that is more context
dependent than Larry Wall ever dreamed about and launch an interpreter
on the Enterprise is actually a worthwhile project for future
generations.

Kay
 
M

Marco Mariani

The said:
Just out of curiousity, have there been any attempts to make a version
of Python that looks like actual English text?


Many have tried that in the decades, but IMHO the best approach is to
just rename the language. We cannot do that since it's already been
trademarked for that very reason.


From Wikipedia:

ENGLISH (actually trademarked in all caps) is a database retrieval and
reporting language somewhat like SQL, but with no actual programming or
update capabilities. Originally released by Microdata in 1973 and named
so that the company's brochures could claim that developers could
generate reports on their implementation of the Pick operating system
using English.
 
A

afriere

Just out of curiousity, have there been any attempts to make a version
of Python that looks like actual English text? I mean, so much of Python
is already based on the English language that it seems like the next
natural step would be to make a programming language which is actually a
spoken one.

I'm reminded of Lingua::Romana::perligata <http://
www.csse.monash.edu.au/~damian/papers/HTML/Perligata.html> which was
done in Perl rather than Python, with the far more noble aim of
programming in a language no longer spoken. ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top