527 points · by haasted · 15y ago · 489 comments
A Dart to JS compiler will never be "decent" compared to having the Dart VM in the browser. Yet I guarantee you that Apple and Microsoft (and Opera and Mozilla, but the first two are enough) will never embed the Dart VM. So "Works best in Chrome" and even "Works only in Chrome" are new norms promulgated intentionally by Google. We see more of this fragmentation every day. As a user of Chrome and Firefox (and Safari), I find it painful to experience, never mind the political bad taste
From here: https://news.ycombinator.com/item?id=2982949
The Dart to JS compiler doesn't have to be "decent" compared to having the Dart VM in the browser to be useful in a world where other browsers don't use the Dart VM, it merely has to be "decent" compared to handcrafted JavaScript performing the same task in another browser.
If direct Dart code runs faster than JavaScript on Chrome, that's a nice bonus, but if it runs as well as similar code that was originally written in JavaScript on the other browsers (when the Dart code is compiled to JS) that's good enough. Dart on the other browsers isn't competing with Dart on Chrome, it is competing with JavaScript on the other browsers and that's how it should be measured.
And if it turns out apps in Dart on Chrome really blow away apps in JavaScript on other browsers to the point where both devs and users start embracing Chrome even more for these gains then hopefully that will light a fire under everyone else to either adopt Dart or do something to fix what would then be an undeniable problem of JavaScript.
If the Dart → JS compiler produces "good enough" results, and web authors wind up adopting it en masse, then suddenly a chunk of the web "works best in Google Chrome", and every other browser manufacturer is put into a very, very awkward position. They can do nothing, in which case their continued relevance depends on Google continuing to ship the Dart → JS compiler (and diminishes as users switch to Chrome). They can license the Dart VM from Google, in which case their continued relevance depends on Google continuing to license the VM and we have another large chunk of the Web based on a single binary monoculture (which worked so well for Flash!). Or, they can try to develop their own Dart VM, in which case they'll be eternally chasing the tail-lights of Google's VM, kept behind by Google's head-start and Google's engineering power. None of those options is very pleasant, in the long run, for anybody who doesn't own Google stock.
As Brendan's original comment points out, this choice is not unique to Dart. Currently browser makers have picked option 3 ("write our own") to deal with V8, option 2 ("licence Google's implementation") to deal with WebM, and so far option 1 ("ignore it") to deal with SPDY.
Under the carefully-managed tension of ECMA, the ECMAScript standard has become a much more practical language to develop in directly, and to target from higher-level languages — and with the agreement of all the major browser vendors including Google. It's not immediately obvious that a project like Dart is even needed; even if it is a major technical advance, it's a political regression.
Why should Google put the brakes on improving client side development just because it puts other browsers in the uncomfortable position of having to license Dart (for free, since it is OSS and has a liberal patent grant)?
The same would be true if Microsoft created some sort of .NET->JS compiler with their own VM for IE, or if Mozilla did the same with some new language. As long as they bridge to JavaScript, more power to them. Client side web development could certainly use some of the tools that these different language environments could offer and if it kicks off another performance race to get browser-side languages even faster (especially on mobile devices), so much the better for everyone.
I really don't see how there is any downside (to anyone but maybe Brendan Eich) to widespread usage of Dart unless the Dart->JS code proves to be suboptimal, but in that case devs won't use it.
Finally, you seem to have missed the fact that Mozilla is already working on an experimentatl implementation of SPDY in Firefox: http://bitsup.blogspot.com/2011/09/spdy-what-i-like-about-yo...
Really though, Brendan has made the argument that Javascript is fixable and that it is a good target for higher level languages, and I don't really agree with either of them.
The changes I see being planned for ES.next don't really address some of the fundamental problems with JS, like network transport, or startup costs because of legacy constraints of not wanting to break existing JS. On mobile devices, loading a lot of Javascript is expensive, and I don't see anything in ES.next to bring it anywhere near competitive with native. If mobile is the future and the predominant way we consume the web, then we are at big risk of being dominated by native. Can we afford to wait years more for a promised fix that isn't even in sight?
For a mobile device, ideally you'd want a dynamic language that could be atleast partially statically optimized for a particular device platform, and transmitted in a highly compact format that is cheap to parse and execute on a mobile VM to not make the device waste bandwidth or precious battery performing tasks that could be done on the server for it (like executing a parse and eval)
Likewise, I don't agree that JS is an ideal intermediate format for higher level languages to compile to. I'm not saying LLVM or JVM bytecode are either, but if your HLL contains numerics like 64-bit ints or longs, for example, it's pretty crappy to translate. There's also double costs here: You're running a HLL compiler to parse, compile, and optimize one language, which then must be parsed, evaled, and optimized a second time on your target CPU.
Something like DVM, or a bytecode specifically designed for JS would be better I think.
If you run Google's closure compiler on JS, for example, in some cases, it produces a very significant speedup than hand-tuned hand-written JS, so saying "never be decent" is a pretty strong claim to make.
It seems pretty obvious to me that unless Google fucks up the VM implementation, it'll always be much faster than compiling to JS, which doesn't even implement the same concepts - let alone semantics - of Dart. In fact, if VM is not much faster, why would they have it at all?
Being faster than handwritten JS is irrelevant, because the VM will be faster still, and that's the difference he's talking about.
The keyword Brendan used was "decent", and frankly, I'll take a stab and say performance of Dart to JS will be beyond decent.
Google hasn't made dart so we can make our web apps faster. They made dart because there's a lot of java developers at google who believe that its easier to write monolithic javascript applications (GMail, G+, etc) using a language like java.
They believe it enough that they will try to convince others to follow suit.
Obj-C and Java are not browser-supported. Sure, there's a native apps vs. web apps contest. Native is winning? Not according to Fred Wilson (AVC) and other observers.
Who knows, really. We're speculating, but let's find out by doing. Mozilla is working on both Open Web Apps that run in modern browsers, and Boot To Gecko.
Edit. I'll have to retract the above. BootToGecko is the mobile platform from Mozilla. It would be awesome to market it harder as such.
Think of it this way: what is GWT? GWT os compiling Java, a statically typed language, into Javascript. If you've used GWT you'll know that particularly early on there was a lot of friction. What's simple in Javascript with anonymous objects and duck typing doesn't quite gel with Java so you've had to do things like use JSNI for edge cases.
Google has some incredibly large and ocmplex JS apps (eg GMail). While GMail isn't written in GWT, GWT is aimed at that kind of application with deferred binding and the benefits of static type analysis.
What if you took that expertise (of GWT and static type analysis in producing Javascript) to produce a language that could run on the server, run in the browser (for browsers that support that) and compile to Javascript (for browsers that don't)?
The last point is particular is key to driving adoption as no one is going to develop only for Chrome.
I see it as no surprise the syntax is Java-like. I fully expect sometime soon to see a JVM implementation that will then leverage all the existing Java libraries.
In that context (IMHO) it makes a lot more sense. It might not be solving the problems you're interested in but it is definitely solving a particular set of problems.
You make this sound like its a bad thing, but that's open-source always and forever. Scratch your own itch.
http://gwtgallery.appspot.com/
http://www.gwtsite.com/whos-using-gwt/
http://www.reddit.com/r/programming/comments/aqsxq/does_anyo...
http://www.quora.com/What-web-applications-use-Google-Web-To...
You now even have options!
[1] https://github.com/jashkenas/coffee-script/wiki/List-of-lang...
One of the biggest pain point in web dev is the inconsistent DOM implementations. I was imagining some sort of DOM-less, HTML5 Canvas-based UI controls. And something about the "Web", Semantic Web/URIs or a new approach to programming on Web. This is NOT a break away language in any sense - its more re-packaging.
The engineer that wrote the memo needed people for his team. To get people to join a team from any of the others at Google, you need to convince them that your team is awesome to work with. At Google, you can't offer more money/benefits, so it has to be a "join us and you'll change the world!" message. That's going to lead to a lot of overblown statements that may or may not end up being true, and may or may not even be believed by the author.
Google is not in the business of doing things that are bad for the web (and when they have done, there's been an about-face, see: Google Video shutdown), even if internal machinations might make it seem that way.
I don't know what the timeline is for Dart but I will say this:
1. If anyone is capable of the long sort of time frame that something like this can benefit from--event requires--it's Google;
2. If there is anyone who's qualified as a domain expert in Javascript generation it is, by virtue of GWT, Google; and
3. If there is anyone who's qualified to speak to the limits of what you can do with Javascript it is, by virtue of Chrome and V8, Google.
If anything, I believe the error here (if you can call it that) is failing to properly set expectations and communicate the goals of the language (as witnessed by all the comments on this thread from people who were expecting something more and/or different).
Google should be proposing a standard, open, byte-code compatible, Intermediate Language standard that can run Javascript and in the interim run on Javascript.
That is something I could see Mozilla and Apple getting behind.
Only once they have actively campaigned for this should they be adding new languages to the browser which fracture the web.
I had hoped that Dart would surprise us and turn out to be a 'machine-code for the web' implementation. This would have been a much smarter move, I believe.
It was really sad to see everybody moving to Flash JavaScript could've done video/audio and games a long time ago.
> That is something I could see Mozilla and Apple getting behind.
Why would you expect either Mozilla or Apple to get behind such a proposal? Apple has a powerful self-interest in making sure the Web remains a second-best app platform behind iOS and desktop OS X. Mozilla wants the Web to be the premier app platform - but it's no bloody good to Mozilla if the web is the world's #1 web platform but Mozilla has no control over it anymore. The last thing Mozilla wants to see is the Web browser become some fairly-easily-implemented, highly-interchangeable runtime platform adhering to a stable, open spec somewhere. This would, I think, be very good for the world at large, but it would undoubtedly be very bad for Mozilla - it's what is known as the commoditization of the platform. Mozilla's self-interest is served by keeping as much of the Web as possible controlled, in the minutest detail possible, by the hard-to-join club of major browser vendors. Right down to things like the lexical syntax of JavaScript. So in reality, as soon as Google proposed such an IL, Mozilla's advocates would start blowing smoke about "oh no, another Java".
Also, going back to 2006 or so when I invited pre-Google Alex Russell and other JS hackers to Ecma TC39 meetings, Mozillans including yours truly have tried to open up the standards process. Mozilla, Opera, and Apple co-founded the WHATWG and set up an open membership structure for it in 2004, to create HTML5. W3C finally relented and internalized much of that structure.
So alleging that "Mozilla" is trying to keep the old boy's club closed is simply false.
I've cited hard, in some cases physical (as in physics) reasons for why there won't be a lower-level bytecode standard for browser-based VMs any time soon. I'm not blowing smoke.
http://www.aminutewithbrendan.com/pages/20101122
A high level bytecode sounds a lot like minified JS source, with a relatively-few extensions to the standard language. Extending is easier than replacing or setting up a new, parallel cross-browser standard.
Your inflamed sense of grievance at "Mozilla" is misplaced. Mozilla has no control other than what users of our software delegate to us by trusting us enough to download and run our stuff. We do not have hundreds of millions in our browser advertising budgets. We do not have billions of revenue with which to influence people or pay for attention and distribution.
If we are really in the way of Web standards, I'll personally pull the plug.
Certainly, VM byte code languages are often simpler than silicon processors' machine languages; perhaps they offer safety guarantees; and perhaps they provide garbage collection. These are all big wins for language implementers targeting such VMs.
But what no virtual machine will ever do is make modules written in different source languages work together transparently. Any time one module calls another module written in a different language, at least one side of that boundary needs to be written with a detailed understanding of both languages' semantics.
Tiny details of the semantics influence the idioms people settle on in that language --- and interfaces are designed around those idioms. For example, JavaScript conditionals treat the empty array and the empty object as true, while Python conditionals treat them as false. Each of these facts shapes what people expect of a "natural" API in that language --- and that ensures that modules written in other languages will always "speak with an accent", or seem unnatural, at best.
You can define a common data world, as the .NET CLR does, and extend each source language to cover that world, but the effect is to change each participant language into a gloss on the common data world. This is why CoffeeScript fits seamlessly into the JavaScript world: JavaScript's and CoffeeScript's data worlds are exactly the same. CoffeeScript cannot deviate from JavaScript's types and objects.
Each programming language is like a city occupying an island: commerce within the city is much less expensive than commerce between islands. Although it's sometimes worth it, dealing with "foreigners" is confusing and risky. No VM will change that.
Mozilla "conspires" to do almost exactly the opposite of what you suggest. Having lots of decent browsers available was our old success condition. Now the mobile world is starting to look locked up, so breaking that open to competition and free choice is our new success condition.
Really? I thought that was the _mission_ of Mozilla. Except for the "stable" part perhaps, because that's quite at odds with innovation.
The track record easily shows that pretty much every single thing you have said is wrong.
class Foo implements Comparable Observable Deniable ...
Why not have interfaces like in Go, where you just define a set of methods and all classes having the methods will automatically implement the interface. Collection<E>
HashMap<K,V>
HashSet<E>
LinkedHashMap<K,V>
List<E>
Map<K,V>
Set<E>
Why not just Array and Hash? And what's up with the whole generics thing - that's just plain old Java. int
bool
String
Object
Why do some types start with lowercase and some with uppercase letter. Why not use a sensible naming convention? square(n) => n + n;
square(5); // returns 25
square2(n) { n + n; }
square2(5); // returns null
Why not have an implicit return value everywhere?I could go just on and on...
Primitives and objects, it kind of makes sense but I do see your point.
> Although you might expect int and double to be primitive types, they're actually interfaces that extend the num interface. This means that int and double variables are also nums.
Is it really necessary in the 21st century to create a language that terminates lines with semicolons? I am sure I have seen some other languages in the past that get by just fine without them.
For example value types would be excellent. Even better would be explicit regions, but I'm sure that's not going to happen.
Also, please fix this:
The type system is unsound, due to the covariance of generic types. This is a deliberate choice (and undoubtedly controversial). Experience has shown that sound type rules for generics fly in the face of programmer intuition. It is easy for tools to provide a sound type analysis if they choose, which may be useful for tasks like refactoring.
And add proper generics. If sound type rules fly in the face of programmer intuition, that means that the programmer's intuition is wrong. The proper response is to inform the programmer of his mistake at compile time, and not to silently ignore it and add dynamic type checks on every contravariant use of generics including array access! That is worse on both programmer productivity because the programmer expects that his program is type safe when he is using static types and on runtime speed because the dynamic checks slow down all programs needlessly. Dart already has dynamic typing; use that when you want it, not something that looks like static typing but really is dynamic typing.
Another thing that would be awesome is if you provide a compact binary format for code.
- no braces where avoidable, no semicolons where avoidable
- release early a free, open source reference development environment that really helps in developing with Dart. The biggest pain with Javascript, imho, is in the lack of development tools really thought out for it, and not just an adaptation of Java/C/whatever other editors
- if you develop said IDE as a web-IDE, even better (why not writte in dart itself?)
- give as many inobtrusive visual cues as possible to easily see tab alignment, syntax coloring, etc.
- integrate unit testing facilities in the IDEBut from a new language standpoint, it's not worth dropping them. The ridiculous arguments that come out of it, the programmers who refuse to use the language because of it, they're things that can and should be avoided by using semicolons like most languages.
I'll never understand why programmers care so much about this, but hey, that's life.
If you semantically, and naturally, communicate "end of statement" with a line break to human readers, why should you have to say it again with a semicolon to the compiler? Programming languages should focus on being DRY.
For those people who come from "ugly" languages like Java you could have a feature in the IDE which auto-inserted (and of course auto-removed) the braces/semicolons so that they felt at home too.
Seeing how Go, which "wasn't done yet" either, handled external feedback... I don't see why anyone would have hopes for dart.
- Requiring a redundant mechanism to mark blocks
- Possible introducing situations where code looks differently than how it executes
is all very mid-90s. python was the first to fix this, but yaml and coffescript do to. In particular, Dart will have to compete with mindshare from .coffee, so at least should be better than that.
I'm fine with the semicolons, but I'm not too keen on using underscore-starting identifiers to determine what is public and what is private.
> I'm not too keen on using underscore-starting identifiers to determine what is public and what is private.
That's also been discussed. It has more going for it than may be at first apparent, but it has detractors too.
I shouldn't need to write 'Point p = new Point(2, 3);'
var p = new Point(2,3); should be inferred as a Point
It's like learning how to read, or learning how to read a new script. At first, you focus on the letters, composing words or sentences. When you get more experience, you read ever-larger blocks of text at once and you no longer need to read aloud or read aloud in your head, you can read whole lines or several lines at once and immediately transfer the concepts embodied in them into your mind (this is effectively how people read - chunks of text at a time, it's also why it's easy to read text where the letters of all words are mingled except the first and last one, a feat that is impossible when reading letter by letter or even word by word).
Anyway, in reading/writing code it's the same - at some point you no longer see a line with statements, you see a block with initializations, or no longer a set of if/then or switch statement, you see a jump table. Once you get to that level, dollar signs to denote variables disappear from the mental model you have, because you no longer see tokens - you see variables (same with semicolons, braces, most indentation, etc.). That's where the comparison came from.
(I also think that that's where eloquent code comes from - it's from programmers who make an efficient and recognizable translation from high-level concepts into the mechanics of the programming language, even if there is no explicit support for such concepts in the language).
if (a == b)
&& (c == d)
it will guess a line end after the first closing paren. WTF?Python is a totally different beast, and I wouldn't include it in the discussion, because it also uses whitespace for block grouping.
The only (contrived) advantage of using semicolons that I can think of is to avoid potential problems with line wrapping. For example, some mail clients add new lines after 80 characters, which would be more likely to break Dart code than JavaScript.
"Concurrency is supported via actor-like entities called isolates. An isolate is a unit of concurrency. It has its own memory and its own thread of control. Isolates communicate by message passing (10.14.4). No state is ever shared between isolates. Isolates are created by spawning (10.11)"
http://www.dartlang.org/docs/spec/dartLangSpec.pdf
I wonder how they compile this down to Javascript?
An interesting question is if this means V8 is gaining threads.
Admittedly, however, I do cringe whenever I see things like x.compareTo(y) or X x = new X();
I mean here in this thread we are already seeing it. Some people like semicolons, some people don't. Some people like a prototype based object system, some people like a class based system. And on and on.
I think what would really benefit us is a platform (like a JVM for the browser with a great API replacing the dom) where people could implement languages against. we would get
1) A lot of competition of languages (see what is happening on the JVM right now... Clojure, Scala, Groovy ... you name it), hopefully giving us better languages. Javascript has its strenghts but could you imagine that in such an environment a language that doesn't allow you to test whether or not something is a string would make it very long?
2) People could make their choice and be happy. Then you can program the server and the client in the same language, which is pretty much the main argument for server-side javascript.
Let the languages compete instead of giving us one and now another language for the platform!
Before Google I worked on an academic project that built a small Smalltalk-like VM that was also a compilation target for something that was very close to unthreaded Java. Worked pretty well.
This would indeed be nice but it seems that google wants to push the language more than the VM. I quite get this because saying "you can now run your favorite language for the browser" seems much much more attractive than saying "look we made programming language 1001 and this is what you people should be using now!".
> In general it's easier to put a typed language on an untyped runtime than it is to put an untyped language on a typed runtime.
I have no knowledge of how one would do this but a lot of dynamically typed languages exist for the (I am assuming) statically typed platforms such as the JVM and CLR now.
I like Clojure and have dabbled with clojurescript but the workflow feels pretty hacky and it is clear that this is not what javascript was made for.
But if they released an open-source version of IE, started shipping IE frequently for Windows, Macintosh and Linux and released the Dart language spec and implementation under an open-source license... well, then I'd like it a lot better.
It doesn't really make sense to ask "Why should I switch from a language I already love?" If you're already productive and love what you're using, then you should probably keep using it.
There are people who want a language that is more modular, scales better than JS for programming in the large, for IDE tooling, or ahead of time compilation, etc. Take a look at the Dart spreadsheet Total for example (https://code.google.com/p/dart/source/browse/branches/bleedi...) I find this code a lot cleaner than JS versions I've seen.
The project page is very unclear, so I ended up on Wikipedia instead. Wikipedia actually has a leaked memo that seems to do a really good job describing the purpose of the language.
Specifically, the language is meant for three environments: server-side, compiled to JavaScript client-side, and fast native client-side once there is browser support. (The main goal is better performance on the client-side, which is deemed to be very difficult with JavaScript.)
However, the language looks so Java-like, one wonders why they didn't just use Java and extend GWT with a native Java client in Chrome. Did it just not make sense to bet the farm on Java when Oracle controls it?
Also, what does the "structured" in "structured web programming" mean?
Dart's a lot more like CoffeeScript than Java.
I would guess it's a reference to the optional static typing. There's a growing movement behind static typing and functional programming that resembles the movements behind dynamic typing and OOP of a decade ago...
The "Hello, Dart!" is written to a console emerging from underneath the code sample.
https://code.google.com/p/dart/source/browse/branches/bleedi... is a more DOM-oriented version of the same program.
http://www.dartlang.org/docs/technical-overview/index.html#h...
http://en.wikipedia.org/wiki/Dylan_programming_language
It was created in the 1990s and it still looks innovative, even compared to a lot of the new 'hot commodity' languages like python and ruby. I knew it wouldn't happen.
If a big corporation like Google put money into something like that, I think it would dominate the market.
But what they have delivered here isn't even interesting.
(The other option for something I would want would be standardized 'web byte-code', so that you just re-target a compiler back-end to emit it, and your language can be used as if it were javascript.
This is neither of those thing and I am sorely disappointed.
Dylan could have been what Objectiv-C is now. It was an awesome project it just had bad timing.
Not a big surprise. PL specialists (let alone theorists) have no place at google. Just look at the previous language coming from outside Google... Go.
Greeter greeter = new Greeter()
or var greeter = new Greeter()
Defining a constant: static final myConst = 1
Plus there are classes, interfaces... It's just Java?Well, it's hard to get that much better than that.
> Plus there are classes, interfaces... It's just Java?
Java didn't invent classes. It certainly looks a lot like Java, but it's more Smalltalk under the hood.
var greeter = Greeter()
there, no need for `new`.Alternatively,
var greeter = Greeter.new()
or var greeter = greeter new
if it's not acceptable to have arbitrary callable objects.> it's more Smalltalk under the hood.
The speed and wide-spread use of Smalltalk with the regularity, flexibility and terseness of Java's syntax? That sounds like a recipe for success.
Agreed. I didn't say you couldn't get better at all, just not much better. I'd personally be in favor of ditching new (or conversely making it a method on the class).
> The speed and wide-spread use of Smalltalk with the regularity, flexibility and terseness of Java's syntax?
Oh, you. You may be right. Making a new language is crazy, especially if you're aiming for widespread adoption. Still, you have to try, right?
Dart is definitely more terse and more flexible than Java. Maybe not perfect, but it's heading in the right direction. Dart is no DSL-friendly beauty like Ruby, but I think:
var odds = [1, 2, 3, 4, 5].filter((i) => i % 2 == 1);
is pretty tolerable without being novel enough to scare people that have never programmed outside of a curly brace language.Ok, fine, but why have both forms?
I'm somewhat disappointed that they insist on a 90's C syntax. It's like Python/Ruby/Coffeescript never existed.
C'mon Google, you can do way better...
Reading these comments I've come across the words: boring, uninspired, underwhelmed...
I couldn't agree more.
JavaScript's prototypal object model can at least keep my attention.
Things I've noticed so far that I don't like: get/set proliferation, semicolons, braces, positional args, var for instance vars, int/num dinostyle pseudo-primitives.
It seems like they tried to do some cool things, but failed in execution. Like "Greeter.withPrefix(this.prefix);" one-line constructor definition .. where this.prefix is a "shortcut that assigns the parameter's value to the instance variable prefix". Eliminate needless code.. but instead of using a dedicated symbol to call attention to the sugar, they used "this." WTF.. did they specifically want to kill scanability.
Things I've noticed so far that I like: using "_" as a prefix to enforce encapsulation.
Enforcing naming conventions as syntax seems at least somewhat python inspired in the sense of bringing the whitespace is significant design to naming is significant.. wish there had been more of that.
If someone other than Google were doing this it would be dead in the water already.
1. Consuctor syntax requires repeating the name of the class when yor define the constructor. So if you change a class name, you have to carefully find all your constructors and rename them.
2. Instance variables in classes seem to be defined at the same level as class methods. Yet one is an instance attribute, and the other a class attribute. So you have irregular scoping rules based on type (data vs. function). This scares me as it indicates functions are "special" and not first-class types in the language.
> leaky and half-featured classes.
This is a common willful misconception. CoffeeScript classes are isomorphic to JavaScript prototypes -- the do precisely the same thing. In addition, there is a shorthand syntax for prototyping objects, if that's more your style: Dog = ->
...
Dog::bark = ->
...
Dog::run = ->
...
Note that the above will produce the same result as: class Dog
bark: ->
...
run: ->
...That said, CoffeeScript provides another interesting use for them: Simulating dynamic binding. Basically, the trick is that `this` becomes the dynamic binding context and `@` represents a dynamically bound variable. You use `fn.call @, x, y, etc...` if you want to pass the dynamic binding to callees. Nested bindings can be established with `Object.create`
- JQuery examples like to abuse 'this'.
- I should always, explictly provide the event as a parameter in the callback.
So '@' is always the object, and 'event' is whatever started the method.
I never use inheritance.
Since I started to do this, my code has become much simpler and cleaner.
They should have just embraced Coffee script.
I would say this is a bit too early to take on the 'maximist' attitude, no?
Like munificent said, someone has gota try. At least he put the flag post down somewhere, and I'm sure he's having fun. Where the maximist point of view doesn't help at the moment is that most of the time It is projects like this one where out of the 1000 features, one or two are genuinely super super awesome new.
Eventually in time, after many projects like this, you end up merging all the 'cool' things you've learned you come up with something super awesome. Somewhat like learned progress. Already the project has grouped many minds together, and that has got to be beneficial.
In fact I don't remember the last time anyone has offered up so many voices in such short time to any language actively being developed nor even in the infantile stages such as this one.
Btw, from a philosophical point of view, today's 'web developer problem' might not be tomorrow's 'web developer problem'.
I'm perfectly willing to live with the Java-like syntax and feel, so long as:
- I can write in the same language on both the client and server side - Solid libraries exist on the server side for interaction with RDBMSes, web services, etc - Good tooling support
Those of you complaining about the syntax...do you honestly think regular javascript is any better? Personally, I loathe javascript's syntax and inconsistencies...if Dart can solve that and give me good server side programming support, I'll sign up. That's the problem with things like Node today...the server side libraries are loosely documented and implemented IMO...it's very much a Wild West environment.
Why would different syntax or explicit types change that?
I don't think you have to replace JS to get better server-side libraries, and better language doesn't automatically give you better libraries and documentation.
You know I'll probably use those socks someday, but its not what I was really hoping for.
Sure, it needs a few refinements here and there, but by and large Javascript is an incredible, flexible, and battle tested language. As a web developer with 11 years of experience, who has worked professionally with RoR, Java, PHP, MySQL, Oracle, and PostgreSQL, my feedback is just stop.
The world doesn't need another tool that obviates the need for engineers to learn Javascript to program on the web. Seriously, Javascript isn't that difficult. Just learn it, buckle down and spend a couple months writing Javascript and you'll be just fine.
If half the time spent writing Dart had been spent learning Javascript instead, then you would think in prototypes instead of classes, anonymous functions instead of one off objects, callbacks instead of um... not having callbacks, and dynamic variables instead of casting, casting, casting.
I'm not claiming Javascript is better then your language of choice, I'm just saying that as a language, it's awesome. It's not broke, and as a web developer I'm not looking for something to replace it.
Javascript has problems. If it didn't, no one would be trying to evolve it and address it's weaknesses. The language had serious weaknesses, some of which were addressed recently (TypedArrays, strict mode, etc) and some of which there is no current fix (consistent, standardized, namespacing and modules), and some of which cause big performance holes ("with" statement).
Prototype based inheritance is extremely verbose to use. That's one reason why CoffeeScript is well liked, and why Classes are coming to JS. Prototypes and eval() also make it hard to develop language analysis tools and IDEs which can provide correct code assistence, which can refactor large code bases, etc
Javascript isn't broken if you're just writing a few lines of JS in jQuery to enhance a web page. But it doesn't really scale well if you're got 500klocs of code and a decent sized distributed team.
P.S. Don't ever use the term "klocks" unless you want to sound like a enterprise middle manager who hasn't touched code in 20 years. Just a friendly tip. :)
P.S. Snide remarks such as that make you sound like a junior programmer who thinks he knows everything. Just a friendly tip ;)
Of course Javascript has problems, every language has problems associated with it. They all have strengths and they all have weaknesses.
From what I've seen, projects like GWT, Dart, and Coffeescript come out of communities of developers other then the web development community. GWT and comes from Java engineers as an attempt to not have to write javascript, Coffeescript comes from Ruby developers attempting to accomplish the same thing. Now Dart is another attempt by the Java community to not write Javascript.
The thing is, I never hear from the web development community that Javascript is broken, missing major features, and needs to be replaced. These are the people using Javascript every day. The people that say Javascript needs these features are people who don't use it that much.
You didn't address any of his points though. Where are the great Javascript tools and IDEs? There are tons of them for languages with static typing and classical inheritance.
Here's just one tiny example: Compare how you go about refactoring code (renaming classes, functions, etc) in Javascript with the many ways that it may be done in Java or C#.
The way I understand it, a terse syntax is useful in getting something working quickly. However, this is not necessarily the best code when it comes to performance or maintenance. Adding "boilerplate" code not only makes the compiler/interpreter more efficient, it also makes the job of the maintainer much easier. Personally, it takes me less time to figure out what a particular piece of code is doing if the datatypes of variables and return values of functions are obvious.
Dart seems to understand this well and so makes typing optional which is useful for prototyping but then also allows you to refactor and explicitly include types to gain performance and improve maintenance for production code. Am I missing something? If not this sounds pretty exciting to me.
"Dart will include a rich set of execution environments, libraries, and development tools built to support the language. These tools will enable productive and dynamic development, including edit-and-continue debugging and beyond—up to a style where you program an application outline, run it, and fill in the blanks as you run."
Sounds like a Smalltalk-style debugger running in the browser.
Though it seems these tools aren't actually ready yet: "This is a technology preview, not a product launch" -- http://dartinside.com/2011/live-from-dart-launch/#liveblog-e...
a = 1
a = "1"; // errorIt takes a day to get used to Python syntax, and another day to make it subconscious, that is to stop forgetting it.
The arrow in CoffeeScript is a pain to type, but overall CS saves you a lot of time.
How come Google that can dictate rules to some extent, doesn't have the balls to fix the long lasting issue with syntax? Why voluntarily subject oneself to, probably, years of pain?! Did they just start following letter-by-letter the success stories, like the one of Javascript? (scheme+smalltalk+java/c syntax)
I can't find an explanation to this.
If this were as commonly supported (and as performant) as JavaScript, and if, as I expect, this allows DOM manipulation, I would prefer it over it, if only for the strong typing.
Also, I haven't read the spec yet, but I would expect the 'VM' to run Dalvik code. If so, this will make it easier to port your web app to Android.
document.query("#menu").nodes.add(sliderMenu.node);
So, yes, DOM manipulation is there albeit kind of ugly. document.querySelector('#menu').appendChild(sliderMenu.node);
If you have suggestions for improvement, please do pass them along.That is, with gwt you get
- strongly typed java syntax
- it abstracts away browser differences, and supports many browsers
- it lets you run mostly the same code on client and server, and gives you access to lots of java libraries on the server
With dart, it seems you get a weaker java syntax, and you lose access to all the existing java libraries on the server. You also seem to get a new interpreted server side environment. Maybe that will be better/faster than the JVM, but that is not obvious to me.
Overall, I agree with a commenter above who said that they should have defined a general VM for web browsers, similar to the JVM, but simpler/faster/more appropriate. Then, all kinds of languages could be cross compiled into it, while you could use the language natively on the server.
I think their original memo got many of the problems right - javascript has become a limiting factor in advancing web development - but I think the solution lies in a more general VM approach.
I think Dart is the preferred way to target that VM. Staying at the language level eliminates binary format headaches!
Besides, the web should not be binary.
I'll happily adopt a new browser language if it offers me benefits that I don't get from Javascript, but I really don't get the new trend of compile to Javascript languages.
https://code.google.com/p/dart/
(Look in the bleeding_edge branch)
Currently doing a repo pull here so I haven't had much time to look around at it yet. I'm cautiously optimistic though, it looks quite a bit like I was hoping Dart would look (a bit of the ECMA4/ActionScript feel on top of JavaScript).
There's a compiler that translates to JavaScript, and a standalone VM.
Does anyone on the Dash team have any feedback on why you guys decided not to go that route?
As for the preferred format, I suspect code with ; and {..} may remove some ambiguity, so it should execute faster. That's the decisive argument in my book.
Besides being useful by itself, I understand Dart as an intermediate language: other languages should compile into Dart. Its syntax should be extremely consistent, so code can be reasoned about.
For one day we'll need 99% accurate machine translation, like from chinese to english and back, but from Perl to Python or Javascript. In some respects that should be easier: translated functions can be tested to work identically.
But, technically what Dart introduces is nowhere new. Have a look for instance at Opa (http://opalang.org) which is open source and already does more than Dart. If you take out the marketing bulls... that it is going to replace JavaScript, when it now just compiles into JS as many other do.
However, it seems like this would actually make it harder to package up dart script files efficiently to minimize multiple http requests; it would be nice if dart had some way of emitting a single packaged up dart file as part of the html translation process.
class Sunflower {
static void main() {
new Sunflower();
}
No thank you! I would rather stay with prototype objects.print('${(1<<31)}'); -2147483648 (correct value is 2147483648)
print('${(1<<30)+(1<<30)}'); 2147483648 (correct)
print('${(1<<30)+(1<<30)+(1<<30)+(1<<30)}'); 4294967296 (correct)
print('${(1<<30)x(1<<30)x4}'); 4611686018427388000 (correct value is 4611686018427387904)
(I've used x instead of star here as the latter does not display on HN.)
This is completely nonsensical.
But mathematically it doesn't make sense to have an int type which does not represent integers consistently. Clearly Javascript can represent 2^31 as a positive integer. In fact it can represent 2^53 as a positive integer (of course in reality it uses a double precision float) as can be verified by typing (1<<20)x(1<<20)x(1<<13) into a Javascript console.
So why is (1<<31) not positive? This is surely something which needs to be fixed in Dart. If they want to make (1<<31) negative, then (1<<30) + (1<<30) should equal (1<<31) and so it should also be negative. Otherwise doing arithmetic is difficult and error prone, which makes it unsuitable as a target for other languages which want to compile down to Dart.
In fact, not having at least 32 bit unsigned integers would be a major drawback. For efficiency reasons you want these to be handled directly by your VM using integer assembly instructions. This is the only way that you'll ever implement efficient bignum libraries for example which require FFT's which necessarily use integers that are an exact multiple of 32 bits in length (Z/pZ for p = 2^(2^L) + 1 usually, where 2^L is a multiple of 64 at least, usually).
"Integers are not restricted to a fixed range. Dart integers are true integers, not 32 bit or 64 bit or any other fixed range representation. Their size is limited only by the memory available to the implementation"
So they obviously haven't got this right. Not only does their implementation not implement this, but it is completely broken anyway because you certainly won't be more efficient than Javascript if your integers are implemented as bignums instead of floats.
main() { var _ = 1;
;;;;;;;;;;;;;;;;;
;; ;;
;; ( (){ }() ) ;;
;; (_ ^_^ _) ;;
;; {; _|_ ;} ;;
;; ;;
;;;;;;;;;;;;;;;;;
}
http://try-dart-lang.appspot.com/s/y8YOUnless the compiler is improved a lot, dart->js' runtime overhead probably makes it impractical for any app less than gmail-size.
Programming language is not just a technology. It's a way of communicating my thoughts. I don't want to think and write (and read!) in just an _efficient_ language.
does that mean all integer math is emulated? Long emulation is slow enough in GWT, but you have the choice of using int if you don't need a long.
Dear Google: seriously? :(
Sorry to be critical, but this looks like technology for technology's sake.
It's early days, and they haven't presented yet, but son I am disappoint.
I guess I'm not super-excited about it because I was expecting something revolutionary, but when you think about where they're coming from, it was to be expected. Lars and co are simply building on V8, so it makes more sense that Dart is some sort of improvement on javascript, rather than something entirely new.
It just doesn't have the syntax for maps that javascript has for objects.
What is frustrating is that there are so many people who can do this job right, yet we are stuck with amateurish programming languages designed by companies like Google. Please try and hire people like Oleg Kiselyov, Simon Marlow, Erik Meijer or some one from the possible hundreds who have worked deep in PL theory for literally decades. On the face of it Gilad Bracha has great credentials, credentials that would make the HR folk happy but one look at some of the stuff he writes and we know things are not going to be good.
http://gbracha.blogspot.com/2011/06/types-are-anti-modular.h...
I think Phil Wadler gave him more respect than was due in the comments :-) Microsoft hired Anders Hejlsberg for .Net which I don't think was a good idea, he is a great engineer but not a PL theory expert. They however "rectified" the situation by hiring Erik Meijer later and his impact via LINQ and F# and improvements in C# is obvious. Not to say that Hejlsberg is not good, but Meijer is better. Getting back on track, I may be wrong but Dart makes me groan. It is one thing to design such a language in 1990, but quite another thing to do it in 2011.
Overall: uninspired. Below what I was expecting. Probably good for Google goals (tooling, migrating developers, etc)
The language is somewhat interesting, but unfortunately saddened by an incredibly boring syntax. At this point, I am thinking that they would have been better off just going with the Go language for this. Looks like something good to migrate fleets of java engineers to, but not something that would inspire "hackers".
Now I feel like it is not worth to create any "brigthly" IDE whatsoever. Just go with eclipse.
I was planning to immediately rush to the language. But changed to wait and see now.
Misses:
- Incredibly uninspired, boring Java-like syntax.
- Not everything is an expression.
- Java-like classes, instead of anything more interesting.
- Lacks simplicity, symmetry and beauty.
- Semicolons.
Some notes: In Dart, you can often create objects directly from an interface,
instead of having to find a class that implements that interface
What?? Why to blur the concepts of classes with interfaces and introduce a quirk? Beauty comes from simplicity and symmetry. named constructors:
var greeter = new Greeter.withPrefix('Howdy,');
Mildly interesting. Every type in Dart is public unless its name starts
with an underscore ("_")
I laughed at this. I always have hated the practice to start with "_" for supposed private variables, in languages without true private. I like it this way in Dart. My little favorite syntax feature until now.`var foo = new Bar()`?
Why can't a constructor just be a regular method that happens to return a new instance? What's with this new nonsense?
I think the overhead of adding that 'new' is worth it. Without it: in var foo = Bar(), is Bar a type or a function? If you decide it should be colored like a type, your syntax colorer needs deeper information about the code, making it harder to write, slower, etc.
Perhaps this is by design, though? Presumably the syntax doesn't look too bad to people who spend all day writing JavaScript (i.e. the target demographic for this language).
Presumably some bright spark will eventually write a Python-to-Dart compiler and then we'll all be happy :-)
Me too! We already have a very readable, simple and elegant language, let's use that. Anyone know why that wouldn't have worked? (Not using the current CPython implementation but maybe the same syntax but with a different (web-only) set of libraries, that is...)
In Dart, you can often create objects directly from an interface,
instead of having to find a class that implements that interface
What?? Why to blur the concepts of classes with interfaces and introduce a quirk? Beauty comes from simplicity and symmetrySounds like Java's anonymous classes. Quite a useful feature, actually.
It's only useful because Java lacks first class functions and syntax for lambdas. This is the single most irritating thing about Java to me. When this is fixed with the release of 8, the only thing Java will be missing is a really good implementation of persistent data structures a la Clojure.
Where it shines IMHO is in the core library (http://www.dartlang.org/docs/api/index.html). Look there and you will find some interesting classes that deal with concurrency and asynchronous operations (Isolate, ReceivePort, Promise<T>). Also, unlike standard Javascript, there are collection classes for specific use cases (like Queue, Set, LinkedHashMap). This is where it is superior to both Javascript and mainstream static typed languages like Java.
- Incredibly uninspired, boring Java-like syntax.
Syntax should be boring. It should not deviate from one's expectations. One should not spend any mental resource thinking about it. someString.append(System.getProperty("line.separator"));
vs some_string += "\n"
Edit: Someone's in disagreement with me, so I'll try and clarify. I'd classify boring code as code where the intent gets lost in the syntax/language or other constructs the maintainer of the code doesn't care about but are required anyway.Trying to open and read a file in Java is probably a better example as the intent (open this file and read the contents) is buried in about 6 lines of boilerplate code
I use Java as an example because in a previous life I used to write it and see this as perfectly acceptable
Circle my_circle = new Circle();
I have to type the word circle 3 times to define a circle. It gets boring. This gets worse if you are trying to do any kind of user input. BufferedReader my_reader = new BufferedReader(new InputStreamReader(System.in));
Had to type reader 4 times. :(I think "beauty" is really a subjective consideration when it comes to programming languages.
It completely does. And I love that it manages to be completely incoherent with Go, the other "Google Language". That's so symptomatic of what google does on that front.
Server-side execution...
The only thing I like is underscore for private variables. Go does the opposite (which I think is a safer approach): anything you want public has to start with a capital. It really works—it is both easy to do and easy to read.
Web language: move data from point A to point B.
Do you even read what you write?
Not only did they create V8, they write many boat loads of JavaScript so they are well placed to address both the technical and human pain points of scaling JavaScript. And in introducing a new language they can't stray too far from the mainstream if they wish large adoption. All that said, I am not moved.
Also, F# is Don Syme's work not Erik Meijer's. Although F# probably gained from some Haskell people in Cambridge (the original one).
I would expect PL theory to deliver great benefits at about the same rate as for other fields, e.g. that pure mathematics does for physics - some of it does; though it's common for it to be reinvented independently by people trying to solve specific problems.
BTW: Notwithstanding the over-general flame-bait title, I think his "types are anti-modular" is really just making the point that, while interfaces reduce your dependence on implementation, now you depend on interfaces. i.e. The problem with using types to hide decisions that you think will change is if your prediction about what will change is wrong. "On the Criteria to Be Used in Decomposing Systems Into Modules" http://www.cs.umd.edu/class/spring2003/cmsc838p/Design/crite...
Perhaps one solution is to specify all the types you use in a module, internally; and provide a mechanism for converting between equivalent types at the boundary, to remove the dependency while facilitating interoperation. This mechanism acts as a buffer or glue (or middleware) - a kind of interface between interfaces if you will.
† Although the technology adoption lifecycle gives the impression that a new technology with interesting properties is just the beginning of great things, the vast majority of new things do not become massively successful - it's just that the lifecycle is based on those that were. http://en.wikipedia.org/wiki/Technology_adoption_lifecycle
The issue is whether the interfacing technique adds in non-essential coupling. A technique that has at least the constraints of another technique will also have trivially have at least the non-essential coupling of the other technique.
Types add constraints, thus increasing coupling (and decreasing modularity).
Although types have benefits. And direct modularity is seldom the only concern. I.e. Correctness and reliability also enhances modularity in an indirect way - an erroneous module definitely decreases modularity.
I'm not sure exactly what you mean. Could you elaborate please?
I'll clarify my view with an analogous example: you can think of a database as having a set of types - its schema. Think of each of the applications that use that database as also having its own set of types - its classes or data structures in general. Now, an example of the "mechanism" I mean is that SQL provides a way for each app to translate data in the database's schema into its own data structures. If its data structures change, the SQL can change to adapt to that; similarly, if the DB's schema changes, it can also adapt by changing SQL (or even creating a virtual schema with another layer of SQL - a view). Of course, this only works if these are only changes of the representation of the information, and the information content itself is the same. If the information changes, in a way that the DB or an app depends on, then there's no avoiding that dependency.
A similar example are JSON/XML API's, where the JSON/XML is like the DB, and the data binding code is like SQL. The "type" of XML is often explicitly defined with an "XML Schema" document; JSON doesn't usually have that, but it is of an implicit expected form - which is still a type, just informally defined. There are also tools for converting between XML types - XSLT, and may GUI "XML mappers" that display two xml schema and let you draw lines between them.
tl;dr These enable "modules" with different types to interoperate without dependency. Each defines its own types at its own boundary, and so can be compiled independently. The middleware glue (SQL/databinder/XSLT/datamapper) facilitates interoperation by converting between types at the respective boundaries of two modules - provided those types are equivalent, i.e. contain the same information, just in a different schema/type.
Does your concept of "non-essential coupling" include the requirement of precisely identical types at the boundary? If so, by loosening that to only require the same information, this mechanism avoids that particular kind of non-essential coupling.
In summary when I saw the language this morning my first thought was: "Nothing to see here". But as a result my second was: "Get back to work". Maybe that's not so bad.
Other than that: it's got coffeescript's fast initializer syntax, but it's not as concise. It's got types but AFAICT no type inference. No destructuring either.
Only thing I can see it's really got going for it is some basic types which could have been provided as a standard Javascript library (and probably will become one...)
Not yet.
> No destructuring either.
There's a proposal floating around for pattern-matching that would address that too.
This is still early days for the language, so there's a lot left to be done.
I agree with you, the first impact with the language is terrible, the syntax is too reminiscent of Java. It seems that at Google Java is popular for web apps (GWT, Closure, ...). This must have had an influence.
I still fail to see what are the improvements over Javascript (while they managed to get the syntax worse). I guess a concurrency model, optional static typing, interfaces. Did I miss anything?
> Types can help you write and maintain your code, but they don't change how Dart programs behave.
That, in my opinion, is not a type system, it's a documentation system. Writing
String a = 1;
should crash the program/produce a runtime error in a language with (optional) static type system. In Dart, in only produces a compile time warning. void doSomething(String a) {
// Do something 1
}
void doSomething(Integer a) {
// Do something 2
}
doSomething("1");
doSomething(1);
That's the sort of thing they mean by types don't change how programs behave. You can't easily change or remove the type system because it's tightly coupled with method resolution. If you have an optional type system, the evaluation semantics of the language cannot depend on the type system because you don't want the program to do something different if you are/are not using the type system.The fact that type errors are only manifested as warnings is a (perhaps odd) design decision, but it doesn't stop them being type errors. They could just as easily made them errors, and String a = 1 would give a compile time error.
Hopefully they'll be a 'warnings as errors' flag for those of us more used to type errors being compile errors.
Uh... like this? http://brendaneich.com/brendaneich_content/uploads/CapitolJS...
C# had a hard constraint to start with - it was supposed to be an easy replacement for Java, it actually started from Microsoft's own Java implementation and it had to ship as fast as possible.
Even so, the language evolved nicely as they left room for improvement in a forward-thinking manner.
Also, C# 1.1 did have 5 things which I terribly miss from Java - delegates, P/Invoke, stack-allocated types without "special" exceptions, object properties and the GAC. From a theory-standpoint, none of them are groundbreaking, but we are talking about a language that's supposed to be grounded in real-world constraints.
I wouldn't be surprised if "performance" of the language meant "able to get our vast fleets of mediocre Java developers to write web apps faster" rather than "able to execute faster".
Yes, because Google is notorious for hiring "mediocre developers".
Or are Java developers especially considered "mediocre" by definition?
Or does dabbling in Ruby/Python/Lisp/Closure/Scala/Haskell make you "non mediocre" by definition?
It's the skills, it's not the language.
I would like to see something with the scope, ecosystem and functionality of, say, Eclipse, written in one of the non-mediocre languages (no, Emacs doesn't come close).
I agree that there are some amazing Java devs out there.
Most Java devs are not amazing (and heck most devs aren't amazing). But Java devs are not amazing with a frequency and depth that both boggles the mind and is entirely expected as that's the point of the language -- accommodate mediocre developers in a large shop producing boring enterprise code.
If you look where it's publicly known that Google uses Java, it's pretty much in Ads. The most boring, enterprisy kind of dev job Google has, but it's the money maker so it has to work despite having unmotivated "I'm just here for the paycheck" developers hacking on it.
Yeah, I know, it was used on the backend of Wave, and via GWT for the Wave web client (which was dog slow btw, I loved Wave, but have yet to encounter a web app as slow). And look where that got us.
As an aside, here's an interesting little writeup about why GWT is bad (with bonus example by pg of all people)
http://ryandoherty.net/2007/04/29/why-google-web-toolkit-rot...
And, at least publicly that's about it. If a dev can't be bothered to just learn the syntax of another language in a couple of weeks in order to properly support their target platform, they are a mediocre developer almost by definition.
All brilliant people, but you have to remember that not everyone thinks types are all that matters. I like type systems, but the majority of the world's shipped code was written in languages with unsound type systems.
var q = from m in grains.OfType<Salt>()
where m.Value.Contains(null)
orderby m.irrelevance
select m;
return q.FirstOrDefault();
which fits in 80 characters on one screen. From this post and your reply, it seems like the your complaint is that LINQ is hard to understand if you write it poorly. But that's true of most programming.The from item in blah syntax is just SQL rearranged, and SQL isn't as expressive as programming language constructs, so why try to emulate it?
It encourages you to write the grain of salt statement I mentioned earlier, which requires programmers to read through and understand the implementation of what you are doing, instead of it being embodied in a meaningful method and called. Of course you could just wrap that in a method, and slowly grow the line to 2-3 wide-screen monitors as you add more conditions.
The more tools you add to the core of a language, the more of a monstrosity of a kitchen sink it becomes (c#/.NET). Now you can loop over a list in 6 different ways! Hooray! That is why Dart looks good - a few basic concepts that can be used to build things suited to a particular problem.
grains.select{|g|
g.is_a?(Salt) && g.value.blank?
}.sort{|a,b|
a.irrelevance <=> b.irrelevance
}.first grains.select{|g|
g.is_a?(Salt) && g.value.nil?
}.sort_by(&:irrelevance).first
Edit: Changed from blank? to nil? since that is probably closer to nothing in C#.foreach (var g in grains) {
if (g.TypeOf() == "Salt" && g.Value == nothing)
saltGrains.Add(g);
}saltGrains.sort(m => m.Value.irellevance);
return saltGrains.First();
or something.
A delightfully blank page :-) Yes it mentions classes, interfaces, optional types, libraries, tools, structured yet flexible language. But all of these are a given. Is there nothing else?
What about Generics, Covariance/Contravariance ? Type inference? Odersky thinks type inference in the presence of subtyping is untenable. Is it the same here? Are interfaces linearized as in Scala? What about immutability? It might be too much to ask for rank-2 polymorphism and Haskellish Type Classes but what about support for delimited continuations? Let me guess, these aren't "design goals". All I am saying is this isn't 1990 either.
For example: " Dart supports optional typing based on interface types. The type system is unsound, due to the covariance of generic types. This is a deliberate choice (and undoubtedly controversial). Experience has shown that sound type rules for generics fly in the face of programmer intuition. It is easy for tools to provide a sound type analysis if they choose, which may be useful for tasks like refactoring."
What Dart brings to the table is a dynamic web language that's somewhat more structured than Javascript by using a class mechanism and optional typing. This is a great region of the design space, inhabited by languages like Common Lisp and Dylan.
In CoffeeScript compilation is entirely local and highly modular.
You can get away from this by having a structural type system, or by being dynamically typed (duck typing ultimately being another form of structural typing). But within the constraints of the type system, you can't get away from this by merely changing the design - unless you put everything into a single module, which is the ultimate in anti-modularity.
Wow. And I thought nobody in their right minds would question Hejlsberg's chops or the work he did for .Net.
He is "not a PL theory expert"? Great. We need less of them in mainstream language design and more pragmatism.
Why not? C# 1.0 was terrible and most of the version since have been exercises in trying to fix it by piling more stuff on, in order to replace previous tentative fixes which did not work for any value of "work" worth using because they lacked generality.
> We need less of them in mainstream language design and more pragmatism.
I hope that's a joke, PL theory experts are nowhere to be seen in mainstream language designs (some have managed to get a claw or two into C# to add actually useful features like... lambdas...), and the "pragmatists" have a field days reinventing problems (not solutions) instead (hello, Go)
What language do you think was perfect at it's first release?
It's meant to be a language for web development. Catering to the HUGE, EXISTING javascript dev crowd and meant to work with javascript (compile to, reuse staff) etc.
Can we please remove our blinders for a little while and stop whining that it's not like Haskell or any other flavor du jour?
I mean, "IE9 support coming soon!", what the hell? What about IE6? This isn't a CSS style or an animation library we're talking about.
Maybe I'm wrong, that'd be nice.
Except for Isolates -> WebWorkers, there's not really anything that can't be emulated in IE6. GWT has to handle a significantly more complex set of semantics and still works on IE6.
But personally, I prefer if there wasn't IE6 support, or any non-HTML5 browser support for that matter. If you're going to do a new VM, do a clean-break, because legacy support is another factor which makes web development a pain.
I believe it compiles to ES 3, which is isn't exactly "modern JS features". IE6 is ten years old. At some point, you've gotta cut the cord!