Typed Python?

  • Thread starter Thomas Reichelt
  • Start date
J

Jacek Generowicz

Jeremy Bowers said:
def is_better_structured_than(a, b): # take Peter's suggestion
"Returns true if a is better structured than b."
if not equivalent(a, b):
raise ThatsNotFairError

return len(a) > len(b)


(It is the only logical interpretation of the statement since in any sane
parse tree of the two on some fair ground they are indistinguistable. If
you don't like this logic, Jacek,

I love your assertion (re parse tree); you have failed to show me your
logic ... but given that your logic appears to lead you to conclude
that structure "quality" is somehow directly related to string length[*],
I must admit that it seems to me that your logic probably sucks.

:)


[*] As opposed to, for example, simplicity of transformation to parse
tree.
 
J

Jacek Generowicz

In the early days of pocket calculators, Texas Instruments had all
these RPN (reverse Polish notation) models.

Wasn't it HP ?
Now, many people argued that computationally RPN made more
sense. But the market has spoken otherwise.

The market has spoken. Microsoft Windows is the best operating system.
No matter how much sense it may make in theory, in practice the
majority of people will NOT buy nor use a RPN calculator.

While power users will.
Sure, there are always going to be those that stick with RPN
calculators and praise their structuredness to no end.

In academia all this is fine and dandy. In business, igonoring
user-friendliness means... well, no business. RPN calculators are a
good example.

User friendliness to whom ? RPN calculators are extremely
user-friendly to power-users of calculators.
Trust me.

I'll pass on this one. I prefer to think for myself, rather than
trusting people ... particularly people who give an impression of not
being particularly well informed in the very same post in which they
tell me to trust them :)
Codeblocks, not Lisp/Scheme's PN expressions,

Never heard of PN expressions. Please enlighten me.
are the way of the future. It's very simple logic: people want
machines to act more like people,

That's not logic; that's an unfounded claim.
they don't want to be told to act more like machines.

Who are these "people"? You seem to be suggesting that the qualities
that Joe Windoze User seeks in a computer are the same that a skilled
programmer seeks in a computer.

Methinks you need to think again.
 
J

Jacek Generowicz

=?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= said:
Yes, I still have a HP48 from my science school days. It was a
great machine. I found the reverse polish notation much more
powerful than the classical notation when doing manual
calculations. However, when progrmaming, it was hell because
you had to keep track of the stack in your head, which is
very difficult. As soon as there's if/then and loops, I think
stack languages become impossible to use.

Perhaps you should ask the good folks over on comp.lang.forth to
comment on the matter ... unless you just want to make an unfounded
statement that makes you feel good inside, of course :)
 
J

Jacek Generowicz

François Pinard said:
Also, there once was a notable distance between Scheme and Python
about lazy evaluation
[...]

but more recent versions of Python offer fairly tractable, almost
easy approaches for such things.

Sorry, maybe I'm being thick ... what sort of lazy evaluation ?
 
?

=?iso-8859-1?Q?Fran=E7ois?= Pinard

[Jacek Generowicz]
Also, there once was a notable distance between Scheme and Python
about lazy evaluation [...] but more recent versions of Python offer
fairly tractable, almost easy approaches for such things.
[...] what sort of lazy evaluation ?

I'm not sure of the meaning of the question. "Lazy evaluation" means
any mechanics by which the language (or system, or programm) waits as
much as possible until a result is needed before computing it.

In Scheme, lazy evaluation is part the language with the `(delay ...)'
and `(force ...)' constructs. In Python, one could already "simulate"
lazy evaluation by various means, but it turned out to be fairly easy
after iterator generators were introduced, and these are now used all
over the place in Python, often yielding interesting speedup.

One may nest an expression to lazy-evaluate within a generator and use
GENERATOR.next() whenever the value is needed. As Python now produce
closures more easily than it used to, the generator could be me made to
save part of the evaluation context for later use. Even nicer, one may
lazily produce a list of values by `yield'-ing them within a loop, and
progressively consume them with a `for'-loop over the generator, say.
 
M

Michele Simionato

Donn Cave said:
Or does it make even sense to evaluate a
programming language based on how far you can get with it in the
first 15 minutes?

Donn Cave, (e-mail address removed)

I evaluated Python based on that ;)


Michele Simionato
 
P

Paul Prescod

Brett said:
This is not necessarily true. While this is how Standard ML and
friends use it, this is not how Python would use it. Type inferencing
can be used to infer types purely for performance reasons.

Well, yes, of course. But in the context of a question about STATIC TYPE
CHECKING as opposed to: "Wouldn't it be great if Python were higher
performance" I felt obliged to point out that there is no free lunch.
The original poster asked for a steak with the consistency of fish and
the flavour of bubble gum ice cream and they aren't going to get it: not
from Starkiller, not from Haskell and not from Python 3000.
...
And as just a general comment, type inferencing in Python without
changing semantics is **very** limited.

Right: and that's for performance reasons, not correctness reasons.
Think about how much the semantics would have to change to be able to
help with type correctness reliably.

Paul Prescod
 
D

Dennis Lee Bieber

Yes, I still have a HP48 from my science school days. It was a great
machine. I found the reverse polish notation much more powerful than the
classical notation when doing manual calculations. However, when
progrmaming, it was hell because you had to keep track of the stack in
your head, which is very difficult. As soon as there's if/then and loops,
I think stack languages become impossible to use.

Try programming an HP41 or earlier, before you had access to an
onboard editor (insert/delete by instruction was about it).

Reminds me, I need to check if the batteries in the old 41 have
leaked out yet...


--
 
D

Dennis Lee Bieber

Never heard of PN expressions. Please enlighten me.
Take the "Reverse" off of RPN... Reverse Polish Notation has the
operator following the operands.
a b +
vs original Polish Notation
+ a b

--
 
V

Ville Vainio

Jacek> logic ... but given that your logic appears to lead you to
Jacek> conclude that structure "quality" is somehow directly
Jacek> related to string length[*],

...

Jacek> [*] As opposed to, for example, simplicity of
Jacek> transformation to parse tree.

I suppose a teacher of high school kids should be more concerned with
the intuitiveness of the construct than the simplicity of
transformation to parse tree.

Seeing "(set! x 10)", many would probably think "yeah, it's a special
form that binds 'x to 10, I get the idea, now got off my face, I have
work to do". You only need to learn once what "x=10" does, after that
it just happens; you don't need to spell it out to the machine.

Of course the scheme syntax also conveys that "mutating a variable is
a bad idea, please reconsider". While someone might appreciate the
constant nagging by the language targeted at your programming style,
most programmers probably don't. For academics (possibly with no code
to write in the first place), this is a minor issue.
 
V

Ville Vainio

Paul> reasons. Think about how much the semantics would have to
Paul> change to be able to help with type correctness reliably.

Would it? Wouldn't optional type declarations combined with type
inference "elsewhere" take care of the correctness aspect as well?

def g(x):
...

def f(x,y) -> str:
...


s=g(3)

s.woohey() # might work, no complaint

s = f(1,2)
if randomevent():
s.woohey() # impossible, type inference croaks
else:
s.hjhj() # ditto
 
J

Jorge Godoy

Seeing "(set! x 10)", many would probably think "yeah, it's a special
form that binds 'x to 10, I get the idea, now got off my face, I have
work to do". You only need to learn once what "x=10" does, after that
it just happens; you don't need to spell it out to the machine.

From what I've read I got that they were trying to show that there's no
ambiguity in using "(set! x 10)" but there is in "x=10": is it an
attribution or a comparison?
Of course the scheme syntax also conveys that "mutating a variable is
a bad idea, please reconsider". While someone might appreciate the
constant nagging by the language targeted at your programming style,
most programmers probably don't. For academics (possibly with no code
to write in the first place), this is a minor issue.

What reminds me that LISP was used to write Yahoo! Store first...
 
V

Ville Vainio

Jorge> From what I've read I got that they were trying to show
Jorge> that there's no ambiguity in using "(set! x 10)" but there
Jorge> is in "x=10": is it an attribution or a comparison?

If you recall, we've got == for comparison in Python and most of the
programming world. There is no ambiguity. x=10 syntax is just
impossible in Scheme without read macro hackery, because of the
s-expression syntax (which does have some virtues).

Jorge> What reminds me that LISP was used to write Yahoo! Store
Jorge> first...

Yes, the Legend of Sir Graham. Lisp does need another success story,
public gets suspicious when the same one is repeated over and over
again.

(No, I'm not implying that Lisp is not being used for real [as in
non-academic] work. It is, Scheme isn't).
 
J

Jorge Godoy

If you recall, we've got == for comparison in Python and most of the
programming world. There is no ambiguity. x=10 syntax is just
impossible in Scheme without read macro hackery, because of the
s-expression syntax (which does have some virtues).

I agree, but usig "==" is unnatural and computer specific. (I'm not saying
that the scheme approach is better.)

Anyway, this is one thing where the s-exp seems less ambiguous. That was my
only point in the message.
Yes, the Legend of Sir Graham. Lisp does need another success story,
public gets suspicious when the same one is repeated over and over
again.

I agree with you.

The same happens for Python and other languages equally powerful.
(No, I'm not implying that Lisp is not being used for real [as in
non-academic] work. It is, Scheme isn't).

I guess it all depends on what is "real" for you. For me, academia is as
real as the business and commercial world. It is more tolerant, sometimes,
but both worlds have its peculiarities. And in academia you are evaluated
by people with much more skills and experience than you, for colleagues,
for other people. In the commercial world, people usually deliver closed
source, i.e., nobody can evaluate if you did it the best way or if you
cheated to get the answer you thought were right.


Be seeing you,
 
V

Ville Vainio

Jorge" == Jorge Godoy said:
>> (No, I'm not implying that Lisp is not being used for real [as
>> in non-academic] work. It is, Scheme isn't).

Jorge> I guess it all depends on what is "real" for you. For me,
Jorge> academia is as real as the business and commercial
Jorge> world. It is more tolerant, sometimes,

"Real" work is admittedly a bit careless choice of words. Non-academic
work is often more concerned with delivering stuff, while academic
work is more exploratory in nature (and often without the obligation
to deliver anything but research papers). Scheme/Lisp like languages
are undoubtedly better for exploratory work, because of the "plastic"
nature of the languages themselves (macros help here).
 
C

Christopher T King

If you are using Python mainly for numerical work and use Numeric or
Numarray for array operations, Fortran 90 or 95 may be the closest

Indeed, Numeric/numarray give you all the performance benefits of using a
statically-typed language without using static types. Because they must
only check the data type once for each vector operation they perform, the
time spent doing this is neglible compared to the actual computation time.
If you are doing vector-based numerical work, these will be better than
nearly any other solution available.
 
?

=?iso-8859-1?Q?Fran=E7ois?= Pinard

[Ville Vainio]
(No, I'm not implying that Lisp is not being used for real [as in
non-academic] work. It is, Scheme isn't).

I surely used Scheme for real contracts, that is, non-academic works,
and I'm aware that others (individuals or companies) also did or do.
Moreover, in my own experience at least, the phenomenon of Python in
commercial circles is more recent and limited that the same for Scheme.
 
V

Ville Vainio

Francois> [Ville Vainio]
>> (No, I'm not implying that Lisp is not being used for real [as
>> in non-academic] work. It is, Scheme isn't).

Francois> I surely used Scheme for real contracts, that is,
Francois> non-academic works, and I'm aware that others
Francois> (individuals or companies) also did or do. Moreover, in
Francois> my own experience at least, the phenomenon of Python in
Francois> commercial circles is more recent and limited that the
Francois> same for Scheme.

Really, when was this? Even back when I learned Scheme (in 1995), it
was regarded as a language nobody really uses (and dropping it out of
school curriculum was being considered already).
 
?

=?iso-8859-1?Q?Fran=E7ois?= Pinard

[Ville Vainio]
(No, I'm not implying that Lisp is not being used for real [as
in non-academic] work. It is, Scheme isn't).
Francois> I surely used Scheme for real contracts, [...]
Really, when was this?

In my case, this was a few years ago, I never precisely remember dates.
I know other people who do Scheme works for a living in these days. I
would feel a bit uncomfortable in their context, because this is all
too much commercial for my own desires, and am not so money-oriented to
fully dedicate myself in these projects that have no free aspects.

There is a kind of strange constant in what people tell me however.
Scheme seems to be often used "under the cover", in that people deliver
stand-alone solutions in which the real engine is not revealed, a bit
like if Scheme was not far from being an industrial secret. :)
Even back when I learned Scheme (in 1995), it was regarded as a
language nobody really uses (and dropping it out of school curriculum
was being considered already).

Hey! This is a world-wide conspiration, driven by those who understand
the competitive advantages they get by knowing and using Scheme! :)

Nowadays, Python is my main weapon, but I surely not make it a secret!
 

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
474,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top