Pages: [1]
|
|
|
Author
|
Topic: Re: Static vs. Dynamic typing (Read 4114 times)
|
|
chiguireitor
Zebranky food
Offline
Posts: 10
|
Hehehe was thinking on bringing python to the fray too (if you take a peek, you'll see that uqmonline is hosted on a Google App Engine "server" which uses python)... but don't want a flame war to start There's two kinds of programmers: the ones that love static typing and the ones that love dynamic/duck typing.
Being a simultaneous programmer on both kind of languages (i use DAILY Object Oriented Pascal, Perl, Python, Javascript and Java) i really like the expressiveness and flexibility of dynamic/duck typing and the functional power of those languages (loved Prolog and Ocaml when i used them on the university).
Things like monkey patching are great and add a lot of value to dynamic languages. However, all these dynamic languages cannot exist without their static brethen and most of those fancy interpreters are coded in one of those less flexible languages, keep that in mind always.
Quick Edit: Didn't know that here in this forum were python coders good to know
|
|
« Last Edit: June 14, 2011, 04:52:53 am by chiguireitor »
|
Logged
|
|
|
|
Megagun
Enlightened
Offline
Gender:
Posts: 580
Moo
|
static typing (a big plus)
I don't know what planet you're coming from, but I don't see how static typing is a "big plus". Dynamic typing may not always catch errors early on, but it makes a language much more flexible. One fairly small example is the ability to use the special value None in Python, rather than resorting to values like -1, since a variable can be any type instead of being restricted to, say, integers. This can actually be extremely useful in certain situations. If you think that that is a big advantage of dynamic typing, you haven't worked with statically typed languages enough. Here's a bit of code that does what you want, plus some more, written in Java (a statically typed language):
int i = 0; //primitive data types such as int can't be null Integer j = null; //Integers can be null Object oj = j; Integer joj = (Integer) oj; //cast Object to Integer The real advantage of dynamically typed languages is that the language syntax can be a lot smaller, and more advanced features can be implemented way easier. Java code tends to be rather extremely verbose, yet Python code is small and elegant. This can be annoying though when you have to read someone else's code. Have fun digging through code to find out what a variable named 'foo' contains! Furthermore, dynamically typed languages allow you to extend existing code with extra features without a lot of pain.
The major advantage of statically typed languages is that stuff will be checked for you at compile-time, which will save you a lot of pain if you're developing an application to launch nuclear missiles at hostile forces. Furthermore, IDEs tend to be a lot nicer for statically typed languages, as they're far more capable of figuring out what exactly that variable named 'foo' contains without running your application and figuring it out that way (bad idea), doing expensive code analysis, or making the user specify it manually in a comment-annotation.
|
|
« Last Edit: June 14, 2011, 05:57:19 pm by Megagun »
|
Logged
|
|
|
|
chiguireitor
Zebranky food
Offline
Posts: 10
|
Now we can flame each other correctly here hahahahaha
Thanks meep-eep
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
|
|