Live data from Hacker News

Dart Is Not the Language You Think It Is

programming.oreilly.com

81–90 of 143 posts

Re: Dart Is Not the Language You Think It Is

#81

How about a virtual machine facility that outputs what the types of variables are at runtime, combined with tools that can collate data from many runs and apply consistent types back to the original source code?

That's dangerous, because you have no way of knowing if you have 100% coverage without doing static analysis, and if you double check everything with static analysis, you might as well only do the static analysis in the first place. (Static analysis won't always give you an answer, but it won't ever give you a wrong answer.) I am reminded of the folks who optimized .kkrieger, which is a 95 kB first-person shooter. Se…

> That's dangerous, because you have no way of knowing if you have 100% coverage without doing static analysis

You are right from a theoretical standpoint, but I'm not so sure this fits with how web applications are known to run and the patterns development usually follows.

Developers who shove an object of one type in an instance or temporary variable one time, and a different one another time are usually doing something bad, even in dynamic environments -- unless there is a specific interface involved. Just because "duck typing" is fast, doesn't mean that it has to be loose.

The point, actually, is to discover where types are being misused as much as to discover what the types are.

> The lesson is: don't let tools change code semantics based only on black-box testing.

I'm also advocating this. However, it seems like you're mainly familiar with dealing with types in statically typed environments. In dynamic environments, the developers still need to know the types. Often, there are hard and fast rules only enforced by convention. This is indeed a source of errors, but by and large, programmers are very good at managing this. In other words, very often, the programmers will know. I see environments like Dart as a way to eliminate such conventions, but still enable very fast prototyping in the beginning. (Ultimately, static types are better for maintenance.)

Re: Dart Is Not the Language You Think It Is

#82
post #72
post #57

Earlier quoted context omitted.

It's really not. It's the equivalent of adding "asserts" to your code.

No, in Dart it's not like that at all - almost the opposite. Type annotations have absolutely no effect at runtime. As the Dart documentation[1] says, "Adding types will not prevent your program from compiling and running—even if your annotations are incomplete or plain wrong. Your program will have exactly the same semantics no matter what type annotations you add." [1] http://www.dartlang.org/articles/optional-type…

Dart can run in production mode where type annotations have no effect, or in checked checked mode where they will trigger a runtime error (i.e. behave like an assert). So you're both right ;)

Re: Dart Is Not the Language You Think It Is

#83
I've read post after post about Dart. It looks really neat. I want to try it sometime.

Now can Google use it to do something big and important? Please? We want to see that it works for you. Invest in it by building products with it and show us we should do the same.

Re: Dart Is Not the Language You Think It Is

#84
post #72
post #57

Earlier quoted context omitted.

It's really not. It's the equivalent of adding "asserts" to your code.

No, in Dart it's not like that at all - almost the opposite. Type annotations have absolutely no effect at runtime. As the Dart documentation[1] says, "Adding types will not prevent your program from compiling and running—even if your annotations are incomplete or plain wrong. Your program will have exactly the same semantics no matter what type annotations you add." [1] http://www.dartlang.org/articles/optional-type…

Types do cause runtime errors in checked mode (which is basically the default mode for other systems with optional types, like Common Lisp and Dylan).

Re: Dart Is Not the Language You Think It Is

#85
post #76

Earlier quoted context omitted.

IDE like Eclipse You don't need to write Dart in the Dart Editor if you don't want the IDE experience. I happily write Dart in Sublime, and Dart has command-line tools that I can use to validate the code that I write. But web developers, who are the primary producers of JavaScript, will happily stick with Node.js, CoffeeScript, or plain JavaScript. If web developers are happy with the tools they have, then that's jus…

>>You don't need to write Dart in the Dart Editor if you don't want the IDE experience. I happily write Dart in Sublime, and Dart has command-line tools that I can use to validate the code that I write. This is the same line argument made with regards to Java too. But the fact of the matter is, these language bring in so complexity with their whole ecosystem. Working without an IDE isn't even worth that torture.

Respectfully, I disagree.

I've written Java in plaintext editors before, and that is truly terrible. Dart is nowhere near that verbose. Dart's imports feel pretty lightweight (rather Python-esque) and the fact that the language has top-level functions and variables means that you're not always trying to juggle a bunch of classes and objects and interfaces when you don't need to. In fact, Dart's style guide explicitly recommends that you don't put things in wrapper objects just because you can. http://www.dartlang.org/articles/style-guide/

I really don't think that Dart brings in any more complexity than you'd have in a JavaScript application. I actually think it's a lot easier to hold a Dart application in your head because all the APIs have a consistent interface. With JavaScript, you often have a bunch of different libraries and you have to remember how each of them behaves.

Re: Dart Is Not the Language You Think It Is

#86
post #51
post #46

Earlier quoted context omitted.

See, this is where the philosophy of languages like Dart and Java differs significantly from Haskell and friends. In the former, it makes sense to write code first and then try to get it to typecheck afterwards. In Haskell, this does not really happen: the types are at the very core of your code. When I write a Haskell program, I start with the types and the code grows from there. The types are really the foundation…

Yea, as always, depends on what you're doing. I agree 100% with your points for when I'm writing mission-critical code from the start. But when I'm busting out UI at 2:00AM, it's all fast and loose. A lot of code I write is somewhere in the middle.

No, you didn't quite see my point. In Haskell, types aren't only about correctness--they're also about expressiveness. They help you program beyond correctness--they even help if you're just hacking around. Moreover, they're sufficiently central to practical code (even, at the risk of repeating myself too much, hacky code) that it wouldn't really make sense to write untyped Haskell and try to stick types on afterwards.

Basically, in Haskell, the types go well beyond correctness. I hope this clarifies what I mean.

Re: Dart Is Not the Language You Think It Is

#87
post #60

Earlier quoted context omitted.

>Who is the audience for Dart? AS3, C#, Java, and JavaScript developers. That's why they went with C-like syntax. It's familiar to most people. >But web developers, who are the primary producers of JavaScript, will happily stick with Node.js, CoffeeScript, or plain JavaScript. I'm writing JavaScript for a few years now. I'm really tired of it. It scales very poorly and there is zero tooling. For example, JSLint is mo…

When I started seriously working with JavaScript, I decided to try to conform to community standards by using JSLint. I was shocked by how terrible JSLint was. It offered corrections for very straightforward constructs such as: var count = 0; for (var i = 0; i I have no idea why JSLint would tell me that I should move the definition of "i" to the top of the function (am I supposed to pretend I'm writing ANSI C for ob…

You can use JSHint to fine-tune your linting rules.

Re: Dart Is Not the Language You Think It Is

#88

How about a virtual machine facility that outputs what the types of variables are at runtime, combined with tools that can collate data from many runs and apply consistent types back to the original source code?

Members of the team and community have talk about such a tool, also tools that remove type annotations to prove that they don't effect performance, or remove them from local variables to match the style guide.

Wow, I wonder why I got down-voted for stating something that was simply true. I guess it's bad the people discussed the possibilities of these tools? Interesting...

Re: Dart Is Not the Language You Think It Is

#90
post #33

Dart is exactly the language that I think it is. It is too bad that it doesn't run on many browsers but that isn't going to change. What is the point of using Dart other than to join Google's garden of ugly walls?

There's no wall; the spec is public, and the implementation is open source. Any other browser could add direct Dart support tomorrow if they wanted to.
Post reply on HN