Slashdot Mirror


Dart Is Not the Language You Think It Is

An anonymous reader writes "Seth Ladd has an excellent write-up of Dart: 'When Dart was originally launched, many developers mistook it for some sort of Java clone. In truth, Dart is inspired by a range of languages such as Smalltalk, Strongtalk, Erlang, C#, and JavaScript. Get past the semicolons and curly braces, and you'll see a terse language without ceremony. ... Dart understands that sometimes you just don’t feel like appeasing a ceremonial type checker. Dart’s inclusion of an optional type system means you can use type annotations when you want, or use dynamic when that’s easier. For example, you can explore a new idea without having to first think about type hierarchies. Just experiment and use var for your types. Once the idea is tested and you’re comfortable with the design, you can add type annotations."

55 of 312 comments (clear)

  1. There are two kinds of programming languages.... by Anonymous Coward · · Score: 5, Interesting

    Those people always bitch about and those no one uses.

    Since I have yet to hear any complaints about Dart, I can only assume it's in the latter category and no one cares.

  2. Unadvantages! by Shaiku · · Score: 5, Interesting

    Once the idea is tested and youâ(TM)re comfortable with the design, you can add type annotations.

    I've been doing this with comments since 1999 and it works great! Of course I still haven't gotten around to that final step of going back and adding all those comments but I love the flexibility!

    Unless you like bugs, type-checking is a good thing. Lack of type enforcement encourages what -- lack of forethought?

    1. Re:Unadvantages! by farble1670 · · Score: 5, Insightful

      It lets you throw something together quickly for a proof of concept

      the thing about type safety ... even if you use a non-type safe language, you still have to get it right or your crap will crash, or worse, run and do something unexpected. you still need to be type safe, it's just that you have to find all your bugs at runtime in stead of compile time. do we need to discuss why it's better to catch bugs at compile time?

    2. Re:Unadvantages! by Longjmp · · Score: 3, Insightful

      Unless you like bugs, type-checking is a good thing. Lack of type enforcement encourages what -- lack of forethought?

      My thoughts exactly. Any language that makes you believe you can leave the "thinking" to the compiler is the wrong approach.
      Might as well program the next Mars rover in PHP.

      (not that PHP is bad as such, it just makes lazy programmers more lazy)

      --
      There are fewer illiterates than people who can't read.
    3. Re:Unadvantages! by lennier · · Score: 2

      Might as well program the next Mars rover in PHP.

      Now that's just silly. Of course something mission-critical like a space probe won't be running PHP.

      It'll be running jQuery on node.js.

      what do you mean the latency from our data center on Pluto is lousy? look at the cost savings we get from the free cooling!

      --
      You are not a brain: http://books.google.com/books?id=2oV61CeDx-YC
    4. Re:Unadvantages! by dreadway · · Score: 5, Interesting

      IMO the thing which crippled large Smalltalk projects was the corporate IT market embracing programming technologies which looked more like C. You had to fight hard to make Smalltalk code look like a procedural language, which a larger body of programmers were already used to. Java, C++, and C# look more like C, so I guess they have that going for them.

      Smalltalk is a strongly-typed, late-binding language. Smalltalk's Object>>#doesNotUnderstand behavior is a hindrance for production-quality code only to the extent that your programmers are unwilling or unable to read and use someone else's API. Oh, and maybe your system design should not suck, no matter what programming technology is involved.

      I worked for years as a Smalltalk programmer on big, corporate IT systems involving hundreds of programmers and handling hundreds of millions of $$$ per day in production, but corporate IT has had a mood swing and now our systems mostly use the early-binding programming technologies. I like being gainfully employed, but am not persuaded the tradeoffs of the extra code, convoluted syntax constructions, and tool paradigms actually represent any improvements. And finally, believe it or not, but the less senior programmers apparently have difficulty reading and understanding the code (even with its early-binding features) written by far more experienced programmers than myself, which in turn results in numerous and varied production defects. Who would have thunk it, eh?

    5. Re:Unadvantages! by Anonymous Coward · · Score: 2, Insightful

      In my experience, there is no such thing as a proof of concept or a prototype or whatever qualifier you have for something that isn't done, unless you only put it in front of other developers.

      The moment you put a proof of concept in front of a PHB or other similar, their brain immediatly melts and the only though they can form is "oh look, it's already done!".

      Never, ever count on being able to "go back later and _really_ implement it".

      Of course, this is only a problem in poorly run organizations. Unfortunately, this in 99% of organizations.

    6. Re:Unadvantages! by sproketboy · · Score: 3, Insightful

      Nope. Smalltalk died because projects written in it were unmaintainable. Simple as that.

    7. Re:Unadvantages! by Anonymous Coward · · Score: 2, Informative

      C has simple, strong type safety.

      No. Try to put this in one file:

      double f(double x) { return x*x; }

      and this in another

      #include <stdio.h>
       
      int f(int x);
       
      int main()
      {
        printf("%i\n", f(1));
      }

      Then compile with C and link both files together. The compiler will not complain. The linker will not complain. That's not type safety.

  3. Since I think nothing of Dart by Spy+Handler · · Score: 5, Funny

    not having heard of it, and thus never having any thoughts about it, and since you say it's NOT what I think it is (nothing), I guess Dart *is* something!

    1. Re:Since I think nothing of Dart by c0lo · · Score: 2

      Meanwhile, in a galaxy far-far away:
      Sith Ladd has an excellent write-up of Darth

      --
      Questions raise, answers kill. Raise questions to stay alive.
  4. Understanding Dart's goals by Necroman · · Score: 4, Informative

    I've been following Dart on and off since it's announcement. I'm still a little skeptical of the language, but I'm a fan of what they want to do. Here are their basic goals:

    • Create a class based (OOP) language for doing browser heavy apps (like GMail).
    • Allow it to inter-op with today's browsers (hence compiling to Javascript)
    • Create a DartVM so the code can run faster than there javascript counter-parts. This also allows for server-side, but this much lower on their priorities.
    • Make the language easy for Java/C++/C# developers to learn.
    • Only work with "the modern web". meaning IE9 and higher.

    There is a lot more to it than this, but it's sort of a beginning. The language still hasn't hit 1.0, so no one is seriously using it (as the language itself was seeing large changes up until recently). Google has not talked about anyone outside of the Dart team itself that is using Dart within Google (they are doing it, it's just not being talked about yet).

    Since 1.0 is expected this summer, you probably won't see many people using it until that milestone is hit. Once 1.0 is hit, people will be more willing to create real products with it, so you can expect to see more about Dart after that. As well, once the DartVM makes its way into Chrome (which will happen sometime after 1.0), you'll probably see a lot of press about the first Google App that is written in Dart.

    It's still early in Dart's life. The only people really seriously using it are people that like learning new languages. Companies and most developers won't touch an in-progress programming language out of fear that syntax and behavior changes will screw them up.

    --
    Its not what it is, its something else.
    1. Re:Understanding Dart's goals by Kal+Zekdor · · Score: 2

      I actually have taken a liking to TypeScript for that purpose. It is rather fancy. I never touch "raw" js any more, I just treat it as a compiled blackbox.

    2. Re:Understanding Dart's goals by shutdown+-p+now · · Score: 3, Insightful

      That sounds like a maintenance nightmare. The code you're writing and debugging is not the code actually running

      When you're writing native desktop apps, the code that's actually running is also not the same as what you're writing and debugging - the former is assembly, the latter is C or C++.

    3. Re: Understanding Dart's goals by Kal+Zekdor · · Score: 2

      Welcome to compiled languages. Still, people continue to use C/C++, so it can't be that problematic.

  5. Re:So, like Lisp by Aguazul2 · · Score: 2

    No, nothing like Lisp.

  6. Re:There are two kinds of programming languages... by stormboy · · Score: 4, Insightful

    Get ready to hear some bitching about Dart on this thread, then review your assumption.

  7. Re:There are two kinds of programming languages... by Anonymous Coward · · Score: 5, Insightful

    I vote for no one cares.

    I for one never encountered a situation where I thought "gee, if only I could prototype without types!". Types matter. When solving even the most basic data processing problem there's "input" and "output". Specifications are very clear on the formatting and types. What happens in between is dictated by those types.

    Typeless programming in shorthand for lazy markup.

  8. Yet Another Language -- what good is it? by l0ungeb0y · · Score: 4, Interesting

    Or so that was my first thought. Then I got to the end of the article

    Dart compiles to JavaScript and runs across the modern web

    And suddenly I find it potentially very useful. I have a NodeJS project to develop a Streaming Service later this week. While I was planning on writing it in Coffeescript, the classic OO nature of Dart with Type Checking and Interfaces(!) seems like a potentially better match since the NodeJS app will be a clustered streaming service -- just the sort of application whose architecture could greatly benefit from these language features. If that succeeds, I know of a large retailer wanting to create a NodeJS middleware as a REST API to legacy systems, who might find Dart as compelling as I do.

  9. Re:So, like Lisp by kwerle · · Score: 2

    Turing complete?

  10. Wish it had better JS interop by kwerle · · Score: 3, Insightful

    I fooled around with Dart a few months ago. I like the language. But I really want to be able to use it AND all the javascript libraries that do lots of work for me. It's my opinion that it will be hard for Dart to get traction if all those libraries have to be rewritten.

  11. Type Checker by mdmkolbe · · Score: 2

    Dart understands that sometimes you just don’t feel like appeasing a ceremonial type checker.

    Given that in Dard, the type checker is only ceremonial as far as I can tell, this is an interesting choice of words. The purpose of a true type checker like you find in Haskell, Agda, ML, ATS, etc. isn't just ceremonial. It guarentees certain properties of the resulting program (e.g., that variables of a certain type actually contain an object of that type, that you can never apply an invalid operation to an object, etc.). That is far from ceremonial.

  12. Just experiment and use var for your types.... by randomErr · · Score: 2

    Isn't that just Visual Basic 6, VBScript, JScript, ActionScript, Real Basic, Jabaco, or JavaScript/ECMAScript? There are languages out there and even C# has the dreaded 'var' in it as well. I just don't see Dart's use outside of Google products.

    --
    You say things that offend me and I can deal with it. Can you?
    1. Re:Just experiment and use var for your types.... by ebno-10db · · Score: 2

      I just don't see Dart's use outside of Google products.

      So? It's Google! By definition everything they do is wonderful, brilliant and the future. But their greatest product of all is hype, and they ship it in volume.

  13. Re:Welcome to the chopping block by larry+bagina · · Score: 2

    Being killed off is better than the alternative -- forced integration with google+. Will they require you to login to google+ to run the javascript transpiler? Will they auto-post your error log to your google+ page? Will they remove the "+" operator (like they did with search)? Who knows!

    --
    Do you even lift?

    These aren't the 'roids you're looking for.

  14. The proliferation of computer languages by Taco+Cowboy · · Score: 4, Insightful

    I haven't used DART yet, so I will not comment on the strength or the weakness of it

    But, all through the decades that I've been in the scene, there have been so many programming languages invented, but so few of them being used

    Some of the more widely used programming languages like C, for instance, are not perfect, but they are being used partly because of legacy, partly because of momentum, and partly because of the laziness of programmers to learn new, more useful languages

    Talking about legacy, the other day there was a piece on Cobol, and that IBM is trying to extend Cobol to the cloudsphere

    As for the languages that are not so-widely used, some of them are downright weird, but then, there are gems among them. The only downside for those few gems is that the ecology is not there to enable those few gems to become more widespread

    I guess it's kinda Darwinian game plan --- not all surviving/thriving species are perfect, and not all the extinct species are bad, either

    --
    Muchas Gracias, Señor Edward Snowden !
    1. Re:The proliferation of computer languages by angel'o'sphere · · Score: 3, Informative

      C++ implements all this with C features called setjmp and longjmp.

      http://en.wikipedia.org/wiki/Setjmp.h

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    2. Re:The proliferation of computer languages by Pseudonym · · Score: 2

      What can't you do in C?

      Write a robust system that has a sufficiently complex job to do, on time and on budget.

      In particular, if you find yourself having to write an interpreter first, you probably should have used another language. (Unless, of course, the interpreter is the job.)

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    3. Re:The proliferation of computer languages by Pseudonym · · Score: 4, Informative

      setjmp and longjmp do many useful things, but stack unwinding is not one of them, and it's far from "easily and automatically". If you're trying to do the same thing as a real exception system, setjmp/longjmp imposes a large maintenance overhead (and significant run-time overhead, but the maintenance overhead is arguably much more important) on your program, even if you never raise an exception.

      Incidentally, I do have a few quibbles with the list you responded to. C programmers do object creation and destruction just fine, it's only exception raising and stack unwinding which requires the manual effort. And RAII is a means, not an end in itself.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    4. Re:The proliferation of computer languages by bmk67 · · Score: 4, Insightful

      What can't you do in C? Not a hell of a lot, sure - but the level of effort is often not worth it. I've spent 20 years doing development primarily in C, and it's often not the right tool for the job.

    5. Re:The proliferation of computer languages by Ghaoth · · Score: 2

      Program in binary. There are no limitations except the processor and time....a very, very lot of time.

      --
      Nos Morituri te salutamus
    6. Re:The proliferation of computer languages by Pseudonym · · Score: 2

      Please ask Google what "stack unwinding" means. It doesn't mean resetting the stack pointer.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    7. Re:The proliferation of computer languages by ultrasawblade · · Score: 2

      I like the way you thunk.

  15. Re:So, like Lisp by ebno-10db · · Score: 3, Insightful

    more restrictions and unnecessary syntax

    I like syntax. It helps human beings read code. It was never intended for anything else.

    BTW, what language is going to evolve back to Lisp and be usable for writing OS kernels, drivers and other such primitives?

  16. Re:So, like Lisp by ChunderDownunder · · Score: 2

    I was going to say BitC but that language evolved away from s-expressions to something more Haskelly.

  17. ActionScript + Python + Ruby by RedHackTea · · Score: 2

    That's what I think. ActionScript allows the same static/dynamic switch:

    for(var i:int = 0; i < 0; ++i) { }
    for(var i = 0; i < 0; ++i) { }

    But, in strict mode, it will give you warnings for the 2nd.

    --
    The G
  18. As long as it kills Javascript by OhANameWhatName · · Score: 2, Insightful

    I'll support it. Javascript is a thoroughly horrible language with anachronistic syntax that requires specialised skills to understand. If Dart has the potential to rid my life of Javascript, please Google .. get it out there!!

  19. Re:There are two kinds of programming languages... by dreamchaser · · Score: 2

    I'm not sure why you were modded Troll. I tend to agree. Types are no good if they are not enforced. Either use a language that doesn't enforce typing or use one that does. This in between approach is indeed lazy.

  20. There are problems with new languages by angel'o'sphere · · Score: 3, Insightful

    One Problem is teaching.

    One problem is "compatibility" or "easy to learn". E.G. regarding keywords.

    C has a keyword: static.
    C++ has the same keyword: static.
    As Java aimed to be similar to C++ and "easy to learn" it also has a keyword static.

    While the meaning of the "keyword" in Java and C++ is the same, it differs from C. (Oh! and this already is not true as you can use 'static' in C++ similar to C if you just use it for free functions and data).

    So what does 'static' mean?

    http://dictionary.reference.com/browse/static
    http://www.thefreedictionary.com/static
    http://www.merriam-webster.com/dictionary/static
    http://oxforddictionaries.com/definition/english/static

    Unfortunately 'static' in a programming language has no meaning at all. Why is the "starting method" in Java called "static void main(String[] args) {}"? Yeah, because in C and C++ it is called main(). Pascal has not that problem.

    What do you think a non native english (oh, well what about the english?) considers if he hears the word 'static'?

    Good, now lets bash Python and Groovy. What is a "def"? Oh? A definition? Are you certain you can distinguish what the difference between a definition and a declaration is?

    So "methods" are now "declared" (or is it defined?) by the introducing keyword "def"? Oh, for fuck sake, I got it wrong again.

    Oki, in Python you declare, oh no!!!! you define methods with the keyword "def". In Groovy you define variables (oh! no!!!!! you declare!!!) with the keyword "def".

    Yeah, I could rant forever ...

    All new languages we see here and there are only languages for programmers that already can program.

    But, what is about expressing your mind?

    What about teaching programming? Imho Java is one of the most difficult languages to teach. Why? Because you need to know already so much about programming to grasp it!!!!! (Same for C# ofc).

    However: modern times show: you don't need to understand Java/C# (just a replacement for most modern languages) because the programing tasks a modern developer has (especially compared to the tools he has at hand) is so mondane. C++ on the other hand only shows how super smart and knowing you need to be to use the language, or not to shoot into your foot.

    So where are we?

    New languages should use new keywords, that describe precisely what they mean. No void, no static, no final or for that matter finally, no fucking def, var or func. Did I forget one? I certainly did. And they should have reasonable defaults. I hate Java meanwhile, "public void doit() {}", "private boolean done = false". Then we get to "static final String DID_WE_DO_IT = "yes we did";" What is so hard in having methods be PUBLIC by DEFAULT and attributes PRIVATE by DEFAULT?
    Writing code is still possible, even if it hurts my hands and my eyes. But reading? I simply don't want to read code anymore ... neither C++ nor Java nor C#. The redundancy hurts me literally.
    In a typical Eclipse window I would estimate 30% of all characters/words are simply superfluous. And the fact that they all have a different colour emphasizes this.

    How would a real world language look to you if it was written like this: "I want (that is me the guy writing) that we (that is us, you who are listening, and me who is talking) that we (well, dont be mistaken, I only want it, it is not an order) that we (yes, I invite you to participate) go to the beach (and want does not mean it is super important ... it is kinda void)? (And all words in () above in a different colour? Like pink (ARRRRGGG!!!!) light green ( /*facepalm*/), dark and light blue, emphazised(bold) full

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    1. Re:There are problems with new languages by Kielistic · · Score: 3, Insightful

      If you think all those words are superfluous you probably don't have much knowledge of compilers or IDEs. The static keyword has very well defined meaning in every language it is used in. As do all those other keywords you seem to hate. Should we kill modern programming languages and go back to what, a stripped down functional paradigm because you deem all this stuff superfluous and hard to teach to beginners?

      Programming is about precision. I should never have to guess at what the compiler is going to do with my code; programming is not a natural language. You are damn right I want a void return type. I want OO static members. I want all the information that can be put into method/function/variable definitions so I can take a quick glance and see what it does, takes and returns. So that my IDE, if I'm using one, can auto-complete most of the code for me. So that the (JIT-)?compiler or interpreter can understand all kinds of fancy syntax that lets me do more and write less.

      Those five things you mention have nothing to do with C or C++. They are programming concepts and pretty basic ones at that. Obviously you have to understand the basics before you can move on to intermediate.

    2. Re:There are problems with new languages by vux984 · · Score: 2

      The static keyword has very well defined meaning in every language it is used in.

      I think his point was that that static doesn't map semantically very well. They could have just made the keyword "ketchup" and defined it the same way and it would be no better or worse.

      You are damn right I want a void return type

      But why call it "void" and why call it a "function" if it doesn't return something?

      To be honest, I kind of see his point.

    3. Re:There are problems with new languages by Kielistic · · Score: 2

      It is called static because it is statically allocated. It is a compiler concept which became an OO concept due to being somewhat similar. It is static; it is the same when I access it here as it is when I access it there. It is not arbitrary any more than any word is arbitrary. Why make up new words now when we have an established lexicon? Nothing maps semantically well into English because it is a natural language with all kinds of context involved. Programming languages have to be context free which is why we class them as context free languages.

      Few OO languages call it a function. It is called void because it returns nothing. It is so the compiler knows where the return type ends and where the method/function name begins. It keeps things consistent and consistency is good. A few languages do leave it out now because some people think that removing redundancy is more important than consistency. These quirks are present in older languages because lexical analysis is a complicated task and it was simpler and more effective to leave the heavy lifting up to the human that found it easy.

    4. Re:There are problems with new languages by mbkennel · · Score: 2

      No we don't. Designing good languages takes lots of experience.

      We need a fresh start in human cognitive ergonomics as applied to programming. No, actually we don't---there's been plenty of research already.

      What we need is for people to actually care about these things, which means appreciation of non-trivial academic knowledge and experience of older people who've been there before. It means appreciating that good syntax, as it relates to underlying semantics, is essential for human performance even if various choices are equivalent to a compiler.

  21. Re:There are two kinds of programming languages... by Pseudonym · · Score: 4, Insightful

    Yeah, exactly. What the writeup calls "appeasing a ceremonial type checker" is more properly called "debugging".

    Don't get me wrong, I like the thrill of the chase, the satisfaction of tracking down a really hard bug, as much as anyone. But I like programming even more. Using a well-designed type checker, I can find bugs in my program and convince myself that I'm programming rather than debugging.

    --
    sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  22. Re:So, like Lisp by angel'o'sphere · · Score: 3, Funny

    I can confirm that. The keys are still where they ment to be. However if you use Emacs you are likely assuming that this is a nice editor. Well, as far as I can tell it is a nice operating system, but it lacks a decent editor. Honestly you should give vi or vim a try.
    No offense, only a full hearted wish for your future!

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  23. A version of Dart that compiles to asm.js? by ras · · Score: 2

    For those of you who don't know, asm.js is a subset of JavaScript that's meant to be easy to compile. In other words if you use asm.js the code your will work in all browsers, but should run faster in some. In that FAQ they say their compiled asm.js runs at about 1/2 the speed of C, making it roughly twice as fast as JavaScript V8.

    Which is wonderful, except that JavaScirpt is a prick of a language, and so I'd imagine that asm.js is a tedious, prick of a language. But Dart compiled to asm.js - sounds like a marriage made in heaven.

  24. Re:There are two kinds of programming languages... by Anonymous Coward · · Score: 2, Insightful

    Wait a minute. I'm a programmer BECAUSE I'm lazy.

  25. Re: What can't you do in C? by j1m+5n0w · · Score: 5, Insightful

    Return a list from a function. Sure, you can legally do it, there's nothing in the language inherently stopping you, but experienced C programmers will avoid returning a list at all costs, because suddenly you have to care about whether the caller frees the list properly, and what if the things in the list are used elsewhere and we need to do reference counting etc.. etc... I've worked on a C codebase that was a couple hundred thousand lines of code, and I can't think of anywhere that we ever returned a list from a function. I can't think of any Haskell program more sophisticated than "hello world" that I didn't use "map" and other list functions all the time.

    Ultimately, the cost of manual memory allocation isn't just the extra work you have to do to make sure you aren't leaking or corrupting memory, it's the algorithms you won't allow yourself to even consider because the memory management would just be too hard.

    I'm not saying C doesn't have it's place, I'm just saying that there are software engineering costs associated with using C as opposed to a higher-level language.

  26. Re:There are two kinds of programming languages... by gl4ss · · Score: 2

    And then there's Python.

    people bitch about python. at least I do.

                                          whitespace has effect. who has time for that..

    --
    world was created 5 seconds before this post as it is.
  27. Re:There are two kinds of programming languages... by H0p313ss · · Score: 3, Interesting

    And then there's Python.

    people bitch about python. at least I do.

                                          whitespace has effect. who has time for that..

    Same, but it's almost my only complaint. Other than that it's an elegant language, my favorite for scripting.

    --
    XML is a known as a key material required to create SMD: Software of Mass Destruction
  28. Re:There are two kinds of programming languages... by H0p313ss · · Score: 2, Informative

    Yeah, exactly. What the writeup calls "appeasing a ceremonial type checker" is more properly called "debugging".

    Don't get me wrong, I like the thrill of the chase, the satisfaction of tracking down a really hard bug, as much as anyone. But I like programming even more. Using a well-designed type checker, I can find bugs in my program and convince myself that I'm programming rather than debugging.

    Agreed. The languages I've used the most would be Smalltalk, C++, Javascript and Java (in rough chronological order, some overlaps), two are weak typed two are strong typed.

    After a day grinding out hundreds of lines of productive Java trying to do anything in javascript just makes me want to drown kittens... well perhaps kittens named Brandon Eich. (Sorry Brandon... I've just seen too many sins committed with your language.)

    --
    XML is a known as a key material required to create SMD: Software of Mass Destruction
  29. Re: What can't you do in C? by VortexCortex · · Score: 4, Insightful

    Return a list from a function. Sure, you can legally do it, there's nothing in the language inherently stopping you, but experienced C programmers will avoid returning a list at all costs.

    Hmm, that's odd. So C has its place but it's avoided because it lacks garbage collection? My C code has automatic garbage collection and OOP facilities. It's got lists and maps, and a comprehensive collections library. It's just under 30 thousand lines of code, but then it's just a game engine. It only has to do everything the computer actually can. If you don't have these basic facilities in your C library, it's your own damn fault. Seems to me if I want I can always have it in C, there's no excuse for not having it.

    My memory manager replaces the malloc / free facilities, so it can even be added to other C code-bases, hell, I use it in C++ code because it's faster than the GC in the standard library (for the way I use it). So it's not like I have to call reference counting functions; Just the GC_recycle() function, or enable it to run automatically, which blocks on malloc() / free(), and optionally gives each thread their own local GC rather than a unified approach such that part of the program can garbage collect while another keeps running.

    However, when my testers bitch about stutter in Java / Android No matter how badly I want Java or JavaScript to give me control of the damn garbage collector, so it doesn't run in the middle of the rendering loop or intense action sequence, I can't have it. I have to implement an object cache atop Java and pre-allocate everything, try my hardest not to give the GC a chance to run, and if I slip up once and let that fucker have control, it's game over, literally, when the enemy attacks and the game lags for half a second.

    I return lists from functions all the time you dumbass. I'm an "experienced C programmer". Stop painting with such a wide brush, you're getting the paint in you eyes.

    An AC adds:

    Or return a function from a function?

    I throw Function pointers around like crazy, that's how efficient state machines, decision trees, or other flexible structures are formed. Hell, my Entity-like system allows Actors to composite sets of functionality as it transitions states to create efficient AI -- Just because it's fleeing doesn't mean it's still not searching for Health. It would be like if C++ let you pick which methods you inherited from multiple parents on the fly. I mean hell, returning and passing a function pointer is how I implemented multiple sorts:
    list->sort( list, list->getSortRoutine( SORT_MERGE ) );
    // or
    myCustomRoutine = getCurrentSort();
    list->sort( list, myCustomRoutine );

    That first "list" being passed in the sort function pointer invocation is where your magic "this" pointer comes from in C++.

  30. Re: What can't you do in C? by jimshatt · · Score: 2

    However, when my testers bitch about stutter in Java / Android No matter how badly I want Java or JavaScript to give me control of the damn garbage collector, so it doesn't run in the middle of the rendering loop or intense action sequence, I can't have it. I have to implement an object cache atop Java and pre-allocate everything, try my hardest not to give the GC a chance to run, and if I slip up once and let that fucker have control, it's game over, literally, when the enemy attacks and the game lags for half a second.

    You could write your own garbage collector for the JVM, which gives you 100% control over when, where and how to GC.

  31. Re:There are two kinds of programming languages... by DuckDodgers · · Score: 2

    Sometimes the type system gives more overhead than safety. A wonderful satirical example in Java: https://github.com/Mikkeren/FizzBuzzEnterpriseEdition

    You also have to weigh developer feedback time. I've developed web applications with Java Struts, coding directly to the Java Servlet API, Play Framework 1.x, and Play Framework 2.x (in Java, not Scala), and Python with Twistd. In order of speed of development of correct (i.e. in production without known bugs) code, they are from fastest to slowest: Python with Twistd, Play 1.x, Play Framework 2.x, Java with the Servlet API, Java Struts. Play Framework 1.x and Python give you instant reload. You save your changes, hit F5 in your browser, and see your change immediately. Anything I built without that takes three times as long. Play Framework 2.x doesn't have it, because under the hood Play 2 uses Scala and at least on my machine, best-case-scenario a Scala recompile of modified files after I change some Java file takes 5+ seconds. With Struts and just using the Servlet API, I have to reload the damn application and that's 10 seconds or longer. It seems like a trivial thing, but it's huge.

    I'd say hot reload brings Java on par with Python for development, except Python has one extra feature: the REPL. "How does X work?" type.. "Oh, that's how it works", go back to coding. With Java, even in an IDE it's "create a public static void main (String [] args) throws Exception { /* actual code I want to test */ } " and either put Imports at the top or use fully qualified package names. So the equivalent "fast try something out" I do with Python still takes four times as long.

    There's a reason that Google and Facebook and Twitter all use C++ and Java behind the scenes. But there's also a reason millions of sites use PHP, Python, Ruby, and Perl up front - because the development speed is so fast that you're into your testing (and unit tests) in a third the time of the Java version. So if your Java build takes three weeks of coding the application and one week of coding the tests, and your scripting language version takes one week of coding the application and two weeks of coding the tests (to offset the weaker type system), you still get to market faster with the scripting language.

    Maybe the ideal is something like Perl6 (which has optional typing but does enforce type constraints when they're listed) or Groovy (which you can convert to Java more or less as-is once your rapid development phase is over).

  32. Re: What can't you do in C? by bbn · · Score: 2

    I want to se your C code for this simple Haskell function:

    f x y = x*y

    When applied to just one argument:

    g = f 5

    You get back an one argument function that will multiply by 5:

    g 4 equals 20.

    h = f 10

    h 4 equals 40.

    Your task is to write a C function, that does not memory leak (although it is hard enough even if you are allowed to leak), that based on some parameter will return a another function that is different each time. Like in the above Haskell code, I shall be able to invoke your C function multiple times, for example with the values 5 and 10 and get back new functions that will multiply with 5 and 10. The later must of course not override the behaviour of the former.