473,756 Members | 5,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2179
JCM
Jason Tesser <te**********@y ahoo.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**********@y ahoo.com> wrote in message
news:ma******** *************** **************@ python.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**********@y ahoo.com> wrote in message news:<ma******* *************** *************** @python.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.Vecto r, index is an int

String myStr = (String) myVector.get(in dex);

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********@jhr othjr.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

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

Similar topics

6
1492
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 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...
11
1876
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 enable programs to change their structure as they run." I wonder if this definition is correct. Can we define dynamic languages this way?
9
2634
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 more OO approach to fit my needs. Altough I used an OO approach previously for some subparts of the library it became somewhat difficult to maintain all those parts since they really are the same thing coded for each part (code duplication). So...
1
3151
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 many questions. To keep it simple, I'll describe the basics of what I'm trying to design. I've created a TextBox composite control that consists of a label for
7
3391
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 either AND or OR but never mixed together. We can use Northwind database for my question, it is very similar to the structure of the problem on the database I am working on. IF(SELECT OBJECT_ID('REPORT')) IS NOT NULL DROP TABLE REPORT_SELECTION
13
14617
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 Nicolai M. Josuttis. Chapter 14.) How to implement analogue of this technique via static polymorphism? Perhaps there is special design pattern for this purpose...
2
1499
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' So I see the number 3 can't be converted to string type automacially.
45
1881
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 python. maybe, one day, you will be able to program in VisualBasic" This hurts. Please give me informations about realy famous aplications.
5
2585
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 algorithm to solve a certain messy problem, and many different things. For that I often use several general modules that I have written, like implementation of certain data structures, and small general "utility" functions/classes, plus of course...
0
9275
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,...
1
9846
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
9713
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...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
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
5142
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
3806
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
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.