This evening, on Scala Programmers After Dark: True Confessions!
Tonight's topic: Are you curious about "monkey patching"? Hear what
others will admit when given dark glasses and dim lighting!
"I googled it once."
"I forgot what it is."
"I have no intention of ever doing it!"
Also be sure to join us next week, when we will ask leading scala
lumniaries about "hot fixes".
On 08/02/11 17:48, Russ Paielli wrote:
> Dynamic typing lends itself to rapid prototyping and generally
> getting small-to-medium-sized, non-critical applications up and
> running faster.
For the benefit of the curious, this particular statement is both very
popular and very not true in the veriest sense.
I think this belongs over in [scala-debate].
- --
Tony Morris
http://tmorris.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1Q//UACgkQmnpgrYe6r62UAgCgt7bG47UKfI9OYHRpUOtjSv5s
KyUAoMxAVrC8mm/I9KxBSVlW8RJ0HfBs
=JdfA
-----END PGP SIGNATURE-----
so far i've read
"less code, because you don't have to write the types" -> it's also potentially less readable & type inference can also achieve this
"faster prototyping" -> i disagree. i can write code quick & dirty in java which is the most cluttery language that i can handle. my ide takes care of writing a lot of the code for me.
-------- Original-Nachricht --------
> Datum: Tue, 08 Feb 2011 17:03:13 +1000
> Von: Tony Morris <tonym...@gmail.com>
> An: scala...@googlegroups.com
> Betreff: Re: [scala-user] benefit of dynamic typing?
I agree with you. My experience is that people are using "dynamic languages"
because they were scared away by very verbose and cumbersome statically typed
languages like Java to more fun-looking languages like Ruby. Not because they
actually need the dynamic parts, but more as some kind of protest and
demarcation against the established business/enterprise programming cultures.
Cheers,
Mirko
--
Mirko Stocker | m...@misto.ch
Work: http://ifs.hsr.ch | http://infoq.com
Personal: http://misto.ch | http://twitter.com/m_st
This is an excellent opportunity to point you at my favourite paper on this subject "What To Know Before Debating Type Systems" :-)
http://cdsmith.wordpress.com/2011/01/09/an-old-article-i-wrote/
--
paul.butcher->msgCount++
Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?
http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: pa...@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher
Somewhere in The Making of Python series of articles [1], Guido van Rossum explains why he
thinks dynamic typing is great. I should re-read them as I don't recall the exact arguments...
Still in Artima, I just found a small article [2] exposing some of the classical arguments
of dynamic typing and showing (in accompanying slides, not seen yet) how the same things
can be done in Scala...
From an uninformed point of view, to bring back the discussion on Scala, where, if I
understood correctly, dynamic typing have been introduced in trunk in some form or other,
I think one possible interest of dynamic typing is to avoid using reflection in some
cases, like building dynamically a data structure from some hierarchical markup language
(XML, Json, Yaml, etc.).
[1] http://www.artima.com/intv/pythonP.html
[2] http://www.artima.com/weblogs/viewpost.jsp?thread=253855
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --
(assuming that you've now read that link that I posted :-)
Bear in mind that anyone who is on this list (including me) is likely to be pro static typing, so you may not get a particularly balanced view here. Having said that, I've spent a great deal of time writing code in dynamically typed languages (primarily Ruby, but also Python and various Lisp variants) so I hope that I have a reasonable grounding in both cultures.
If you want one concrete example of something that's much easier to achieve in a dynamically typed language, take a look at mocking frameworks. Indeed, the framework that I've been discussing on this list over the last few days, even though it's written in Scala, is effectively dynamically typed (it passes AnyRefs around and casts them to what they "should" be at runtime).
If there's a way to achieve this without resorting to dynamic typing (or extra-linguistic techniques such as runtime code generation or a compiler plugin), I certainly don't know what it is. Although I'd be delighted if someone could point me in the right direction if it is possible.
On 08/02/11 20:44, Paul Butcher wrote:
> If there's a way to achieve this without resorting to dynamic
> typing (or extra-linguistic techniques such as runtime code
> generation or a compiler plugin), I certainly don't know what it
> is. Although I'd be delighted if someone could point me in the
> right direction if it is possible.
I know a way, but that depends on what you mean by mocking. By this, I
mean what underlying problem are you trying to solve by mocking?
I've seen a few answers to this, but there is one that stands out as
most popular: testing by quantifying against interface
implementations. Specifically, asserting that some property holds for
all instances of an interface. A noble goal indeed.
The short answer to your question is then,
"org.scalacheck.Arbitrary.arbFunction1" solves all problems that
mocking sets out to solve, although a little differently and more
effectively. I will attempt a brief explanation of why this is the case.
First, observe that an interface is a tuple of zero or more functions.
For example:
interface CharSequence {
def charAt(index: Int): Option[Char]
def first3Or(n: Int, or: => (Char, Char, Char)): (Char, Char, Char)
}
...is equivalent to the pair:
(Int => Option[Char], Int => (=> (Char, Char, Char)) => (Char, Char,
Char))
So then, the "quantification against interfaces" becomes
"quantification against tuples of functions."
With automated testing (not to be confused with xunit testing), we can
generate tuples of values for quantification if we can generate the
values to put in. This is because the notion of "generation" forms a
monad. So for the tuple (A, B, C) if we have generators for A, B and C
(genA, genB and genC), then we can get a generator for (A, B, C) as
follows:
for(a <- genA; b <- genB; c <- genC) yield (a, b, c)
Next the question becomes, can we get generators for functions (to
quantify over ala "mocking")?
If we formalise this question, we can get it down to the following
(important steps omitted here, but they are covered in the QC paper):
Can we inhabit this signature?
(T => Generator[A]) => Generator[T => A]
The answer is yes for a given useful definition of Generator.
In conclusion, if you accept this as a solution to the underlying
problem that "mocking" sets out to achieve, then the goal is certainly
achievable within a static type system (I have even implemented this
in Java). Indeed, it is static typing that makes it even more useful
than otherwise. So not only have you a solution within a static type
system, but it is significantly more thorough in the objective
(program correctness verification) and it also requires less effort on
your behalf (automation).
For more, see ScalaCheck, QuickCheck and automated specification-based
testing. The Java implementation, including an arbitrary generator for
function values, is in the Functional Java project. I have also
written this in python at a previous place of employment, but it is
useless/impractical in my opinion.
I hope that helps.
- --
Tony Morris
http://tmorris.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1RJwAACgkQmnpgrYe6r61uiwCfcpw3IJQC3KwZ7ivlla6m2wse
3OAAnRcJRrUYiFUtizogUHMThypUK7Gn
=/l69
-----END PGP SIGNATURE-----
I am familiar with ScalaCheck (although I've not used it in anger). I can see how it's a really useful tool for testing functional code. I'm struggling to see how it could solve the kind of problem that mocks (using the more traditional meaning of the word) address for code with side-effects.
This is probably best illustrated with an example. Imagine that I'm writing the control system for a nuclear missile installation. I'm trying to test the code that launches the ICBMs when the Big Red Button is pressed. Clearly I would rather avoid the side-effect of destroying the world each time I run my test suite :-)
Here's how I would do this with traditional mocks:
> trait Launcher {
> def launch(): Unit
> }
>
> class UserInterface(launcher: Launcher) {
> def bigRedButtonPressed() { ... }
> }
>
> "The Big Red Button" should {
> "launch ICBMs" in {
> val mockLauncher = mock[Launcher]
> mockLauncher.expects('launch).once
>
> val ui = new UserInterface(mockLauncher)
> ui.bigRedButtonPressed
> }
> }
This test should pass if and only if the launch function is called exactly once.
I'm not sure how I could achieve this with the approach you outline?
Personally, this reminder sent me back to your previous message and I am happy to have
followed the link, as I find that you captured well most of the debate.
> If you want one concrete example of something that's much easier to achieve in a
dynamically typed language, take a look at mocking frameworks. [...]
>
> If there's a way to achieve this without resorting to dynamic typing (or
extra-linguistic techniques such as runtime code generation or a compiler plugin), I
certainly don't know what it is. Although I'd be delighted if someone could point me in
the right direction if it is possible.
Indeed, I mentioned reflection to build classes but now I doubt we can do that (it can
change visibility and such, but not sure about creating fields for example).
IIRC, most Java-based mocking frameworks use bytecode instrumentation to generate the objects.
One big difference I've noticed between strongly-typed and weakly-typed languages: programmers who don't have a good foundation in programming with strongly-typed languages can't produce solutions very quickly or very well in strongly-typed languages, compared to what they can accomplish in weakly-typed languages.
Considering the vast armies of old VB programmers, as well as the newly-forming armies of JavaScript and PHP programmers, who I am positive would not be very effective using a strongly-typed language like Scala, there's little doubt these programmers would be able to generate solutions efficiently ot effectively without a weakly typed language.
Brian Maso--On Tue, Feb 8, 2011 at 2:44 AM, Paul Butcher <pa...@paulbutcher.com> wrote:
On 8 Feb 2011, at 06:42, HamsterofDeath wrote:
> maybe i don't see the obvious, but .... i don't see an advantage. none(assuming that you've now read that link that I posted :-)
> at all. what can one possibly achieve by inviting runtime errors?
Bear in mind that anyone who is on this list (including me) is likely to be pro static typing, so you may not get a particularly balanced view here. Having said that, I've spent a great deal of time writing code in dynamically typed languages (primarily Ruby, but also Python and various Lisp variants) so I hope that I have a reasonable grounding in both cultures.
If you want one concrete example of something that's much easier to achieve in a dynamically typed language, take a look at mocking frameworks. Indeed, the framework that I've been discussing on this list over the last few days, even though it's written in Scala, is effectively dynamically typed (it passes AnyRefs around and casts them to what they "should" be at runtime).
If there's a way to achieve this without resorting to dynamic typing (or extra-linguistic techniques such as runtime code generation or a compiler plugin), I certainly don't know what it is. Although I'd be delighted if someone could point me in the right direction if it is possible.
--
paul.butcher->msgCount++
Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?
http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: pa...@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher
Best regards,
Brian Maso
(949) 395-8551
br...@blumenfeld-maso.com
So you can do something like
Let object = // somehow dynamically discover an ActiveX called
"mine" in the current environment
object.doThis (1,2,3)
I guess, since the scala.nsc.tools.Interpreter is just one <<set (object,
XXX) andThen eval( "object.doThis (1,2,3)" )>> call away, we can easily do
that in scala as well :)
Cheers,
Razie
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 08/02/11 17:48, Russ Paielli wrote:For the benefit of the curious, this particular statement is both very
> Dynamic typing lends itself to rapid prototyping and generally
> getting small-to-medium-sized, non-critical applications up and
> running faster.
popular and very not true in the veriest sense.
Yeah things change a little once we start talking about side-effects.
Nevertheless, the situation is being addressed.
http://www.cse.chalmers.se/~rjmh/Papers/QuickCheckST.ps
- --
Tony Morris
http://tmorris.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1RtycACgkQmnpgrYe6r60XrACdFrMv1QywSGj/k6aGxExOcDoF
99EAn10aOzmkyyVuMpJIG/qUXd5keFLk
=ccb8
-----END PGP SIGNATURE-----
One thing I have found is that programmers who have a good foundation
in programming, and this includes type theory, intuitonistic log,
would rarely choose a language without significant machine-checked
static verification (call that weakly typed if you like) for practical
productive use.
- --
Tony Morris
http://tmorris.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1Rt7MACgkQmnpgrYe6r63WMgCgp/n6ppR49zwOvkjzIhj2a7F8
lf8AoMWNBSQ/T8DiM3DwZpA3b9/atXpI
=S4v7
-----END PGP SIGNATURE-----
On 09/02/11 07:19, Russ Paielli wrote:
> On Tue, Feb 8, 2011 at 12:33 AM, Tony Morris <tonym...@gmail.com>
> wrote:
>
>>
>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
>>
>> On 08/02/11 17:48, Russ Paielli wrote:
>>> Dynamic typing lends itself to rapid prototyping and generally
>>> getting small-to-medium-sized, non-critical applications up
>>> and running faster.
>> For the benefit of the curious, this particular statement is both
>> very popular and very not true in the veriest sense.
>>
>>
> I beg to differ. The rapid prototyping capability of, say, Python
> is well known.
I think if you interview those with a solid understanding of the
underlying computability theory, you'd get a different result. Even
so, "well known" does contribute anything.
> It may or may not constitute a significant advantage over Scala
> (or Haskell), but that's a separate issue from the truth of the
> statement quoted above.
It doesn't. I prototype my Scala with Haskell all the time. And here
is one of the major reasons why: when I screw up, the type system
shouts at me in a very informative way. There are a zillion other reasons.
Let's be clear, I have used python in depth. I have never met an
well-informed argument that claims it is useful for rapid prototyping.
Not even close. Surprise me.
>
> Personally, I would favor Scala over Python even for rapid
> prototyping, but I know at least one very competent aeronautical
> research engineer who uses Python to prototype advanced concepts in
> air traffic management. His focus is on the concepts and
> algorithms, and he feels that Python is the fastest and cleanest
> way to prototype them. I suspect he would appreciate Scala too if
> he tried it, but he just hasn't perceived the need yet.
I'm not sure why this is mentioned. The original statement remains false.
>
> Python is also very popular among scientists and engineers who use
> Numpy and Scipy for advanced calculation and rapid prototyping.
> These people may or may not be misguided, but I think we can safely
> assume that most of them are not simple-minded dolts.
There is a distinction between "being wrong" and being "simple-minded
whatever." The entire reason I use Haskell (practical static typing)
mostly in my work is because of the degree to which I am wrong. This
is a crucial factor in "rapid prototyping" and is the reason that even
Java trumps Python for such a task.
>
> --Russ P.
>
- --
Tony Morris
http://tmorris.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1RuesACgkQmnpgrYe6r61PpQCfUxCsNlMDgvRdQoAqolNgjM13
OvUAmwXfW3ORYuZwZBLiqnXwA3Oedowv
=TsbF
-----END PGP SIGNATURE-----
Building objects/functions from some description that is external to the
code (SQL, WSDL, JSON).
Take a look at E4X. The thing is great.
So dynamic typing benefits mostly in the integration sphere - plugins
and so on.
--
Best Regards,
Volodymyr Kyrychenko
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 08/02/11 18:50, Dennis Haupt wrote:Hi Dennis,
> i was hoping for a piece of code that shows how easily it can be
> written using dynamic typing and then showing how troublesome it
> was if one were forced to use static typing.
There is a reason that no such thing is forthcoming.I didn't see anyone say that on this thread, but I have heard it
>
> so far i've read "less code, because you don't have to write the
> types" -> it's also potentially less readable & type inference can
> also achieve this
countless times. It's nonsense and demonstrates a lack of
understanding of type systems. For example, it is extremely rare that
one needs to write type annotations in haskell. There are also
languages where *you only write types*. You end up with less code and
proof of program correctness. How about that -- terse and correct!That's because it's blatantly false, regardless of Java. These claims
> "faster prototyping" -> i disagree. i can write code quick & dirty
> in java which is the most cluttery language that i can handle. my
> ide takes care of writing a lot of the code for me.
merely invite education on the topic at hand.
====
To share an anecdote, I once worked with someone who told me that
dynamic typing was "great for prototyping" because to get started with
python, you simply write:
x = 3
"See! No handwaving with types!"
So I changed his file extension from .py to .hs and loaded it with
GHCi. We continued down this path; while I took advantage of the
richer libraries of haskell and more amenable syntax (for example, try
to achieve point-free or compositional programming in python; yeah
exactly). It wasn't long before there were bugs in the python code and
it was also messier. I invited him to try again. Same result again.
Unfortunately for him, he called me names and ran away. He didn't come
out of his office after that and I quit that job. I haven't seen him
since.
- --
Tony Morris
http://tmorris.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1RCBoACgkQmnpgrYe6r63NOwCdG5OwpEMOUTtl/mxAwZLzQJ/l
TFQAoKjjKiCiBvTYN4hNcNGNEPkenqiP
=ofPC
-----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Let's be clear, I have used python in depth. I have never met an
well-informed argument that claims it is useful for rapid prototyping.
Not even close. Surprise me.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 08/02/11 16:42, HamsterofDeath wrote:
> it's not related directly to scala, but what are the benefits of
> dynamic typing? what can you do that you can't with statically
> typed languages (especially scala)? maybe i don't see the obvious,
> but .... i don't see an advantage. none at all. what can one
> possibly achieve by inviting runtime errors?
>
>
>
Not all programs can be represented by a given terminating static type
system. Scala's type system is turing-complete, involving
non-termination. Runar Bjarnason recently proved this by encoding the
SK combinator calculus, which is known to be turing-complete.
In practice, and for a sufficiently practical type system, these
instances of programs that cannot be encoded are rare and so the
advantages of dynamic typing might best be paraphrased, "allows
expression of esoteric programs."
Unfortunately for progress in this
area, and for reasons for which I can only offer conjecture, these
cases are thought to be more common than is actual.
PS: I hope you're aware of the onslaught that you've invited.
On 2/7/11 11:48 PM, Russ Paielli wrote:This evening, on Scala Programmers After Dark: True Confessions! Tonight's topic: Are you curious about "monkey patching"? Hear what others will admit when given dark glasses and dim lighting!
Then there's "monkey patching." I googled it once, but I forgot what it is,
and I have no intention of ever doing it.
"I googled it once."
"I forgot what it is."
"I have no intention of ever doing it!"
Also be sure to join us next week, when we will ask leading scala lumniaries about "hot fixes".
> What nobody mentions is that languages with dynamic typing are perceived as EASIER to use and are DESIRABLE by the general population. There is plenty of empirical evidence to back that up: just look at all the people using said languages. There is not smoke without a fire. If people are using something means it meets their needs (or they think it does) and they see no compelling reasons to switch.
> I see people criticizing dynamic languages without ever spending enough time to try one. Yet, one of the most common reactions when someone says "Scala is too complicated" is "They haven't given it an good try". Maybe we should all give dynamic languages a good try, note the features that makes them being perceived as "easier" and try to add these features to Scala using libraries. Of course, not everything should make it across, and things like "monkey patching" are best left alone.
>
> Another interesting aspect of this never ending debate is the question: What makes Scala better than Java?
> - Omitting type declarations when declaring variables (also true for dynamic languages to a greater extent).
> - Closures (...also available in dynamic languages).
> - Passing functions to manipulate collections (also present in many dynamic languages).
I think a statically typed functional language like Scala really shines because functions are strongly typed. You know what you are getting because you say "I want a function that takes these parameters, and returns this type". As a callee in Ruby/Javascript you really can't guaranty you are getting an appropriate function passed to you without a bunch of runtime checks. In Scala you know at compile time whether things are peachy. When I presented the Scala Language Tour [1] to a Ruby UG, the oooos and ahhhs came after I showed them that functions are not just a generic honeypot, but are instead specific types based on parameters and return type.
Now, one can argue that *defining* the type of the function is really the equivalent of implementing the runtime checks... but my point is I am forced to *ensure* type-safety in Scala whereas I have to *remember* to in Ruby/JS.
The other argument I hear is "unit tests ensure type safety in dynamic languages". Ok, I kind of buy that, unit tests are good, but only as good as you can write them ;) I like my unit tests to focus on functionality, not language typing problems.
Craig.
[1] - http://basementcoders.com/2010/11/scala-language-tour/
Well, it does go further than that to be fair. All that typing also
helps the compiler generate more efficient code (by a considerable
margin). Everything in Ruby is dynamic dispatch (message passing) and
you really only discover things go wrong at run time and it's
basically impossible to optimize.
--
Jim Powers
On 10/02/11 02:08, Tom�s L�zaro wrote:
> I stil don't understand when people say it's faster to prototype in dynamic
> languages.
Argumentum ad ignorantiam. It doesn't get any easier than that.
- --
Tony Morris
http://tmorris.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1TGiIACgkQmnpgrYe6r62StACgxcsK4GVRZ3Q84sPM5rt581IJ
S5cAn0Dyy3gPJdbUUxcT3xmKRodYBVkS
=hftG
-----END PGP SIGNATURE-----
If we're talking about rapid prototyping and rapid application development, static typing is the least of one's worries.
Having an environment where the UI is designed quickly, persistency generated automatically and all those other things one needs are automated, that's what gives you whatever speed you're looking for here. If you just want to hack text and syntax that may or may not work, then nothing can stop you but don't tell me that's what makes you more efficient.
That's not it! The environment, libraries and tools ( including automated build and deployment tools) make the difference.
Type swing java code in vi and you're just as hopeless and slow as doing JavaScript web apps in whathaveyou. Once it compiles you know it *may* work but throw nullpointers...While the JavaScript thing - well, there's no knowing that it would even work.
Resilience to change and content assist can be implemented even in JavaScript with the right tools, it's just that its not enforced by a compiler. Same as swapping the wrong jar file at runtime and getting "method not found" exceptions.
...I forget, what were we arguing here?
Oh, instant results. Much like fixing java code in the middle of an eclipse debugging session and continue with the fixed code, after eclipse deployed the fix and instantly rolled back to the caller? Can your python interpreter do that? Or it starts over again?
I don't see a big difference between properly test-harnessed and continuously integrated apps of either static or dynamic type.
So I don't think any of the things said here are what the real difference is ... The seriousness and completeness of the environment makes the difference! The specificity and applicability of the language to the problem domain, including libraries is!
Having said that, without a compiler to double check my wiring I feel like writing assembly on paper :)
And as a last note, dynamic languages I've seen tend to *not* have the level of development support usually associated or expected from static ones.
Thanks,
Razvan
To me, all these things add up to programming by bluff. If nothing calls
your bluff at an inopportune time, you may congratulate yourself on a
job well done.
And if you believe that it is better to be lucky than good, then this
will appeal to you.
It does not appeal to me.
Note that nothing I've said is about the relative virtues of so-called
dynamic languages vs. so-called static ones. But if this is your
approach to programming, choice of language or language characteristics
aside, then I think it does just amount to programming via bluff and
bluster.
Randall Schulz
Randall R Schulz wrote:
> On Wednesday February 9 2011, Ittay Dror wrote:
>> After reading the thread, I think the main benefit of dynamic
>> languages is that you need to know less before starting to program in
>> them: * no need to learn much about type systems
>> * no need to know how to set up a build system
>> * less need to design well - these languages lend themselves more
>> easily to hacking ("oh, i've got an instance with a missing method,
>> well, i'll just add it now")
>> * quicker way to learn as you type - no compilation, just reload the
>> page etc.
>>
>> Ittay
> To me, all these things add up to programming by bluff. If nothing calls
> your bluff at an inopportune time, you may congratulate yourself on a
> job well done.
You can bluff in statically typed languages as well: NPE,
ArrayIndexOutOfBounds, etc. Maybe static languages (esp. scala with,
e.g., Option) make it hard for you to bluff, but it comes down to good
design. And with good design you are also safe in a dynamic language.
What I feel dynamic languages lack are these:
* external analysis: which allows navigating between classes in the IDE,
code completion, early detection of typos/missing arguments etc. These
are important for a large code base
* good support for refactoring. for large code bases, when you refactor
a method, you want to be sure of all the places that use it.
* performance and optimizations
** Note: I wanted to link
http://shootout.alioth.debian.org/u32/javascript.php as proof, but it
seems that javascript is up to 70 times faster than java there...
s/Haskell/Agda
To best understand the issues of the original question, learn a more
advanced language along with several different type systems with
various trade-offs. Python, Scala and friends do not cut it. This is a
plea in disguise.
- --
Tony Morris
http://tmorris.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1ToH8ACgkQmnpgrYe6r63ODQCgwGIHuVkmfuf767HcZp1DF48l
27YAnjFhqJmdnwTPtkA5+C62JVaCBy5B
=QbjJ
-----END PGP SIGNATURE-----
Its a pretty emotive subject and given you're posting on a statically
typed language mailing list you're probably already preaching to the
choir. (Scala is my favourite language too BTW).
For me the main advantages of dynamic languages are:
* simplicity: you can pick up any decent dynamically typed languages
like CoffeeScript, JavaScript, Ruby, Python, Groovy et al in a few
hours typically. I've been doing Scala for a while and I still keep
learning things about the language and its type system. Scala is very
deep. Given their simplicity you feel you can master
JavaScript/Ruby/Groovy as a language pretty quickly as the language
doesn't do as much (though you then just spend a lifetime learning
APIs and trying to remember the names of methods :). There's
definitely a crowd of folks who just wanna get stuff done easily; for
them a simpler language has appeal.
* compiler speed: while this isn't true of all static and dynamic
languages, with Ruby / JavaScript / CoffeeScript apps, you hit reload
in your browser and everything reruns near instantly. e.g. to start
the CoffeeScript/JavaScript build tool Cake, re-generate the
CoffeeScript parser then run all its unit tests takes about 0.35
seconds on my laptop. You're typical JVM based language build tool has
barely even had chance to print that its starting to run by that time.
e.g. SBT takes 61 seconds to compile scalate-core on my laptop (1408
classes) after pausing for a few seconds before even deciding to
compile anything.
While I love Scala to bits, SBT is just about noticing you changed a
file by the time a typical Rails/JavaScript web app reloads itself and
renders itself on your browser. Scala's compiler is relatively slow
compared to dynamic languages - as its doing loads more things and it
generates much faster code at the end (so its a trade off really). But
when folks are building relatively small apps, just grabbing some data
from a database or web resource of some kind and painting it in a
browser the RADness of dynamic languages is very appealing due to the
very fast code-reload loop. Its also worth noting that in many typical
web apps; you've HTML, CSS, JavaScript/JSON, SQL to deal with most of
the time - dynamically typed languages of sorts, so having static
types in your programming language when most of your work is spent
moving columns from SQL/JSON to objects to HTML elements / ids /
classes; using static typing doesn't have a massive benefit as you're
mostly just moving named slots around.
While things like the REPL shell, JRebel and SBT really help give
Scala a bit more of a dynamic language feel, its still not really in
the same RADness league as the JavaScript/Ruby's of this world. But
then there's loads of applications out there that are large, involve
large teams and are not 'small' apps that hit this dynamic language
sweet spot; where incremental compiling with things like SBT start to
become a little better.
For me though the benefits of Scala far outweigh the advantages of
dynamically typed languages; though I hope the Scala community keeps
trying to improve the simplicity for programmers (e.g. easier to grok
docs that hide more of the language plumbing) & try to improve the
compiler speeds & incremental building features so that it feels more
like the RADness of dynamically typed languages.
Though I guess one big remaining benefit for one particular
dynamically typed language, JavaScript is the user interface platform.
These days all browsers, modern mobile devices and tablets have a
pretty quick JavaScript engine. The webkit + JavaScript user interface
platform does make JS appealing (or rather CoffeeScript which compiles
very quickly to JS or can be interpreted directly in the browser).
While I'd sooner write Scala, the user interface landscape is pulling
me towards CoffeeScript purely for its compiler speed, RADness and the
fact that it runs nicely inside all browsers and devices without a
really slow code generation step (am looking at you GWT; imagine
taking GWT and adding the slow scala compiler in there too, how unRAD
that'd be).
I'd love it if one day we could use Scala as a kinda CoffeeScript
alternative; though given how slow both GWT and the Scala compiler
already are, I suspect it'd just be too slow and unresponsive for UI
development. Though there's still plenty of other software out there
where Scala is the perfect choice! :)
--
James
-------
FuseSource
Email: ja...@fusesource.com
Web: http://fusesource.com
Twitter: jstrachan
Blog: http://macstrac.blogspot.com/
Open Source Integration
** Note: I wanted to link http://shootout.alioth.debian.org/u32/javascript.php as proof, but it seems that javascript is up to 70 times faster than java there...
Ittay wrote: "to learn *much*"
You mostly learn about strings, ints, floats, something to structure that, and some simple
collections (lists, hash maps) and you are good to go.
I still see things like
def padTo [A1 >: A] (len: Int, elem: A1) : Iterator[A1]
as a bit scary (slowly starting to learn type theory, covariance and similar concepts).
On 09/02/2011 23:59, Razvan Cojocaru wrote:
> Type swing java code in vi and you're just as hopeless and slow as doing JavaScript web
> apps in whathaveyou. Once it compiles you know it *may* work but throw
> nullpointers...While the JavaScript thing - well, there's no knowing that it would even
> work.
I use Eclipse all day on a large Java code body, partially unknown, and I really
appreciate it.
But if we are talking about fast prototyping and small scripts, I appreciate being able to
fire my favorite lightweight editor (I get it in the second while I wait up to one minute
for Eclipse to start on the 5 years old Windows computer we have at work), type a few
lines and get instant result.
I can do small scripts in Scala and I appreciate it, it is one of the first compiled,
statically typed language I use offering coding facilities (type inference) and capability
to run as script. But its startup time isn't stellar, compared to, say, a simple Lua script.
It can be unimportant (to do a task occasionally) or not (to run a script 100 times per day).
> Oh, instant results. Much like fixing java code in the middle of an eclipse debugging
> session and continue with the fixed code, after eclipse deployed the fix and instantly
> rolled back to the caller? Can your python interpreter do that? Or it starts over
> again?
I admit that's a very nice feature of Eclipse (as long as you keep changes within a
method). IIRC, Visual Studio was able to do that for C[++] code way before Eclipse.
> Having said that, without a compiler to double check my wiring I feel like writing
> assembly on paper :)
I did that in my early days of computing (coinciding with early days of personal
computers). I had at school a board with an hexa keyboard and LED display, and we had to
write down on paper the assembly mnemonics, compute by hand the jumps, and use tables to
convert all this to hexa... Was fun! For very simple code... :-)
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --
If you're not, why don't you take it to scala-debate.
Just an observation from the outside, unfortunately adding to the noise (and I
tilt my head in shame).
Regards,
-Martin
> If we're talking about rapid prototyping and rapid application development, static typing is the least of one's worries.I disagree. Static typing imposes that you make decisions "early"
often resulting in a poor type zoo. The point of a (literal)
prototype is to explore the solution space then possibly throw away
the actual result and move forward with some better understanding.