473,699 Members | 2,311 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Typed Python?

Moin,

short question: is there any language combining the syntax, flexibility and
great programming experience of Python with static typing? Is there a
project to add static typing to Python?

Thank you,

--
greetz tom
Jul 18 '05
176 8126
Peter Hickman wrote:
...
They never seemed to indicate that their architecture was anything
special or that their competitors' was especially bad. Just that they
could develop good code faster than their competitors.


Elsewhere they do claim architectural advantage:

http://www.paulgraham.com/lwba.html

"One way we used macros was to generate Html. There is a very
natural fit between macros and Html, because Html is a prefix
notation like Lisp, and Html is recursive like Lisp. So we had
macro calls within macro calls, generating the most complicated
Html, and it was all still very manageable."

"Users could write their own Rtml templates to describe what they
wanted their pages to look like. We had a structure editor for
manipulating these templates, a lot like the structure editor they
had in Interlisp. Instead of typing free-form text, you cut and
pasted bits of code together. This meant that it was impossible
to get syntax errors. It also meant that we didn't have to display
the parentheses in the underlying s-expressions: we could show
structure by indentation. By this means we made the language look
a lot less threatening."

"We could write the code to say, if the user clicks
on this link, go to the color selection page, and then come back
here. This was just one of the places were we took advantage of
this possibility. It made our software visibly more sophisticated
than that of our competitors."

Paul Prescod
Jul 18 '05 #111
Ville Vainio <vi***@spammers .com> writes:
The only thing I learned was doing functional programming, handy ways
to use recursion etc (using set! was forbidden in the excercises). I
could have learned the same things with Python. And I don't think I
"missed" anything, got perfect score and generally considered the
course trivial.


Well, there's always the possibility that the course was crap. This is
not unusual, as I've suggested before.
Jul 18 '05 #112
Paul Prescod:
... It also meant that we didn't have to display
the parentheses in the underlying s-expressions: we could show
structure by indentation. By this means we made the language look
a lot less threatening."


Every sufficiently advanced LISP application will eventually reimplement
Python.

Neil
Jul 18 '05 #113
Ville Vainio <vi***@spammers .com> wrote in message news:<du******* ******@mozart.c c.tut.fi>...

Frankly, there is no real reason to learn Scheme.


I have to beg to differ. I am using Bigloo (Scheme) for 3 years now
for pursuing my research PhD in physics (atmospheric physics and
chemistry).

Believe it or not: I had to translate all my former Python programs to
Bigloo because I was at the point where I was not any longer happy
with Python. Numarray was such a big mess (yes I have some experience
with similar things: IDL, Matlab and especially Yorick) and Python is
simply to depressing.

Bigloo gives me all that what I need and what makes me happy. So
saying Scheme is as worthless experience calls for troubles.

What makes me happy:

- I can give types and that /tremendously/ improves readability and
catches type erros but at the same time I am /always/ using all the
freedom of Scheme programming.

- Bigloo has pattern matching

- Object orientied programming (one can even create new types)

- Foreign function interface is very sound and very easy to use (no
need of SWIG)

- Bee development environment

- I do not use the following but they are there: Java backends
(automatically produced from Scheme code) and .NET integration

- And yes: the compiler: ./a.out

- I use it on: Mac OSX, Sun OS (I am steering, post- and preprocessing
there Fortran code with the help of Bigloo), and Linux.

- And much, much more

- disadvantages: every Scheme implemenation is a unique
implementation. However, Python is also a unique implementation ...

Bigloo is very sound and I wouldn't mind to use it in any production
code in any of my "imaginativ e" companies.

Scheme works so well out for me, though, my knowledge of Scheme is
very shallow but it makes me happy to program in (as opposed to
Python).
Fensterbrett
Jul 18 '05 #114
In article <ma************ *************** *********@pytho n.org> (Wed, 07
Jul 2004 23:13:49 -0700), Paul Prescod wrote:
Hamilcar Barca wrote:

The concepts in Scheme matter a great deal in computer science. Those
that are "craving ... fun" may do it on their own time.
Why not have fun while learning computer science?


That would be good.
Scheme is just a programming language. It is not in and of itself a
revelation of the deepest concepts of computer science.
I agree here, too.

If I had to learn a new language now, and I got to choose, I'd learn
Scheme. Unfortunately, I do have to learn a new language now, and I get
to choose any two of the languages in the set of Java and Scala. I would
have liked Java before I learned Python.

You don't seem to have taken it this way, but I don't intend to bash
Python. It's still my opinion that Scheme is a better language,
theoretically and for instruction on principles (now known as "paradigms" ,
than Python. If I had to choose, between LISP (which I know) and Python,
for a "real" project, I'd choose Python.
Python supports recursion, second order functions, numerical programming
and hundreds of other important concepts.
How about currying and deferred list evaluation?
In my mind, Scheme actually lacks important stuff like the idea that
types can be created (not simulated, but CREATED) by programmers and not
just language designers.
I think your mind is correct. This lack is deliberate and even CLOS seems
to support concrete data types better than ADTs.
It also lacks various other OOP concepts (in its standard form).


In my limited experience, it's complete lacking in OO. There are many who
argue that functional programming is "better" than OOP, where

(setq better 'opinion)

Is this a good place to insert my "Smalltalk is the only language good
enough for teaching people to program" rant?
Jul 18 '05 #115
>>>>> "Hamilcar" == Hamilcar Barca <ha******@tld.a lways.invalid> writes:
Python supports recursion, second order functions, numerical
programming and hundreds of other important concepts.


Hamilcar> How about currying and deferred list evaluation?

Deferred list evaluation: generators
Lazy evaluation in general: lambda : f(1,2)
Currying: lambda x,y : f(x,y,1,2)

Hamilcar> Is this a good place to insert my "Smalltalk is the only
Hamilcar> language good enough for teaching people to program"
Hamilcar> rant?

What's better about Smalltalk compared to Python, educationally? Just
a brief list will do.

--
Ville Vainio http://tinyurl.com/2prnb
Jul 18 '05 #116
> Currying: lambda x,y : f(x,y,1,2)

lambda x: lambda y: f(x,y,1,2)?

but then
(lambda x: lambda y: f(x,y,1,2))(3, 4)

won't work.

so much for currying?
k
Jul 18 '05 #117
>>>>> "chain" == chain lube <ch********@hot mail.com> writes:

chain> Ville Vainio <vi***@spammers .com> wrote in message news:<du******* ******@mozart.c c.tut.fi>...

Frankly, there is no real reason to learn Scheme.


chain> Believe it or not: I had to translate all my former Python
chain> programs to Bigloo because I was at the point where I was
chain> not any longer happy with Python. Numarray was such a big
chain> mess (yes I have some experience with similar things: IDL,

Considered complaining to Numarray people instead of interpreting it
as a flaw in Python? Sometimes even filing a bug report might help.

chain> Matlab and especially Yorick) and Python is simply to
chain> depressing.

Could you show us a code example about what depresses you? Consider
this a good chance at advocacy, concrete examples always work. I was
sold to Python when I saw how easy doing CORBA is.

chain> - I can give types and that /tremendously/ improves
chain> readability and catches type erros but at the same time I
chain> am /always/ using all the freedom of Scheme programming.

Is Bigloo statically typed? If it isn't, you can equally well assert
the argument types in python functions.

chain> - Bigloo has pattern matching

Very much doable in Python. Pattern matching is rarely needed, though
- a couple of if-elif's will typically do fine (because that's what
pattern matching essentially is).

if tuple_types_are (argtuple, (int,[str], (int,int)):
pass

chain> - Object orientied programming (one can even create new
chain> types)

Folks here say Python kinda supports OOP too.

chain> Scheme works so well out for me, though, my knowledge of
chain> Scheme is very shallow but it makes me happy to program in
chain> (as opposed to Python).

Again, why? List some reasons, and we'll see if there is something
that would help you in e.g. ASPN Python cookbook.

Of course if Python "depresses" you, there might be some deeper
personality incompatibiliti es issues between you and the
language. Python tends to make me happy, esp. when I'm doing list
comprehensions :-).

--
Ville Vainio http://tinyurl.com/2prnb
Jul 18 '05 #118
Ville Vainio <vi***@spammers .com> writes:
>> "chain" == chain lube <ch********@hot mail.com> writes:
chain> Ville Vainio <vi***@spammers .com> wrote in message news:<du******* ******@mozart.c c.tut.fi>... >>
>> Frankly, there is no real reason to learn Scheme.

chain> Believe it or not: I had to translate all my former Python
chain> programs to Bigloo because I was at the point where I was
chain> not any longer happy with Python. Numarray was such a big
chain> mess (yes I have some experience with similar things: IDL,

Considered complaining to Numarray people instead of interpreting it
as a flaw in Python? Sometimes even filing a bug report might help.


Though using a language in which the stuff you need already works the
way you want it, might help more.
chain> - I can give types and that /tremendously/ improves
chain> readability and catches type erros but at the same time I
chain> am /always/ using all the freedom of Scheme programming.

Is Bigloo statically typed? If it isn't, you can equally well assert
the argument types in python functions.
You are completely missing the point.

Specifying the type in Bigloo will make the code run more quickly,
while asserting the type in Python will make the code run more slowly.
chain> - Bigloo has pattern matching

Very much doable in Python. Pattern matching is rarely needed,
Chicken and egg. The Blub Paradox. etc. etc. ...

Python provides no built-in support for pattern matching, therefore
your average happy Pythoneer will not be familiar with pattern
matching, the point of pattern matching, the benefits of pattern
matching, or the situations in which pattern matching is a big win. If
they ever do try to do pattern matching, it will probably be via some
clunky home-grown implementation, which will not exhibit pattern
matching in its best light. Therefore, they are likely to conclude
that there is no use for pattern matching ...
though - a couple of if-elif's will typically do fine (because
that's what pattern matching essentially is).


.... yup, you prove my point exactly.

My point is, of course, not specific to Python or to pattern matching;
you can replace them with any language, and any feature missing from
that language.
Jul 18 '05 #119
>>>>> "Jacek" == Jacek Generowicz <ja************ **@cern.ch> writes:
Considered complaining to Numarray people instead of
interpreting it as a flaw in Python? Sometimes even filing a
bug report might help.
Jacek> Though using a language in which the stuff you need already
Jacek> works the way you want it, might help more.

It's throwing baby out with the bathwater. If something is amiss in a
library, you typically don't switch the whole language (at least in
industrial/corporate setting). You would need to switch languages
every other day. Well, I've seen worse - some people actually
*implement* new languages because e.g. Python has no library that does
<fill_in>.
Is Bigloo statically typed? If it isn't, you can equally well assert
the argument types in python functions.
Jacek> You are completely missing the point.

Jacek> Specifying the type in Bigloo will make the code run more
Jacek> quickly, while asserting the type in Python will make the
Jacek> code run more slowly.

So performance was the problem? The OP should have said so, perhaps
posted some benchmarks.

Jacek> Python provides no built-in support for pattern matching,
Jacek> therefore your average happy Pythoneer will not be familiar
Jacek> with pattern matching, the point of pattern matching, the
Jacek> benefits of pattern matching, or the situations in which
Jacek> pattern matching is a big win. If

Ok, give an example where built-in pattern matching (i.e. something
not doable with a library) would be a big win.
though - a couple of if-elif's will typically do fine (because
that's what pattern matching essentially is).


Jacek> ... yup, you prove my point exactly.

Last time I checked, pattern matching essentially *is* about

1. Finding the pattern that matches the valuable of a variable

2. Unpacking the found value to a tuple.

So please try to avoid speaking in the abstract and give something
concrete.

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

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

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.