473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

dynamic typing questions

I work for at a college where I am one of 2 full-time
developers and we are looking to program a new
software package fro the campus. This is a huge
project as it will include everything from
registration to
business office. We are considering useing Java or
Python. I for one don't like Java because I feel the
GUI is clunky. I also think that we could produce
quality programs faster in Python.

The other programmer here is very concerned about
dynamic typing though in Python. He feels like this
would be too much of a hinderance on us and too easy
for us to make a mistake and not catch it until
runtime making debugging harder.

OK what are your guys thoughts here? How have you all
overcome the lack of static typing? Is Python a
bad decision here? By the way we will be using
Postgres in the back if that matters to anyone.

Jul 18 '05 #1
12 2144
JCM
Jason Tesser <te**********@yahoo.com> wrote:
....
The other programmer here is very concerned about
dynamic typing though in Python. He feels like this
would be too much of a hinderance on us and too easy
for us to make a mistake and not catch it until
runtime making debugging harder.


I come from a mixed background and have worked on projects in both
statically and dynamically-typed languages. My only strong advice is
to avoid weakly-typed languages like C, so it's good to not hear you
asking about that one :)

It's true some errors which could have been caught at compile-time by
statically typed languages will not be caught until runtime in Python.
But the decreased development time you'll enjoy partly makes up for
this. To fully make up for it I suggest (as I'm sure will others)
robust unit-testing. Also, adding an occasional "assert type(x) ==
expected_type" might be helpful.
Jul 18 '05 #2
Jason Tesser wrote:
OK what are your guys thoughts here? How have you all
overcome the lack of static typing? Is Python a
bad decision here? By the way we will be using
Postgres in the back if that matters to anyone.


I have no problems with dynamic typing, but it seems that this comes as
a big problem to you. My advice, since you are two, is that you agree on
something that makes your life easier in the future, like to keep a
record of every declared variable, or that you agree on a naming policy,
like starting every int name with i (icounter) and every float with f
(fmeasure) while you get used to the dynamic typing. This way you'll
have an easier time catching and, more important, avoiding the errors.

But I think that once you get used to Python and it style, you won't
miss static typing at all.

Gedece
Jul 18 '05 #3

"Jason Tesser" <te**********@yahoo.com> wrote in message
news:ma*************************************@pytho n.org...
I work for at a college where I am one of 2 full-time
developers and we are looking to program a new
software package fro the campus. This is a huge
project as it will include everything from
registration to
business office. We are considering useing Java or
Python. I for one don't like Java because I feel the
GUI is clunky. I also think that we could produce
quality programs faster in Python.

The other programmer here is very concerned about
dynamic typing though in Python. He feels like this
would be too much of a hinderance on us and too easy
for us to make a mistake and not catch it until
runtime making debugging harder.

OK what are your guys thoughts here? How have you all
overcome the lack of static typing? Is Python a
bad decision here? By the way we will be using
Postgres in the back if that matters to anyone.
Look into Test Driven Development (see Kent
Beck's book by that title.) As Jason says, unit testing
will pretty much eliminate any advantages of static typing,
leaving only the disadvantages.

Also, pervasive testing has so many other advantages
that I'm beginning to think that debuggers were the
single worst invention in history.

John Roth

Jul 18 '05 #4
You can find some useful links at:

http://www.ferg.org/projects/python_...e-by-side.html
Jul 18 '05 #5
Jason Tesser <te**********@yahoo.com> wrote in message news:<ma*************************************@pyth on.org>...
I work for at a college where I am one of 2 full-time
developers and we are looking to program a new
software package fro the campus. This is a huge
project as it will include everything from
registration to
business office. We are considering useing Java or
Python. I for one don't like Java because I feel the
GUI is clunky. I also think that we could produce
quality programs faster in Python.

The other programmer here is very concerned about
dynamic typing though in Python. He feels like this
would be too much of a hinderance on us and too easy
for us to make a mistake and not catch it until
runtime making debugging harder.

OK what are your guys thoughts here? How have you all
overcome the lack of static typing? Is Python a
bad decision here? By the way we will be using
Postgres in the back if that matters to anyone.


Dynamic typing is usually considered an *advantage* of Python, not a
disadvantage. Usually, if you're keeping track of what the variables
mean, you can use them usefully without errors. The thing about
dynamic typing is that functions are more flexible, making something
that would cause an error in Java not cause one in Python. So even if
the error would be caught in Java, it would run fine in Python. the
distinction between certain types (such as number types) is weak in
Python, making everything more flexible, but it is still strongly
typed where appropriate (eg. numbers and strings). If you still need
something to make sure types are used correctly, try PyChecker.
Sometimes (rarely), it gives an error for type use when it would run
well, but it catches everything.

Daniel Ehrenberg
Jul 18 '05 #6
John Roth:
I'm beginning to think that debuggers were the single worst invention in history.


Atomic bomb, MS-DOS, daylight saving time, C, ... are you sure?

--
René Pijlman
Jul 18 '05 #7
Jason Tesser wrote (relevant excerpts only):
We are considering useing Java or
Python. The other programmer here is very concerned about
dynamic typing though in Python. He feels like this
would be too much of a hinderance on us and too easy
for us to make a mistake and not catch it until
runtime making debugging harder.

OK what are your guys thoughts here? How have you all
overcome the lack of static typing?


IMHO, the impediments introduced by static typing are not worth the benefit
of catching type errors at compile time. Further, you still have to do
testing to find other bugs.

The increased productivity due to dynamic typing in Python allows for more
testing time to catch _all_ errors (type or otherwise). Development +
testing time for a Python program usually turns out to be much less than
just development time for an equivalent Java program (for me, at least). An
interesting read is Guido van Rossum's interview at
http://artima.com/intv/strongweak.html

Also note that even in Java, static typing does not achieve much in many
cases (except requiring more keyboard typing), as illustrated in the
following example:

// myVector is a java.util.Vector, index is an int

String myStr = (String) myVector.get(index);

If the object in the vector is not a String, it is only at run time that the
error will be caught.

Admittedly, static typing allows the compiler to produce faster programs.
But the question isn't if it is fast. The question is if it is fast enough.

--
Shalabh
Jul 18 '05 #8
Jason Tesser wrote:
OK what are your guys thoughts here? How have you all
overcome the lack of static typing? Is Python a
bad decision here? By the way we will be using
Postgres in the back if that matters to anyone.

Maybe try the confrontational approach, if all else fails:

Acknowledge that static typing is "cute." Then mercillessly press him
on how often it really helps, and how much time does it save relative
to Python.

Whenever he cites an advantage of static typing, ask him how often it
really helps. How often does the compiler really catch that, and is
this really something that Python won't catch at runtime?

If he cites the ability of the compiler to catch incorrectly passed
arguments, point out that Python can still catch these at run time,
probably as well as Java could. Remind him that static typing can
catch these only if the incorrect argument happens to have a different
type: static typing is a swiss cheese protection mechanism.

If he cites the ability to catch spelling errors: first point out that
that's unrelated to static typing. Some statically-typed languages
have this problem (Fortran). And a dynamically-typed language can
require declarations. But, even though Python doesn't, it's not that
serious a problem in Python. Unlike a certain other dynamically typed
(I guess) language beginning with P, variables just don't pop out of
nowhere if you just use them. So the only time Python can't catch a
spelling error is when it's on the left side of an assignment (or
imported, or whatever). If he says that's still worse than Java,
concede it. It's true after all. Then ask him how often that
happens, and how much time he thinks that will save compered to
Python.

If he says that compiler errors are easier to locate than runtime
errors, point out that Python, like Java, has a very good exception
handling mechanism that identifies the locus of errors. While you're
at it, ask him whether debugging run time errors was ever that bad.
After all, Java has those, too.
At the same time, pimp the advantages of dynamic typing.

Ask him if he's ever written a class, a union, or done some other
silly thing to define a variable that can have a "special" value.
Remind him that this isn't necessay in Python, thanks to dynamic
typing. (Incidentally, this happens to me a lot.)

Ask him how many times he's defined some ridiculous class hierarchy to
get some pathetic, contrived imitation of polymorphism. Point out
that, in Python, this isn't necessary. Things don't have to be
subclasses to be polymorphic. Subclasses can be used for what they
were intended for: inheritance.

Ask him how often he uses type casting (which should be a lot, since
he prefers Java). Remind him that every time he uses type casts he
defeats the point of static typing, and has to go though more effort
to do so.

Ask him if he's ever gotten a Runtime error in Java for a type casting
error. If no, or not often, ask him why he expects this so much in
Python. If yes, ask him if he felt annoyed that the Java compiler
wasn't able catch it for him, or happy that Java's runtime was up to
the task.
I believe there is very little practical advantage of static typing.
Most of the advantages are small, cute little things, but not things
that won't still be caught at runtime by Python. The wrong type is
almost certain to be caught by Python sooner or later.

And, in the end, I really don't think type mismatch errors are very
common (compared to other types of error).
Finally, if you still end up using Java, count your blessings. Java
is not that bad. You could be using C++ or Visual Basic.
--
CARL BANKS http://www.aerojockey.com/software
"If you believe in yourself, drink your school, stay on drugs, and
don't do milk, you can get work."
-- Parody of Mr. T from a Robert Smigel Cartoon
Jul 18 '05 #9
"John Roth" <ne********@jhrothjr.com> writes:
Also, pervasive testing has so many other advantages
that I'm beginning to think that debuggers were the
single worst invention in history.


Pervasive testing is much easier in an interactive enviroment with a good
debugger.

'as
Jul 18 '05 #10

"Alexander Schmolck" <a.********@gmx.net> wrote in message
news:yf*************@black132.ex.ac.uk...
"John Roth" <ne********@jhrothjr.com> writes:
Also, pervasive testing has so many other advantages
that I'm beginning to think that debuggers were the
single worst invention in history.
Pervasive testing is much easier in an interactive enviroment with a good
debugger.


It's much easier if you automate your tests, you write them
first and you write the code for each one as you write the test.

Then you don't need the debugger. Usually.

John Roth
'as

Jul 18 '05 #11
If you believe that dynamic typing is a mistake then I have a bridge
in London to sell you. ;-)

Daniel Klein
On Fri, 19 Dec 2003 07:03:39 -0800 (PST), Jason Tesser
<te**********@yahoo.com> wrote:
I work for at a college where I am one of 2 full-time
developers and we are looking to program a new
software package fro the campus. This is a huge
project as it will include everything from
registration to
business office. We are considering useing Java or
Python. I for one don't like Java because I feel the
GUI is clunky. I also think that we could produce
quality programs faster in Python.

The other programmer here is very concerned about
dynamic typing though in Python. He feels like this
would be too much of a hinderance on us and too easy
for us to make a mistake and not catch it until
runtime making debugging harder.

OK what are your guys thoughts here? How have you all
overcome the lack of static typing? Is Python a
bad decision here? By the way we will be using
Postgres in the back if that matters to anyone.


Jul 18 '05 #12
In article <c3************@beastie.ix.netcom.com>, Dennis Lee Bieber wrote:
Dave Benjamin fed this fish to the penguins on Wednesday 24 December
2003 00:26 am:

Lake Havasu City, Arizona. ;)

Next to lots of beach front property, I take it <G>


Yes, sir, we'd like the lake installed over here, please...

--
..:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:.
: d r i n k i n g l i f e o u t o f t h e c o n t a i n e r :
Jul 18 '05 #13

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

Similar topics

6
by: Jason Tesser | last post by:
I work for at a college where I am one of 2 full-time developers and we are looking to program a new software package fro the campus. This is a huge project as it will include everything from...
11
by: Neuruss | last post by:
I've been reading an article published in E-Week entitled "Microsoft Lures Open-Source Programmer", which contains a definition for dynamic languages as follows: "Dynamic programming languages...
9
by: Gibby Koldenhof | last post by:
Hiya, Terrible subject but I haven't got a better term at the moment. I've been building up my own library of functionality (all nice conforming ISO C) for over 6 years and decided to adopt a...
1
by: sleigh | last post by:
Hello, I'm building a web application that will build a dynamic form based upon questions in a database. This form will have several different sections that consist of a panel containing one to...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
13
by: Krivenok Dmitry | last post by:
Hello all! Perhaps the most important feature of dynamic polymorphism is ability to handle heterogeneous collections of objects. ("C++ Templates: The Complete Guide" by David Vandevoorde and...
2
by: J. Peng | last post by:
Python's variable is dynamic type,is it? But why this can't work? Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: unsupported operand type(s) for +: 'int' and 'str' ...
45
by: azrael | last post by:
Hy guys, A friend of mine i a proud PERL developer which always keeps making jokes on python's cost. Please give me any arguments to cut him down about his commnets like :"keep programing i...
5
by: bearophileHUGS | last post by:
I often use Python to write small programs, in the range of 50-500 lines of code. For example to process some bioinformatics data, perform some data munging, to apply a randomized optimization...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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,...

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.