News for hackers. Stuff that matters.
Re:Anders Hejlsberg: You Can't Maintain Large Programs in Ja... by mgkimsal on Monday June 04, 2012 @07:29AM (#4063501)
As a couple others have said, you likely wouldn't need a codebase that size in JavaScript, even for an equivalent functionality, because of the type of programming the language allows.

A bit OT, but it might prove the point. I'm a Groovy enthusiast, and have done this exercise a few times. I'll give a presentation of Grails - basics of Grails, basics of Groovy, then demonstrate a Grails app. I'll walk through all the functionality of the app, then ask the Java developers in the audience for a guess as to how many lines of code they expect the app takes.

I clarify I'm asking for lines of code that I had to write, not necessarily in supporting libraries and such. I still get estimates from the Java devs of 25-30k LOC most of the time. Sometimes someone will be brave enough to estimate 15k. The real answer is closer to 6k.

Re:Anders Hejlsberg: You Can't Maintain Large Programs in Ja... by kristiandupont on Monday June 04, 2012 @09:10AM (#4063797)
I agree that JS code will generally be shorter than Java code because 1) you don't explicitly describe your types, and 2) JS is more expressive and there are things that you can just do more neatly.

However, there are many classes of code and #2 applies more to some than others. If you are writing something algorithmic like Peter Norvig's famous spell checker[1], the primitives of your language make a big difference. On the other hand, if you are writing something that is larger but of lower complexity where your code is more like configuration of a bunch of pages, this makes less of a difference.

Also, it's at least possible that the people who see your code assume a higher standard of maturity than your 6kloc has. We've all tried creating an apparently complete app rapidly, only to work on it for ages afterwards, implementing fault tolerance, graceful degradation etc. etc.

[1] http://norvig.com/spell-correct.html

Re:Anders Hejlsberg: You Can't Maintain Large Programs in Ja... by riffraff on Monday June 04, 2012 @05:58PM (#4066176)
anyone has evidence of similar projects done in java and javascript showing how js is much more expressive?

Sure, the lines end up less wide, but while you gain something by using function() over inner classes, you also end up reinventing package declarations and visibility all the time, so I don't see a clear advantage of one over the other.

(notice: I do understand people will generally do things in Java that they won't in JS, such as adding setters and getters, but I have seen that done in plenty of "big" js libraries, so I doubt that counts.)

Re:Anders Hejlsberg: You Can't Maintain Large Programs in Ja... by dalke on Monday June 04, 2012 @08:54AM (#4063737)
This may just mean that Java developers are poor at estimating LOC, or that you are a much better Groovy developer than they are Java developers.

Have you asked Grails/Groovy developers the same question? Have you written equivalent Java code to compare outright?

Re:Anders Hejlsberg: You Can't Maintain Large Programs in Ja... by mgkimsal on Monday June 04, 2012 @01:24PM (#4064908)
Good questions, and no. Anecdotally, talking to other Grails developers - ones who have switched from Java - they all acknowledge that they write fewer - often far fewer - lines of code.

I agree on the point that people may just be bad estimators, but I was assuming at least some of them have done approximate LOC counts on their own code from time to time to get estimates. I do.

Re:Anders Hejlsberg: You Can't Maintain Large Programs in Ja... by georgemcbay on Monday June 04, 2012 @02:11PM (#4065113)
"This may just mean that Java developers are poor at estimating LOC"

Surely he must have a FactoryOfFactoriesFactory class in there to make factories of his factory factories. That's at least 1k LOC right there!

Re:Anders Hejlsberg: You Can't Maintain Large Programs in Ja... by ternaryoperator on Monday June 04, 2012 @01:54PM (#4065032)
Agreed. And given that he's just taught the basics of Groovy to the audience, the likelihood of them being able to accurately project how many LOCs it will save them seems pretty low.
Re:Anders Hejlsberg: You Can't Maintain Large Programs in Ja... by mgkimsal on Monday June 04, 2012 @03:33PM (#4065493)
That's part of the point, in a way. Not to prove to people how much they don't know in a negative way (but maybe it comes across that way), but to provide a hopefully fairly shocking number to get them to rethink some of their basic assumptions about development. Using even a moderately different toolset can yield dramatically different (and I'd argue usually better) results.
Re:Anders Hejlsberg: You Can't Maintain Large Programs in Ja... by dalke on Tuesday June 05, 2012 @05:39AM (#4068031)
Is there any rigorous study more recent than Lutz Prechelt's "An Empirical Comparison of Programming Languages"? That estimates a factor of two difference in lines of code between Java/C/C++ and Python/Perl/Tcl, albeit for a rather small project.

So I've been using "factor of two" as a rough benchmark. Of course, this assumes appropriate library support; if most of the C code implements a priority queue while C++ has that as part of the standard library, then the comparison is invalid.

I don't know if for this Grails comparison if the extra factor of two comes from Groovy or from the effectiveness of Grails over whatever the Java programmers would use for web app development.