The Artima Developer Community
Sponsored Link

Artima Developer Spotlight Forum
Steve Yegge on Rhinos and Tigers

66 replies on 5 pages. Most recent reply: Jul 12, 2008 10:14 PM by Gregor Zeitlinger

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 66 replies on 5 pages [ 1 2 3 4 5 | » ]
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Steve Yegge on Rhinos and Tigers Posted: Jun 16, 2008 9:44 PM
Reply to this message Reply
Advertisement

Google's Steve Yegge gave a presentation at the recent Google I/O conference, focusing on his work with Rhino, the JVM-based JavaScript implementation. Yegge published a transcription of his presentation in Rhinos and Tigers.

While most of Yegge's talk centers around the importance of server-side scripting, and why Rhino and, by extension, JavaScript, are good choices for scriptable server applications, he also discusses the choice between static and dynamic typing in a language. He especially notes that Scala's more rigorous type system can pose a dilemma to Java developers who prefer static typing on the JVM:

I've got the [Scala] language spec here in my backpack. Oh, my god... I mean, like, because it's getting a little bit of momentum, right? So I figure I've got to speak from a position of sort of knowledge, not ignorance, when I'm dissing it...

And so before, I was like: "Oh yeah, Scala! Strongly typed. Could be very cool, very expressive!"

The... the the the... the language spec... oh, my god. I've gotta blog about this. It's, like, ninety percent [about the type system]. It's the biggest type system you've ever seen in your life, by 5x. Not by an order of magnitude, but man! There are type types, and type type types; there's complexity...

But the funny thing about Scala, the really interesting thing — you guys are the first to hear my amazing insight on this, OK? — is: it's put the Java people in a dilemma. There's a reeeeeeeal problem...

The problem is, the Java people say, "Well, dynamic languages, you know, suck, because they don't have static types." Which is kind of circular, right? But what they mean, is they say: No good tools, no good performance. But even if you say, look, the tools and performance can get as good, they say, "Well, static types can help you write safer code!"

It's... you guys know about those talismans? The ones, where, "What's it for?" "To keep tigers away"? (some chuckling) Yeah? And you know, people are like, "How do you know it keeps tigers away?" And your reply is: (sneering) "Do you see any tigers around here!?" (minor laughter)

Scala, now, is the tiger that's going to kill Java. Because their [type-talisman] argument now has become a paradox, similar to the Paul Graham Blub Paradox thing, right? Because they're like, "Well, we need static typing in order to engineer good systems. It's simply not possible otherwise." The Scala people come in and they go: "Your type system suuuuuucks. It's not sound. It's not safe. It's not complete. You're casting your way around it. It doesn't actually prevent this large class of bugs. How many times have you written catch (NullPointerException x) ... in Java? Our type system doesn't allow [things like] that... Our type system does what you said your type system was doing...

So, therefore, you should be using it!

And the Java people look at it and go: "Wehellll... (cough cough)... I mean, yeah, I mean... (*ahem*)" (running finger under collar, as if sweating profusely) They say, "Welllll... you know... it's awfully... cummmmmbersome... I..."

"We can actually get around the problems in practice that you guys say your type system is solving through Good Engineering Practices."

Yegge follows these notes about the Scala type system with some examples from his own work where dynamic languages were able to scale to large numbers of users, as well as large numbers of developers:

Let's do proof by – say, argument by example! You know, an existence proof. IMDB is written in Perl, right? Yahoo! – many of their properties are written in PHP. A lot of Microsoft stuff's written in VB, right? ASP .NET? Amazon.com's portal site is Perl/Mason...

A lot of companies out there are building big, scalable systems – and I mean scalable in the sense of throughput and transactions, stuff like that, but also scalable in terms of human engineering — in these dynamic languages with no static types. [Using nothing more than good engineering principles.]

What do you think about Yegge's comments regarding Scala's type system and dynamic languages?


Fred Garvin

Posts: 52
Nickname: fredgarvin
Registered: Jan, 2008

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 12:36 AM
Reply to this message Reply
Yegge cleverly uses Scala's impressively sound, yet overly complicated, type system as a means both to poke fun at holes in Java's type system and to show how static type systems can be more complicated than they are worth. He misses the point, however, regarding the ultimate goal of a static type system.

Call me crazy, but in my opinion the real purpose of a modern static type system should be to *help people* read, write, and maintain good code. That's it. If it's not doing that, if it's making me think about rules of generic variance and not my logic, something is wrong. If it's making me type a lot of type literals in my code instead of inferring them, something is wrong. Indeed there's a laundry list of type system related failures in Java, but does that mean static typing proper is a failure?

It would be much more constructive if Yegge and others would think about what good comes from static typing. A solid static type system paired with a friendly and familiar Java-like grammar with a heavy dose of type inferencing would be hard to dislike. Think of all the tools that could be built around a language like that. Think IntelliJ IDEA. Think C# 3.x features. Static typing enables deterministic refactoring, code analysis, code navigation, code completion, etc. At the same time you have a dynamic feel to the language with pervasive type inferencing, closures, and extensions. In essence you can have the best of both worlds.

I'm bored with smug dynamic vs. static talks like Yegge's.

Paul Beckford

Posts: 51
Nickname: phaedrus
Registered: Feb, 2007

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 5:22 AM
Reply to this message Reply
Type inference doesn't help that much either. It has the same problems, but just requires less key strokes. Take a look at this paper:

http://pico.vub.ac.be/%7Ewdmeuter/RDL04/papers/Bracha.pdf

Your basic point is right. The compiler should help were it can, and get out the way were it can't. The problem is that with an imperative language you cannot statically verify your code as correct. It is that simple.

The best options I've seen so far are:

1. Go pure functional and use something like Haskell.
2. Use a more expressive static type system like Scala.
3. Use a pluggable type system as an optional tool where it helps.
4. Focus on program correctness instead of type safety and rely on TDD/BDD instead.

I agree with Steve, Scala serves to show the limitations of the Java approach. Scala is more "safe", but it is a lot more complex (and ugly) as a consequence.

Once people become more aware of the downsides of static typing, then a pluggable approach as advocated by Gilad Bracha becomes more attractive. DYnamic approaches become more attractive too. It comes down to education I think.

Steve could moderate his tone, but what he is saying is correct.

Paul.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 6:52 AM
Reply to this message Reply
> Type inference doesn't help that much either. It has the
> same problems, but just requires less key strokes. Take a
> look at this paper:

I love how Bracha gets right to the heart of the issue. In the first few paragraphs, he basically sums up the whole dynamic vs. static typing debate:

"Types provide a conceptual framework for the programmer, that is extremely useful for program design, maintenance and understanding."

"the fact is that a mandatory type system greatly reduces the number of legal programs that can be expressed in a language"

(I assuming 'legal' implies valid and correct here)

"real systems tend to be too complex to formalize."

That's really it. And the idea of having both is something people using Jython (or others) are doing right now. Maybe a language that incorporates both would be useful and granted mixing two languages could be cumbersome in relation but this isn't just a possibility, it's reality.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 6:58 AM
Reply to this message Reply
> Type inference doesn't help that much either. It has the
> same problems, but just requires less key strokes. Take a
> look at this paper:

With regards to inference, I'm not sure I get his point. One of the advantages I see of type inference in Scala is that because you have not annotated your type, you can actually go around and change everything else and as long as that is consistent, it will still compile. The focus on the developer's work seems off target.

Nemanja Trifunovic

Posts: 172
Nickname: ntrif
Registered: Jun, 2004

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 7:23 AM
Reply to this message Reply
> A lot of
> Microsoft stuff's written in VB, right?

Wrong. Besides, VB.NET is statically typed.

> ASP.NET?

Almost all ASP.NET code is being written with static languages such as C# and VB.NET (not that it makes much sense, IMHO, but it is still a fact).

Paul Beckford

Posts: 51
Nickname: phaedrus
Registered: Feb, 2007

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 7:47 AM
Reply to this message Reply
> > Type inference doesn't help that much either. It has
> the
> > same problems, but just requires less key strokes. Take
> a
> > look at this paper:
>
> With regards to inference, I'm not sure I get his point.
> One of the advantages I see of type inference in Scala is
> s that because you have not annotated your type, you can
> actually go around and change everything else and as long
> as that is consistent, it will still compile. The focus
> on the developer's work seems off target.

I haven't used type inference much, but I'm happy to take Gilads word for it. He is right about most things :)

I think his point is that the restrictive nature of a given static type system is no less restrictive just because the types are inferred rather than manifestly declared.

Logically this makes sense I think.

Paul.

Doug Clinton

Posts: 1
Nickname: dclinton
Registered: Dec, 2007

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 8:56 AM
Reply to this message Reply
Ahh, good old Steve Yegge. It's funny, because none of the Scala fans I've heard talk about it are saying that Scala is going to kill Java. Quite the opposite, they're very happy that both can co-exist.

The main debate I have been hearing is whether to basically freeze the Java language feature set and use Scala for the more advanced stuff like Closures, etc., which, it is becoming apparent, do not shoe-horn well into Java.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 9:24 AM
Reply to this message Reply
I just noticed this from the original post:

> How many times have you written catch (NullPointerException x)

I can honestly say I've never done this (to my best recollection) in a production application. I'm not saying there's never a case where you would want to do that but I haven't run into it. I'm not really sure what it resolves. You need to solve the root issue of the NPE. The only times I've seen NPE's produced consistently was in a system were squashing exceptions was the norm.

Carson Gross

Posts: 153
Nickname: cgross
Registered: Oct, 2006

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 9:28 AM
Reply to this message Reply
> I haven't used type inference much, but I'm happy to take
> Gilads word for it. He is right about most things :)
>
> I think his point is that the restrictive nature of a
> given static type system is no less restrictive just
> because the types are inferred rather than manifestly
> declared.
>
> Logically this makes sense I think.

Well, let's look at a simple example:

<pre>
var foo = getAFoo()
foo.doSomething()
</pre>

In a statically-typed-but-inferred language like C# 3, that will compile no matter what the return type of <code>getAFoo()</code> is as long as that type has a method on it called <code>doSomething()</code>. So you get some form of duck typing there, making your program more flexible than a statically typed system with no type inference.

I agree with Yegge that Scala is even more out of hand than java, but that's because the design center for their type system is soundness, rather than ease of development. When a type system gives you solid code-completion and refactoring tools, it has helped you. When it forces you to write hieroglyphics to return a list of Foo's, it has hurt you. So static type-system designers should optimize for the former and avoid the latter.

This current discussion is throwing the baby, the tub and all the copper plumbing, plus a viking range, out with the bathwater.

Cheers,
Carson

Max Lybbert

Posts: 314
Nickname: mlybbert
Registered: Apr, 2005

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 10:20 AM
Reply to this message Reply
/* Let's do proof by – say, argument by example! You know, an existence proof. IMDB is written in Perl, right? Yahoo! – many of their properties are written in PHP. A lot of Microsoft stuff's written in VB, right? ASP .NET? Amazon.com's portal site is Perl/Mason...
*/

A lot of Microsoft's stuff is written in C#, and much of Windows is still in C or C++ from what I understand. VB.NET essentially took the language model expected by the CLR (static typing, exceptions, OOP), and gave it a VB-like veneer.

Yegge used to work at Amazon, but my understanding is that much of the Perl has been replaced with Java.

For the record, I really like Perl. It took a while, but I even like Javascript and Python. I think it's instructive that Microsoft has statically typed languages and dynamically typed languages. I find it interesting that the CLR is being modified to work better with projects such as Iron Python. I've noticed that Google uses statically typed and dynamically typed languages. I can't think of many professional development shops that are 100% statically typed or 100% dynamically typed. In the end, I think Yegge's gone a little far in his "dynamic languages for everything" belief.

Paul Beckford

Posts: 51
Nickname: phaedrus
Registered: Feb, 2007

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 11:47 AM
Reply to this message Reply
> > I haven't used type inference much, but I'm happy to
> take
> > Gilads word for it. He is right about most things :)
> >
> > I think his point is that the restrictive nature of a
> > given static type system is no less restrictive just
> > because the types are inferred rather than manifestly
> > declared.
> >
> > Logically this makes sense I think.
>
> Well, let's look at a simple example:
>
> <pre>
> var foo = getAFoo()
> foo.doSomething()
> </pre>
>
> In a statically-typed-but-inferred language like C# 3,
> that will compile no matter what the return type of
> <code>getAFoo()</code>

Yes. But I believe this is because 'var' means "use duck typing here please". That is not the same as type inference, where the type is inferred from the context. So:

foo::doSomething() {
answer = "done";
return answer;
}

The complier can infer that 'doSomething' has a return type of String. This is no different that manifestly stating the return type as String, which I believe is Gilads point.

Paul.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 11:59 AM
Reply to this message Reply
> Yes. But I believe this is because 'var' means "use duck
> typing here please". That is not the same as type
> inference, where the type is inferred from the context.

That is incorrect. Assuming we are talking about Scala, the type of that variable is inferred from the context and it uses that inferred type to determine whether the doSomething() call is legal. If the type of foo did not have a doSomething() method declared, the code would not compile.

The difference (as I understand it) between this and duck-typing is best explained with an example. Suppose we have three types: A, B, and C where B and C extend from A.

A has method foo(), so via inheritance, so do B an C.
B has a method bar().
C has a method bar().

Note that even though B and C both have a method bar(), they are declared separately.

Now consider the following code (I think this is valid Scala, humor me if I've messed up):

var object
= if (test) {
new B()
} else {
new C()
}

object.foo() // OK
object.bar() // does not compile


If duck-typing were used, there would be no problem with the second call.

Carson Gross

Posts: 153
Nickname: cgross
Registered: Oct, 2006

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 1:27 PM
Reply to this message Reply
> If duck-typing were used, there would be no problem with
> the second call.

Right, which is why I said "something like duck-typing." The C# 3 code above will be less likely to need to be changed as you modify code in other parts of the system since you aren't forced to annotate the types.

I'm not convinced that the benefits of being able to write object.bar() above are worth the costs, because I like solid code completion, navigation and refactoring tools, and dynamic languages, especially JavaScript, ain't gonna give them to me.

(I know everyone keeps saying they will, but they can't and they won't. If you have to execute all your code to figure out what the actual upper-bound type of a variable is... I don't know why I bother arguing about this.)

I also find being able to delete a method and run a relatively fast compile (versus a ten minute test suite) to see what's broken pretty useful.

Static type systems are about tools first, and correctness a very distant second. The academic communities focus on soundness and the implementation of many of their ideas in Java generics has caused a lot of us day-to-day developers to recoil in horror, quite correctly IMO. But, as I said above, there is baby and bathwater to separate here.

We *can* have a terse, statically typed programming language with "scripting sensibilities" (e.g. a killer change-the-code-and-hit-refresh development cycle) that supports all the great tools that the guys at JetBrains keep cranking out.

Seems to me that the statically-typed community needs to find someone who works at Google, or maybe Facebook, and who writes semi-coherent, stream-of-consciousness postings that don't admit that there are any trade offs to be made in language design, so we can keep up with Mr. Yegge.

OK, that was a bit offsides...

Cheers,
Carson

Paul Beckford

Posts: 51
Nickname: phaedrus
Registered: Feb, 2007

Re: Steve Yegge on Rhinos and Tigers Posted: Jun 17, 2008 1:35 PM
Reply to this message Reply
> > Yes. But I believe this is because 'var' means "use
> duck
> > typing here please". That is not the same as type
> > inference, where the type is inferred from the context.
>
> That is incorrect. Assuming we are talking about Scala,
> the type of that variable is inferred from the context and
> it uses that inferred type to determine whether the
> doSomething() call is legal. If the type of foo did not
> have a doSomething() method declared, the code would not
> compile.
>
> The difference (as I understand it) between this and
> duck-typing is best explained with an example. Suppose we
> have three types: A, B, and C where B and C extend from
> A.
>
> A has method foo(), so via inheritance, so do B an C.
> B has a method bar().
> C has a method bar().
>
> Note that even though B and C both have a method bar(),
> they are declared separately.
>
> Now consider the following code (I think this is valid
> Scala, humor me if I've messed up):
>

> var object
> = if (test) {
> new B()
> } else {
> new C()
> }
>
> object.foo() // OK
> object.bar() // does not compile
>

>
> If duck-typing were used, there would be no problem with
> the second call.

OK. I think I get you. There is a difference here to duck typing. I'm not convinced that the difference is that significant though.

Besides you need to guess where to use var ahead of time. I'm not convinced. Lets see if it catches on :)

Paul.

Flat View: This topic has 66 replies on 5 pages [ 1  2  3  4  5 | » ]
Topic: Steve Yegge on Rhinos and Tigers Previous Topic   Next Topic Topic: Sun Releases JDK 6 Update 7 with VisualVM

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use