Slashdot Mirror


Why JavaScript On Mobile Is Slow

An anonymous reader writes "Drew Crawford has a good write up of the current state of JavaScript in mobile development, and why the lack of explicit memory handling (and a design philosophy that ignores memory issues) leads to massive garbage collection overhead, which prevents HTML5/JS from being deployed for anything besides light duty mobile web development. Quoting: 'Here’s the point: memory management is hard on mobile. iOS has formed a culture around doing most things manually and trying to make the compiler do some of the easy parts. Android has formed a culture around improving a garbage collector that they try very hard not to use in practice. But either way, everybody spends a lot of time thinking about memory management when they write mobile applications. There’s just no substitute for thinking about memory. Like, a lot. When JavaScript people or Ruby people or Python people hear "garbage collector," they understand it to mean "silver bullet garbage collector." They mean "garbage collector that frees me from thinking about managing memory." But there’s no silver bullet on mobile devices. Everybody thinks about memory on mobile, whether they have a garbage collector or not. The only way to get "silver bullet" memory management is the same way we do it on the desktop–by having 10x more memory than your program really needs.'"

407 comments

  1. Easy by ArcadeMan · · Score: 5, Interesting

    Stop loading dozens of fucking libraries and frameworks and learn to really code.

    1. Re:Easy by Jartan · · Score: 2

      Stop loading dozens of fucking libraries and frameworks and learn to really code.

      In other words consider the memory cost of your actions and don't rely on the GC?

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

      We already know how to "really code". We just got sick of reinventing the wheel every time we start a new project. Now we let the libraries do the tedious crap, and we focus our attention on where it's actually needed.

      You're going to use our library-heavy code, and you're going to like it. You already do, in fact. You're lying when you pretend otherwise.

    3. Re:Easy by girlintraining · · Score: 4, Insightful

      Stop loading dozens of fucking libraries and frameworks and learn to really code.

      If memory management was so easy, we wouldn't have devoted so much of our programming guides, style manuals, etc., to it. It's not a simple matter of "I wave my hand and the problem goes away." It has existed since before there were "dozens of fucking libraries and frameworks" and at a time when people did know how to "really code"... it has existed since the very. first. computer. And it hasn't been solved to this day.

      The main reason, I suppose, is the same reason why we haven't yet found The One True Concrete that all things can be built out of, or the One True Operating System upon which everything can run, or the One True... you get the damn idea. Men much smarter than you have devoted their entire careers to trying to solve the problem, and it's incredibly pretentious of you to toss off a one liner like it's (puts on sunglasses) just a simple matter of programming.

      --
      #fuckbeta #iamslashdot #dicemustdie
    4. Re:Easy by Anonymous Coward · · Score: 5, Funny

      Stop loading dozens of fucking libraries and frameworks and learn to really code.

      Because *REAL* programmers don't use libraries or frameworks. In fact, *REAL* programmers don't even use wussy text editors like vi or emacs; they use butterflies.

    5. Re:Easy by ADRA · · Score: 1

      Thank you so much Ada, you've enlightened an entire generation of developers how wrong we've been our entire careers. Please please teach us the holy grail of never reusing code. We're all listening.

      --
      Bye!
    6. Re:Easy by Anonymous Coward · · Score: 1, Insightful

      Stop loading dozens of fucking libraries and frameworks and learn to really code.

      YEAH, anything beyond C is OVERHEAD!

    7. Re:Easy by girlintraining · · Score: 1

      Thank you so much Ada, you've enlightened an entire generation of developers how wrong we've been our entire careers. Please please teach us the holy grail of never reusing code. We're all listening.

      We'll get to that, but first we need to talk about these things called deadlines, managers, and paychecks. After I'm done with the Q&A about those three things, anyone who still wants to seek the Grail may sign up on the sheet here on the desk... (blows away some dust)... Now, open your text books to page 25...
      -- Ada

      --
      #fuckbeta #iamslashdot #dicemustdie
    8. Re:Easy by JustOK · · Score: 1

      Only 1 butterfly.

      --
      rewriting history since 2109
    9. Re:Easy by Jane+Q.+Public · · Score: 2

      "... and it's incredibly pretentious of you to toss off a one liner like it's (puts on sunglasses) just a simple matter of programming"

      Agree. But the memory management thing really is an issue, too.

      Take Android, for example. Android was designed to allow apps to remain in memory until you manually kill them, or the OS gets around to doing it, if ever. And the OS is notoriously lax at doing so. And yes, it was designed that way on purpose. Google doesn't want people killing apps... it cuts off their data stream and ads. Yes, really. So they built the whole OS that way. According to some people I spoke to who worked on Android.

      Fortunately workarounds have been developed by the community, but for stock Android it's still a real issue, and it really is built into the OS.

      Which still means I agree with you. You aren't going to just put on your programmer sunglasses and on a daily basis sidestep things that were designed into the OS. Ain't gonna happen.

    10. Re:Easy by lesincompetent · · Score: 1

      Indeed it is. Try to demonstrate the contrary if you want (forwards, not backwards towards assembly).

    11. Re:Easy by egr · · Score: 1

      How the fuck is this insightful?

    12. Re:Easy by TheDarkMaster · · Score: 1

      Fucking true.

      --
      Religion: The greatest weapon of mass destruction of all time
    13. Re:Easy by hedwards · · Score: 2

      I know, anything beyond manually flipping switches is overhead. C is a terribly bloated mess.

    14. Re:Easy by loufoque · · Score: 4, Funny

      Memory management is easy. Just program in C instead of JavaScript, problem solved.

    15. Re:Easy by TheDarkMaster · · Score: 1

      What he meant is the waste of memory that frameworks cause. And if you really knows what you are doing, is better to do your own specialized code than using a generic-framework one.

      --
      Religion: The greatest weapon of mass destruction of all time
    16. Re:Easy by brantondaveperson · · Score: 2

      Memory management is easy. Just program in C++ using smart pointers instead of JavaScript, problem solved.

      FTFY.

    17. Re:Easy by betterprimate · · Score: 2

      This is true, but it's JavaScript we're talking about. Project requirements are rarely scoped and developed from the ground up. Most apps and sites are dependent upon bloated frameworks and libraries that are not tailored for mobile capabilities; said frameworks were developed for the desktop.

      Not to mention very few JS developers know how to properly manage memory.

    18. Re:Easy by EdZ · · Score: 2

      There is a strange obsession among many that the only good RAM is empty RAM. Don;t shunt stuff out of memory until you need to, and it'll still be in memory next time you need it. Unless you want to page everything (rather than saving the important parts on sleep and assuming whatever is left in RAM might not be there again at wake but probably will), then there's no reason to turf anything out of RAM until you need that space for something else.

    19. Re:Easy by loufoque · · Score: 1

      That's for plebs.
      Better use real RAII.

    20. Re:Easy by brantondaveperson · · Score: 2

      Point is of course, you can't just forget about memory. And garbage collection has no place on a mobile device.

    21. Re:Easy by Anonymous Coward · · Score: 0

      It's sad even how few people claiming to be "C" programmers really understand how much work there is to memory management in a modern system beyond libc's "malloc" and "free". Go write (or even just find and read/understand) a useful, efficient, multithreaded embedded/mobile memory management library. Then take it down a level and go understand Linux kernel memory management.

      And I saw you posted that C programmers don't really need to use libraries, anyway. So I assume you are just calling mmap and brk syscalls directly in your code? Sounds simple enough...

    22. Re:Easy by loufoque · · Score: 1

      shared_ptr is reference counting, which is pretty much garbage collection.
      Just manage your memory without relying on this but by designing your application taking into account which objects are responsible for the lifetime of other objects (ownership).

    23. Re:Easy by Anonymous Coward · · Score: 0

      You don't get paid to code, do you? Be honest.

    24. Re:Easy by jythie · · Score: 1

      Eh, what do you expect. The bulk of the people moving to mobile development are coming from the worlds of desktop or web applications. Barely any have significant embedded experience and just treat the system as a mini-desktop.

    25. Re:Easy by girlintraining · · Score: 1

      Point is of course, you can't just forget about memory. And garbage collection has no place on a mobile device.

      Yeah, but mobile devices are just like our brains... we're really only using 10% of it... the rest is overhead for the operating system. x_x

      --
      #fuckbeta #iamslashdot #dicemustdie
    26. Re:Easy by tyrione · · Score: 1

      We just solved the Roman Concrete formula. One down. But seriously, Javascript by definition isn't concerned with tighly managed edge-cases and memory leaks by design. Those are left to the architect who is designing their code; and by that I mean modifying millions of pre-existing javascript code that is in itself often poorly optimized code.

      I seriously doubt most CS majors today have to get knee deep into Assembly and C programming. Most programs opt for C++ and Java while leveraging their respective garbage collection designs. Hopefully, we see Universities and even High schools requiring C/C++/ObjC with LLVM/Clang/LLDB and Compiler-RT when learning their respective languages. I could give a rat's ass about Java.

    27. Re:Easy by Anonymous Coward · · Score: 0

      C++ smart pointers do use RAII.

    28. Re:Easy by steveha · · Score: 2

      There is a strange obsession among many that the only good RAM is empty RAM. Don;t shunt stuff out of memory until you need to, and it'll still be in memory next time you need it.

      Hmmm, not sure I agree with this as a blanket statement. I guess it depends on what you mean by "until you need to".

      I just built my wife a new computer. The old one was only five years old, with a quad-core 64-bit 2.5 GHz CPU, but it had horrible performance issues running Firefox. The problem was that my wife is a "power user" for the web, with dozens of web pages open, and Firefox was caching so much stuff that just the Firefox memory usage was well over 4 GB of RAM. Since the total RAM in her computer was 4 GB of RAM, she was experiencing horrible thrashing.

      It made me wish that Firefox would start de-allocating RAM. Hold, let's say, 10 pages open, the most recently used (MRU) 10. If she clicks on one of her old browser tabs, load that page from the disk cache and free the RAM from the oldest page in the MRU list.

      The kicker is that Linux tries very hard to keep disk data cached in RAM. If the system has sufficient memory pressure, then Linux will let go of the cache, but if Firefox were only keeping the 10 MRU pages, the rest should be in RAM. So my thought experiment is that the old pages should usually re-load very fast. (Even if the Linux kernel has to go to the actual disk to get back the page, that is still faster than having the system thrash gigabytes of RAM in and out of the swap partition. And I think that with Flash and JavaScript, many pages are much smaller on the disk than they are in RAM, multiplying the savings.)

      Not only does her new computer have a much faster CPU, it has 16 GB of RAM. No more thrashing. So I guess it's a solved problem for her desktop use.

      It seems like for mobile, the memory pressure should be hugely worse. The major difference is that you won't see the kind of thrashing my wife saw because there is no disk-based swap partition.

      --
      lf(1): it's like ls(1) but sorts filenames by extension, tersely
    29. Re:Easy by skids · · Score: 1

      And if you really knows what you are doing, is better to do your own specialized code than using a generic-framework one.

      I'm sympathetic to this argument. I even use it frequently. But one thing to note is that using frameworks would not be quite so utterly inefficient if the development community could make their mind up which ones are worth using instead of several apps all loading their own flavor-of-the-month, each choading on your RAM instead of sharing between apps

      One thing I wish TFA had addressed is the prospects for much larger RAMs in mobile devices. It addresses the CPU speed prospects, but then goes on to point out memory as the bigger problem, and never touches on what is likely to occur in that area.

    30. Re:Easy by jhol13 · · Score: 1

      Mobile devices have one to two gigs of memory. Why GC works on PC with same amount of memory, but "has no place" in a mobile device?

    31. Re:Easy by Anonymous Coward · · Score: 0

      Either I don't understand your irony, or you like all those kids who got a three months course in Ada and think they are experts, while in reality they have absolutely no clue about the language. Compare to something like C++, Ada is a difficult language to master and a PITA for lazy programmers, but it's all about code reuse and good programming practice.

    32. Re:Easy by Dahamma · · Score: 1

      shared_ptr is reference counting, which is pretty much garbage collection.

      Not at all. Shared pointers are just an encapsulation for reference counting that can delete the object when it's no longer used. There is no garbage - the memory is around when needed, and freed as soon as it isn't. And there is no collection - the last shared pointer object goes out of scope, and its destructor can delete the object it contains.

      This sort of thing is what object oriented programming is all about, it's not just a shortcut to hide your variables and put your functions inside different namespaces...

    33. Re:Easy by Anonymous Coward · · Score: 0

      No, refcounts and GC are completely different.

      Refcounts are a way to automatically manage a manually allocated, C-style memory heap where pointers are sacrosanct. You write down somewhere how many pointers exist to a particular object, increasing or decreasing that number whenever new references come or go. Whoever sees it go to zero is responsible for freeing the memory.

      GC is different. In a GC, you don't free memory at all. Allocation is cutting the bottom off an already existing memory space and giving you the memory. When the allocator runs out of memory, it scans through the entire heap to see what's still reachable and copies the reachable bits back down to the bottom of memory, 'freeing' memory in the process.

      Advantage of GC is that memory leaks aren't possible and neither is memory fragmentation. Disadvantages are that memory deallocation/object finalization is nondeterministic, you get annoying pauses as the GC has to traverse the entire object graph to determine what to copy, and most importantly you have to deal with pointers changing all the time. Which is why most C++ environments don't support a garbage collector; it's difficult to write one that doesn't break code in horrible ways, and they typically have to be conservative collectors that assume any valid aligned pointer in memory could actually be part of the object graph.

      Advantage of refcounts is that you get almost all the advantages of GC without having to pay the cost of either extravagant memory usage or high random latency bursts (GC pauses). The only disadvantage is that you can't make complex object graphs with reference cycles, but the vast majority of code isn't going to create such structures; in most cases making one type of pointer (e.g. parent pointers in trees) not count is sufficient to break cycles. CPython managed to get along with only reference counting until around 2.4 or so, and even then the GC can't break reference cycles if __del__ has been defined (due to language issues) - but nobody is complaining about that.

      I mean, seriously, imagine how much slower CPython would be if it was an exclusively garbage collected language.

    34. Re:Easy by Anonymous Coward · · Score: 0

      If you're relying on libraries like that, you're already doing it wrong.

      Every C programmer I've ever known spends the first several years playing around with memory management libraries which try to generic solve memory management issues. Invariably they just add needless complexity.

      Every seasoned C programmer I know (10+ years) stopped bothering. You learn and use a strict set of patterns, which are quite simple and well worn. You minimize dynamic allocations by staying away from generic data structures--e.g. for a linked list, you embed the sibling pointers in the object itself, rather than allocating a separate container node... extremely few data structures need to hold random, arbitrary, and untyped objects.

      Memory management is only difficult if your data structures and API are too complex, rather than appropriately and narrowly tailored to the immediate task. Simplify, simplify, simplify.

      And the Linux kernel is a bad example for you, because their allocation strategies are sweet and simple, especially when you strip away many of things that are unnecessary for userland applications. There's been infinitely more words written about them then the code actually implementing them. But in any event, allocation strategies has little to do with the complexity of memory management. The complexity comes from managing ownership and lifetime.

    35. Re:Easy by brantondaveperson · · Score: 1

      I don't believe that GC works effectively on a device with any amount of memory. As stated in the (extremely interesting) article, GC works best by using anywhere above four times more memory than your application actually needs. That doesn't fit with any definition of 'works' that I'm comfortable using.

      Also, my PC has 8 gigs of memory - backed up by a large hard-disc as a virtual store. Your mobile device has 1-2 gigs of memory, backed up by nothing.

    36. Re:Easy by Joce640k · · Score: 0

      You minimize dynamic allocations by staying away from generic data structures--e.g. for a linked list, you embed the sibling pointers in the object itself, rather than allocating a separate container node...

      No, you don't. If you've got any brains you start using C++.

      --
      No sig today...
    37. Re:Easy by TheSeatOfMyPants · · Score: 1

      Why would she need dozens of tabs currently active rather than use an extension like TooManyTabs? Don't get me wrong, I've been a power user since I first got on with Netscape 1.x, and used to be way over the top with the number of Firefox tabs -- then I started getting tired of the performance hit, and stopped to think whether I really needed ALL of them open simultaneously. Turned out that I didn't -- I usually had a bunch pointing to comments I was planning/writing (many of which I never got around to finishing), articles I planned to read (which now go into Readability or TMT), articles thought I might want to reference (now in TMT or bookmarked), plus the usual assortment of app tabs (Gmail, shopping cart, etc.). After all, I can only have so many windows & tabs visible at the same time...

      I'm still a Firefox power user, but usually max out tab usage at around 20 and run a similar number of extensions. My computer's a single-core 2GHz (an exciting upgrade from my old 1.6GHz last year) with 1GB of RAM, running Linux for the performance boost over WinXP. Not ideal, but given I'm just doing generic web/office stuff that doesn't require a really high-powered system, it's OK -- and frankly, I'm a lot happier with my stuff this way than I was back when I casually bought replacements rather than do things like take the time to ask myself "do I REALLY need 90 tabs active?"

      --
      Now mostly at Usenet:comp.misc & SoylentNews.org (it's made of people!)
    38. Re:Easy by Jane+Q.+Public · · Score: 1

      "Unless you want to page everything (rather than saving the important parts on sleep and assuming whatever is left in RAM might not be there again at wake but probably will), then there's no reason to turf anything out of RAM until you need that space for something else."

      You have a good point, too, but I don't agree 100%. Especially given the actual reason Google did it that way. I think the balance should be somewhere between the two extremes. I just don't think Android effectively finds that middle.

    39. Re:Easy by JDG1980 · · Score: 1

      Stop loading dozens of fucking libraries and frameworks and learn to really code.

      Why reinvent the wheel? If I need an image carousel on my site, sure, I could write my own in raw JS, but I'm not arrogant enough to believe my image carousel would be better than the 5,000 others already out there, especially since many of these have been used by multiple people and already extensively debugged. If you're writing desktop applications and want to compress data, do you write your own compression code or do you use zlib? How many people write their own JPEG decompressor? Almost no one – everyone uses the native OS functionality, or if you are writing portable code, you use libjpeg(-turbo).

    40. Re:Easy by steveha · · Score: 1

      Why would she need dozens of tabs currently active rather than use an extension like TooManyTabs?

      Thank you for telling me about TooManyTabs. It didn't occur to me to search for extensions that would kill all but the MRU tabs, so I guess it's my fault she didn't use that extension.

      So, in summary, she wasn't using that because neither of us had ever heard of it. I'll look into it.

      frankly, I'm a lot happier with my stuff this way than I was back when I casually bought replacements

      Well, good for you. But I'm not sure "casually" is really the right word for a new computer after five years.

      We can afford the computer, the extra RAM also helps VirtualBox run Windows 7 better (she mainly uses Windows for Netflix), the new larger hard drive means she is no longer running out of disk space, the extra speed sure doesn't hurt, and I'm going to repurpose her old computer (not just throw it away or something). And, I succeeded in making her new computer quieter than her old one, always a plus.

      Also, I prefer to set up a new computer and then keep the old one unchanged for awhile to make sure the new one is working out, rather than trying to upgrade a computer in-place; the latter is much more stressful if the upgrade goes sideways, which would have left her without a computer had it happened.

      So, my reasons for building a new computer for her seem pretty adequate to me. And, please pardon me for saying so, but your lecturing tone really rubbed me the wrong way.

      I was planning to use her computer as my new computer (my old one is an Athlon XP, and I think it's over a decade old), but now I want one just like her new one. I might actually want to recompile Android from source, and 16 GB is the minimum recommended RAM for doing that. Wow, I remember when 16 GB would have been large for a hard disk, let alone system RAM.

      --
      lf(1): it's like ls(1) but sorts filenames by extension, tersely
    41. Re:Easy by El+Royo · · Score: 1

      A flippant answer but it misses the point. As does the original article. It's true that writing performant mobile apps is hard. But it's always true that writing good code that has to perform in a constrained environment requires attention to performance and memory.

      However, one thing that JavaScript libraries tuned for mobile provide is an optimized approach to common problems that are handled differently on different mobile browsers. The framework I use (and I wrote the book on it, literally) is Enyo. As a simple example, Enyo provides a number of scroll strategies that it choose from based upon the OS and even the version. Are you aware of all the bugs in the various versions of the Android browser? How about the bugs introduced in one version iOS and fixed in the next? Having a framework deal with the wildly different browser implementations so you can focus on actually, you know, writing an app is important.

      The original article goes to great lengths to talk about GC and brings up the strawman of video streaming and image manipulation. If you want to do those on mobile today, go native. If you want JS as a front-end, use PhoneGap. Pick the right tool for the job. He then talks about pure programming performance. Tell me, how many apps do you have on your phone that are processor bound? I would guess almost all of them sit around and do nothing until you tap a button. Responsiveness is completely different from outright performance and it's completely possible to write rich, responsive apps in mobile using JavaScript.

      --
      Author of Enyo: Up and Running from O'Reilly Media
    42. Re:Easy by Anonymous Coward · · Score: 0

      Garbage collection can be an important issue for Javascript, but a more accurate title might be "Why Javascript on mobile is slower than Javascript on the desktop", and there are two reasons -- CPU and RAM.

      RAM limitations mean you need to garbage collect more, CPU limitations mean garbage collection is slower. But, as you well know, neither of those mean it is SLOW, just that it is slower than your desktop.

      Any programmer can achieve anything in any language (given enough cpu, storage, memory), but a good programmer can achieve it with code that runs efficiently.

      Basically -- of course your phone runs webkit slower than your desktop does. Your phone has 1/3rd the power at best, and anywhere from 1/4 to 1/32nd the amount of memory. And it's storage is likely slower too. Reasons why webkit requires extensive work on it to be done by any team wanting to use it for (relatively) low powered, low memory devices.

    43. Re:Easy by Anonymous Coward · · Score: 0

      shared_ptr is reference counting, which is pretty much garbage collection.

      This is the exact point where you proved beyond a shadow of a doubt that you're a retard.

    44. Re:Easy by betterprimate · · Score: 1

      Men much smarter than you have devoted their entire careers

      When you say this, you sound dismissive and stupid. From your former posts, I know you are not stupid but simply dismissive. From that, I can only derive that you have psychological and esteem issues.

      Just saying.... this comes from someone who has an IQ over 200.

      Now, a better of way of phrasing the same sentiment would be, "smart men have invested more time and work into [this topic] than you have."

    45. Re:Easy by Anonymous Coward · · Score: 0

      shared_ptr is reference counting, which is pretty much garbage collection.

      Not at all. Shared pointers are just an encapsulation for reference counting that can delete the object when it's no longer used. There is no garbage - the memory is around when needed, and freed as soon as it isn't. And there is no collection - the last shared pointer object goes out of scope, and its destructor can delete the object it contains.

      This sort of thing is what object oriented programming is all about, it's not just a shortcut to hide your variables and put your functions inside different namespaces...

      Looks like you never completed college. Garbage collection is the act of deleting data (garbage) that is no longer needed, regardless of whether said collection is automatic or manual. This is a pretty simple concept. Reference counting is a form of automatic collection that has the benefit of being deterministic (deleting immediately when the garbage is no longer needed instead of at some arbitrary point in the future) but also has the problem of choking on cyclical data structures (A->B->C->A means A,B,C will never be deleted). new/delete and malloc/free are a form of manual collection, on stack objects in C++ are deterministic automatic collection again but don't have the cycle problem of reference counting.

    46. Re:Easy by Kalumba · · Score: 1

      Emacs DOES have the butterfly function. Good ol' C-x M-c M-butterfly command.

      --
      Knowledge is power, but wisdom is divine!
    47. Re:Easy by gl4ss · · Score: 1

      I'm curious, what difference do you think it being "embedded/mobile" memory management library makes? (and please, no bs about it absolutely having to be some two phase allocation since its mobile.. I had enough of symbian and it's unnecessarily complex memory management that served no purpose at all after the first psions)

      plenty of sw work just fine with malloc and free and no fancy bloat systems on top.

      --
      world was created 5 seconds before this post as it is.
    48. Re:Easy by Anonymous Coward · · Score: 0

      Are you suggesting we throw all libraries out the window? You mean, re-invent the wheel every week and/or in every project? That's not going to help you write more effective code for the current project. It may work as a teaching method, taken over many projects.

      The rule of thumb is that other people can code better than you can, especially framework and library developers for the average library. Thinking otherwise is vein and arrogant at best.

    49. Re:Easy by Anonymous Coward · · Score: 0

      Stop reinventing the wheel and start learning how to use frameworks.
      Oh yeah, and GTFU.

    50. Re:Easy by serviscope_minor · · Score: 1

      Huh?

      RAII and smart pointers are not mutually exclusive. You get a smart pointer pointing to your object or an exception if it can't be destructed.

      All shared_ptr does is take care of non-local ownership issues.

      --
      SJW n. One who posts facts.
    51. Re:Easy by gbjbaanb · · Score: 1

      huh? Smart pointers work *because* of RAII, there's no "I'm better than you because I roll my own destructors and don't use the library systems that help".

      There shouldn't be any willy-waving here, real men use C++ and don't need to worry about memory management and object lifetimes much anymore.

    52. Re:Easy by loufoque · · Score: 1

      All shared_ptr does is allow for lazy GC-style memory management in C++.
      ownership usually does not need to be shared.

    53. Re:Easy by loufoque · · Score: 1

      shared_ptr is a distortion of the RAII principle.
      RAII says that you acquire a resource in a constructor and free it in the destructor. shared_ptr does not free the resource in the destructor, it decrements a reference count, and if it reaches zero it frees the resource.

      Proper RAII is exclusive ownership. shared_ptr is for lazy GC-style coding.

    54. Re:Easy by angel'o'sphere · · Score: 1

      shared_ptr has absolutely nothing to do with garbage collection.
      Managing your memory without relying on what? GC or smart_ptr?
      Without smart_ptr you write your own code everywhere where I would use a smart_ptr, what would be the point of that?
      Also, you do know (yes you do, or?) that "object owner ship" is an completely artificial concept you only need to simplify your memory management code? In GC languages there is no "object owner ship", that means no architect or coder has to invent an owner for certain other objects to be able to manage their memory.

      The typical problem e.g. is: you wrote some code where you need a lots of objects of type X. Someone else wrote an algorithm using such Xs. And I now optimize the code by introducing a cache.

      I *can't* introduce a cache because without my cache noticing *your* object owners decide they can delete/free objects that I still have in my cache. That means my first naive implementation won't work.

      I have to figure what your object owners are and rewrite your code and all your memory management just to introduce a cache! And on top of that I likely have to invent a new "owner".

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    55. Re:Easy by angel'o'sphere · · Score: 1

      GC works best by using anywhere above four times more memory than your application actually needs.
      That is complete nonsense.
      It heavy depends on the application (they way the application is doing its own caching e.g.) The less "overhead" memory you grant the application the faster the GC will be, because the less unreferenced objects are there.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    56. Re:Easy by TheRaven64 · · Score: 1

      The problem is that there isn't a good interface between the kernel and applications in most desktop operating systems (OS X is the exception, L4 HURD does it the best way but has 2 users) for letting them know that you're getting low on physical memory. The kernel knows when you're low on memory, but doesn't have any knowledge of the application's data structures so can't make very intelligent decisions about what to swap out. The application can easily throw away stuff from caches, but isn't ever told that it needs to. Mobile operating systems provide applications with explicit notifications that now would be a good time to delete some cached data. On a modern desktop, some of the trades are now very weird - it's often cheaper to refetch data from the network than it is to do a few page faults (although only if you're not on an SSD).

      --
      I am TheRaven on Soylent News
    57. Re:Easy by TheRaven64 · · Score: 1

      No, refcounts and GC are completely different.

      You started well, but then ended up badly. Garbage collection is an abstract concept, reference counting is a concrete mechanism. GC means deleting objects after they are no longer referenced. It can be implemented manually, using reference counts, using tracing, or using reference counts with automatic cycle detection. The last two are equivalently expressive, but have very different cache interactions. The rest of your post talks about one specific subset of implementations of tracing garbage collectors.

      --
      I am TheRaven on Soylent News
    58. Re:Easy by Anonymous Coward · · Score: 0

      Gee isnt this wonderful. Smartphones taking web browsing back to 1998.

    59. Re:Easy by serviscope_minor · · Score: 1

      All shared_ptr does is allow for lazy GC-style memory management in C++. ownership usually does not need to be shared.

      Well yeah, especially with move constructors. But, I still don't get how you use it instead of RAII. shared_ptr itself uses RAII.

      --
      SJW n. One who posts facts.
    60. Re:Easy by loufoque · · Score: 1

      The principle of RAII is that you acquire a resource in a constructor and release it in the destructor.
      When you copy, you copy the resource.

      shared_ptr does not do that. The destructor does not release the resource, and copying just aliases the resource.

    61. Re:Easy by TheDarkMaster · · Score: 1

      Not utterly, but is inefficient. At best, you need to load more code to do "X" with a framework than you can do with a specialized (and smaller) code. The gain may seem small, but in many cases makes all the difference

      --
      Religion: The greatest weapon of mass destruction of all time
    62. Re:Easy by RoboJ1M · · Score: 1

      So, this trend of moving your MVC/P/VM engine from the server (.NET, python, etc) to javascript (knockout) is a bad thing?
      Because I've ALWAYS wanted a decent reason to tell people to stop doing that.

    63. Re:Easy by gbjbaanb · · Score: 1

      you say it yourself - you acquire a resource in the ctor, and release it in the dtor... so you acquire the shared_ptr (which increments a ref count) and release it in the dtor (which decrements the ref count).

      That's still RAII, the true meaning of RAII is that the acquisition and releasing occurs deterministically, so you always know what the system is doing for you. there's no surprises like in GC systems where the resource is still held for an unknown amount of time.

      RAII has nothing directly to do with resource allocation and free, its all to do with deterministic initialization and cleanup. There's a subtle difference, in that it works for a lot more than just allocating memory.

    64. Re:Easy by turp182 · · Score: 1

      It's a logical progression actually, all of the major development approaches have large libraries that are convenient and provide a base level of functionality (C/C++/Java/.Net).

      The issue with Javascript is that the libraries have to be loaded onto the client at runtime (rather than being installed).

      Do any browsers implement library handlers (I don't have time to check right now)?

      This would include:
      1. Store all JS libraries.
      2. When a script depends on a library, check the version, get new version from script's site, but also keep old version. If the version is already on the client, just load it up.
      3. Rinse and repeat.
      4. Allow user to clear or remove specific libraries via a GUI.

      This would allow the "framework(s)" to be "installed" on the client, and it's not like you end up with GBs of scripts (MBs for sure). A manager could enforce a maximum script pool size and then, when the limit is reached, delete the oldest, least used scripts as needed.

      Anyway, I'm a bit naive when it comes to web stuff, I'm mostly server side or Winforms, but I'm very familiar with caching strategies.

      --
      BlameBillCosby.com
    65. Re:Easy by K.+S.+Kyosuke · · Score: 1

      Yeah, but mobile devices are just like our brains... we're really only using 10% of it.

      Do people still believe in that nonsense? :/

      --
      Ezekiel 23:20
    66. Re:Easy by Anonymous Coward · · Score: 0

      I agree with your overall point, but shared_ptr is nothing at all like garbage collection. It is closer to RAII because it is deterministic and synchronous (immediate when the last reference holder goes out of scope). There is no garbage collector thread scanning for dead wood and occasionally stopping the world, all in painful and non-deterministic ways. GC a tradeoff with upsides (no code to "manage" memory, no such thing as a dead pointer to crash on) and downsides (stop-the-world GC, jittery GC CPU use & significant memory overhead), and as the original post discusses, the downsides are prohibitive in a memory-constrained environment.

    67. Re:Easy by EvanED · · Score: 1

      Looks like you never completed college.

      Looks like you are too insistent on there being exactly one definition for "garbage collection."

      First, you say that garbage collection can be automatic or manual. And while it's true that you'll sometimes see "automatic garbage collection" used to be specific, you essentially never hear people use "garbage collection" to refer to anything but automatic GC. It's possible that the only times I have is in statements like "we use the term 'automatic garbage collection' to make it clear that it is not manual." I can't find a citation for where the term was first used. Remember, you can't always say that the meaning of a compound term is just the composition of its parts! (Look how many Slashdotters think that "kliobyte" is rightfully 1024 bytes.)

      Second, it's not even the case that the common use of GC refers to just automatic memory management in general. It's definitely commonly used to refer specifically to tracing collectors, excluding (pure) reference counting. I don't particularly like this usage, but it's widespread enough I think it's really hard to say it's wrong. (I like to use "automatic memory management" for the catchall and "tracing GC" for, well, tracing GCs.)

    68. Re:Easy by EvanED · · Score: 1

      Two additional points:

      1.) The GC article on wikipedia that you linked to starts off by saying "garbage collection (GC) is a form of automatic memory management." Your own source directly contradicted one of your statements!

      2.) One argument for the more specific use of "garbage collection" to refer to just tracing collectors is by way of the other use of "garbage collection", which is the process that happens usually once a week where people come by and get your trash cans, then take all the garbage you've generated over the course of that week and take it to the dump. They don't come by every time you unwrap or empty a food container, just like tracing collectors don't come by as soon as the program generates new garbage by making part of the heap graph unreachable; yet that would be the analog to reference counting.

    69. Re:Easy by EvanED · · Score: 1

      That is complete nonsense.
      It heavy depends on the application (they way the application is doing its own caching e.g.) The less "overhead" memory you grant the application the faster the GC will be, because the less unreferenced objects are there.

      Not really. Efficient (non ref-counting) GCs themselves all have substantial memory overheads just because of the way they divide the heap up into spaces and move objects around.

      Yes, application performance does affect a lot: a program that is much better about allocations and makes a lot fewer of them will trigger far fewer GC cycles. But unless it just allocates all the memory it needs right away at the start and never calls new again, it still needs the GC overhead.

      The "4x vs. what the application needs" is misleading in some sense -- it's not what the application needs, it's relative to a version of the program that uses manual memory management. So it should be "GC needs 4x more memory to be efficient than a manually-managed version." So if you say "I'll just reduce the size of the program's cache to make the GC do better", to get an apples-to-apples comparison you'll also have to do the same for the manually-managed version, and you'll be back to 4x.

    70. Re:Easy by EvanED · · Score: 1

      The principle of RAII is that you acquire a resource in a constructor and release it in the destructor.
      When you copy, you copy the resource.

      That's an extraordinarily limited definition of RAII in my opinion.

      For example, the Wikipedia article on RAII states "Ownership of dynamically allocated objects (memory allocated with new in C++) can also be controlled with RAII, such that the object is released when the RAII object is destroyed. For this purpose, the C++11 standard library defines the smart pointer classes std::unique_ptr for single-owned objects and std::shared_ptr for objects with shared ownership."

      It also cites Bjarne Stroustrup as the inventor of the term "RAII". Let's see what he has to say: "The technique for managing resources using local objects is usually referref to as [RAII]" [The C++ Programming Language, special edition, p.366]. Doesn't say that the constructor must copy and the destructor must release exactly -- just that they must manage the resource.

      Or let's look at what is probably one of the most widely-regarded C++ books, Herb Sutter's Effective C++ (3rd ed). Sutter defines RAII as "the idea of using objects to manage resources" [p. 63 in Item 13]. Later he says "Item 13 introduces the idea of [RAII]... and it describes how auto_ptr [also doesn't fit your definition] and tr1::shared_ptr are manifestations of this idea for heap-based resources" [page 66 in Item 14]. Then he goes on to describe possibilities for a question "that every RAII class author must confront: what should happen when an RAII object is copied?" [page 67].

      So no, you're wrong.

    71. Re:Easy by datavirtue · · Score: 1

      When they say "thinking about memory" do they mean the amount used or management? Under garbage collection you still have to think about memory usage, just not the actual management. Sounds like people they are used to garbage collection don't know how to do either. On a PC you can turn your app into a bloated memory hog without regard for space and things will generally run fine but on a small device with a weak processor and very limited memory you have to avoid filling up RAM for both of those reasons--it has to manage memory with CPU cycles and hogging RAM is going to slow or render the application or the system inoperable.

      They talk about garbage collection in the sense that you don't have to worry about the amount of RAM available--GC simply doesn't help you there, in fact it make that problem worse.

      --
      I object to power without constructive purpose. --Spock
    72. Re:Easy by loufoque · · Score: 1

      Those people saying that don't make it a very good idea.
      Stepanov, the inventor of the STL, clearly recommends a non-aliasing non-sharing approach to scope-based resource management.

      And I found him to be a more interesting guy than Bjarne or Herb when it comes to C++ programming.

    73. Re:Easy by rufty_tufty · · Score: 1

      "And garbage collection has no place on a mobile device."
      I would change and say that garbage collection has no place on an real time application, and I believe a mobile device should run an RTOS, even though no modern ones do.
      Garbage collection is a great tool if you have sufficient memory and no real time requirements.
      GC can help make programs more readable and programs should be written for humans to read and only incidentally for machines to execute. However in the many situations where it is not appropriate we shouldn't be using it and UIs are one of those.

      But isn't this the way it should be, you knock up a prototype in the most convenient language for the job, then profile it, then improve it where it needs improving?

      --
      "The weirdest thing about a mind, is that every answer that you find, is the basis of a brand new cliche" -
    74. Re:Easy by shutdown+-p+now · · Score: 1

      Google doesn't want people killing apps... it cuts off their data stream and ads.

      From the perspective of ads, there's no difference whatsoever between an app that's invisible in background, and an app that's not running at all.

    75. Re:Easy by shutdown+-p+now · · Score: 1

      Writing fast, high-performance, memory-constrained code is not easy, yes. So? You still need to do so if you want your apps to run well on mobile, which is pretty much the whole point of TFA.

    76. Re:Easy by EvanED · · Score: 1

      Those people saying that don't make it a very good idea.

      You didn't say it was a bad idea, you said it wasn't RAII.

      (OK, you did kind of say it was a bad idea, but that wasn't what I was replying to.)

    77. Re:Easy by angel'o'sphere · · Score: 1

      Indoubt an app like yahoo weather report needs any skills at all to be written. I doubt the difference between a naive implementation and a super good fine tuned one by a master C++ programmer is noticeable. Reason: you only write 1% of the bottom line functionallity. The rest is drawn from libraries that you have no controll over.

      Anyway, bottom line most of (all?) the people here claiming that they can manage memory in C++ likely can't ... I never saw a program the last 30 years that had no memory related bugs. Regardless wether it was an allocation/deallocation problem or simple read/write behind or other buffer overflows.

      The funny thing is memory problems often stay undetected because several things have to happen at once: make a mistake here, *and* stumble over it again later.

      E.g. if I put by accident a 0 into the middle of a string (and garbage behind it) the string is still a valid string for all C functions. That the memory got garbled no one realizes imediatly.

      The latest errorr e.g. a few days ago. A new ring buffer got introduced. It was linked into all modules that. beofre used a buffer.

      One module failed. The "owner" of the module claimed it was the new buffers fault. It was not.

      He had a bug since 2 years that did not manifest itself.

      He was reading in a text file (the whole file into memory). He only allocated the exact amount of bytes according to the size of the file. So he ommited the 0 byte (which he should have added after reading in the file at the end). However till yesterday the file was an odd number of bytes sized text file. And the malloc routine allocated a few bytes more to make it an 4 bytes "padded" block of memory. The malloc routine was zeroing out the memory before returning. So the text file had a few 0 bytes at its end by default. Until yesterday. A new ring buffer got introduced *AND* the text file changed (its size) ... unrelated.

      The programmer with the bad file reading and moving code blamed the coder of the ring buffer.

      Anyway ... as I said before: I hardly have ever seen some C or C++ code that had not either obvious bugs or died unexpectetly by non obvious bugs.

      If we still had 2megs of ram THEN we perhpas hat programmers that new something about memory management.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    78. Re:Easy by angel'o'sphere · · Score: 1

      There is no single GC algorithm that uses ref counting.
      Ref counting DOES NOT WORK, to reclaim unused memory in the sense a GC works.
      No one can distinguish between a "normal program" where memory is allocated manually versus a GCed one. As in all situations you only have one of both. In the rare cases where you might have both you can assume one is buggy, or both (like in a research study at an university).

      Bottom line in C++ versus Java e.g. a simple algorithm will have exactly the same memory footprint and exactly the same deallocation "overhead". Claiming that reading 100 lines of text where each line is in a String object is more costly in Java/C#/JavaScript than in C++ is just complete nonsense.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    79. Re:Easy by EvanED · · Score: 1

      There is no single GC algorithm that uses ref counting.

      That depends on how you define "garbage collection", and there's not even close to universal agreement about whether refcounting is included. For instance, Aho et al.'s dragon book includes a section "Reference Counting Garbage Collectors". Anyway, I don't really care what definition you use; when I put the parenthetical in "efficient (non ref-counting) GCs" it was less to say "hey I like the broader definition" and more to clarify exactly what I meant.

      As to the rest, I just replied to your other response to me. :-)

    80. Re:Easy by EdZ · · Score: 1

      The problem was that my wife is a "power user" for the web, with dozens of web pages open, and Firefox was caching so much stuff that just the Firefox memory usage was well over 4 GB of RAM.

      I have the opposite issue: My current firefox session has over 360 open tabs (a bad habit of using them in leiu of bookmarks), but uses less than 1gb of RAM, of which I have 16gb available.

    81. Re:Easy by spiralx · · Score: 1

      No, because JS scripts get cached locally and loaded from there if already present - many, many sites use Google's JS library CDN as the source for libraries, as then the user's browser only ever downloads each file once, and then every site that also links to the same library loads it from the local cache.

      Plus there's things like local storage now, which means web sites can store data and assets locally (up to a limit), and use that as a cache. Writing a remote version check and update handler is pretty trivial for an application.

    82. Re:Easy by turp182 · · Score: 1

      Thanks for the info. I was aware of some caching, but I don't know any specifics (which could vary by browser).

      Do you know if the files are cached by file or file/site (where the same library would be downloaded multiple times)? And I'm assuming file name is the key to uniqueness, a header or other info inside the file would require more I/O than a directory read. Given anyone can edit a JS library I imagine the site is included as part of the cache key.

      I shall seek out the Google for more information...

      --
      BlameBillCosby.com
    83. Re:Easy by turp182 · · Score: 1

      Sorry for the spam, but I searched and found a good article about HTTP caching (I mostly use TCP). No response necessary.

      Thanks again.

      --
      BlameBillCosby.com
    84. Re:Easy by spiralx · · Score: 1

      Glad you found the info, I meant to reply sooner but got distracted by shiny things.

      There's been a huge flux in all areas of web development the last few years, who knows what will come up in the new few. At the moment a good portion of the problems I have is there's too much code out there for everything, all in different states of development and with slightly different features and methodology - it's not always easy to find the right tools. Still, I'm sure something like the Apache Commons, Spring, etc. will eventually arise as a de-facto standard.

    85. Re:Easy by TheSkepticalOptimist · · Score: 1

      Yes and no.

      Yes, there is a tendency for people to just pick up a library, use a few features of it, but then bloat their product with them.

      On the other hand

      I also hate it when people always assume they know how to build a better mouse trap and do everything from scratch.

      When it comes down to it, a library tends to be created by many people, most likely smarter than you, that is also field tested on hundreds or thousands of sites and products. You get the benefits of the experience and testing by using it, unlike trying to roll your own untested code that you just assume is better out of arrogance.

      I think if you are using more than 50% of the features of any library, go for it, but to use an expansive library just to not have to write a few features is lazy and not beneficial.

      --
      I haven't thought of anything clever to put here, but then again most of you haven't either.
    86. Re:Easy by bensyverson · · Score: 1

      Ugh, I wish I could moderate this +1000. Javascript is actually fast. The reason people think it's slow is that they're loading elephant.js, cucumber.js, antidisestablishmentarianism.js, squeek.js, and basically any word appended with ".js"

    87. Re:Easy by Anonymous Coward · · Score: 0

      Reference counting is not garbage collection, and even suggesting that it is suggests a lot of ignorance about what GC is.

    88. Re:Easy by Anonymous Coward · · Score: 0

      You need, at least, a second butterfly for when marketing changes the specs.

  2. always by Spaham · · Score: 5, Insightful

    You always need to think about memory. Like you need to think about what you're doing.
    Too bad for the "write app get rich" idiots.

    1. Re:always by egr · · Score: 2

      You always need to think about memory.

      +1, you have to always think about memory, no matter what language and garbage collection or not, memory leaks will still bring your system to a crawl.

    2. Re:always by AuMatar · · Score: 1

      Yup. When I worked at Amazon the #1 question on internal mailing lists was "my Java webservice feezes up and breaks SLA whenever GC kicks in, how do I fix this?". GC is not a silver bullet, and you're going to end up thinking about memory on anything non-trivial.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    3. Re:always by Anonymous Coward · · Score: 0

      What were you talking about?

    4. Re:always by K.+S.+Kyosuke · · Score: 1

      If Java is the problem, Zing may be the answer.

      --
      Ezekiel 23:20
    5. Re:always by Anonymous Coward · · Score: 1, Informative

      You think about it a *lot* less in a garbage collected language. There's a big difference between occasionally realizing one part of your system is using a lot of memory and spending time almost every day asking if something will leak or double free.

      But they're correct that generational garbage collection uses more RAM to solve the same problems. Usually even if it's compacting.

    6. Re:always by Kjella · · Score: 1

      You always need to think about memory. Like you need to think about what you're doing. Too bad for the "write app get rich" idiots.

      But there's plenty "good code, crap idea" that won't make you rich either, most that have gone viral haven't been massively complicated, complex state of the art games. They've been simple, fun and easy to get into while being rather run-of-the-mill technically. Sure, you can't be hopeless but a lot are sufficiently skilled while the l33t coding skillz won't do any good on their own.

      --
      Live today, because you never know what tomorrow brings
    7. Re:always by girlintraining · · Score: 0

      You always need to think about memory. Like you need to think about what you're doing.
      Too bad for the "write app get rich" idiots.

      Those "write app get rich" idiots are likely your future employers. They don't know how to program, and they have markedly little understanding of it; That's your job. Oh, and they want it done fast, cheap, and right. Think you can score all three? No? Okay then -- maybe you need to take a step back and realize that programming for money these days is about building a program using a finite number of tools and resources, on a budget, and under a deadline. And I have yet to work on a project where there was enough of anything I needed to do it fast, cheap, and right.

      So either I'm one of those "write app get rich idiots", or I'm one of those in the unemployment line I guess. Three guesses which one I picked -- first two don't count. These are the realities of professional programming; We don't have time for perfect... we'll settle for "it compiles" and using something that after hours of beating it with a hammer just started working, but we don't know why... that's just how it is. I didn't write the rules, I just write the code.

      --
      #fuckbeta #iamslashdot #dicemustdie
    8. Re:always by ADRA · · Score: 1

      Most high level languages these days don't leak unless you leave explicit permanent handles to things laying around. Is that what you're talking about, or not-quite garbage collectors which are really just poor substitute reference counting solutions. I haven't worried about true 'leaks' in code for years. Occasionally (like yearly maybe) which are leaking bad references (generally due to greedy singletons). The most interesting part of memory management I and probably most people deal with is are the trade offs between caching vs. re-fetch/re-creating transient data, which has everything to do with memory management and nothing to do with leaks.

      --
      Bye!
    9. Re:always by egr · · Score: 1

      If the language leaks memory (without any misdeed by the programmer) I consider it to be a bad language. Actually I was exactly talking about dead/bad references, caching and frequent re-allocations.

    10. Re:always by Anonymous Coward · · Score: 2, Insightful

      Garbage collected languages have live-leaks that can have exactly the same memory bloat consequences that other memory leaks do. It's where you keep around a reference to an object sub-graph that you aren't actually using. This gets extra bad if you end up building up a linked list of such leaked objects and the linked list grows in size as your application runs. So you do need to think about live leaks every time you store a reference, it's just that the consequences are likely to be less dire if you get it wrong. If you are only thinking about this once a year, that probably means your code is riddled with this issue. So the GP is exactly right in stating that "memory leaks will still bring your system to a crawl" even for garbage collected languages.

    11. Re:always by hedwards · · Score: 1

      Garbage collection isn't perfect. The system doesn't have any way of knowing the difference between a value that's been saved for a purpose and one that's just been forgotten about.

      Sure, the system can figure out when memory isn't accessible any more, but that doesn't cover all the memory that's been allocated and not released.

    12. Re:always by Anonymous Coward · · Score: 4, Insightful

      I write C code all day everyday and never once worry about whether something will leak or double-free. You quickly learn patterns which make object lifetime management safe and simple. In C++ they generically call it RAII. But the basic patterns are simple and are trivial to follow in C, there's just less syntactic sugar (which often is a good thing because you then tend to economize).

      The number of times I've leaked memory in C is probably less than I've leaked memory in a GCd language (yes, you can leak memory in GC). If memory management is anything more than a simple chore, then you're doing it wrong. It does take practice, though.

      Don't get me wrong, I also use mark+sweep (e.g. Lua) and reference-counted (e.g. Perl) garbaged collected languages. Good times. You just can't use a GC'd languages for anything that will use a lot of memory in a single process. This is why people complain about Java all the time. The time spent walking the object tree grows faster than linearly. The article is fails to grasp that point, although the Microsoft C# engineer nailed it when he mentioned that object references can grow exponentially. The reason why more memory makes it seem like GC is faster is simply because with more memory you can just let junk sit around longer, and then destroy the entire heap all at once. At least, for web pages, which tend to be ephemeral. That doesn't work well for long-lived server processes though, in Java or C#, which can't avoid constantly cycling through all memory.

      If you must use a GCd language for memory intensive stuff, you need to use multiple processes and IPC, not just threads, so you can partition your heap memory. Partitioning that way will improve GC algorithmic performance better than linearly. Unfortunately Java and C# don't make multiprocess architectures as easy to implement as in Unix+C, where you can create nameless socket pairs, pre-fork, and pass file descriptors, etc, over the channels, all without polluting any external namespaces--i.e. no loopback ports or temporary files.
       

    13. Re:always by EvanED · · Score: 3, Insightful

      The reason why more memory makes it seem like GC is faster is simply because with more memory you can just let junk sit around longer, and then destroy the entire heap all at once. At least, for web pages, which tend to be ephemeral. That doesn't work well for long-lived server processes though, in Java or C#, which can't avoid constantly cycling through all memory.

      It's more than that though, and it's not just that it seems faster -- it is faster. And it's not just because your program may end before needing to collect or something like that.

      The reason that GCs are memory intensive is because of the design of good GCs, which are usually generational. They have multiple memory spaces, and move objects between them. The presence of those spaces are what increases the memory requirement, because you need to make them big enough to contain a bunch of dead objects too or you'll hit the performance wall I'll talk about in a second. The GC will actually move objects from one space to another.

      The reason that having too little memory hurts is not just because your GC runs more frequently, but you start losing out on the benefits of having those multiple spaces. The division between long-lived and short-lived objects starts to diminish, because an object doesn't have to live as long to get promoted to the next generation. You might promote objects to the oldest generation sooner, and the older generation loses out on some of the mitigating reasons why GC doesn't have to be so bad.

      In short, GC actually works well speedwise even for long-lived processes, in spite of them churning through memory. They just need more memory (3-5x) to get the same performance.

    14. Re:always by Anonymous Coward · · Score: 0

      And the "I'll write this one clever bit and an API, actually writing the rest of it is someone else's problem on a different team.

      Objected Orented has been the *death* of so many good projects that did their little function fine, but never actually completed a project.

    15. Re:always by TheRaven64 · · Score: 1

      You can leak memory in a garbage collected language quite easily - especially one like JavaScript that doesn't have any kind of weak reference (ECMAScript 5 draft fixes this with WeakMap, by the way), by keeping pointers around longer than you need to.

      --
      I am TheRaven on Soylent News
    16. Re:always by shutdown+-p+now · · Score: 1

      To be even more precise, GC gives you better amortized performance (i.e. if you average out the amount of time spent allocating and deallocating stuff over the entire lifetime of your program). But this does not mean that the cost is actually spread out evenly - what you get with GC is that your program runs a little bit faster most of the time, but then occasionally you get those spikes in response time when it actually has to trace the object graph. For large graphs, the spikes are prominent enough that it starts being visible to the user, e.g. when GC kicks in while the user is scrolling a list or doing some other UI operation that needs to be smooth.

      GC is great for server-side or disconnected processing apps. It's tolerable for desktop apps. And it messes things up on low-powered devices with requirement for very short UI response times (e.g. mobile/touch).

    17. Re:always by Anonymous Coward · · Score: 0

      Good point. But note that copying GCs improve things by a constant factor. Almost all these GC tricks only reduce work by constant factors. But ultimately any system which has to walk through each and every object in the system has serious algorithmic constraints on performance, period, because the object graph can and often does grow faster than linearly. The numbers are fundamentally stacked against you.

      At the end of the day, for systems with large working sets you simply must manage your memory, one way or another, whether you're in a GCd language or not. Automated GC comes with a high price, and you can't waive it away.

      If people accepted the fact that there'll never be one language to rule them all, and put as much effort into maintaining proficiency in multiple languages as they do defending their favorite language on web forums, it would be a moot point and we could all live happily ever after.

      My favorite language, Lua, supports closures and coroutines second to none, and it would be impossible in practice (i.e. not worth the effort) to support those without mark+sweep collection. I have no problem accepting the tradeoff given the right circumstances.

  3. That's just not a viable option. by Anonymous Coward · · Score: 4, Informative

    Since JavaScript is so damn lacking, those libraries are ESSENTIAL for anything beyond the smallest JavaScript app.

    Even if you don't use jQuery, for example, you're going to need to find and then use some other library that does the same thing, or write a whole shitload of code yourself to implement the same functionality. Zepto works as an alternative for some people, but even it still has some overhead.

    That applies to almost anything you want your app to do. If you want to work with objects, arrays or even strings in any way beyond the simplest of manipulations, you're going to need to use some third-party code, or write a whole lot of it yourself.

    JavaScript developers are so wholly dependent on these third-party libraries because the JavaScript implementations themselves are so bloody lacking. It's totally different than a language like Python, where there's a rich, yet still compact and efficient, standard library that developers know will be available on just about every user's system. JavaScript programmers have to provide this basic infrastructure with each and every app they write.

    1. Re:That's just not a viable option. by narcc · · Score: 0, Troll

      Since JavaScript is so damn lacking, those libraries are ESSENTIAL for anything beyond the smallest JavaScript app.

      That's because you're not familiar with JavaScript. Remember: all those "essential" libraries are written in JavaScript. You'll find that tons of features in those bloated libraries are just useless wrappers!

      It's not 2006 any more. If you're still using jQuery, or some other goofy library, you're just wasting everyone's time.

      You'll find that just about every feature your "essential" library provides has a native equivalent that works across browsers -- even as far back as IE 8.

      Do the web a favor and just learn JavaScript. You'll find that it's more than capable. Your users will undoubtedly appreciate the performance boost!

    2. Re:That's just not a viable option. by aztracker1 · · Score: 1

      I don't know that it's the purpose of JS to offer quite so much... I know that, for example NodeJS offers a lot, but outside the core, there's not too much there. Underscore takes care of most of the inconsistent bits for current browsers as far as JS itself goes... which is itself relatively light. Most of what Zepto/jQuery offer are with regards to the BROWSER specific bits.

      I know it is semantics, but it really bugs me that JS gets such a bad rep because of the browsers' shortcomings.

      --
      Michael J. Ryan - tracker1.info
    3. Re:That's just not a viable option. by ShanghaiBill · · Score: 5, Insightful

      Even if you don't use jQuery, for example, you're going to need to find and then use some other library that does the same thing

      Furthermore, popular libraries like jQuery, Mobile-jQuery, etc. are much more likely to have clean, efficient, memory-lite implementations that some "roll-your-own" code. If you choose your libraries carefully, learn to use them, and avoid "rolling-your-own" unless really necessary, your code will certainly be smaller and cleaner, and usually be faster, smaller, and use less memory.

    4. Re:That's just not a viable option. by bucktug · · Score: 3, Interesting

      I really do appreciate a good framework... My favorite one currently is Vanilla-js http://vanilla-js.com/

      Check it out. Amazing performance.

      --
      I had a flame... but she had a fire.
    5. Re:That's just not a viable option. by Nerdfest · · Score: 4, Insightful

      Learning a flaky, inconsistent language is only prolonging the problem. The web needs to move to something sane. As I said to someone the other day, it's extremely sad that the two most popular languages used for web development are two of the worst languages around (JavaSCript & PHP). It does go a ways towards explaining the quality of web software in general.

    6. Re:That's just not a viable option. by TheDarkMaster · · Score: 0

      The very first mistake is try to make a complete GUI application in a shitty language like Javascript.

      The second mistake, when you cannot avoid the first one, is to forget that computing resources are finite and therefore must be used as efficiently as possible. This include using bloated frameworks when you CAN make smaller code to do the same job, and rely on the "silver bullet" GC.

      --
      Religion: The greatest weapon of mass destruction of all time
    7. Re:That's just not a viable option. by loufoque · · Score: 1, Insightful

      Yet C developers have no problem using C, which is much more minimal language, to do much more than what you do with JavaScript, and they rarely depend on shitloads of libraries.

    8. Re:That's just not a viable option. by amicusNYCL · · Score: 4, Insightful

      You'll find that just about every feature your "essential" library provides has a native equivalent that works across browsers -- even as far back as IE 8.

      That's a pretty naive view that over-simplifies the situation. One major use for a framework, for example, is to normalize the behavior of different browsers. Another major use is to provide implementations to create interface elements. Now, obviously, everything is natively supported because the Javascript framework is right there doing it, natively. But why should I write the necessary logic to create a draggable window, or a tree view, or sortable grid, when I can just pull that in from a framework? ExtJS is the kind of framework I'm thinking of. Why should I implement ajax-style uploads inside an iframe when they already did that for me, and I can just set up a form panel, indicate it is a file upload form, and write the important stuff?

      Even though I can use a massive ExtJS application on a phone, we're not talking about massive applications per se, we're talking about mobile Javascript. So there are things like Sencha Touch for that. Sure, I could write native applications for every device listed under the supported devices section, but why is it smart to do that when I can write a single codebase that I can package for multiple devices?

      Or maybe I'm just not "familiar" with Javascript, or development concepts in general. Hopefully you can enlighten me on the merits of reinventing the wheel every time you create something.

      --
      "Our two-party system is like a bowl of shit looking at itself in a mirror." - Lewis Black
    9. Re:That's just not a viable option. by ducomputergeek · · Score: 2

      I built an online shopping cart once that was originally 42k of javascript. Handled all the tracking of items, tax, and shipping in a variety of ways and even developed a multi-vendor capable version that was still under 55k. It powered an online ordering system for restaurants and coffee shops and it worked amazingly fast. All the server had to do was render pages from the products database in HTML. There weren't any writes to the database until the user clicked "order". It ran amazingly fast. Of course we still cared about those things as "broadband" was a 256k DSL line back then.

      --
      "The problem with socialism is eventually you run out of other people's money" - Thatcher.
    10. Re:That's just not a viable option. by Mashiki · · Score: 0

      Learning a flaky, inconsistent language is only prolonging the problem. The web needs to move to something sane.

      What the hell are you talking about? I thought being a programer entitled oneself to be a masochist. After all, if it was about sanity, people would have lit java on fire in 2005, and run the other way.

      --
      Om, nomnomnom...
    11. Re:That's just not a viable option. by brantondaveperson · · Score: 1

      Python..... efficient....

      First time I've heard those two words together in sentence without "is not" between them.

    12. Re:That's just not a viable option. by mypalmike · · Score: 5, Funny

      > Yet C developers... rarely depend on shitloads of libraries.


      $ ls -l /usr/lib | wc -l
      shitloads

      --
      There are 0x40000000 types of people: those who understand 32-bit IEEE 754 floating point, and those who don't.
    13. Re:That's just not a viable option. by snadrus · · Score: 3, Informative

      The last major jQuery jump dropped IE8 & older support because there were too many quirks they didn't want to bloat everyone's use of the lib with.

      --
      Science & open-source build trust from peer review. Learn systems you can trust.
    14. Re:That's just not a viable option. by narcc · · Score: 1

      Learning a flaky, inconsistent language

      JavaScript is "flaky" and "inconsistent"?

      What on earth are you talking about?

    15. Re:That's just not a viable option. by Dahamma · · Score: 1

      HAH! In fact, it's pretty much the opposite in practice. C requires shitloads more libraries (from the application developer's point of view) to do the same things that (browser-based) Javascript does, since Javascript/HTML already has shitloads of built-in functionality.

      Just try to do "much more than what you do with JavaScript" in C by only linking with libc.

      The problem with "libraries" in Javascript is they are really pretty much just script includes, and most Javascript apps just load them all into the global namespace up front. Static libraries in C let you only include the code you use, and dynamic libraries tend to be shared across all processes that use them.

    16. Re:That's just not a viable option. by loufoque · · Score: 1

      You realize you have thousands of packages installed, right? That's not a couple of Javascript apps.

    17. Re:That's just not a viable option. by Nerdfest · · Score: 4, Insightful

      Compared to those other two, Java is a dream language.

    18. Re:That's just not a viable option. by loufoque · · Score: 1

      You simply code what you need instead of depending on framework that do everything for you.

    19. Re:That's just not a viable option. by Anonymous Coward · · Score: 3, Insightful

      How is this informative? My guess is that it was modded up by people who, like the poster, have only basic experience writing JavaScript.

      When you're writing code in any language as a hobby or just getting your feet wet, you love the simplicity of minimal overheads and writing everything yourself, because of course you can do a better job than all the other shmucks. When you're writing code for a living or you advance beyond variations of hello world, you come to realise that you're not actually more enlightened than the pro's and that frameworks actually do make for more maintainable code which is cleaner and more efficient than you could have written yourself, as well as more rigorously tested and secure. When you're writing significant code, you see, you are taking advantage of large parts of the core of all frameworks, which you would otherwise have had to reinvent yourself in a far poorer fashion.

      In short, if your needs extend as far as simple form validation, maybe the framework is overkill, but once you're starting to write substantial web (and non-web) applications, you'll really learn to appreciate frameworks. Frameworks are also used widely for simpler sites because no-one is prepared to pay you to reinvent the wheel. In these cases, one can usually take advantage of subsets of Frameworks, to avoid loading lots of unnecessary code.

      For what it's worth, this argument applies to all languages, and you won't find any sensible programmers writing directly to win32 or X api. Instead, they're using .NET, GTK, QT, Wx, etc. because they know that they would spend their life writing essentially equivalent implementations themselves to cover the features that they need. Sure, one might use win32 directly for a simple utility (been there recently, in-fact), but not for any serious application.

    20. Re:That's just not a viable option. by exomondo · · Score: 2, Insightful

      Learning a flaky, inconsistent language

      JavaScript is "flaky" and "inconsistent"?

      What on earth are you talking about?

      He means it's gained popularity.

    21. Re:That's just not a viable option. by narcc · · Score: 0

      Sure, I could write native applications for every device listed under the supported devices section, but why is it smart to do that when I can write a single codebase that I can package for multiple devices?

      Here's what you don't realize: You don't need a giant library or framework to do that. If you know what you're doing (and it doesn't take much knowledge or skill) you can deploy your mobile app across various platforms and devices from a single codebase -- without any platform or device specific code save what's necessary for packaging. You can effortlessly deploy from the same code base to BlackBerry, Android, and iOS -- no framework needed.

      Now, if you want to use something like PhoneGap to make it easier to use features like accelerometers, gps, etc., that's much more reasonable. There's an actual benefit to libraries that offer specific functionality (three.js, for example). You'll find, however, that things like jQuery mobile *will* kill your performance.

    22. Re:That's just not a viable option. by phantomfive · · Score: 3, Insightful

      Try picking a random package and getting to cross-compile for a platform like, for example, Windows. You'll suddenly realize how many dependencies there actually are.

      --
      "First they came for the slanderers and i said nothing."
    23. Re:That's just not a viable option. by jythie · · Score: 1

      And yet programmers in other languages with the same capabilities somehow manage. Javascript is plenty capable, you just have to give up some general purpose conviene when you are shifting from a server or desktop enviroment to an embedded one. It is a lesson people working in any language on an embedded system have to learn, but some communities seem more willing then others. People coming from web development seem particularly resistant.

    24. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      Ah yes. Good old Java. Can't get enough of abstract generic service facade implementation

      Please. Java these days is awful. Ill stick to C mixed with Node and some occasional Py.

    25. Re:That's just not a viable option. by ImdatS · · Score: 1

      Yet C developers have no problem using C, which is much more minimal language, to do much more than what you do with JavaScript, and they rarely depend on shitloads of libraries.

      Hmm, try doing something in C without stdio, stdlib, etc - I dare you to print out one single character in C without using stdio....

      C is a quite barebones language; if you didn't have all the libraries, you couldn't do anything in it except running some loops, if/else's and such.

    26. Re:That's just not a viable option. by Rockoon · · Score: 3, Insightful

      JavaScript is "flaky" and "inconsistent"?

      What on earth are you talking about?

      I think that hes talking about JavaScript being flaky and inconsistent.

      --
      "His name was James Damore."
    27. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      This is hogwash. I've written several apps that are several actual megs of JS sourcecode, properly designed and annotated, each having no need for any real frameworks beyond the most minimal of tools provided by the likes of core jQuery (and that is only a concession because nobody wants to learn how to do things in raw JS anymore because they're LAZY).

      You just have to know what you're doing and not assume that frameworks are necessary for ANY project. They're not - they're mostly just crutches for bad or lackluster programming practices. Every time I hear a programmer tell me they NEED a meg of JS libraries, they're really telling me they don't know or understand JS, and just want to pretend they know about it. Either that, or they would have needed similar libraries in other languages, so there's no real point in whining about it.

    28. Re:That's just not a viable option. by TheDarkMaster · · Score: 1

      Really? My "Ajax" implementation is much more simple than jQuery, and works well.

      --
      Religion: The greatest weapon of mass destruction of all time
    29. Re:That's just not a viable option. by narcc · · Score: 1, Insightful

      It's pretty well-known that jQuery is an absolute mess. A lot of effort has gone in to improving it, sure, but that sort of makes the point, doesn't it? Take a look through the code yourself. It still isn't pretty.

      To call it "memory-lite" is just absurd. (Get a profiler and run some tests if you have trouble believing that.)

      It's also hard to argue that a complex generalized solution to some problem will be faster than one written with a specific case or set of cases in mind. The abysmal performance of jQuery for even simple operations is evidence enough of that. (See any one of a zillion tests, or run a few of your own if you can't find one to your liking and you'll see what I mean.)

      jQuery isn't stellar, obviously, but it makes jQuery UI and jQuery Mobile look positively light-weight in comparison! jQuery has often been blamed for PhoneGap's performance problems. Again, this is something you can see for yourself.

      Even the most ardent jQuery fan will acknowledge that jQuery (expecially jQuery UI and Mobile) is a performance killer, they'll just say "it doesn't matter because computers are getting faster every year" or something equally silly in defense of their favorite library. To claim that jQuery is actually *faster* than a native solution is just crazy.

      Just for fun

    30. Re:That's just not a viable option. by Dahamma · · Score: 1

      You mean frameworks like... X11? Freetype? Glib? Pthreads? Openssl? Libxml2? Gnome-terminal itself (which basically a *text* terminal) links with 52 different libraries. Implementing them all yourself would be absurd. Even a reasonably complex non-GUI executable like mysqld links with a couple dozen libraries.

       

    31. Re:That's just not a viable option. by arth1 · · Score: 1

      stdio is part of standard libc, so you don't need to link in any libraries to use putc(string,stdout).
      And half of stdlib are macros.

    32. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      That article's point is specifically that framework is designed for mobile WEBSITES, and is thus not suited for making APPS.

      So either you didn't read what you linked, or you implicitly lied about what it says. That means you're either an idiot or a liar. Which is it?

      Any other response, including the obviously false "b-b-but PhoneGap apps are, like, basically the same as websites!" you just started composing, are an irrevocable confession that it's "both".

    33. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      Hyperbole. Nothing about targeting mobile, either web or native, is effortless.

    34. Re:That's just not a viable option. by Wattos · · Score: 1

      The difference is that these are shared libraries. They live in shared memory and are only loaded once for each application which is using them.

      In the web, each library is loaded every time.

    35. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      Please tell me that you didn't run EVERYTHING on the client side. I shudder to think of the security implications of that.

    36. Re:That's just not a viable option. by Pseudonym+Authority · · Score: 1

      Nonsense. I test all my code on universal Turing machines and it never runs out of resources.

    37. Re:That's just not a viable option. by Kielistic · · Score: 4, Interesting

      I'm giving up moderation to post this but it has to be said. You keep claiming jQuery is slow and crappy because a few frameworks that exist on top of it are slow. Both jQueryUI and jQueryMobile are designed to completely change (and unify) what the browser controls look like. Of course they are slower than native. I even went to your little site and ran this one : http://jsperf.com/jquery-body-vs-document-body-selector. jQuery came up about 5%-6% slower than native. If you give up a unified, well tested framework and a tenth of the development time for a 5% speedup you are either working on something very special or need to be fired immediately.

      jQuery is not a performance killer. If it was you wouldn't see it on nearly every website more complicated than "hi my name is narcc". What it does do, however, is cut development time considerably. Provides a consistent experience across most browsers and gracefully falls back when browsers don't provide native solutions. And provides far more web-specific features that Javascript does not (otherwise people wouldn't use it).

      I won't claim that jQuery is faster than every native solution. But it is probably faster than your native solution. And infinitely more maintainable.

      Just for fun: Just look at how readable and maintainable that code is. I'd love to try to figure out why a $100000 web-application isn't working in BroswerX 10 months after somebody else wrote it written like that.

      Additionally: if you are doing 2+ million operations than yes maybe you might want to devote some time to writing a specialized function. But normally you're only doing less than 50 on a fairly complicated web-app so your benchmarks won't show too much of a difference there.

      Just for my own fun. What happens if you go : document.querySelector('.menu > a:last') in IE9?

    38. Re:That's just not a viable option. by Kielistic · · Score: 1

      cstdio : C library to perform Input/Output operations

      Keyword: library. It is included by default because C would be nearly useless in normal usage without this library.

      It does not matter if it is in standard libc or if it is all macros. It is a required library to do anything because without it everyone would have to constantly reinvent the wheel, poorly.

    39. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      Hmm, try doing something in C without stdio, stdlib, etc ...

      Then it is not C.

    40. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      Hmm, try doing something in C without stdio, stdlib, etc - I dare you to print out one single character in C without using stdio....

      C is a quite barebones language; if you didn't have all the libraries, you couldn't do anything in it except running some loops, if/else's and such.

      In a 16-bit PC environment with a color monitor in a text mode:
      *(char far *)(0xB8000000L) = 'A';

      Or, with a monochrome display adapter:
      *(char far *)(0xB0000000L) = 'A';

      Using BIOS:
      _emit(0xB8, 0x41, 0x09, 0xBB, 0x0F, 0x00, 0xCD, 0x10);

    41. Re:That's just not a viable option. by Count+Fenring · · Score: 1

      More accurately, they branched the codebase into the 1.x branch that supports IE8 and the 2.x branch that doesn't, because a large set of support windows now don't include OldIE. Both of which are fully supported.

    42. Re:That's just not a viable option. by narcc · · Score: 0, Troll

      You keep claiming jQuery is slow and crappy because a few frameworks that exist on top of it are slow.

      No, I've been claiming that jQuery is slow and crappy all on it's own. jQuery UI and Mobile just happen to be even slower.

      jQuery is not a performance killer.

      Actual data suggests otherwise. This is completely objective. You can test this for yourself. You pay a VERY steep price for using jQuery even for very simple things.

      What it does do, however, is cut development time considerably.

      Have any metrics? From what I've seen, it adds significant development time over the life of the application. Do you know how common it is to see multiple versions of jQuery loaded on the same page? (jQuery even has features to help allow that to happen!) Do you have any idea how difficult is is to dig someone out of a mess like that?

      The only way jQuery could possibly "cut development time" is if you never maintain your code -- and only then if typing speed is your biggest bottleneck.

      I won't claim that jQuery is faster than every native solution. But it is probably faster than your native solution. And infinitely more maintainable.

      Have you looked at the jQuery codebase? It's like a group of amateurs that didn't understand either JS or the DOM wrote a library. Oh, wait, that's exactly what happened! (Seriously, check the Usenet archives. It's a riot.)

      No surprise, the developers are still less than competent. How on earth did this abomination get so popular? It's a complete mystery to me.

      Or do you mean code written using jQuery? Now that's impossible to maintain! (For reasons mentioned earlier and later.) Add to it that jQuery code is mostly written by amateurs who don't know any better (or professionals that don't want to face the simple fact that JavaScript is not C# and they'll need to learn some new concepts). When you see jQuery, you can safely assume that the code is a mess anyway.

      Provides a consistent experience across most browsers and gracefully falls back when browsers don't provide native solutions.

      Nonsense. jQuery has *never* been cross-browser -- and never really did well across the few browsers it claimed to support! The word "consistent" is a bad joke. when paired with "jQuery". How long has it been around now? It still doesn't have a stable API!

      Oh, and did you hear? They're dropping support for IE8 and below. Not that it did a great job of supporting those browsers anyway, but it's yet another reason that jQuery has LONG outlived its utility.

      If it was you wouldn't see it on nearly every website more complicated than "hi my name is

      See my earlier post. Take the challenge and see how various websites actually use jQuery. If you're not completely disgusted, I can't help you.

      Here's why see jQuery used everywhere: JavaScript is difficult to learn. Well, that's not quite right. It's really easy, actually, but it's not at all like Java, C#, or any other popular language. It just looks a lot like popular languages. That causes a lot of confusion from developers who are used to picking a new language by reading a few code samples and hitting google a few times. You simply can't learn JavaScript that way.

      jQuery came with false promises like cross-browser compatibility and a myth of ease-of-use. Developers who never touched JavaScript before took jQuery as an "easy way out" -- never mind that none of the promises it made were ever true, that's what they were told and that's what they believed. They were told that JavaScript is difficult or full of pitfalls. That wasn't true, of course, it's just that the language was so different from what developers were used to from language's with similar syntax that they m

    43. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      Python, Ruby etc. are shit on mobile too.

    44. Re:That's just not a viable option. by tibit · · Score: 1

      For a shopping cart - why not? There's zero implications. Eventually the server gets a list of what was ordered, by whom, and where to ship it, and asks for payment. Now if you're idiotic enough to presume that the server will ask the client for pricing and such, then you're just that - idiotic.

      --
      A successful API design takes a mixture of software design and pedagogy.
    45. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      How did you solve security?
      I mean, who prevents the client from changing some prices or tax rates in your javascript?

    46. Re:That's just not a viable option. by TyFoN · · Score: 1

      It is only essential when you make a crappy web 2.0 dynamic "web app".

      I hate with a passion when web pages try to do fancy things like open windows inside a web page that don't respond to the browser back button or make links rely on java script.

      I managed to make perfectly fine web pages around 2000 without javascript. We just did it with regular HTML and .. wait for it.. server side code.

      Having to load a new page is not bad and you get the added bonus of making the back/forward/bookmark buttons work again.

      99% of the javascript used in out there is imho just crap and completely unnecessary to deliver the information the webpage is supposed to do.

    47. Re:That's just not a viable option. by serviscope_minor · · Score: 1

      shitloads

      Just to check is that a proper metric shitload or a fake power of two shitload (now properly known as a shititiload)?

      --
      SJW n. One who posts facts.
    48. Re:That's just not a viable option. by loufoque · · Score: 1

      But I do that everyday. There aren't many at all.

    49. Re:That's just not a viable option. by loufoque · · Score: 1

      The C standard library is extremely lightweight, that's the point.

    50. Re:That's just not a viable option. by loufoque · · Score: 1

      Wait, are you seriously comparing a full-featured GNOME program with a trivial Python script?

    51. Re:That's just not a viable option. by mcvos · · Score: 1

      Ah yes. Good old Java. Can't get enough of abstract generic service facade implementation

      That's not an issue with the language itself, but with the overdose of architecture programmers tend to throw at it. Though Java is definitely showing its age. The simple lack of closures is unforgivable.

    52. Re:That's just not a viable option. by mcvos · · Score: 1

      By not having the server take those values from the client, but from its own database, I presume.

    53. Re:That's just not a viable option. by JDG1980 · · Score: 1

      I've wondered before why jQuery isn't supported natively in browsers by now. It's probably the single most widely used framework; it should be an integral part of the language, much like the C standard libraries are for ANSI C.

    54. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      or just ldd it

    55. Re:That's just not a viable option. by narcc · · Score: 1

      Ignoring the fact that it's broken and incompetently written, it also has a very unstable API.

      Add to that the ridiculous feature overlap between jQuery and vanilla JS and it's clear that such a fit would be very uncomfortable.

    56. Re:That's just not a viable option. by TheRaven64 · · Score: 1

      FreeBSD and glibc are both around 1.3MB. That's pretty large compared to the 100KB JavaScript libraries that the original poster was complaining about, and that typically doesn't include the library that implements the math.h functions. Try running ldd on a C binary sometime and see what else it depends on.

      --
      I am TheRaven on Soylent News
    57. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      That is until you install it (java) on the client.

    58. Re:That's just not a viable option. by codeButcher · · Score: 1
      --
      Free, as in your money being freed from the confines of your account.
    59. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      He probably isn't that stupid.

    60. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      COBOL doesn't need no damn framework! Just do it.

    61. Re:That's just not a viable option. by TheDarkMaster · · Score: 1

      Do not try to argue with fanatics.

      --
      Religion: The greatest weapon of mass destruction of all time
    62. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      Yeah, everyone codes their own socket and threading implementations from scratch every time...

    63. Re:That's just not a viable option. by qbast · · Score: 1

      If I remember correctly, closures were supposed to be included in Java 6 and later 7. So I will believe it when I see it in officially released jvm.

    64. Re:That's just not a viable option. by Kielistic · · Score: 3, Informative

      Or do you mean code written using jQuery? Now that's impossible to maintain! (For reasons mentioned earlier and later.) Add to it that jQuery code is mostly written by amateurs who don't know any better (or professionals that don't want to face the simple fact that JavaScript is not C# and they'll need to learn some new concepts). When you see jQuery, you can safely assume that the code is a mess anyway.

      Pure bullshit. Ignoring the glaring fallacy of "I've seen amateurs do bad things so jQuery is bad" I will just comment on it being difficult to maintain. Javascript in general is difficult to maintain in a large web application. jQuery makes things easier because it provides a fairly consistent syntax for common things you would likely do in a web application.

      Oh, and did you hear? They're dropping support for IE8 and below. Not that it did a great job of supporting those browsers anyway, but it's yet another reason that jQuery has LONG outlived its utility.

      Their future branch has cut off support for legacy browsers. This is for people who don't need them and to ease production of new features. They still maintain the 1.x line that fully supports IE8. This is where it is clear you are talking from inexperience and flat out lying to avoid admitting you've been less than truthful. It is very rare you ever see jQuery do something inconsistently between the common browsers. Definitely less than you see vanilla javascript being inconsistent.

      The ONLY reason you see jQuery used today is that those same developers never bothered to learn JavaScript. They assume jQuery saves them time and effort (it does not, it costs them time both early and in the long term) because that's what they were told years ago.

      Explain how jQuery doesn't save time? It is a framework that provides common functionality that people want from Javascript. So without a framework your options are to re-write that functionality every time you want it or build your own framework. Both of those options will be less maintainable in the long-run and far more bug-prone (being less tested etc). You can't just keep claiming "jQuery bad; reinvent wheel good" with some handwaving about performance and amateurs and blathering on about how much smarter you are for using vanilla Javascript instead.

      Fortunately, developers are starting to realize that they've been fooled and are actually starting to learn JavaScript.

      Or maybe Javascript has started to become consistent enough and functional enough for specific tasks that people can easily use it for simple tasks now. People that don't have to worry about any kind of legacy support that is.

      With any luck, by 2015 we might not have jQuery bogging down the web.

      With any luck by 2015 we won't have Javascript bogging down the web. It is a language that is not a good match for what it is used for in this case.

    65. Re:That's just not a viable option. by Kielistic · · Score: 2

      Yes, the fanatic is the one being reasonable and rational about using libraries. Not the people shouting "Libraries are horrible and people that use them must be stupid". I don't care what library you use. I don't care if you want to write base Javascript. But if your argument boils down to "using libraries is bad and only lazy people use them" you're probably just suffering from a serious case of Not invented here syndrome.

    66. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      "I even went to your little site and ran this one...".

      Very mature.

    67. Re:That's just not a viable option. by TheDarkMaster · · Score: 1

      Sorry, Javascript IS slow. Libraries goes a bit more slow (you cannot load only part of then, and the functions are generic), JQuery is slow AND bad developed. Using a lib is not the problem, the problem is using a bad one and without a better reason than "I use then because is more easy".

      --
      Religion: The greatest weapon of mass destruction of all time
    68. Re:That's just not a viable option. by Wdomburg · · Score: 1

      [mberg@mberg ~]$ ldd /usr/bin/gnome-shell | wc -l
      100
      [mberg@mberg bin]$ ldd /usr/bin/gnucash | wc -l
      123
      [mberg@mberg bin]$ ldd /usr/bin/konsole | wc -l
      92
      [mberg@mberg ~]$ ldd /opt/google/chrome/chrome | wc -l
      70

    69. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      you cannot load only part of [libraries]

      False. jQuery and Dojo both support custom builds where you take only the components you intend to use.

      This is an example of why you and narcc are the real "fanatics" here; you have emotionally invested yourself in the conclusion you want to believe and refuse to deal in facts because you're terrified of learning something that will prove you wrong.

    70. Re:That's just not a viable option. by MacDork · · Score: 1

      Since JavaScript is so damn lacking, those libraries are ESSENTIAL for anything beyond the smallest JavaScript app.

      That's why I use the one true library: Vanilla JS Just look at those benchmarks! You're a fool if you use any other library!

    71. Re:That's just not a viable option. by EvanED · · Score: 1

      stdio is part of standard libc, so you don't need to link in any libraries to use putc(string,stdout).

      You need to check yourself on that. You don't need to explicitly instruct the compiler to include additional libraries because, as Kielistic says, compilers include it by default.

      Here's a hint: libc... is a library.

      Here, I'll prove it:

      $ cat printf.c
      #include <stdio.h>
       
      int main() {
          printf("Hello %s!\n", "world");
      }
       
      $ gcc -o empty -nostdlib printf.c
      /usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000400144
      /tmp/ccwbCMMw.o: In function `main':
      printf.c:(.text+0x17): undefined reference to `printf'
      collect2: ld returned 1 exit status

    72. Re:That's just not a viable option. by LordKronos · · Score: 1

      I really do appreciate a good framework... My favorite one currently is Vanilla-js http://vanilla-js.com/

      Check it out. Amazing performance.

      That's funny and cute. I thought it was a real framework for a moment. But that aside, the website is dishonest in their comparisons. They try to make the complexity of the "vanilla.js" code look much smaller by unnecessarily mentioning you have to include the jquery library (even though you only do it once per page regardless of you many times you use it in that page), and they include the script tags on the jquery example but not the vanilla.js example (or does vanilla.js somehow magically not need script tags to denote that it's script?). So to give a more honest comparison, lets look at their fading example. here's the real comparison:

      vanilla.js:
      var s = document.getElementById('thing').style;
      s.opacity = 1;
      (function fade(){(s.opacity-=.1)0?s.display="none":setTimeout(fade,40)})();

      jquery:
      $('#thing').fadeOut();

      uhhhhhhhhh.....you know, I think I'll take the jquery one, thank you. Same thing with the ajax example...not as drastic as the fade example, but the jquery example is MUCH cleaner looking to me.

      But oh yeah, there is the performance issue. 12,137,211 ops/sec with vanilla.js, vs only 350,557 with jquery. Yeah, that is quite compelling....except that I'm generally only doing a handful of operations per second, not 12 million, and the difference between a few nanoseconds and a few more nanoseconds really isn't that big of a deal. In the VERY rare case where I'm doing something where performance becomes an issue, I'll optimize where needed, but I don't waste my time prematurely optimizing.

      You know what I like to actually optimize? Getting things working correctly. Think jquery is a waste? Well, lets look at that fading example above. Pretty darn simple, isn't it? Surely nothing tricky there. So lets see. jQuery seems to work fine. How about that more monstrous vanilla.js version they posted. ok, it's working fine in firefox. How about chromium. Oh interesting. Look at that. It fades out almost all the way, but never totally disappears and gets hidden. Why is that? The code LOOKS to be correct (though perhaps that < 0 should be <= 0 ...nope, that wasn't it). Ok lets do some debugging of the opacity value on each iteration:

      1
      0.9
      0.8
      0.7000000000000001 (uh oh, I see where this is going)
      0.6000000000000001
      0.5000000000000001
      0.40000000000000013
      0.30000000000000016
      0.20000000000000015
      0.10000000000000014
      0.10000000000000014
      0.10000000000000014

      oh, hey. look at that. chromium never lets the value get below 0, so that function keeps getting called forever, but never actually finishes and hides it. OK, so that's one stike against it.

      Here's another thought...what happens if the element with id 'thing' doesn't actually exist? Oops, he forgot to check for null, so anything after his .style in the first line of code line will never get executed because the javascript will abort with an error at that line. OK, 2 strikes.

      OK, now what about when it is time to reshow the block we just hid. Hmmmm...now was that #thing object set to block or inline display? Oops, he forgot to save the state. We can set it to blank to go back to the default, but what if it was already overridden before we got to the value? Ooops. Strike 3.

      Yes, his example could be adjusted to fix all of these issues, but that's the point. The code looks horrendous and it has at least 3 bugs in that simple example so you are going to have to make it even more complex. Meanwhile my jquery example simply worked and I'm already on to the next thing.

    73. Re:That's just not a viable option. by skerit · · Score: 1

      How is it flaky? The DOM API might be a mess, but Javascript itself is a nifty little versatile language. Or are we bitching about the loose typing again?

    74. Re:That's just not a viable option. by skerit · · Score: 1

      Yeah, exactly. When people bitch about JavaScript it's mostly about the DOM api or the browser inconsistencies. Or they're confused about the loose typing and prototypal inheritance.

    75. Re:That's just not a viable option. by spiralx · · Score: 1

      Wow, that guy is a huge dick.

    76. Re:That's just not a viable option. by datavirtue · · Score: 1

      I think the problem is that all the freakin Javascript has to be loaded and processed (Javascript JIT??). I maintain that Javascript should only be used when implementing AJAX calls or fancy user interfaces. When you are building applications that do a lot on the client side you are loading a bunch of stuff and Javascript as a system was not designed for that. I call abuse. As a developer web applications appeal to me because of their ease of deployment and easy access, but compared to building rich desktop clients the development process and paradigms suck--a real pain for seemingly simple things. Enhanced data tables are one thing which require a library to implement--as they must be on the client side--and I wouldn't claim these as simple. That's just one thing in a handful that crop up in developing a decent web application that can replace those that are desktop/rich client based. If you want to target all devices you face a list of compromises in order to tone down impact on the mobile devices. It would be nice if the Javascript could be compiled and cached.

      http://stackoverflow.com/questions/7807235/javascript-just-in-time-compilation

      I think V8 solves a lot of these problems.

      https://developers.google.com/v8/design

       

      --
      I object to power without constructive purpose. --Spock
    77. Re:That's just not a viable option. by shutdown+-p+now · · Score: 1

      No, we're bitching about insane local variable scoping, insane scoping rules for "this", insane implicit type conversions, insanely verbose syntax for lambdas etc.

      There's nothing "nifty" in JS, if you know at least one comparable dynamically typed language. All competitors beat JS thoroughly on pretty much any measurement you can think of, except for popularity.

    78. Re:That's just not a viable option. by amicusNYCL · · Score: 1

      Here's what you don't realize

      I'm glad you're so familiar with me.

      If you know what you're doing (and it doesn't take much knowledge or skill) you can deploy your mobile app across various platforms and devices from a single codebase

      That's right, if you're developing a mobile app then a substantial amount of the code is going to be the same regardless of platform.

      What if you're developing a website that needs to be responsive for all orientations, both desktop and mobile? Should you avoid using something like Bootstrap or HTML5 Boilerplate and implement all of that yourself?

      I don't think there is a competent programmer alive who does not use libraries. I think you're talking out of your ass, I think you're being naive. When you create an application that uses ajax, do you actually sit there and type out a function with a try/catch block to look for various implementations of the ajax object? Doesn't it make sense to put a function like that into a file that you can use on all of your sites, and doesn't it make additional sense to add more common utility functions, adding methods to built-in objects (e.g., adding Array.indexOf if it doesn't exist), etc? Because that's a library, even if you write it yourself. It sounds like your only argument is not using libraries that other people make. Using libraries that other people make is a major part of every kind of software development. Now, there's no reason to include all of ExtJS, for example, if the only thing I'm looking for is a normalized ajax interface, but that's hardly an argument against not using any libraries or frameworks for anything. Almost everything has a place.

      That being said, when I'm answering questions on web development forums I'll occasionally see someone come in with a question about their site that they're including 5 different versions of jQuery on, in addition to mootools and dojo or whatever else. There are plenty of people who don't know how to program who copy and paste whatever they can find to try and get anything to work, but, again, that's not a reason for all programmers to completely forgo frameworks and libraries.

      --
      "Our two-party system is like a bowl of shit looking at itself in a mirror." - Lewis Black
    79. Re:That's just not a viable option. by narcc · · Score: 0

      I don't think there is a competent programmer alive who does not use libraries.

      Read my post again. I'm not arguing against all libraries, just their unnecessary use. In the case of jQuery, jQuery Mobile, and jQuery UI their use is not only unnecessary it's actually harmful -- particularly on mobile.

      What if you're developing a website that needs to be responsive for all orientations, both desktop and mobile?

      If you're using JavaScript for layout, you've already failed.

    80. Re:That's just not a viable option. by amicusNYCL · · Score: 1

      If you're using JavaScript for layout, you've already failed.

      I'll overlook the revealing fact that you didn't bother to suggest an alternative, and just ask why is Javascript bad for layout? Assume, for the context of the question, that I have a base of several hundred thousand users across a range of government, commercial, and educational organizations who have been having their layouts calculated by Javascript for the last 5 years, including with IE6, without reporting layout problems.

      --
      "Our two-party system is like a bowl of shit looking at itself in a mirror." - Lewis Black
    81. Re:That's just not a viable option. by fzammett · · Score: 1

      None of that is "flaky"... these are all features of the languages that if you bothered to learn you'd see that it makes JS one of the most flexible languages out there.

      Some devs can't deal with the freedom to think for themselves and need rigid rules to function. Not the languages's problem.

      --
      If a pion (n-) collides with a proton in the woods & noone is there to hear it, does lamdba decay into the source pa
    82. Re:That's just not a viable option. by narcc · · Score: 0

      Do you actually need to ask? I don't even know where to begin! Do a google search, you'll find much more that I could possibly jam in to a forum post.

      (Other users who are not completely floored by the question: feel free to chime in.)

      Learn to use CSS. In the context of this discussion, pay particular attention to @media

      I wonder if you use tables for layout as well...

    83. Re:That's just not a viable option. by Kielistic · · Score: 1

      (you cannot load only part of then, and the functions are generic)

      As mentioned above: often times you can only load what you want. More importantly though- you want the functions to be generic. That is what a library does. Provides common, generic functions so you don't have to keep rewriting them over and over. One point of testing instead of many.

      "I use then because is more easy"[sic]

      That is absolutely a valid reason to use a library when time and money are concerns (so pretty much always). In fact it is the entire reason libraries exist in any programming language. Nobody cares if a page took 0.01 seconds to load or 0.009 seconds to load. Everybody cares if it takes longer to develop, is undocumented and not properly tested though.

    84. Re:That's just not a viable option. by amicusNYCL · · Score: 1

      Learn to use CSS.

      How exactly do you think Javascript accomplishes the actual layout? Do you think the browser understands Javascript instructions for laying out elements, or would we instead use Javascript to... I don't know, dynamically change the element's CSS depending on the resolution and orientation? Or show/hide/position various elements depending on the same (by changing... wait for it... the CSS classes or properties). Or to get an element to completely fill the entire viewport, in all browsers, with no overflow. Pure CSS is fantastic when you can focus only on browsers that support what you're trying to do. To fill in the gaps, you use Javascript to help out.

      There's a great example here of what I mean. Not only do many mobile browsers ignore the handheld media type, but some (including iOS Safari) use the non-standardized media queries instead. Go ahead and read through that article, notice at the end how they suggest using Javascript to fill in the gaps.

      --
      "Our two-party system is like a bowl of shit looking at itself in a mirror." - Lewis Black
    85. Re:That's just not a viable option. by TheDarkMaster · · Score: 1

      Generic functions is a good thing when is well implemented and reasonable fast, two points where most "javascript libs" fails. As example, I experimented using the jQuery to do Ajax calls, but the way to do this is... atrocious. Works? Works, but what a cost?

      And, when your code is only one in many, all competing for the CPU time, the execution time counts.

      --
      Religion: The greatest weapon of mass destruction of all time
    86. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      a bad dream

    87. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      Yes, most of them are random C libraries...

    88. Re:That's just not a viable option. by Dahamma · · Score: 1

      Trivial Python script? Neither his thread nor the article as a whole is remotely about "trivial" *or* "Python". it's about about HTML5/Javascript programming (in complex web/client apps) vs C. I am comparing complex Javascript apps with complex C apps.

      Netflix uses Javascript for most of their platforms (everything from browsers to the Playstation 3). Most of the Google browser apps like Gmail, etc use it. So does Facebook. Hell, Microsoft now supports MS Store apps (formerly "Metro") written entirely in Javascript, and in fact it's the only platform available for Media apps on the XBox One *and* the PS4 (both of which I am working on now, having done a previous 360 app in C# and PS3 app in C/C++).

      I sense that you have never actually done a complex project like that in Javascript. So *maybe* you just aren't the right person to be able to compare Javascript app development with C... libraries are libraries, whether it's jQuery for Javascript or curl, openssl, libxml2, etc for C. Unless you are doing something trivial in C you are obviously using plenty of external libraries, or reinventing the wheel a dozen times.

    89. Re:That's just not a viable option. by narcc · · Score: 1

      Yes, that's correct. Now ask yourself why JavaScript need enter in to it at all? (Are you going to advocate browser detection? You'll find more than enough on comp.lang.javascript about that bad practice!)

      I don't know, dynamically change the element's CSS depending on the resolution and orientation?

      If that becomes a need, chances are you've already failed. When it makes sense, which is rare, you'll find mobile browsers more than capable thanks to long-standing and broad CSS3 support across the major platforms.

      As for the handheld media type, your article is woefully out-of-date. CSS3 Media Queries are far from "non-standard" in case you didn't know. (I should also point out that for mobile devices, in virtually all cases, it's not necessary to change your CSS at all. If you found some bizarre case where that was necessary, using the outdated handheld media type wouldn't make sense anyway!)

      And you want to use a heavy-weight JavaScript library to "fill in the gaps" (that likely don't exist) on a subset of antique devices where you might find a minor layout problem? That's insane. I'll take it a step farther and guarantee that you'll find more "gaps" using JavaScript for layout on old mobile devices than you will with CSS.

      Anyhow, I'm not going to argue with you about this. It's clearly going to be a huge a waste of my time. Unless your incompetent, you'll figure this out on your own eventually.

      Good luck.

    90. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      Because some people don't have javascript enabled, and some users use browsers that don't support javascript, or don't work with elements created through javascript very well, like screen readers for the blind or color blind.

    91. Re:That's just not a viable option. by amicusNYCL · · Score: 1

      And you want to use a heavy-weight JavaScript library

      Heavy-weight? No, I didn't say anything about the Javascript needing to be heavy-weight.

      --
      "Our two-party system is like a bowl of shit looking at itself in a mirror." - Lewis Black
    92. Re: That's just not a viable option. by loufoque · · Score: 1

      A complex application in Javascript? Come on, be serious. Web applications are hardly complex. The very few that are are written in C or C++.

    93. Re:That's just not a viable option. by Kielistic · · Score: 2

      I've already explained why these libraries are well"enough" implemented and reasonably fast. Supporting multiple and different implementations of JS across multiple browsers has traditionally been a real pain. That is where all the extra crap comes in on these libraries. You can't just keep reiterating a lie. A 5%-10% slowdown is well worth a 50% reduction in development time.

      I experimented using the jQuery to do Ajax calls, but the way to do this is... atrocious. Works? Works, but what a cost?

      $.get('url', callback);

      Too hard for you? More options are available to you with easy to read and well documented labels. I'd much rather read that than a swath of if statements that can be labelled and ordered any way the developer felt like at the time.

      And now you are going to say that ajax is slow in jQuery? Maybe I misread that but it really looks like it. 99.9% of the time any ajax request takes is going to be the time the internet spends transferring the data. Not the library wrapping the system calls.

      It seems to me the problem isn't everyone else not knowing how to use Javascript. It seems like the problem is you don't know how to use a library effectively. Then you go and believe other people that quote benchmarks to justify your lack of knowledge. Benchmarks like: look how many million times a second more vanilla Javascript can access the body tag than jQuery can. Not exactly a useful benchmark. Libraries are a good thing (notice how every popular language has hundreds-thousands of them?). Trying to justify libraries are always bad in Javascript is only cognitive dissonance. For some reason you have decided jQuery is bad and now you must defend that no matter what lest you admit a mistake.

    94. Re:That's just not a viable option. by spiralx · · Score: 1

      The first two are about 1% of the internet, and how do screen-readers distinguish between DOM elements in the original HTML and DOM elements created by Javascript?

    95. Re:That's just not a viable option. by shutdown+-p+now · · Score: 1

      Let me guess - you're a guy who only knew Java or PHP until you learned about JS, and you've read some blog post explaining how "if you ignore the problems with DOM, JS itself is a great language" (you can usually tell people like that because they blindly repeat that phrase in any discussion about JS), on the basis that JS has closures, which makes it kinda like Lisp (except you understand it, unlike Lisp), which therefore makes it awesome.

      How can I tell? Well, the fact that you have no idea what I'm actually talking about is an obvious giveaway. For example, insane local variable scoping. People who've used JS and other languages (and therefore have some basis for comparison) know that what this refers to is the fact that you can put a "var" declaration inside, say, a for-loop, but its scope will in fact extend to the entire function body. Which you will usually realize when you capture that variable inside a lambda in the body of the loop, and then find out that all your closures share the same variable. Now, what does this feature have to do with "freedom to think for themselves" and "most flexible languages out there"? Absolutely nothing, of course. It's just brain-dead design. The only other language that has anything similar is *drum roll* VB6. Nice company, folks.

      So, my advice... if you want to understand the comments you're replying to, consider familiarizing yourself with a couple more languages outside of JS. You'll know that you've had enough breadth once you understand why the statement "JS is one of the most flexible languages out there" invokes bouts of uncontrollable laughter from anyone in the field.

    96. Re:That's just not a viable option. by HappyPsycho · · Score: 1

      Compiled library vs interpreted library, not really a fair comparison.

      Look at the glibc source and it will probably be a bit smaller than that 1.3MB.

    97. Re:That's just not a viable option. by HappyPsycho · · Score: 1

      Then can the browser vendors at least look at the fucked up work arounds they had to do to get jquery to even work and fix them?

      That way the implementations are at least somewhat consistent? Things are much better than they once were but it still sucks.

      My view on the matter is anyone who is criticizing Jquery / Dojo / and is suggesting vanilla javascript is completely ignoring the fact that the reason allot of these frameworks exists is the base implementations are horribly, horribly broken and the effects of a piece of javascript can be inconsistent even within the same browser.

      HTML & CSS suffer from the same problem though thankfully to a lesser degree.

    98. Re:That's just not a viable option. by narcc · · Score: 1

      Then can the browser vendors at least look at the fucked up work arounds they had to do to get jquery to even work and fix them?

      The problem is that jQuery is so poorly implemented -- and so badly broken that there no value can be gained from its examination!

      It's pretty obvious that Resig et al. don't have a clue. The "work arounds" are "fucked up" because they were written by rank amateurs who *still* don't know what they're doing!

      As far consistency between browsers, I agree that things have improved. Even IE. So much so, in fact, that a few polyfills is often more than adequate to take care of the differences between browsers. (Just be careful with them. Some are great, while others are total garbage.)

      Read the links I posted and dig around comp.lang.javascript for a little bit. If you're still advocating the use of jQuery after that, I don't know what to tell you!

      My view on the matter is anyone who is criticizing Jquery / Dojo / and is suggesting vanilla javascript is completely ignoring the fact that the reason allot of these frameworks exists is the base implementations are horribly, horribly broken and the effects of a piece of javascript can be inconsistent even within the same browser.

      But neither jQuery or Dojo actually solved the problem! (Sometimes they'd even make the problem worse...) The myth from years ago was that jQuery took care of all your cross-browser concerns. That was never even a little bit true. jQuery was, and still is, inconsistent across even the few browsers it claims to support. That's to say nothing of it's ever-shifting API!

      Things are not nearly as broken as you seem to think they are. The differences between browsers can easily be managed by knowing what features to avoid -- and you don't need to avoid very much at all! Usually a small and simple polyfill or two will take care of any features you need -- even if you need to support antique versions of IE.

    99. Re:That's just not a viable option. by TheRaven64 · · Score: 1

      I don't have the glibc sources to hand, but du in /usr/src/lib/libc on FreeBSD tells me that the libc sources are around 13MB. /usr/src/lib/msun (the libm sources) are another 1.9MB.

      --
      I am TheRaven on Soylent News
    100. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      Array + Array = String! That's not insane type coercion, that's a language feature that frees your mind from rigid rules, maaaan! I mean, sure, the LSD helps, but it's mostly the freedom and flexibility.

    101. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      Dependencies are irrelevent. C libraries are not loaded but memory mapped and therefore do not consume excessive memory. Also many applications use lazy binding and do not attach themseves to libraries until they need it. But in systems with memory mapped libs and library casching this do not affect performance a bit since attaching to a lib do not actually load it.

      So no that do not compare to how JS loads libraries as textfile into RAM and them have to either JIT them using even more RAM not to mention the CPU usage or interpret them, which means that the text have to stay in memory.

    102. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      As I described above a C memory do not require RAM which makes your comparision invalid. Also: how do you think JavaScript do those things? Yeah trough C libraries.

      "Just try to do "much more than what you do with JavaScript" in C by only linking with libc."
      Linking do not consume much memory so this is irrelevent. Loading the entirety of libc into RAM would be something different, but thats only done when you actually need something in the library, and still you would not load more than you need as memory mapping only loads the part of the lib you needs to access.

      Static libraries in C are not something that you would use other than for system utilities that need to work when dynamic loading are failing. Static libraries are as I stated before not really loaded but memory-mapped and in some systems shared between applications in order to save memory.

      One solution would be for a javascript engine to detect loading of popular libraries and override them with native implementations but that would create problems with versioning.

    103. Re:That's just not a viable option. by Dahamma · · Score: 1

      There is so much wrong with this post it's kind of sad...

      As I described above a C memory do not require RAM

      This statement makes no sense in any possible way I read it. I'm not even sure what "a C memory" is, but any normal executable requires memory, of course.

      Static libraries in C are not something that you would use other than for system utilities that need to work when dynamic loading are failing.

      Not necessarily true at all. I work a lot in embedded systems and game consoles, where static linking is really common for C/C++ apps (to have better control over system libs, and for performance).

      Static libraries are as I stated before not really loaded but memory-mapped and in some systems shared between applications in order to save memory.

      This statement doesn't make any sense either. A static library is just an archive that the linker pulls from to include code into another executable. Therefore it's NOT shared between "applications" (I assume you mean processes in this case). Shared/dynamic library code, on the other hand, is shared between processes on many (but not all) operating systems.

      One solution would be for a javascript engine to detect loading of popular libraries and override them with native implementations but that would create problems with versioning.

      That generally wouldn't work since Javascript is a dynamic language, and by design the code can be self modifying.

    104. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      And thats one reason C code are more memory efficient. Instead of having a single very large framework C coders depend on libraries that have what they need.

      Furthermore C libraries do not need to be loaded untill they are actually used, they are usually memory-mapped and handled by the cache manager. JavaScript on the other hand need to be fully loaded and parsed before it can be called.

    105. Re:That's just not a viable option. by Anonymous Coward · · Score: 0

      JavaScript and PHP are very different and I would not object to using PHP in the browser as much as I object to JS. If we had efficient libraries implemented in C like we have in PHP that covers what the JS framework currendly does that would be a huge increase in performance compared to JS.

      However while the PHP team just add new funcions at will JS have several implementations and getting libs into them are quite tricky, we can see that in the develompent of WebGL.

  4. First rule of garbage collections by viperidaenz · · Score: 1

    If you don't release all references to it, it will never be collected (that includes circular references if you're dealing with a reference counting garbage collector, like some IE browsers)

    1. Re:First rule of garbage collections by Anonymous Coward · · Score: 0

      Wrong.
      The first rule of garbage collections is "You do not talk about garbage collection."

    2. Re:First rule of garbage collections by Anonymous Coward · · Score: 0

      The Second Rule of garbage collection is "YOU Don't Talk About GARBAGE COLLECTION"

    3. Re:First rule of garbage collections by angel'o'sphere · · Score: 2

      Reference counting is not garbage collection, please understand that.
      E.g. a group of objects that is referencing each other, but none of them is referenced from the stack or a "global" variable will never be deleted. But a garbage collector would find those objects and free them.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    4. Re:First rule of garbage collections by viperidaenz · · Score: 1

      Reference counting is a method of garbage collection. Please understand that. It is not the only method.

      Garbage collection is an automatic method of reclaiming memory not required by the program, nothing more. Counting references is one (bad) way of doing it.

    5. Re:First rule of garbage collections by angel'o'sphere · · Score: 1

      Reference counting is NOT a method of garbage collection as as it cant find all kinds of garbage

      Perhaps you should read a book about it?

      Reference counting btw is not _that bad_ as there are many special cases where it is the fastest and most reliable method of memory management where you neither want to do it manually nor want/have a real GC.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  5. intercept memeory allocation by fermion · · Score: 1
    way back when one of the routines I depended on, and wrote myself, was something that stored all memory allocations, checked before deallocating, and checked on the end of a routine. It basically patched malloc() and dealloc(), or whatever. It would throw an error if I made a mistake. Still, even with such help, that can be easily turning off for production, memory allocation is tough and it one of those things that separates a skilled developer from a script kiddie, so to speak.

    But in the real world, in most cases, cycles and memory is much cheaper than skilled developers. Hand coding memory is like hand coding widgets. Like on any project, sometimes optimization is necessary. I would think that mobile apps would be just like any other app. Run a profiler, see what is making the code get stuck, and fix it. When I was doing C, there were times when I had to drop to assembly because the C was too slow. It would been hugely irresponsible to do it all in assembly, but sometimes yes.

    --
    "She's a scientist and a lesbian. She's not going to let it slide." Orphan Black
    1. Re:intercept memeory allocation by Anonymous Coward · · Score: 0

      I used a development tool over 20 years ago that did something similar. When your program quit it gave you a list of everything you allocated which you failed to free. It would even tell you which lines in your code allocated that memory. It did lots of other amazing things and could catch all sorts of lurking bugs. I've long forgotten its name.

    2. Re:intercept memeory allocation by plover · · Score: 1

      Microsoft has long provided CRT macros for mapping memory allocations and finding leaks. Turning on _CRTDBG_MAP_ALLOC does exactly what you describe. http://msdn.microsoft.com/en-us/library/10t349zs.aspx

      --
      John
    3. Re:intercept memeory allocation by GiganticLyingMouth · · Score: 1

      Sounds like Valgrind

    4. Re:intercept memeory allocation by loufoque · · Score: 1

      Memory management is simple to any C or C++ developer. If you have difficulties with it, you are a bad developer.
      In C++, exception-safe memory management can be a bit tricky, but since C++ globally makes things simpler if you follow the right idioms, it still ends up being easier.

      I work in high-performance computing, and my focus is on the in-core and shared-memory optimization of numerical code. There is no need to ever go to assembly. Just write the right C code, using attributes or built-ins if necessary (in my field, I use SSE and AVX intrinsics), and check the compiler generates the right thing.

    5. Re:intercept memeory allocation by angel'o'sphere · · Score: 1

      Memory management is simple to any C or C++ developer.
      If that would be the case people had not shifted away from C/C++.
      If that would be the case software would not randomly crash-
      If that would be the case software had far less security breaches.
      If that would be the case software would be much faster (not having the code clutterd with "if (a != null) do something with a")
      Etc.
      Etc.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    6. Re:intercept memeory allocation by TheRaven64 · · Score: 1
      Having worked in HPC, allow me to translate your post for the benefit of everyone else:

      Hi, I work on a subset of problems where aliasing is intentionally reduced and where the algorithms that we use are, by design, amenable to shared-nothing parallelism, although we used shared memory for efficiency. The code that I write has very little similarity in structure or requirements to the vast majority of software in the world, but because it runs on very expensive hardware I regard my views base on this code as being valid in any setting. Memory management is easy.

      --
      I am TheRaven on Soylent News
    7. Re:intercept memeory allocation by Anonymous Coward · · Score: 0

      If you have difficulties with it, you are a bad developer.

      Unfortunately, 99% of all developers are bad. There is literally no way you can go one single day now without being forced to use a dozen programs written by developers so terrible that they make the world a worse place every time they touch a keyboard.

      (For many of them, the language of choice is Javascript.)

  6. Only a short-term problem by s7uar7 · · Score: 4, Funny

    The only way to get "silver bullet" memory management is the same way we do it on the desktopâ"by having 10x more memory than your program really needs

    Give it a couple of years and that's exactly what will happen. Problem 'worked around'.

    1. Re:Only a short-term problem by Anonymous Coward · · Score: 1

      Read the rest of the article (yes, it is really long). It explains why continued large increases in hardware capabilities in mobile may not continue. But Apple will probably keep building devices that take larger and larger pictures, so you'll still run into issues with apps that deal with photos.

    2. Re:Only a short-term problem by abroadwin · · Score: 1

      Totally true. My first computer only had 16k available. Now that I have 12 gigs of RAM I have 786432x the amount of memory I need, so everything is always fast!

    3. Re:Only a short-term problem by Anonymous Coward · · Score: 0

      The article is bullshit written by morons who have no clue what they're doing.

      Do they somehow think that all android (non native) apps don't work too, because they're garbage collected?

      Do they think that modern phones are still incredibly slow turds (news flash, they're actually about as fast as a Core2Duo at the moment, and rapidly getting faster)

      Javascript is slow because it's a poorly engineered scripting language with a million and one corner cases for the interpreter to deal with, and because there's a limit to how fast it can be interpreted as a result. The current interpreters are actually pretty damn good.

      What we really need is a universal standard byte code, which is language agnostic, for the internet to replace Javascript with (and no, Java Byte Code doesn't count, it's far from language agnostic - it has support directly in the byte code for doing things like allocating objects).

  7. GEt off my LAWN! by Anonymous Coward · · Score: 0

    NOW!!!

  8. Explicit memory management. by tokizr · · Score: 2, Insightful

    You could just 'force' people to use a language with explicit memory management, like by offering [better] support for that particular language (C/C++ is best but I understand people do not enjoy these lower level languages as much). I always thought that the best form of garbage collection is not having garbage collection at all, but managing your memory efficiently and having good allocators. Yet even on languages such as Java/Javascript you can be smart about your objects so to minimize the underlying allocations. I would suppose javascript may be a little harder since it's not strongly typed but it should still be possible.

    1. Re:Explicit memory management. by Anonymous Coward · · Score: 0

      You could just 'force' people to use a language with explicit memory management, like by offering [better] support for that particular language (C/C++ is best but I understand people do not enjoy these lower level languages as much).

      I always thought that the best form of garbage collection is not having garbage collection at all, but managing your memory efficiently and having good allocators.

      Yet even on languages such as Java/Javascript you can be smart about your objects so to minimize the underlying allocations. I would suppose javascript may be a little harder since it's not strongly typed but it should still be possible.

      I love the idea: Write you program so that it manages memory efficiently with a good allocator. And while I'm at it write the program so its meets its requirements and has no bugs.I'll immediately put this suggestion into practice.

    2. Re:Explicit memory management. by loufoque · · Score: 1

      Don't generate garbage; this way you won't have garbage to collect.

    3. Re:Explicit memory management. by phantomfive · · Score: 2

      Yet even on languages such as Java/Javascript you can be smart about your objects so to minimize the underlying allocations.

      The article explains that game developers do exactly this (when they choose to write in Java at all): they allocate all their objects at the beginning, so the garbage collector has nothing to do. In other words their being forced to manage memory in an environment that wasn't designed to support it.

      --
      "First they came for the slanderers and i said nothing."
    4. Re:Explicit memory management. by Anonymous Coward · · Score: 0

      Problem summary:
      - javascript is run interpreted inside a browser (and js has its own GC)
      - the browser is written in java (java has its own GC)
      - java runs in a virtual machine (the vm has its own GC?)
      - the virtual machine interprets the java bytecode, and real time translates/compiles them to native instructions
      - the emitted instructions are run on a ~1GHz arm CPU.

      There is the real WTF. How can it be anything but dog-slow. It is a miracle it does not take days to load a page!

    5. Re:Explicit memory management. by shutdown+-p+now · · Score: 1

      It's not so much about explicit vs implicit as it is about predictable vs unpredictable. With C++ RAII and smart pointers, memory management is largely implicit - if you write good idiomatic C++ code, it won't have a single "delete" in it. But you can still tell when exactly deallocations happen, and from there determine how much they will cost. In JS, you never know when GC decides to kick in. If it was in the middle of you rendering a smooth animation (e.g. user swiping his finger, and you scrolling the screen in response to that), there will be visible stutter and lag, and you can do absolutely nothing about it.

  9. Garbage collection is dumb by 0123456 · · Score: 2

    Breaking news. Full story at 11.

    Garbage collection is supposed to stop dumb programmers doing dumb things, but in reality it just gives them different ways to do dumb things.

    1. Re:Garbage collection is dumb by Laxori666 · · Score: 1

      Man you try using closures with manual memory management. Quite a nuisance. GC is really quite nice.

    2. Re:Garbage collection is dumb by 0123456 · · Score: 1

      GC is really quite nice.

      So long as you don't mind spending weeks trying to eliminate the pauses and bloated memory usage and creating internal caching schemes to avoid having to allocate more objects to be garbage collected.

    3. Re:Garbage collection is dumb by wisnoskij · · Score: 1, Insightful

      Better than spending months trying to get rid of all the memory leaks.

      --
      Troll is not a replacement for I disagree.
    4. Re:Garbage collection is dumb by TheRaven64 · · Score: 1

      It's fine, as long as your closures are only passed downwards. If you ever pass a closure up the stack or to another thread, then it becomes painful.

      --
      I am TheRaven on Soylent News
    5. Re:Garbage collection is dumb by Laxori666 · · Score: 1

      True, but that's where they are the most useful - like for event handlers. To be honest I've never used closures in a language without automatic memory management so I'm not sure how that would end up working out.

    6. Re:Garbage collection is dumb by Laxori666 · · Score: 1

      Ha I see you got sniped by a "I disagree - mod Troll". Funny given what your sig is.

      What it comes down to is that GC is a tool. If you don't understand how it works and assume it's magic, then you'll get bitten in the ass at some point down the line - although for most things it actually won't matter so you can get away with it for a bit. But of course you'll get more out of it if you understand it - for example I recently had to use weakrefs in a Python project to break circular references.

    7. Re:Garbage collection is dumb by TheRaven64 · · Score: 1

      Take a look at C++11, it's pretty hideous. It works, as long as you make sure that everything you use in the closure is either copied or a smart pointer, but you have to be pretty careful not to end up with cycles.

      --
      I am TheRaven on Soylent News
    8. Re:Garbage collection is dumb by wisnoskij · · Score: 1

      Well if you are just a completely incompetent programmer, it cannot save you from yourself.
      But a lot depends on your language. Sure, you could write a GC for C++, but some of C++'s features are not really compatible with garbage collection.

      But a language written specifically with GC being the only option in mind will fair a lot better at doing an optimal job.

      --
      Troll is not a replacement for I disagree.
    9. Re:Garbage collection is dumb by shutdown+-p+now · · Score: 1

      True, but that's where they are the most useful - like for event handlers.

      Actually, closures are far more often used as arguments to higher-order functions which invoke them right back, so it's strict downarg passing (e.g. STL algorithms). Using them for event handlers happens, but is not all that common.

      There is one scenario where closures are used a lot as upargs, though, and that's when you write async code using callback chaining. And, yeah, that's a mess, although shared_ptr helps immensely (and the ability to capture-by-move in C++14 will help even more).

    10. Re:Garbage collection is dumb by Laxori666 · · Score: 1

      Oh that's a good point about the higher-order functions. I hadn't thought about that. I use Python mostly, where map + filter are usually replaced by list comprehensions.
      Good example w/ the async code. Two more uparg closure examples I thought of:
      1) One thing in Python where closures are useful is with wrapping functions. e.g. I made a function which memoizes another function's results based on the hash of its arguments. The cache is stored in the closure that the memoize function generates. It's a very neat thing in that it allows a sort of microcosm to be built, and then essentially be ignored (given you know what you're doing) without complicating the rest of the code, much.
      2) In JavaScript, closures are often exploited to implement hidden variables.

  10. CPython uses reference counting, like objective C by Anonymous Coward · · Score: 1

    The summery mentions Python as one of those garbage collecting languages that have massive garbage collection overhead. But Python actually uses reference counting, which is a garbage collection overhead which is useful in low latency situations. As opposed to the standard mark and sweep garbage collecting like those in Java where every few seconds everything grinds to a hold to clean up memory.

    Objective-C tried the mark-and-sweep garbage collection, the first program I made hung for minutes doing garbage collection, I actually had to force the garbage collector to go ahead at smart points in the program to make it behave. Having the same program using reference counting was a completely smooth experience.
    This is the reason that mark-and-sweep garbage collection is not allowed on the iPhone.

    This problem of mark-and-sweep isn't just an objective-C implementation problem. Java suffers from it identically, this is why it is advocated to force the garbage collector after every request on a website.

    Maybe I am living in a fantasy world, but I find it insane that I have to force a garbage collection at correct moments in the program. Which is why I rather like reference counting, or stack allocation.

    In Objective-C reference counting is now automated by the compiler, so it is just as programmer-friendly as mark-and-sweep.

  11. This is what's going to doom FF OS by slacka · · Score: 4, Insightful

    This is one of major flaws behind these Web based Mobile OS’s, you think that after WebOS, beautiful as it was, Mozilla would have learned their lesson. Instead, they’re trying to drive underpowered hardware with a HTML/JS. All the web technologies are being shoehorned into areas they were never designed for. From DOM being used for Applications to the lightweight scripting language, JavaScript, being used for Apps, to a bloated HTML render as the platform's UI toolkit.

    JavaScript is a nice little scripting language that’s got some nice functional programming features. When you need to need to write heavy applications that require performance, low memory usage, and multithreading, it’s the wrong choice.

    1. Re:This is what's going to doom FF OS by aztracker1 · · Score: 1

      Funny, you don't mention Android being doomed in the same breath... considering even the article mentions that it, being a GC platform has many of the same issues.

      --
      Michael J. Ryan - tracker1.info
    2. Re:This is what's going to doom FF OS by Anonymous Coward · · Score: 0

      Bloated HTML?
      What exactly is bloated about HTML?

    3. Re:This is what's going to doom FF OS by Anonymous Coward · · Score: 0

      JavaScript is a nice little scripting language that’s got some nice functional programming features. When you need to need to write heavy applications that require performance, low memory usage, and multithreading, it’s the wrong choice.

      Multithreading? Problem solved: Daniele Bonetta, Walter Binder, and Cesare Pautasso. 2013. TigerQuoll: parallel event-based JavaScript. In Proceedings of the 18th ACM SIGPLAN symposium on Principles and practice of parallel programming (PPoPP '13). ACM, New York, NY, USA, 251-260. DOI=10.1145/2442516.2442541

    4. Re:This is what's going to doom FF OS by gl4ss · · Score: 1

      Bloated HTML?
      What exactly is bloated about HTML?

      the modern rendering engines.

      that's where the memory is going. caching gradients, caching the rendered text, multiple sizes of the images and so forth. it becomes pretty complex pretty fast and for every pixel on the screen you end up with 5 times the pixels in middle level caches.. which might never get reused anyways..

      --
      world was created 5 seconds before this post as it is.
  12. Re:CPython uses reference counting, like objective by EvanED · · Score: 3, Informative

    As opposed to the standard mark and sweep garbage collecting like those in Java where every few seconds everything grinds to a hold to clean up memory.

    Not to say that tracing collectors don't have a bit of a stuttring problem and I don't want to get into tracing vs reference counting, but:

    1) Decent tracing collectors (and the Java VM has had one for a while) are not nearly as bad as you make them out to be, and

    2) You mean "tracing collector" rather than mark-and-sweep. The latter is just the simplest form of tracing collectors, which is really pretty bad and is essentially never used. The JVM uses a generational collector, .Net uses a semispace collector (I think), all three of which differ pretty significantly in both mechanics and performance characteristics.

    The second point is a bit pedantic and in many stories I probably wouldn't even reply, but in a discussion that is basically specifically about GC it is a good idea to use correct terminology.

  13. One of the issues are.. by houbou · · Score: 1

    the approach to JavaScript development.
    Everybody is to trying to use 1 library for all platforms (mobile, desktop) etc.

    The first thing is to stop this non-sense.

    Use server side technologies to sniff out the client. When working with mobile phones, create or bastardize a library which has the smallest footprint possible to fit your needs.

    1. Re:One of the issues are.. by Anonymous Coward · · Score: 0

      Use server side technologies to sniff out the client.

      By which you mean "read the user agent string, which the client has complete control over"?

    2. Re:One of the issues are.. by houbou · · Score: 1

      well, yes, it is highly possible for the client to fake their user agent string, but in the end, usually, this is done for testing. That being said, if some idiot wants his Firefox to read like IE, well, so be it.

    3. Re:One of the issues are.. by PRMan · · Score: 1

      Apparently there are other ways, as I have my Android tablet set to spit out a desktop User Agent and some sites still manage to serve me underpowered garbage optimized for phones.

      --
      Peter predicted that you would "deliberately forget" creation 2000 years ago...
    4. Re:One of the issues are.. by Anonymous Coward · · Score: 0

      I'm not sure I agree with houbou's solution, but you're describing a non-issue. If a user wants to change the user agent and get the bloated desktop version of the libraries into his/her phone, it's their problem. Meanwhile, 99% of the users that don't do that will get the stripped version.

      I just don't understand why you wouldn't send the stripped version to everyone.

    5. Re:One of the issues are.. by houbou · · Score: 1

      Well, it really depends on your site's design.. And then again there are sites and then there are web apps.. So, for example, say you adhere to the 'Responsive Web" school of design, then, you are going to be building a site which will start from mobile and then scale all the way to the desktop, but along the way, you will be altering your design to get more bang for your buck when you get more resolution from your user-agent.

      If you are using libraries, more than likely, there will be a lot of code from these libraries which might not provide you with any functionality, until you scale up in your browser expectations/requirements and features.

      For the sake of efficiency, it would make more sense to have a smaller, more compact library with only the core functionality you require and then with dynamic loading, add extra javascript module as required and/or use a factory pattern for your API which adapts to the user-agent as well as available features (always better to perform feature detection first).

  14. Memory is cheap by msobkow · · Score: 0

    Memory is cheap. Even for mobile devices. But the vendors want to bend you over backwards for every gigabyte.

    So put the blame where it belongs: on those who would restrict memory arbitrarily.

    64-bit processors are the norm nowadays. Screw anything constrained by 32 bits.

    --
    I do not fail; I succeed at finding out what does not work.
    1. Re:Memory is cheap by aztracker1 · · Score: 1

      going 64-bits gets you very little with a phone that has 512MB of ram.. Personally, given the price of smart phones, they should all have at *LEAST* 2GB of ram.

      --
      Michael J. Ryan - tracker1.info
    2. Re:Memory is cheap by Anonymous Coward · · Score: 0

      So the problem is solved... because you declare it solved?

      No wait. The problem is solved... because you know who to blame?

      Right. Got it.

    3. Re:Memory is cheap by TheDarkMaster · · Score: 1

      Wrong. Memory on mobile is NOT cheap. Memory in a server is really not cheap (your application is only one in a many applications running, uh oh).

      --
      Religion: The greatest weapon of mass destruction of all time
    4. Re:Memory is cheap by msobkow · · Score: 1

      I say again: Memory is cheap.

      Blame the vendor.

      --
      I do not fail; I succeed at finding out what does not work.
    5. Re:Memory is cheap by msobkow · · Score: 1

      Try running Firefox on an old XP box with 512MB of RAM and see how JavaScript chugs.

      --
      I do not fail; I succeed at finding out what does not work.
    6. Re:Memory is cheap by msobkow · · Score: 1

      So there is something special about a memory chip built for mobile vs. a memory chip built for desktop?

      Server, yes, ECC is fractionally more money. And there is a smaller market for specialized servers that may only have a few tens or hundreds of thousands of customers, so that boosts the price a bit.

      But in both the server and mobile spaces, it's primarily an issue of gouging by the vendor. Especially in the mobile space where volume buying is the norm.

      --
      I do not fail; I succeed at finding out what does not work.
    7. Re:Memory is cheap by ImdatS · · Score: 2

      You probably mean "Memory is cheap in terms of dollars".

      On a mobile device such as a smartphone, every micrometer of space counts. Every milliwatt of energy consumption counts. It's not about whether another GB of RAM costs ten bucks or so (whatever it is). It is about efficient use of space and battery.

      If you add more RAM, it not only uses more energy but because it also requires space, it reduces the space available for either the battery or other components. There are numerous other reasons why memory, in a smartphone, is NOT cheap. And $$ is definitely not the main cause why people don't add that much memory (well, for some low-end devices, $$ is also a reason, but for high-end smartphones, that doesn't really count).

    8. Re:Memory is cheap by silas_moeckel · · Score: 1

      Ram takes power to keep running an it's a nontrivial amount. Not a real issue on something plugged into the wall but hell on battery life.

      --
      No sir I dont like it.
    9. Re:Memory is cheap by DMUTPeregrine · · Score: 1

      Mobile phones have 2 major constraints that desktops and servers largely lack: Space and heat. There simply isn't that much area for memory chips, so you can't just stick in extras. There's also little to no space around the chips, so no airflow, and thus very poor cooling. The denser the chip you chose the worse the heating issues become. A lower capacity chip can be placed closer to the processor, reducing latency and vastly simplifying board layout.
      Add price gouging on top of that and you get the current situation in mobile: low memory for high cost.

      --
      Not a sentence!
    10. Re:Memory is cheap by TheDarkMaster · · Score: 1

      I'm not talking about price in dollars, I'm talking in terms of finite resource that must be shared by multiple applications beyond your application. If all applications decide that all system memory is for your personal use, the whole system collapses.

      --
      Religion: The greatest weapon of mass destruction of all time
    11. Re:Memory is cheap by msobkow · · Score: 1

      And what do you think happens on a desktop or server? The memory is shared by multiple processes/programs. This is not something new to these devices. Memory has always been constrained.

      But try running an old XP box with 512MB of RAM and see how your Javascript-heavy web pages fare.

      It's not the world's fault that the vendors sucker you into crap hardware with only 512MB of RAM.

      I'd never even consider buying such a crippled tablet or phone any more than I'd buy a desktop with 512MB RAM. It's just not enough, and hasn't been for years.

      --
      I do not fail; I succeed at finding out what does not work.
    12. Re:Memory is cheap by TheRaven64 · · Score: 2

      Volatile memory is defined as memory that requires power to preserve its contents. All of the 'cheap' memory that you can buy at the moment is volatile memory (and the non-volatile memory is either really expensive, really slow, or both). If you double the amount of RAM, then you double the number of capacitors that must be refreshed every few nanoseconds and so you double the power consumption. You also double the amount of heat that's generated and must be dissipated.

      Now, what's the number one complaint that people have about most smartphones? Is it performance, or is it battery life? If it's performance, then doubling the RAM makes sense. If it's battery life, then doubling the RAM will make people complain more.

      --
      I am TheRaven on Soylent News
    13. Re:Memory is cheap by gbjbaanb · · Score: 1

      yes it is - or it should be. I used to have 512Mb RAM years ago on my desktop and things ran fine. Hell, I had less than that when I first started work - I remember upgrading my dev box to 32MB RAM way back, and visual studio still ran fine.

      Of course, they hadn't layered in so much crap on to it that required all the RAM is does now.

      The same applies to mobiles, there are physical constraints that are not about financial cost, typically battery life, that apply to mobiles. If your app requires 2gb RAM, that means firstly that the phone must have much more than that to work effectively for the user (who will be running other things too, and if they requires 2gb as well, well, you do the math) but it also means that RAM is sucking up juice all the time. If you need that much RAM, it also means your app is not very efficient - even if its only garbage collecting,that means its doing stuff that require CPU cycles that suck up more juice. Net result - you have crap reviews for your battery-draining app and no-one uses it.

      See, the modern myth that computers have so much processing power that's unused may apply to the desktop where 1 user sits there while the CPU twiddles its thumbs. It does not apply on the server where ten thousand users are all asking it to process stuff simultaneously; or on mobile where the CPU tries very hard to do nothing for as often as possible.

      So, the problem does not lie with the manufacturers for making a mobile phone that requires the same form factor as a desktop
      pc, complete with several fans and heatsinks. The problem lies with the programmers, not only for writing code in languages that are not designed for efficiency, but also the programmers who come up with the libraries, frameworks and other systems that are so bloated with crap because they're written from the point of view of someone used solely to coding a desktop PC that has CPU to spare and can't figure out how to write efficient code (which is understandable as they've grown up in a world of bloated crappy libraries and languages that put "ease of coding" way above anything else.

      I mean, if you wrote code in C, the compiler will strip out everything that's not needed. If you write in javascript, you pull in a megabyte of data scripts from several sites, just for 1 function... because its easy to do.

      Similarly, if you code for Android, in Java, you'll see your app is slow. Code it in the NDK and you'll get something very fast. (See for yourself, download Addons Detector and run it to see the development tool used for each of your apps. The fast and responsive apps will all have been written using the NDK). That shows a difference between native code and Java, imagine the difference between native code and javascript!

      So use the right tool for the job. If you only know the javascript pliers, everything will look like a bent nail. Its not that js is bad, but that its not appropriate for this task.

    14. Re:Memory is cheap by msobkow · · Score: 1

      I get your point, but I think the bigger problem is portable device users who expect a dinky little toy to perform as good as their home desktop. They need to remember it's a woefully underpowered device which is going to have trouble dealing with more than one complex task at a time -- and unfortunately for them, that includes visiting a lot of modern websites.

      Were people complaining about the performance of the aforementioned 512MB PC, people would just laugh at them.

      But somehow because mobile is the "new thing" we're all supposed to give a rats ass in the programming world.

      Unless and until mobile devices crank up the memory (not necessarily the CPU), they're going to be second class browser citizens. Browsers are not specialized applets -- they're general purpose programs with interpreters. That means they are going to be bigger and slower than dedicated code, and there is no avoiding that.

      --
      I do not fail; I succeed at finding out what does not work.
    15. Re:Memory is cheap by TheDarkMaster · · Score: 1

      Reread what I wrote ...

      If all applications decide that all system memory is for your personal use, the whole system collapses.

      This does not happen on the desktop because most applications - yet - respect the fact that they need to share resources with other applications (and the desktop pc have a lot more resources than a mobile). But try putting in the same system several applications that do not respect that, and you quickly will have an unsustainable situation.

      --
      Religion: The greatest weapon of mass destruction of all time
    16. Re:Memory is cheap by gbjbaanb · · Score: 1

      that's true - no-one's going to run Crysis on their mobile, but they could easily run Quake. Maybe our expectations of them need to be reduced similarly.

      I do think that we will see mobiles with more RAM and power over time, they're still a very immature industry. One day I hope to see a mobile that I can dock to my TV and get a 'desktop' experience, but I still think the best way to achieve this is not to pander to poor developer's desire to have things handed to them, but to try to keep some efficiency in programming.

      You can get good performance with low-RAM environments. You need to code in C, or C++ with the wonderful RAII, and you suddenly no longer need gobs of RAM for your GC-based language that assumes RAM is free and unlimited. Our problem is fundamentally down to that.

    17. Re:Memory is cheap by Anonymous Coward · · Score: 0

      The number one factor limiting mobile performance is heat dissipation. So no, doubling RAM will not increase performance for anything that is limited by CPU or GPU. Since unlike CPU and GPU RAM currently can't be switched of, adding RAM will actually _limit_ the performance of all other components.

    18. Re:Memory is cheap by angel'o'sphere · · Score: 1

      Sorry, your argument is missing the point (and is imho nonsense) .
      On a Desktop you have 4 to 8 gogs or even far more memory. A single application perhaps has a footprint of 1 gig, or like Chrome creates a lot of processes with one gig size. And all together they use up 100ds of gigs of swap space.
      No, the idea that desktop apps "respect each other" is complete nonsense.
      Every Desktop app is written with the idea: the whole computer belongs to me.
      And that is what, right now, does not work on mobile platforms. But in ten years even mobile platforms will have different problems, AGAIN.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  15. Android GC sucks by Miamicanes · · Score: 2

    The problem isn't that Android phones have "limited ram", the problem is that Android's garbage collection sucks miserably at dealing with short-lived objects -- a problem that was fixed & mostly a non-issue with J2SE by the time 1.4 or 1.5 came out more than a DECADE ago.

    10 years ago, when J2SE 1.5 was out and its garbage-collection problem was already a historical footnote, a laptop with 512mb, 32-gig hard drive, and 700-1000MHz CPU was fairly respectable. A Galaxy S3 has a gig of ram, 16 or 32 gigs of internal flash, and a 32-gig class 10 microSD card costs $20 on sale.

    1. Re:Android GC sucks by cnettel · · Score: 1

      A Pentium III-M or early Pentium M was far faster, on a clock by clock basis, than a single ARM core in most modern smartphones. They get ahead a bit by sporting multiple cores, but that won't help you much in Javascript, or in the really tricky parts of GCing in most VMs (not sure about Dalvik).

    2. Re:Android GC sucks by Anonymous Coward · · Score: 0

      ... and yet Java is still incredibly slow even on my 3.7ghz quad-core with 16 gigs... hmm

    3. Re:Android GC sucks by shutdown+-p+now · · Score: 1

      The problem isn't that Android phones have "limited ram", the problem is that Android's garbage collection sucks miserably at dealing with short-lived objects -- a problem that was fixed & mostly a non-issue with J2SE by the time 1.4 or 1.5 came out more than a DECADE ago.

      If it's such a non-issue, then why are the guys that are designing lambdas and associated sequence processing algorithms for Java 8 are trying so hard to avoid boxing/unboxing of primitives?

    4. Re: Android GC sucks by Miamicanes · · Score: 1

      Try excluding .jar files from "every time accessed" antivirus scanning. It'll cut the load time for something like Netbeans from 30-60 seconds down to 5-7 seconds or less. Antivirus re-scanning *kills* classloader performance.

  16. A lot depends on what you're trying to do... by ducomputergeek · · Score: 3, Insightful

    Most the "Apps" I'm being hired to write are basically CRUD form apps that are designed to read info from tables in a database. Usually to take forms already in use by desktops written in Java or .Net or in some cases god only knows what and adapt them for use on mobile devices.

    I've frankly found jQueryMobile + HTML5 + Phonegap/Cordova makes this task farily easy to undertake client side. Actuallly in most cases the cost is still developing and deploying the API side in your choice of server side scripting language. And often that's based upon a perl script that I wrote circa 2000 to take form input, validate, and then go fetch data from a database and return in XML, YAML, or JSON these days. Other projects, the server side is in PHP or C# or Java. Just depends on what the client already has.

    Now I can see trying to buld other types of apps using HTML5/JS is asking for disaster.

    Sorry, I'm an old perl guy who thinks use the right tool for the job and there is still more than one way to do it.

    --
    "The problem with socialism is eventually you run out of other people's money" - Thatcher.
    1. Re:A lot depends on what you're trying to do... by Anonymous Coward · · Score: 0

      Old guys know how to predictably do things. They use Assembly and Cobol, while all the little self-centered youngsters believe into inventing another shit "framework" every single day. Plus a boatload of new "methodologies" which are as useful as M.B.A. types. ("Scrum", "Agile" and all the other quick-and-dirty crap).

  17. Do whats right by the consumer by Anonymous Coward · · Score: 0

    Don't make the consumer pay (in battery life and frustration) for fad frameworks and poor coding practices. A company pays you (who in turn is paid by the consumer) for something Good.

    1. Re:Do whats right by the consumer by Anonymous Coward · · Score: 0

      A company pays you (who in turn is paid by the consumer) for something Good.

      Not necessarily. Sometimes they're paying you not for something Good, but for something "a lot of." Finish that work order, and then: next work order! And the customer is happy because they paid for four hours labor instead of twelve.

  18. How about giving some examples, son? by Anonymous Coward · · Score: 1, Interesting

    Yeah, we know about document.querySelector(). It's still limited and more of a pain in the ass to use than jQuery's $().

    Here's what you're going to do, son. You're going to go through these lists of library functions, and you're going to list the native equivalent, and how well it's supported by the major browsers:

    http://api.jquery.com/

    http://underscorejs.org/

    http://mochi.github.io/mochikit/doc/html/MochiKit/index.html

    We're even starting easy, and just giving you three JavaScript libraries to cover. Remember, you have to do this analysis for each and every one of those functions.

    I sure hope that you don't give up once you realize how wrong you are with your bullshit claim that "every feature has a native equivalent that works across browsers".

    Oh, and if you don't prepare this comparison and have it ready within a few hours, we're going to know that you're wrong and that you're full of shit, son.

    1. Re:How about giving some examples, son? by narcc · · Score: 1, Insightful

      I clicked on the first link and scrolled a down a bit.

      The answer appears to be "most of them" and "most of the remainder if you know how to write for loop".

      Like I said earlier: do the web a favor and just learn JavaScript.

      You'll find that it's not only easier, but your code will be significantly faster. If you're dropping jQuery, you'll find that your code is also significantly easier to read and maintain. No need to make giant chains just to get your performance from "horrible" to "terrible" -- you get "acceptable" automatically, and "good" or "fantastic" once you have a better understanding of the language.

      Yeah, we know about document.querySelector()

      Apparently not. Take a look around the web. You'll find that the bulk of jQuery use can be replaced by querySelector and querySelectorAll -- often just by getElementById and getElementsByClassName.

      Really, I've seen lot's of sites and code samples that use jQuery just to select a single element by id! All because the author either didn't know about getElementById or was too lazy to type it out. It's horrifying.

      There are other stupid uses as well. Dropdown menus built with jQuery, like the popular superFish menu. What makes this particularly crazy is that it's trivial to build a dropdown menu without jQuery, or any JavaScript code at all! All you need is a little CSS. (Just a few lines, as it turns out.) If you don't have the 10 minutes it takes to figure it out yourself the first time, there are several websites that will generate a cross-browser pure CSS dropdown menu for you with just a few simple clicks!

    2. Re:How about giving some examples, son? by Anonymous Coward · · Score: 0

      I clicked on the first link and scrolled a down a bit.

      The answer appears to be "most of them" and "most of the remainder if you know how to write for loop".

      So basically, you're wussing out as the GP predicted you would, but you're not honest enough to admit that's what is happening.

    3. Re:How about giving some examples, son? by Crudely_Indecent · · Score: 2

      I think the biggest point against using JS libraries is that most sites load the entire library in order to use one feature. Certainly, these libraries can reduce the amount of JS used on a site/page/app - but when the entire library is loaded for a single trivial feature, the advantage is lost.

      --


      "Lame" - Galaxar
    4. Re:How about giving some examples, son? by Pseudonym+Authority · · Score: 2

      If you would turn on caching then that wouldn't be a problem.

    5. Re:How about giving some examples, son? by Crudely_Indecent · · Score: 0

      Caching will help with data transfer times, but the library is loaded regardless. If it isn't used, it's a waste of memory - which was my point.

      --


      "Lame" - Galaxar
    6. Re:How about giving some examples, son? by Pseudonym+Authority · · Score: 1

      Oh, never mind. I thought that that was yet another complaint that the 50KB or whatever transfer for jQuery was just unreasonable to load over and over.

    7. Re:How about giving some examples, son? by Count+Fenring · · Score: 2

      And that dropdown menu works in the absence of hoverstate support? I'm a big proponent of doing it in CSS if you can, but Javascript is basically necessary to get menus that support touch, even if it's just by adding and removing a toggle class.

    8. Re:How about giving some examples, son? by narcc · · Score: 1

      Sadly, the best you can do is get them to drop down. At least it takes very little JavaScript to make your CSS menus work on touch screens, and less code is always a good thing.

    9. Re:How about giving some examples, son? by Anonymous Coward · · Score: 0

      ... and if you do the same thing in javascript, you're not really going to see any kind of a noticeable difference in performance, most likely.

    10. Re:How about giving some examples, son? by angel'o'sphere · · Score: 1

      Caching does not help if two JavaScript apps load "the same" library from two different domains.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    11. Re:How about giving some examples, son? by Count+Fenring · · Score: 1

      But there's a trade-off between less code run and less code written (by you, that needs to be looked at to maintain/debug). You have to make an informed choice about performance vs available time and visible complexity. jQuery et al. arel going to turn out much smaller blocks of code (that have to be written, and later read by the maintainer) for a lot of common operations. This is especially true if your support window includes IE or mobile.

      There are a lot of tasks where using a resource (that's likely already in cache, if you're loading from the CDN) to smooth over AJAX handling or deferred event assignment is absolutely more valuable than making it so an operation that runs maximum three times per pageview can run a billionty times per second. And there are times when it would be stupid.

    12. Re: How about giving some examples, son? by Anonymous Coward · · Score: 0

      :focus and :active pseudo-classes to the rescue!

    13. Re: How about giving some examples, son? by Anonymous Coward · · Score: 0

      Thank you. That's why it's recommended to use the google Ajax libraries. Even though I hate google, it prevents the user from having to download the same library multiple times.

    14. Re: How about giving some examples, son? by Anonymous Coward · · Score: 0

      I'd forgotten about that - I've built those before - but they're not globally reliable enough, particularly on mobile, and they impose limitations on markup structure.

  19. Except, its not? by Shados · · Score: 1

    Short of issues with CSS transforms and in some cases hardware acceleration in general on Android, its not all that slow really.

    I have a nexus 4, which isn't low end but its no Galaxy S4 or iPhone 5 either as far as web performance goes, and for the vast majority of websites, it works just fine, with a few delays for ad-heavy sites, sites making heavy use of CSS transforms and animations (which are slow regardless of what you do with JavaScript...I'm being told the situation on iOS is much better), and a few outliers here and there that do things that could be considered edge cases. Sites using jQuery Mobile tend to be terrible, because its a terrible library, but even our main site with tens of thousands of lines of very complex and resource intensive javascript (a fairly advanced web app replicating desktop-like features) works ok, and we didn't even try to optimize it for mobile (we have a mobile specific version but it doesn't have all the features yet so its too early to compare).

    But average websites like Slashdot (the normal site, not the crappy mobile one), anything google, news sites, blogs, what have you? The pages load pretty much instantly. How much faster do you really want it to go?

    1. Re:Except, its not? by Anonymous Coward · · Score: 0

      Strangely, I find my Nexus 4 with Android to be painfully slow compared to webOS on the same device. Unfortunately, webOS is still in alpha for this device, so... meh.

  20. Re:CPython uses reference counting, like objective by Laxori666 · · Score: 1

    You're talking about "stop-the-world" garbage collection, which Python is also an example of. It doesn't have to do tracing, but it still grinds everything to a halt when it cleans up memory. I think real-time garbage collection is hard to come by these days.

  21. Bollocks by Anonymous Coward · · Score: 0

    I remember running Ruby and Java applications on a 64 meg 133 MHz Pentium machine back in 1997. They worked just fine back then. Many mobile devices today are far more powerful than that. The phone I have in my pocket (a Nexus 4) has thirty two times more memory and a CPU that is clocked eleven times faster, and has four times as many CPU cores! I don't know why VM designers (on mobile at least) don't make good use of the vast amount of research in garbage collection that has been done in the past fifty years and continue to use what amount to the simplest garbage collection algorithms that were first invented by John McCarthy and his colleagues in the 1960s for the first Lisps.

    1. Re:Bollocks by gl4ss · · Score: 1

      I remember running Ruby and Java applications on a 64 meg 133 MHz Pentium machine back in 1997. They worked just fine back then. Many mobile devices today are far more powerful than that. The phone I have in my pocket (a Nexus 4) has thirty two times more memory and a CPU that is clocked eleven times faster, and has four times as many CPU cores! I don't know why VM designers (on mobile at least) don't make good use of the vast amount of research in garbage collection that has been done in the past fifty years and continue to use what amount to the simplest garbage collection algorithms that were first invented by John McCarthy and his colleagues in the 1960s for the first Lisps.

      yeah, It's being slow is more to do with slow rendering of the elements currently. gradients, transforms.. all that shit is what takes all the memory, it's not exactly javascript itself in most cases - so the article is quite a bit of BULLSHIT and pretty much made just to show that iOS is better than unnamed platform xxxxxxxx.
      and those gradients and css effects are used instead of hard made graphics so that the site designers don't need to do multiple sets of graphics..

      garbage collected languages could and were used on mobile phones that didn't have even one megabyte of ram.. fun times.

      --
      world was created 5 seconds before this post as it is.
  22. This makes no sense by bill_mcgonigle · · Score: 1

    You could run certainly run Ruby on any mobile device if it had a magic garbage collector that solved everybody's problems. Except there's no such thing that's immune to idiot developers who allocate memory or variables and leave reference to them hanging around. The same problems apply to java on Android.

    TFS hasn't inspired me to read TFA, so sorry if it's explained there.

    --
    My God, it's Full of Source!
    OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
  23. Re:CPython uses reference counting, like objective by loufoque · · Score: 1

    Generational GC can still be mark and sweep (and most of them are). Generational or not is orthogonal.

  24. Industry trade secrets revealed by WaffleMonster · · Score: 4, Insightful

    I've found the best way to get developers to stop being lazy is to give them shit hardware.

    The mistake is buying the latest quad core 2GB android goodness... Give them a 5 yr old piece of shit and the resulting mobile apps will rock.

    1. Re:Industry trade secrets revealed by Anonymous Coward · · Score: 1

      Heh. The only problem is finding a 5 yr old piece of shit that runs Ice Cream Sandwich and Jelly Bean... I do want mobile apps that take advantage of the new features.

      Maybe you can get a new phone and sabotage it so it runs slower and has less RAM. :-}

    2. Re:Industry trade secrets revealed by DNS-and-BIND · · Score: 1

      Then your developers quit because they didn't get the latest quad core goodness. Developers HATE working on anything but blazing-fast hardware.

      --
      Shutting down free speech with violence isn't fighting fascism. It IS fascism!
    3. Re:Industry trade secrets revealed by JDG1980 · · Score: 1

      I've found the best way to get developers to stop being lazy is to give them shit hardware.

      Giving developers "shit hardware" is a good way to alienate them and reduce their productivity. And as Donald Knuth noted, premature optimization is the root of all evil.

      First you write the code and get it working, then you test performance on whatever hardware you might be targeting as your minimum requirements, and then, if necessary, you profile and optimize to get it working at an acceptable speed on the target platform.

    4. Re:Industry trade secrets revealed by Anonymous Coward · · Score: 0

      Realize that usually people will skip the "test performance on whatever hardware you might be targeting as your minimum requirements" step. Or maybe only do it once. Or maybe not do it thoroughly.

    5. Re:Industry trade secrets revealed by Anonymous Coward · · Score: 0

      Rule #1: Never hire a programmer that isn't lazy. They never find the faster way to do something.

      Rule #2: Always give the programmers the fastest thing to develop on. Why pay them to watch the computer?

      Rule #3: Never give the programmers or testers the fastest machine to test on. They think everyone has one.

      - Posting as AC because its too much work to keep logged in.

    6. Re:Industry trade secrets revealed by Anonymous Coward · · Score: 0

      not really -- I have a HTC EVO that runs ICS. It's really really really really really slow.

  25. Re:CPython uses reference counting, like objective by EvanED · · Score: 2

    Generational GC can still be mark and sweep (and most of them are).

    So looking around, it seems like "mark and sweep" does not have a single meaning. I didn't actually know this, and it means that I was wrong to say that the AC I replied to was wrong.

    However, I learned "mark and sweep" (and my use is supported by this survey paper and, I believe, the second edition of the dragon book (see, e.g., the lecture 17 slides from here) though I can't check right now) to be a specific GC algorithm that basically works like an automated free() that traces and marks reachable objects then walks all heap blocks and frees any unmarked blocks. Specifically, this is a non-moving collector.

    I also learned generational GCs to necessarily be moving collectors, though I suppose you could come up with some somewhat convoluted scheme that does not do this and would still be somewhat deserving of the term.

    I'm not sure, but suspect that my usage is more standard.

  26. Mobile is not a special case by Anonymous Coward · · Score: 0

    Little computers are essentially the same as bigger computers were, a few years ago. If garbage collection was ok on the desktop in 2003, then it's ok on mobile. If it's not ok on mobile, then it's wasn't ok when you learned python. Anyone who does a split decision on this is either a hypocrite, or has to admit we're in some kind of brief transition period where mobile either just recently grew up or is about to.

    And yes, garbage collection is ok, because having 10x of the memory you need is ok, because memory is dirt cheap and anyone who is running out, is either a pussy or else they're doing their nuke sims on their phone and need to stop that. Wrong tool for job, LANL-man.

    1. Re: Mobile is not a special case by Miamicanes · · Score: 3, Interesting

      10 years ago, desktop computers didn't page to hard drive sectors with half-lives of 100k writes or less, and siphon the bits through a single-bit (SPI/MMC mode) or 4-bit wide (SD-mode) cocktail straw. As a few guys @ XDA learned the hard way, micro-SD wear-leveling is NOWHERE close to being as robust as what's in a desktop SSD, and onboard flash (like what's in the Nexus 4) might not have "SSD" logic *at all* (leaving its management *entirely* up to the OS to cut costs). Vigorously swap to a mostly-full microSD card, and you can *literally* push it into "hard error" land and end up with weakened cells in just one single weekend of aggressive benchmarking. Blindly swapping to internal or microSD flash desktop-style is NOT consequence-free, and is *totally* unsafe to do on any phone without microSD (at least end users can toss & replace a worn-out microSD card).

    2. Re:Mobile is not a special case by Anonymous Coward · · Score: 0

      Little computers are essentially the same as bigger computers were, a few years ago. If garbage collection was ok on the desktop in 2003, then it's ok on mobile. If it's not ok on mobile, then it's wasn't ok when you learned python. Anyone who does a split decision on this is either a hypocrite, or has to admit we're in some kind of brief transition period where mobile either just recently grew up or is about to.

      And yes, garbage collection is ok, because having 10x of the memory you need is ok, because memory is dirt cheap and anyone who is running out, is either a pussy or else they're doing their nuke sims on their phone and need to stop that. Wrong tool for job, LANL-man.

      You know what? 10 years ago, swapping to the hard disk wasn't really OK. It was a performance killer. It still is a killer on the desktop, and it's still a killer on the phone.

      The phone of today is the PC of a decade ago. It has real constraints, and anyone developing for it needs to recognize them and plan for them.

      It wouldn't hurt for desktop and web devs to start living in a real world too. Neither of those is an unbounded resource environment either.

    3. Re: Mobile is not a special case by Anonymous Coward · · Score: 0

      If your mobile device happens to be running Linux, you can -really- crank out some extra memory performance by having a very small (256mb?) swap area and setting vm.swappiness down around 20-30 or thereabouts. However, this should actually only be enabled once you are very close to production, and not still in the implementation phase. If your developed product depends on it, you're doing it wrong.

      The reason being that a lot of things will allocate various pages, touching them only once or twice, and never looking at them again. It gives the OS some place to dump those pages off to, so things that are hardly or never used after startup can be dumped. In a production system with a small amount of swap, you'll often have that swap mostly full, and hardly ever read from, only written to.

      Granted, flash devices aren't the best for it, but.. I'm pretty sure someone else pointed out that your average phone isn't going to live long enough to see it's inevitable flash death.

    4. Re:Mobile is not a special case by shutdown+-p+now · · Score: 1

      Mobile is a special case because mobile devices are battery-powered 99% of the time, and are size-constrained. This means that you have optimize for perf, because you don't get an option of just throwing more CPU and RAM at the problem as we did on the desktop.

    5. Re: Mobile is not a special case by Miamicanes · · Score: 1

      I almost forgot... there's another problem discovered at XDA. Some/many/all microSD cards don't actually maintain erase counters per block... they just have a single global counter that gets incremented whenever an erase occurs somewhere (regardless of whether you're erasing 1 block or 1000), and the controller itself makes certain assumptions about your use pattern before deciding the card is "exhausted" and disabling further writes. I believe Sandisk cards, in particular, are *extremely* conservative and pessimistic about lifetime erase cycles allowed, and are the cards that caused the "wear-out" problems I was referring to. They weren't necessarily worn out and experiencing uncorrectable hard errors at that point, but WERE controller-locked into readonly mode after just a few days of swapfile activity.

      It's less of a concern now, but it was a REALLY big deal back when a large class-10 microSD card would EASILY set you back a hundred dollars or more (as recently as 18-24 months ago).

  27. javascript by Anonymous Coward · · Score: 0

    Everybody and their dog is pushing javascript/html5 as if it is some kind of panacea and guess what happens. They discover that it isn't the OS unifying silver bullet they hoped for. More like a new C++ (the first version from the 70s) for the web. Everything about JS is still garbage: Memory footprint, the tools (or lack of), debugger, profiler, the JS web developer mentality, it even lacks basic support for stuff like imports/includes of javascript files.

    I really look forward to five years in the future when there is an abundance of crappy javascript/html5 business applications nobody sane would want to maintain. It's like Java Applets all over again.

    Yeah FUTURE!

  28. Bloat by Animats · · Score: 1

    Software bloat is a consequence of stressing time-to-market over cost. Nothing gets rewritten to throw out old stuff. Look how bloated the Linux kernel has become.

    It seems to take half a gigabyte to load a web browser today. New languages don't help; "Hello world" in Go is over a megabyte.

    There are reasons for needing a lot of memory. Like loading the model for a jet engine into Autodesk Inventor, which requires many gigabytes and many processors. Or loading a game like GTA V, which has a big chunk of Southern California in there. But big phone apps that don't do much? Bad programming.

    One win in the phone world is the lack of virtual memory. Virtual memory has become a crutch - just bring in everything including the kitchen sink, and let the pager throw out the useless stuff. This results in slow program loads and random delays during operation. Worse, there are programs that think they're so important that they load something that sits in memory just to keep their stuff active. (I'm looking at you, "jusched.exe". If that's running on your machine, delete it. Its sole purpose in life is to keep the Java system paged into memory, needed or not. Without it, Java programs (if you run any) will load slightly more slowly when no Java program has executed recently. There are similar memory drains for OpenOffice and Windows Office.)

    All virtual memory can do, at best, is create the illusion you have about twice as much RAM. This is achieved at a cost of going out to disk that's 10,000 times slower than RAM. It was a win 40 years ago when memory cost a million dollars a megabyte. Not so much now.

    1. Re:Bloat by zippthorne · · Score: 1

      And.. wasn't the original point that you could "allocate" memory for huge, sparse objects, but only really use the portion you actually need, with the buffer of paging in case you go over a bit, to keep things from crashing?

      I'm fairly certain that it was never intended to allow an application that needs 500MB, to run in 50MB of RAM....

      --
      Can you be Even More Awesome?!
    2. Re:Bloat by EvanED · · Score: 1

      And.. wasn't the original point that you could "allocate" memory for huge, sparse objects, but only really use the portion you actually need, with the buffer of paging in case you go over a bit, to keep things from crashing?

      I'm fairly certain that it was never intended to allow an application that needs 500MB, to run in 50MB of RAM....

      It depends what you mean by "virtual memory", because there are two meanings; but at least I would say "no."

      The "real" meaning is just the fact that programs deal in virtual addresses, which are then translated to physical addresses. The address 0x4000 in your process and 0x4000 in my process are completely different.1 This has basically nothing to do with how much space programs need and everything to do with making it so processes can't step on each others toes for both ease of programming and security.

      The added layer of indirection2 that was added to support virtual memory also made it easy to do automatic paging of memory to disk, and that's the other definition of virtual memory. But even here I would say there's a lot to argue against your statement that "it was never intended to allow an application that needs 500MB to run in 50MB"; at least if you make that less extreme. Before virtual memory there were overlays, which were basically regions of memory that the program, on its own volition, paged in and out to get at extra resources. I'm not nearly old enough (or insane enough) to have dealt with them, but some systems provided some explicit support for overlays, though still with a lot of programmer burden to designate what needed to go into in the overlays. So dealing with programs that had much larger memory requirements than available memory was already a common problem. I can't imagine that this would have escaped the notice of people designing paging systems. That being said, I can't go back in time and read the thoughts of the people putting in MMUs. :-)

      (One disadvantage of the paging vs overlays is, ironically enough, the programmer effort. Because it requires you to think about exactly what goes in each overlay, it means that you can't just haphazardly place stuff in memory and hope it works then whine that it doesn't because it thrashes too much.)

      1 shmget blah blah blah
      2 "All problems in computer science can be solved by another level of indirection, except for the problem of too many layers of indirection"

  29. <flame> on JavaScript by manvsteeth · · Score: 1

    Just pretend I wrote a pretentious OOP/strongly typed bash session on JavaScript. Because we already know what a hot sloppy mess it is. Alas the alternatives have failed us (Applets, Silverlight...), so open wide, here comes the **** sandwich.

  30. This is why I write my own JS by FuzzNugget · · Score: 1, Informative

    This is why, for anything other than very obscure and complicated functionality that would put a project way over budget, I write my own JavaScript. That includes AJAX functions, dynamic element management, form data collection and processing and all the fancy stuff that jQuery makes super easy.

    Because when you use a generalizing library or framework, you trade convenience for performance and contribute to the continual problem of lazy programmers relying on unnecessarily powerful hardware.

    Currently, jQuery loads 90+ KB of JavaScript and processes a whole lot of it every time you invoke functionality that uses it. Similarly capable CMS tools I've built load ~30KB of original JavaScript and only run the relevant functions when called, rather than parsing through and jumping around reams of nested and interdependent routines.

    1. Re:This is why I write my own JS by Anonymous Coward · · Score: 0

      Good god, man. Writing 30 KB of JavaScript on your own and living to tell the tale?

  31. bloat memory bugs by RedHackTea · · Score: 1

    I find the added bloat better than relying on "mobile app developers" (MAD) to write error-free code in relation to memory. You can still have memory bugs with a GC-enabled language, but it's less likely. IMO, most client-side code should be written in a GC-enabled language. Everyone is attracted to writing client-side apps, but usually only intelligent geeks are interested in server-side code -- where speed and memory-efficiency matter more. Ask yourself... do you want apps on your phone to use GC-enabled languages? Have you met the typical "mobile app developer"? Do you want the language to be easier for quicker innovation and less crashes? Or do you want lean, fast apps? Of course, you can have both if the mobile device allows multiple languages. Not trying to write shill... but Ubuntu's Phone will allow writing apps in either JavaScript or C/C++ (http://www.ubuntu.com/phone/app-ecosystem). Bang it out quick and more safely in JS. If the app gets huge (and you get paid handsomely) and needs to be leaner/faster, re-write in C++.

    --
    The G
  32. JavaScript on iPod touch is slow by Anonymous Coward · · Score: 0

    one thing that i have noticed is that websites load faster when i turn JavaScript off on my iPod touch. of course, i loose like 75% of a website's functionality. grrr...

    Search engines don't work right and most menus on websites don't work. even websites designed for mobile devices use javascripts. i can't find a text-only version anywhere. just saying.

  33. Rust by TopSpin · · Score: 2

    Memory management is an issue that has me excited about Rust. Rust memory management is explicit, easy to use, deterministic, efficient and safe. The language designers understand that garbage collection is costly and that endemic use of a garbage collector limits applicability.

    Although Rust does have reference counted heap objects on the so-called "exchange" heap, memory is normally allocated on the stack or on a "local" heap (via an "owned" pointer) that has "destructor-based memory management," much like C++ objects but without the leaks and wild pointers.

    The result is the vast majority of allocated memory is not managed by the garbage collector. Use of the exchange heap is exceptional and explicit, yet immediately available when necessary. Otherwise, memory "management" is reduced to efficient stack pointer manipulation or simple, deterministic destruction. Compile time checks preclude bad pointers and simple leaks so common with traditional systems languages.

    There is a series of detailed blog posts about Rust memory management here.

    Rust was inspired by the need for an efficient, AOT compiled systems programming language that is productive, concise and at least as safe as contemporary "managed" languages. Its memory management scheme goes directly to the point of this story.

    --
    Lurking at the bottom of the gravity well, getting old
    1. Re:Rust by Anonymous Coward · · Score: 0

      Owned pointers are ones to the exchange heap. Managed pointers point into the local GC heap.

      It's all cool in theory, I just wish they'd hurry along with a stable, performant implementation.

    2. Re:Rust by Anonymous Coward · · Score: 0

      Unable to take this language seriously (along with all the others made past 1995 sans Haskell) when the individuals advocating it continually use phrases/words like this:

      * memory management is explicit -- what does this mean?
      * deterministic -- what does this mean?
      * efficient and safe -- subjective/opinion
      * endemic use of a garbage collector... -- what does this mean?
      * reference-counted heap objects -- what does this mean? (note: i become immediately afraid when someone mentions "objects" (a vague term to describe ambiguous crap that the CPU itself has no knowledge of/familiarity with) next to the word "heap" (something the CPU does have knowledge of))
      * "exchange" heap -- what does this mean?
      * "local" heap -- what does this mean? (note: there is only one "heap" on most CPU architectures, so now we have added abstraction)
      * via an "owned" pointer -- what does this mean?
      * wild pointers -- what does this mean? (i'm left with the impression it refers to this)
      * Use of the exchange heap is exceptional and explicit yet immediately available when necessary -- what does this mean?
      * Memory "management" is reduced to efficient stack pointer manipulation -- uhh, what? the language sits around modifying content at %esp and %ebp along with some offsets? sounds far from efficient)
      * ... or simple, deterministic destruction -- what does this mean? (note: 2nd use of word "deterministic")
      * Compile time checks preclude bad pointers and simple leaks so common with traditional systems languages -- what does this mean and how does this work, considering that the value stored at a pointer (or what it points to) can be manipulated at run-time, so how would the language "deterministically know" (see what I did there?) what's "bad" vs. "good"?
      * ... that is productive, concise ... -- what does this mean? (also borders on subjective/opinion)

      Surely I cannot be the only programmer who when reading PL advocacy posts notices this "buzzword ahoy" trend. It appears that the language is chosen intentionally in attempt to give the impression of "a powerful language" when it's much more likely -- when going entirely off of the above description, mind you -- that the language wastes more time trying to automate things that should be left to a human mind to decide.

      This and many other reasons are why people prefer C: it's not as time-consuming to write (for the programmer) as assembly language, yet its operational behaviour is parallel to that of the actual processor. Some other languages such as Lisp are the same way. They stay "close to the CPU".

      Pro tip for younger programmers: any time you see the word "object" used, it mandates at least 1 (and more likely several) layers of abstraction between the programming language and the actual processor. In turn, that means CPU time is wasted dealing with the abstraction (to figure out what to do with this "ambiguous thing") rather than if you had used something the processor is natively familiar with. And with x86 (most common), there are maybe 4 "types of data" the CPU is familiar with/can operate on natively. Anything else requires actual code, thus abstraction, to disambiguate/handle/figure out.

      Remember: computers are tools intended to make our tasks easier. By trying to turn the computer into a human being (making judgement calls, etc.) the tasks in turn often become harder than they need to be, and in turn often slower.

    3. Re:Rust by Anonymous Coward · · Score: 0

      Most architectures don't even have a concept of a stack, let alone a heap - it's all just memory.

    4. Re:Rust by Anonymous Coward · · Score: 0

      Every architecture I have programmed on in the past 25 years has had "the concept of a stack" at the CPU level. I've worked on 65xxx, 680x, PIC, and x86. Proof:

      65xxx: register S (stack); example opcodes PHA/PLA, TXS, JSR/JSL/RTS/RTL/RTI, TXS, PEA/PEI, etc.
      680x: register SP (stack pointer); example opcodes PSHx/PULx, JSR/RTS, INS, etc.
      PIC (16c84): register PCL (hard to explain tersely), example opcodes CALL/RETURN, RETFIE/RETLW
      x86 (i386): registers esp (stack pointer) and ebp (base pointer); example opcodes PUSH/POP xx, CALL/RET, FDECSTP/FINCSTP, etc.

      All this is implemented at the silicon level (well, barring today's x86, where it's done at the microcode level -- every opcode is done that way, I have no idea what the underlying non-microcode hardware is like). And if you want a more recent architecture: ARM (register SP, and with clever manipulation, register LR; example opcodes PUSH/POP, STMxx/LDMxx, etc.).

      If some particular PL decides to "implement a stack" using software, this just proves my point, re: excessive levels of abstraction, more distance between the actual code and the CPU, resulting in wasted CPU time.

      If your point was "the stack itself is just RAM", then my response is "um, DUH?", as I don't see how that has any relevancy to any point I've made (other than possibly someone not having familiarity with CPU architecture). :-)

    5. Re:Rust by Anonymous Coward · · Score: 0

      Have a look at this:

      http://sourceforge.net/p/sappeurcompiler/code-0/2/tree/trunk/

      Essentially a memory-safe C++ variant. In other words, Bell Labs technology without the built-in Cyber Warfare Weaknesses.

      http://www.infoworld.com/d/security/in-his-own-words-confessions-of-cyber-warrior-222266

      Compiles into C++.

    6. Re:Rust by EvanED · · Score: 1

      I think you may be trolling, but I'll try to respond as if not in the case I can enlighten either you or someone else as to any of your questions. I actually know very little about Rust, and I think I'll deliberately not look up anything about it while responding here so you can see that it's not a matter of TopSpin just throwing around meaningless buzzwords. As a result I'm not evaluating the correctness, just whether or not TopSpin's post makes sense to someone with a fair bit of knowledge about memory management. (Of course the flip side is that if I get a lot wrong here (in terms of what Rust is or does), then that means TopSpin did a bad job after all. :-))

      deterministic -- what does this mean?

      It means... it's deterministic, i.e. not at the whim of things like what the OS or user decides to do to you?

      It's used slightly more specifically meaning though when it comes to memory management. In particular, it is usually meant to mean that a block is freed at the moment it becomes garbage instead of some point in the future.

      Suppose I have a Java File object allocated in the heap; it has a finalizer that will close the file when the object is finally collected. When does that happen? No idea, because it depends on when the GC runs. Maybe that's right now. Maybe the user is AFK and the program is idling, and the File won't be collected until the user comes back after her nap in an hour. Maybe you have multiple threads that are each allocating memory, and they interact in nondeterministic ways because of the OS's scheduler, and so the point at which the GC is triggered will vary from run to run.

      More to the point: the time is unexpected and potentially distant.

      Contrast that with when heap objects are destroyed. You know when they are destroyed: they're destroyed when the currently-executing function returns. In C++, you know that the destructors will run when the block they are a member of exits. True, you may not know exactly when that happens in wall-clock time, but you know when it'll happen relative to the code. This is important because an fstream object that you allocate on the stack in C++ will actually close when the function returns. This is both predictable and probably soon.

      (This usage of the term is, however, extremely standard, so it's in some sense it's your ignorance for not taking them seriously because of it, not their weird terminology.)

      efficient and safe -- subjective/opinion

      Eh, not necessarily. Both are technically spectrums, and so yes, you could say that there's an element of opinion. But if you are in, just to make up a number, the safest 10% of the spectrum or the most efficient 20% of the spectrum, it's pretty hard to argue that you're not safe and efficient.

      Especially when it comes to safe, which they are using as an abbreviation for "memory safe" (which TopSpin probably should have used). That has a reasonably specific definition, so there's not a ton of room for interpretation. (For example: is C# memory safe? After all, it has unsafe blocks.)

      (Mind you I'm not evaluating the correctness of those claims, just the plausibility.)

      endemic use of a garbage collector... -- what does this mean?

      I actually don't know. :-)

      reference-counted heap objects -- what does this mean?

      Probably, C programmers can think of an "object" as synonymous with a heap block.

      So, heap blocks are reference counted so they are freed when the last reference is released. (And if you "don't know what reference counting is"... well, then you be trolling sir.)

      "exchange" vs "local" heap

      They're just names for their two heaps. I would guess that they have something to do with either threads or functions -- the local heap being

    7. Re:Rust by EvanED · · Score: 1

      Two followup thoughts:

      First, thinking about it a little more, I guess you could argue because architectures usually provide instructions for at least making function calls, that functions aren't an abstraction. I see the point, but I stand by my statement for a few reasons. First, those instructions usually don't really do anything that you couldn't do without them. (Maybe Sparc, with its register windows, is an exception?) It's usually just a shorthand, perhaps ever-so-slightly more efficient, for a store of the instruction pointer into a register or onto a stack, then a jump. Second, while an instruction used for calls is common, specific instructions for returns are less so. For instance, MIPS provides the jal instruction (jump and link) for calls, but I think there is no return instruction -- you just jump to the value in the ra register. Third, there is no additional CPU knowledge beyond the initial and final control transfers: CPUs don't know about the local variables (you could easily implement functions without using the hardware stack -- and some languages do this to provide support for closures and other features), CPUs don't know about the region of code occupied by a function (and often there is no "the code region"), etc.

      Second, I thought of another great example of an abstraction that doesn't really cost CPU time: labels. Take goto cleanup; ... cleanup: .... The CPU has no idea about cleanup. That has been entirely removed by the compilation toolchain, and turned into a symbolic address. The name cleanup is undoubtedly an abstraction for "the address of here", and yet it costs no CPU time.

      Or take C++ objects. C++ objects, unless you explicitly request otherwise, basically have no additional overhead vs C structs and C functions. So are objects bad and structs or functions also bad, or are structs and functions good and objects also at least sometimes good?

    8. Re:Rust by TopSpin · · Score: 1

      * memory management is explicit [merriam-webster.com] -- what does this mean?

      Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
      Automatic vs. Explicit Memory Management: Settling the debate

      * deterministic [merriam-webster.com] -- what does this mean?

      I thought it was self evident. Here is a discussion of the matter.

      * endemic [merriam-webster.com] use of a garbage collector... -- what does this mean?

      Pervasive would be a better word. Languages that make garbage collected allocations for most or all things. For example in Java, aside from primitives, all allocations conceptually occur on the a garbage collected heap.

      reference-counted heap objects

      Reference counting: counting the number of references to an object.
      Heap: an arena of memory maintained by a memory allocator. Also CPUs typically have no knowledge of how software manages heaps. You may be thinking of virtual memory
      Objects: object in the generic sense of some amount of memory managed on a heap. These lecture notes show the same usage. The editors of this page also use the word 'object' in exactly the same manner when discussing pointers. It's not that hard to follow.

      Putting it together we have objects on a heap for which reference counts are maintained; reference-counted heap objects.

      "exchange" heap -- what does this mean?
      * "local" heap -- what does this mean?

      The link I provide to Patrick Walton's blog would get you there. Also, there is documentation, Sorry if discussing a new programming language involves terms you haven't heard. Computing can be like that sometimes.

      (note: there is only one "heap" on most CPU architectures, so now we have added abstraction)

      Now you are definitely confusing heaps and virtual memory. There are usually many, possibly thousands of heaps on a system at any given time with many distinct implementations of which the CPU is entirely ignorant. Memory allocators and virtual memory are different things.

      * via an "owned" pointer -- what does this mean?

      Similar to a C++ auto_ptr or unique_ptr. Again, the link I provided would get you there.

      * wild pointers -- what does this mean?

      Dangling pointer and wild pointer are synonomous.

      Use of the exchange heap is exceptional and explicit yet immediately available when necessary -- what does this mean?

      I provided a link directly to a discussion of this.

      Memory "management" is reduced to efficient stack pointer manipulation -- uhh, what? the language sits around modifying content at %esp and %ebp along with some offsets? sounds far from efficient)

      Incrementing a decrementing stack pointer registers is very efficient. Offsets are computed at compile time and the instructions typically require one CPU cycle and no memory access, given a naive model of a CPU. These techniques are a ancient and ubiquitous. Sorry you weren't familiar with them.

      or simple, deterministic destruction -- what does this mean?

      Others seem

      --
      Lurking at the bottom of the gravity well, getting old
  34. Re:CPython uses reference counting, like objective by EvanED · · Score: 1

    So I just checked, and the dragon book does agree with my interpretation that mark-and-sweep is a specific GC algorithm that is non-moving and runs in time proportional to the total number of heap blocks (live and dead). It also agrees that generational GCs are moving collectors.

  35. javascript is slow by epyT-R · · Score: 1

    javascript is slow, period. It's an interpreted language. The best optimization you get is some kind of preprocessed bytecode, and that's still not as efficient as native. You might not notice this on a modern desktop, and while little mobile cpus may clock at 1500mhz, they're not much faster than a pentium 2 300.

    1. Re:javascript is slow by shutdown+-p+now · · Score: 1

      javascript is slow, period. It's an interpreted language. The best optimization you get is some kind of preprocessed bytecode, and that's still not as efficient as native.

      Just so you'd know, JavaScript has been JIT-compiled to native code for years now (starting with V8 in Chrome, if I remember correctly). And no, that's not "some kind of preprocessed bytecode", that's actual native code. It's still slower than C, but that's because the inherent dynamism of the language makes it much harder to optimize.

  36. Article itself is a waste of memory by tknd · · Score: 2

    GC sucks, real programmers can do memory management, blah blah blah. Tell me the last time a programmer made billions because "he could memory manage" and I'll show you plenty of poorly written websites, apps, software, that suck at memory management yet still managed to become popular and used by millions.

    The market decided long ago that fewer programmer hours was better than users waiting a few seconds everyday for their device to GC. Users don't exactly like it, but it works, they get their hands on a more than usable product faster.

    But back to the article. In the article there's some fancy charts about how iphone 4s only has 512mb of ram. Ok, a mobile device isn't going to run with a swap file because, well, the manufacturer decided to skimp on Flash chip quality so not only does writting to flash suck, but it also runs the risk of forcing the cell to over-provision (meaning shrink in usable capacity). But iphone 4s will be 2 years old in 4 months! 2 years = EOL in the phone world.

    How about a more current phone? Ok, the Google LG Nexus 4 which will become 1 year old in 5 months comes with a whopping 2GB of RAM. And its a relatively cheap phone! That's already half of my 2011 Macbook Air's RAM. Prediction? In 4-5 years, mid-range phones will be shipping with 4gb of RAM.

    Ok, let's go the other direction. Let's say we all agree and programmers should sit down and memory manage again. Hurray! Problem solved? No. Because programmers are inherently bad at memory management. Memory will leak. Look at some popular web browser named after a type of animal. So instead of your phone pausing for a second to GC, now your app just crashes! AWESOME.

    The standard software engineering practice still applies. Design your system. Build your system. Once it is usable and more importantly has a market, then profile for optimization.

    1. Re:Article itself is a waste of memory by TopSpin · · Score: 4, Insightful

      The market decided long ago that fewer programmer hours was better than users waiting a few seconds everyday for their device to GC.

      No, actually, that's not what happened. As the summary and the story itself (both of which went unread apparently,) point out, one of the most successful systems to emerge in the market recently, iOS, is not a GC environment.

      Over here you may learn about iOS memory management. Without getting too far into that wall of text one discovers the following:

      If you plan on writing code for iOS, you must use explicit memory management (the subject of this guide).

      Ok, so your claim that GC is the only viable solution for contemporary application development is demonstrably false. Lets look some other assertions:

      programmers are inherently bad at memory management. Memory will leak [if programmers must manage it].

      First, the vast number of iOS applications not leaking shows that a non-GC system doesn't necessary have to leak. At least not badly enough to compromise the viability of the platform, which is the only meaningful criteria I can think of when it comes to the market.

      Second, why assume programmers are inherently bad at a thing when that thing has traditionally been exposed via terrible, error prone, demonstrably awful mechanisms? It seems to me that among widely used tools we leaped from 'systems' languages with truly heinous MM primitives (C/C++) directly into pervasive GC systems. Aside from Objective C+ARC there just aren't enough good non-GC systems to make broad generalizations. Thus, you may be right about programmers, but you can't prove it, and I doubt it.

      Finally, what proof is there that pervasive GC is better at not leaking than a good explicit MM system? Anyone with an Android system and a bunch of apps will quickly discover that pervasive GC does not eliminate leaks.

      [some phone] comes with a whopping 2GB of RAM

      Goggle Glass has 682mb of RAM. There is always a new platform into which we much fit our software and the new platform is usually resource constrained, so there will never be a day when questioning the cost of GCs is wrong. Maybe the wearable you eventually put on will have 8 GB of RAM. The computers you swallow or implant or sprinkle around the lawn probably won't. The fact the next generation of phones can piss away RAM to greedy GCs just isn't particularly informative.

      --
      Lurking at the bottom of the gravity well, getting old
    2. Re:Article itself is a waste of memory by gl4ss · · Score: 1

      android emerged after iOS and is gc'd.. though of course GTA III for it isn't garbage collected.

      but, having wrote garbage collected mobile code with jar size limit of 64kbytes and heap of ~300kbytes(java isn't inherently memory hungry!)... stop bitching - or better yet start bitching about the ui libs and how they just trash memory because they suck. pretty much all the trashed memory is just getting trashed due to graphics.

      --
      world was created 5 seconds before this post as it is.
    3. Re:Article itself is a waste of memory by maccodemonkey · · Score: 1

      android emerged after iOS and is gc'd.. though of course GTA III for it isn't garbage collected.

      but, having wrote garbage collected mobile code with jar size limit of 64kbytes and heap of ~300kbytes(java isn't inherently memory hungry!)... stop bitching - or better yet start bitching about the ui libs and how they just trash memory because they suck. pretty much all the trashed memory is just getting trashed due to graphics.

      And, to be perfectly honest, performance of non-native code and the memory handling both suck under Android.

      I think Google's choice of Java for Android was one of their poorest choices. Maybe it's because I worked on iOS first, but Obj-C is an open source language and would have been perfect. But I would have settled for C++, and that says a lot. Yeah, Android offers native code, but none of the UI frameworks work with it, forcing this awkwardness.

    4. Re:Article itself is a waste of memory by Anonymous Coward · · Score: 0

      iOS currently kills nearly every application within a few seconds of you not using it. Killing the application forces it to free. This is not memory management, this is "I can't trust anyone so I can't let them exist". iOS 7 promises to change this. Good luck, Apple.

    5. Re:Article itself is a waste of memory by Anonymous Coward · · Score: 0

      iOS currently kills nearly every application within a few seconds of you not using it.

      The following types of iOS apps may run in the background and retain memory:

      Apps that play audible content to the user while in the background, such as a music player app
      Apps that keep users informed of their location at all times, such as a navigation app
      Apps that support Voice over Internet Protocol (VoIP)
      Newsstand apps that need to download and process new content
      Apps that receive regular updates from external accessories

  37. Re:CPython uses reference counting, like objective by Anonymous Coward · · Score: 0

    look at j9 realtime

  38. Not memory management by EmperorOfCanada · · Score: 1

    I have a fairly javascript intense website but it is primarily used for layout etc. There is no way I am using more than a few dozen K of RAM with my variables including temp ones created in loops. Thus garbage collection and whatnot should not apply to my site. Yet my site is dog SLOW on the iOS platforms as compared to even old desktops.

  39. Slashdot's mobile site is TERRIBLE by Anonymous Coward · · Score: 0

    Ever since they "upgraded" it to use shitloads of javascript to dynamically load content.. it's been absolutely unusable on my phone. Absolutely unusable.

  40. Re:CPython uses reference counting, like objective by Anonymous Coward · · Score: 0

    But python stops the world for a short time, only at the time an object loses reference. Therefor it is a lot more predictable when garbage collection happens, and more smoothly averaged over the execution of your application. I am not talking how python uses a mark-and-sweep when dealing with circular references.

    Objective-C does mark-and-sweep in a separate thread and is able to garbage collect without stopping the other threads. However in my case it was too slow to follow my program. My program was creating objects for a calculation and once the calculation was finished removed the objects. The objects were rather large as they were full HD RAW video frames. After a few calculations the memory was full and my computer started swapping.

    With reference counting this doesn't happen because when you lose a reference on an object it is immediately removed.

  41. Re:CPython uses reference counting, like objective by loufoque · · Score: 1

    There are essentially two garbage collection algorithms: mark-and-sweep and stop-and-copy. Both can be generational, incremental, concurrent, etc.

  42. give me ie5.5 by Anonymous Coward · · Score: 0

    and I'll rip your heart out

  43. Apple by Anonymous Coward · · Score: 0

    Maybe its also because Safari SUCKS DOGS BALLS (no ad blocking, no proper tab management, etc) - and Apple have nobbled any other browser's javascript support.

    F***ing Apple piss me off. Either Fix Safari so it's better than a TOTAL PIECE OF SH**, or let all browsers use un-nobbled javascript. Jobs is gone, so you can stop with the fascist draconian BS.

  44. 10 times more memory? by angel'o'sphere · · Score: 1

    Articles like this simply show that many hobby programmers don't know how garbage collection works.

    On top of that, following the other posts in this discussion, no one seems to realize: if you use JavaScript you are bound to GC. You can not deactivate it or get rid of it. If you want to do mobile programming in C then be prepared to be limited to certain platforms.

    Back to the claim you end up with programs that allocate/claim 10 times more memory as they need to avoid GC.

    Exactly that approach is the reason for slowness. A traditional garbage collector only starts running when all memory is exhausted. That means if you assign an application a big process space (like with the extra flags in a java virtual machine) you actually make your program slower! Because when the GC starts it will have to examine a huge working set (which is meanwhile all dead). Having as little memory as possible would make GC much faster, because the dead objects are much fewer.

    OTOH I would not know how to do that in JavaScript.

    In my experience slowness usually has nothing to do with GC but the program simply is slow by itself. People use arrays and iterate over them endless to find stuff to work on instead of a HashMap etc. They redraw the whole screen instead of the component/dialog that needs it. They assign nulls to "speed up the GC", they catch every exception and eat it or rethrow it ... instead of realizing what the error of a certain function means, they put try/sleep/try again loops around vital stuff, like fetching a file from a server or establishing a DB connection.

    Or in JavaScript instead of using a tool that removes unused code from libs, they load the whole library, preferred at page load.

    Anyway, I agree with other posters that we need better browsers, perhaps better DOM access or DOM models and certainly better languages than JavaScript like TrueScript and CoffeeScript e.g. or SmallTalk in the browser, that would be superb.

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    1. Re:10 times more memory? by shutdown+-p+now · · Score: 1

      Having as little memory as possible would make GC much faster, because the dead objects are much fewer.

      But you'll be running it much more often, which will negate the benefit (and, in fact, will make things even slower).

    2. Re:10 times more memory? by EvanED · · Score: 1

      Congratulations, you have a very specific statement which I can demonstrate is exactly, concretely wrong. Then I'll describe why the rest of your statements, which are more waffley, are also wrong as a result. (Being wrong is good, I'm just in a slightly antagonistic mood now, sorry!)

      Because when the GC starts it will have to examine a huge working set (which is meanwhile all dead).

      So this reflects a fundamental misunderstanding of how GCs in actual use work. (There's another problem too, but I'll stick with that one.) For purposes of this post, by "GC" I am sticking with the definition that excludes reference counting.

      The simplest GC algorithm, mark-and-sweep, does look at all heap blocks, both alive and dead. However, no one uses mark-and-sweep.* Why? It's slow, and the fact that it has to look at dead objects is one reason for this.

      Instead, GCs in actual practice are moving collectors. (Usually they're called copying collectors but I prefer this term.) What they do is traverse the reachable object graph, and as they encounter a live object they copy it to another part of memory. (Redirecting references to it is also part of the algorithm that isn't so relevant for this post, but it's why I like "move" instead of "copy" to describe it.)

      The simplest copying collector to describe is probably a semispace collector. you divide the heap into two regions, a from half and a to half. You allocate in the from half. When the GC runs, it traces over the object graph starting from the root set, and when it finds an object it hasn't seen before, it moves it from the from half over to the to half. When the collector has completed its search, it switches which half it calls from and to, and it's done.

      Note that at no point did the collector do anything with dead objects! Nothing at all! The only performance impact that dead objects have is indirect, in terms of increased GC frequency and reduced cache locality.

      GCs in practice aren't usually semispace collectors but even better, but they still follow the same principle: they only do things with live objects and don't do anything at all with dead ones.

      However, note that the semispace collector has doubled the amount of memory needed. If you reduce the memory below that, you not only increase collection frequency but you reduce the "don't have to look at dead objects" benefit because you collect more objects that are soon to be dead.

      (Incidentally, why is all this moving data around actually not bad in practice? I'll give three mitigating factors. First, it lets you do generational GC, which brings even more benefits. Second, as objects are copied around, the collector actually improves the cache locality -- the cache locality immediately after a semispace collection is likely to be rather better than a manually-managed program! (Of course that mitigating factor is destroyed a bit by what the collector itself does to your cache, but it's still part of the larger factor.) Third, when talking about how GC is slow they often ignore the fact that malloc/free are actually not exactly speedy themselves all the time. In the worst case, malloc might have to spend a fair bit of time looking through the free list for a block, and free might have to do a bit of time coalescing blocks. It's not as expensive as a collection of course, but again it's part of the larger story. By contrast, a copy collector can allocate memory blisteringly fast, with basically just a pointer increment and a check to make sure it didn't go beyond the end of the heap (which would trigger another GC cycle).)

      * I've recently learned that there may be a more broad definition of mark-and-sweep, e.g. as described on Wikipedia. I'm sticking with the narrower one, as per Aho et al.'s dragon book, which is basically automating the usual C malloc/free functions. (The moving collectors I describe later work completely differently from malloc/free.)

    3. Re:10 times more memory? by angel'o'sphere · · Score: 1

      The only one who is wrong here is you.
      I suggest you simply pseudocode on paper a mark and sweep algorithm. But dont forget to also pseudocode the allocator, so you see how messed up the object structure is you have to clean up :)
      Don't know why you want to lecture me about GC algorithms ... I thought I knew most of them already.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    4. Re:10 times more memory? by angel'o'sphere · · Score: 1

      That sounds plausible only on the first glance.
      It depends heavily on the way your application is allocating (and "deallocating") memory.
      The GC Is only invoked more often when you run OOM often. The GC only needs "more" time when it bottom line does more work (e.g. in a generation allocation/collection schema).
      It makes much more sense to profile the application and memory usage and fine tune the amount of memory assigned to the VM than simply giving it "10 times the amount it needs" in the hope that is good.
      My last "big" project we had perhaps 45 Java VMs running, each with memory assigned in the range of 2gigs to 20gigs. Ofc that was ona big iron with 1TB of ram. Nevertheless it would have been a complete waste to just give every VM x times more memory. Especially in that situation as on Solaris VM and OS are tighly interconnected. A VM with 20gig assigned memory also takes immediately 20gig swap space.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    5. Re:10 times more memory? by EvanED · · Score: 1

      I suggest you simply pseudocode on paper a mark and sweep algorithm.

      OK, so I was going to respond by saying "why are we talking about mark and sweep?", but I checked myself and I'm thinking too much from the viewpoint of the desktop. So let's look at both.

      On the desktop, pure mark and sweep isn't very popular, and is mostly used as a component of a more complex GC, like in the final age of a generational collector. The JVM doesn't use it, .Net doesn't use it, PyPy doesn't use it, V8 doesn't use it, Allegro CL doesn't use it, SBCL doesn't use it, Chicken Scheme doesn't use it, Racket doesn't use it, and Glasgow Haskell doesn't use it. The Boehm-Weiser collector for C uses it because it doesn't have a choice. SpiderMonkey uses mark and sweep, but work is underway on other collectors. Perl, (I think) CPython, and Flash use reference counting primarily, with mark-and-sweep to reclaim cycles. Ruby and Lua are the only current systems I could think of that unabashedly use mark-and-sweep. Even counting all of the exceptions, we're still 9 systems with a copying collector vs 7 that use mark-and-sweep. (I would say that dropping Perl/Python/Flash from the count entirely is reasonably fair, which would make it 9-4, and to be 10-3 when SpiderMonkey's generational collector is done.)

      So in one sense I want to say that you are off-target when you're talking about mark-and-sweep, because how it behaves as the amount of memory changes is not particularly relevant as the most popular platforms don't use it. What matters is how copying generational collectors (which most of the "don't have it" have some variant of) perform. And for generational collectors, it's absolutely true that they take a lot of memory to perform well. That statement is supported by hard evidence gathered by Matthew Hertz and Emery Berger and published in 2005. If you disagree, I look forward to your study.

      (I do see your response here. It's possible that giving too much could lead to further degregation. But 3-5x the memory requirement of a manually-managed version (what people are describing as "what it needs") is supported by the above evidence as well as reasoning about what's going on inside the system.)

      On the other hand, that's not the mobile space, which is the primary purpose of the article. For instance, I am not positive about this, but I infer that Davlik uses mark and sweep. (They separate mark bits from the objects because of some memory stuff which I would guess also means they don't move objects.) I can certainly imagine that the GCs in place in mobile apps are less mature and more likely to use mark-and-sweep.

      ----

      However, Hertz and Berger look at mark-and-sweep allocators too, and in overall results mark-and-sweep does worse than the best collector (a 2-generation generational collector with mark-and-sweep old space) and second-best collector (a 2-generation collector with a semispace old space) across the entire range of memory sizes tested. In fact, all collectors tested (5 in total, vs two versions of manual allocation) Get nearly monotically better as you increase available memory; and that result holds even for the individual benchmarks (whereas the relative order of how good the collectors are can vary; in some, mark-and-sweep is the best at low memory overheads).

      I'm not going to claim the benchmarks are the best or all-inclusive, but that paper is still by far the best analysis I've seen of performance of manual vs automatic memory management. So when it says that performance gets better as you provide more memory, it'll take rather more than someone asserting on /. to convince me otherwise (no offense).

    6. Re:10 times more memory? by angel'o'sphere · · Score: 1

      I did not nring this topic up/back to talk about various types of allocTion and GC schemes.

      You claimed it does not matter how many "dead" objects you have. I claimed: it does.

      Hence I proposed you think a few hours about how memory allocation and GCs realy work by writing some pseudo code.

      AGAIN: there is no need to teach me about GC algorithms. Even if I don't know the names, as I'm bad with names, I would wager I know them all.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    7. Re:10 times more memory? by EvanED · · Score: 1

      You claimed it does not matter how many "dead" objects you have. I claimed: it does. Hence I proposed you think a few hours about how memory allocation and GCs realy work by writing some pseudo code.

      But you told me to write pseudocode for a bad, unpopular GC (mark-sweep). And I said even in my original post that yes, you're right that it looks at dead objects. My point was that isn't what's used, and better and more common GCs rarely or never do anything at all with dead objects.

      Here, I'll give you pseudocode (in some unholy mix of C and Python I wrote for some reason) for a semispace collector, which is completely unaffected by the number or size of dead objects (except in terms of how often it runs):

      const int SPACE_SIZE = 100 * 1024 * 1024; // 100 MiB, just because
       
      void * start_of_from_space = malloc(SPACE_SIZE);
      void * end_of_from_space = start_of_from_space + SPACE_SIZE;
      void * next_alloc = start_of_from_space;
       
      void * start_of_to_space = malloc(SPACE_SIZE);
      void * end_of_to_space = start_of_to_space + SPACE_SIZE;
       
      struct TypeInformation:
          int size // including header
          int references[] // offsets into the object that contain pointers to other objects
       
      struct Header:
          TypeInformation * type
          void * forwarding
       
      struct Block:
          Header header
          byte data[]
       
      // 'size' includes enough space for the header
      void * allocate(int size, TypeInformation * type):
          if next_alloc + size > end_of_from_space:
              do_gc()
              if next_alloc + size > end_of_from_space:
                  panic() // memory is full.
       
          Block * block = next_alloc
          block->header.forwarding = NULL
          block->header.type = type
          next_alloc += size
          return block
       
      void do_gc():
          next_alloc = start_of_to_space
          for each pointer p in the root set:
              p = move(p)
          swap(start_of_from_space, start_of_to_space)
          swap(end_of_from_space, end_of_to_space)
          next_alloc = start_of_from_space
       
      // Moves 'object' to the to space, and returns the new address. If the object
      // has already been moved, just returns the address.
      Block * move(Block * object):
          if object->header->forwarding != NULL:
      // Object was already moved
              return object->header->forwarding
       
      // Copy the object
          void * new_location = next_alloc
          next_alloc += object->type->size
          memcpy(new_location, object, object->header.type->size)
          object->header.forwarding = new_location
          new_location->header.forwarding = NULL
       
      // Move its referees
          for each offset in new_location->header.type->references:
              *(new_location + offset) = move(*(new_location+offset))
       
          return new_location

      I don't know for sure it's completely correct, but it's at least the general idea. As it traverses the object graph it moves the objects to the other space. When it's done with that, it's done. No looking at dead objects at all. If there is exactly one live object, it will move that object and then it's done.

      That sort of thing is what GCs do now. At the "worst", you have to do a mark-sweep phase and look at dead objects only when you do a full collection, which is a small percentage of total collections for almost all programs, and even that doesn't happen with all algorithms.

    8. Re:10 times more memory? by angel'o'sphere · · Score: 1

      What you describe is a generational GC where you have 3 or more generations of objects.
      Here my argument still applies. If I make the space for the young generation to big, I have much more objects there, regardless if dead or alife.
      Don't forget: inside of the young generation I still have to figure which objects are alife to copy them in the older space. And for that again usually mark and sweep is used.
      The problem with such approaches is now that objects are not referenced by pointers but by double pointers, otherwise you could not move them around (you would need to update all pointers pointing to them if they get moved).
      So we trade in a faster GC for a slightly over all reduction of runtime due to double dereferencing.
      Anyway. I did not want you to post code, lol. Thanx anyway. It was more ment as a mental chalange. the general picture of a generational GC is indeed correct.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  45. Slashdot mobile website by cs96and · · Score: 1

    If this is the case, why is the new Slashdot mobile website so javascript heavy? I simply cannot use it on my phone and have to revert to the desktop version, which runs much smoother and faster. Mobile websites should be lighter and faster than their desktop counterparts, not the other way around!

  46. baby steps by Anonymous Coward · · Score: 0

    Yeah, yeah, it's an issue now but the devices are getting faster and more powerful by the year. This is a temporary problem that technology will solve in the long run, we're just at the beginning of a device that's evolving very quickly. Don't loose sleep over it.

  47. Re:CPython uses reference counting, like objective by TheRaven64 · · Score: 1

    I implemented GC for the GNUstep Objective-C runtime using the Boehm collector (which, amusingly, performed better than Apple's 'highly optimised' collector in my tests, but then there's a reason that the AutoZone team doesn't work at Apple anymore...) and didn't notice any problems with pausing in typical applications, and did see a noticeable decrease in total memory usage, largely due to programs not leaving objects in autorelease pools for as long.

    GC support was deprecated for two reasons. The first is that lots of Objective-C idioms rely on deterministic destruction. Although people are discouraged from using objects to manage scarce resources, you still have classes like NSFileHandle that own a file descriptor and close it when the object is destroyed. Nondeterminism of destruction made these problems really hard to debug.

    The second problem was that the memory model for ObjC in GC mode sucked beyond belief. Or, rather, the lack of a memory model. It allowed mixing GC'd and non-GC'd buffers at will, but didn't expose this information in the type system. Consider this toy example:

    void makeSomeObjects(id *buffer, int count)
    {
    for (int i=0 ; i<count ; i++)
    buffer[i] = [SomeClass new];
    }

    Will this work? Who knows. If the caller passes a buffer created by NSAllocateCollectable() with NSScannedOption, or passes a buffer on the stack, then yes. If they pass the address of a global that's declared in an Objective-C source file, then yes. If they pass the address of a global that's declared in a C/C++/whatever source file, then no. If they pass a buffer created with malloc(), then no. If they pass a buffer created with NSAllocateCollectable() but without NSScannedOption, then no.

    In short, the whole idea was a clusterfuck from the start. On the other hand, it may be one that's worth revisiting now that Objective-C (with ARC) has a notion of ownership for memory. Source code that uses ARC could be compiled to use GC without a huge amount of pain (although the ARC memory barrier functions seem to have been created with the express intention of not allowing GC to be added later).

    --
    I am TheRaven on Soylent News
  48. But there’s no silver bullet on mobile devic by Anonymous Coward · · Score: 0

    I hate to break it to you but there is no silver bullet on desktops either.

    With garbage collected systems you can leak memory.
    It's just that you leak memory in a different way to deterministic systems (and when you do it's harder to identify with a GC'd system).

  49. Javascript is the death of the net by gelfling · · Score: 1

    Having a script blocker is fine, until you discover that every website in the world has 4 or 5 or 6 or 7 LAYERS of Javascript you have to turn on to do anything with. Hell, some webdesigners decided you need to have javascript turned on to VIEW their page. Yeah there's nothing like watching the list of javscript scroll off the page and climb into the 20's or 30's. It's awesome.

  50. Re:CPython uses reference counting, like objective by EvanED · · Score: 1

    Feel like giving a citation?

    See, I would describe "generational" as a GC algorithm where you have separate memory spaces for objects of different ages. And I really don't see how you can do that without moving objects -- ergo not mark-and-sweep by my definition.

  51. phones have 1GB or so, just like older PC's by Anonymous Coward · · Score: 0

    that run browsers and javascript just fine. So I still don't see the excuse for these phones. Javascript is a repackaged Lisp and Lisp has been around for 50 years. Emacs Lisp ran fine in 1 megabyte computers (microvax 1). Well maybe not fine, but usuably, and 2-4 megabytes was enough.

  52. Re:CPython uses reference counting, like objective by Laxori666 · · Score: 1

    Oh interesting, seems I was wrong. You were right that when an object loses a reference, and it's reference count hits 0, it is deallocated - there's no stop-the-world there. Apparently garbage collection only happens in order to clear circular references - and that's based on the number of objects, not the amount of memory being used. Learn something new each day! Thanks.

  53. Re:CPython uses reference counting, like objective by loufoque · · Score: 1

    Just read wikipedia.

  54. Re:CPython uses reference counting, like objective by EvanED · · Score: 1

    I accept that (non-moving) mark-and-sweep and generational collection are not mutually exclusive in theory. But I already said that in an aside.

    All Wikipedia says is "In order to implement [generational collection], many generational garbage collectors use separate memory regions for different ages of objects". It doesn't provide any suggestion or citation of anything that talks about how you would implement generational collection any other way. What I was really asking is whether you've ever seen such a thing.

    It's possible that it's actually not so hard, and it just requires knowing how remembered sets or whatnot are actually implemented to figure out how it works, and I don't have that knowledge.

  55. Someday by Anonymous Coward · · Score: 0

    Javascript has to take its place in history for the unprecedented holocaust of quadrillions of cpu cycles.

  56. No querySelector or addEventListener in old IE by tepples · · Score: 1

    You'll find that the bulk of jQuery use can be replaced by querySelector and querySelectorAll

    if (!document.querySelector) {
      alert("IE pre-8 is still widely used in China.")
    }
    if (!document.addEventListener) {
      alert("IE pre-9 is even more prevalent throughout the world.")
    }

    1. Re:No querySelector or addEventListener in old IE by narcc · · Score: 1

      querySelector and querySelectorAll are both fully supported by IE8.

      addEventListener support can be added with a very small polyfill.

      See my other posts for some links. If you're still advocating jQuery after that, no one can help you.

  57. Network is billed by the bit by tepples · · Score: 1

    it's often cheaper to refetch data from the network than it is to do a few page faults

    Even if the network costs $10 per GB up or down? Prices like this are common for cellular Internet in the United States. How much money does a page fault cost?

  58. Committing unsaved changes by tepples · · Score: 1

    There is a strange obsession among many that the only good RAM is empty RAM. Don;t shunt stuff out of memory until you need to

    For one thing, shunting stuff out of memory involves committing unsaved changes to slow disk or slow NAND flash memory. For another, closing an application means having to call all its destructors, finalizers, or whatever your favorite language calls things that unwind in-memory data structures and release non-memory resources that an object holds. Responsiveness to user actions requires doing this sort of shutdown in the background rather than when the user is waiting for the application's memory allocation request to complete.

  59. Effects on multi-megapixel images by tepples · · Score: 1

    The article states that users expect phones to run camera applications that quickly process effects on multi-megapixel photographic images. Most people who are not creative professionals tend not to run such applications as often on PCs, especially PCs manufactured when 1 GB was standard.

  60. Needs improvement on one machine but not another by tepples · · Score: 1

    then improve it where it needs improving?

    A program may need improving on users' machines even if it doesn't need improving on the developer's substantially more powerful, substantially cleaner machine.

  61. Things that are impractical to copy by tepples · · Score: 1

    When you copy, you copy the resource.

    How do you copy a non-memory resource such as a network connection? Why would you copy a resource as big as (example from article) a multi-megapixel photo unless you plan to modify one or both?

    1. Re:Things that are impractical to copy by loufoque · · Score: 1

      If your resource is not copyable, then copying is not an operation that is available. Copying is also costly, so If you don't need to copy, then don't copy.

    2. Re:Things that are impractical to copy by tepples · · Score: 1

      How should more than one object make use of the facilities offered by a different, uncopyable object? And as you pointed out in another comment, how should such objects do so without references?

    3. Re:Things that are impractical to copy by loufoque · · Score: 1

      Some objects are responsible for the lifetime management of resources. It's called ownership.
      You don't really need shared ownership. Most of the time it's just used as an excuse for sloppy design.

  62. Event-driven environments by tepples · · Score: 1

    ownership usually does not need to be shared.

    In an event-driven environment, it does. Event-driven environments make it much harder to predict which object will be the last object to hold a reference to a given object.

    1. Re:Event-driven environments by loufoque · · Score: 1

      That's because you're still thinking with references.

    2. Re:Event-driven environments by tepples · · Score: 1

      Other than references, how should one represent a resource that multiple parts of an application share, such as a network connection, a database connection, a cached bitmap, or the like?

    3. Re:Event-driven environments by loufoque · · Score: 1

      Most resources are not shared.

    4. Re:Event-driven environments by tepples · · Score: 1

      Which is why most resources don't need to be wrapped in a shared_ptr that owns them. But some do.

  63. embedded & realtime garbage collection for dec by Anonymous Coward · · Score: 0

    Read through the blog post and some of these comments.
    I'm a bit confused. We solved the garbage collection problem for embedded and realtime devices
    a decade ago. Right now, there are plenty of mobile handheld devices using our technology to
    run applications written in Java (although could as easily be other languages).
    They don't need massive amounts of memory. Well, to be realistic, we could
    fit in a large microcontroller, and have, but it takes a bit of work, Systems with 128 MB, 512 MB are
    plenty sufficient for system level, device access, computational and graphics applications.

    I would agree that the smartphone industry doesn't have this. But that is simply an
    artifact that the smarthphone industry went with Objective-C for iPhone - no GC, and
    with Dalvik for Android - poor GC (and maybe not so great performance).

    On the discussion about Javascript, yes its an interpreted language.
    JIT'ing it improves it. Using the approach we use instead of JIT'ing
    would improve load time and runtime. I don't know what the GC implementations
    for Javascript are right now. I know that our GC technology is not in use for
    Javascript yet.

    The issues of "non-hiccuping" garbage collection have been solved for quite a while.
    We eliminated stop-the-world events. GC can be multicore, multithreaded, parallel
    and concurrent. The problems of compaction and fragmentation have been solved.
    The problems of non-preemption have been solved -- the GC is preemptible.

    Yes, a well coded C program can most likely outperform the
    best "managed code" environment. But I can beat a C program with handcoded
    assembly language (or could at one time when I wrote in multiple assembly languages).
    Throughput performance that is in the same range as C/C++ has been shown with
    benchmarks -- meaning ranging from similar to 30% additional overhead,
    and this could be improved with additional compiler technology but has not
    been a critical issues for our customer base.

    We scale from small footprint singlecore low MB RAM to large
    multicore 100GB+ RAM systems. Your code is the same - assuming you wrote
    good multicore ready, multithreaded code. Our compiler and runtime and GC
    do the rest. You can try out our trial product at www.aicas.com.

    Not making a sales pitch here. If you want that, email me.
    dbeberman -at- aicas.com

  64. Memory WAS not cheap by tepples · · Score: 1

    Memory is cheap today. It wasn't cheap when your user bought his device.

  65. Two PC133 slots by tepples · · Score: 1

    And what do you think happens on a desktop or server? The memory is shared by multiple processes/programs.

    A server is probably running a lot more tasks at once than a desktop, and the amount of memory per task may in fact be less for a server than for a desktop. This is why an entry-level virtual private server has less RAM than even an entry-level desktop PC.

    It's not the world's fault that the vendors sucker you into crap hardware with only 512MB of RAM.

    The desktop box in question was probably built a decade ago when 512 MB was a lot. It shipped with 128 MB and the motherboard had two PC133 slots that maxed out at 256 MB each.

  66. noob perspective by globaljustin · · Score: 1

    well I'm not new to networking and database stuff at all (part of my problem) but I am new to using crap like Javascript and JQuery, and web development in general.

    I call it 'crap' because in my mind so much of CSS, JScript, Javaquery, JQ, etc blah blah is pure bullshit. I'm used to database queries and networking command line server stuff, and that I'm not what I'd call an expert. I used to be a hell of a data scientists and research methodologist however.

    For me it is JavaScript.

    I've read the discussion and I can comment on what I've seen trying to do basic Drupal and Wordpress installs and customization.

    I look at the codebase of websites to learn and when I see JQuery it is used to do some flashy 'thing' that the mid-sized 'web development' company likes to show off with...and the site still has JavaScript as well.

    Trying to research how to use JQuery as a geek off the street is a nightmare. So many different builds and in-house versions that go along with other do-dads that add abstraction layer upon abstraction layer in the design.

    It kills me, the abstraction layers. It kills computer cycles too...just think of all the energy used to auto-play flash ads since just 2008!

    From reading this discussion and limited personal experience my initial reaction to JQuery (shiny bullshit) was correct. I still don't know what to do...no programing language will work like I think it should I think.

    --
    Thank you Dave Raggett
    1. Re:noob perspective by Kielistic · · Score: 1

      You're a little late but I got the notification so I'll respond.

      and the site still has JavaScript as well.

      It's a library, of course it still has Javascript. The point of a library is to extend a language. That's like saying there's no point in using iostream because you're still just using C++.

      Trying to research how to use JQuery as a geek off the street is a nightmare.

      They have detailed api docs at their website. If you're a developer and can't read api docs then you've got other problems. An in-house version doesn't matter unless it's the in-house version at what ever company you've just started working at. In-house software is very common at software companies; being based on jQuery doesn't make it bad all-of-a-sudden (and if it is bad it's not because of the jQuery).

      From reading this discussion and limited personal experience my initial reaction to JQuery (shiny bullshit) was correct

      Most Javascript is used for making ui more interactive / rich. That is pretty much its use case in the browser. The majority of people like and want a rich user-experience so wanting the web to be more like your database queries and command line server stuff isn't going to fly. jQuery is a library that adds a lot of functions you would want to do in a browser. It reduces the amount of code to write and the amount of code that needs to be maintained. Anyone who works on a lot of software knows that that is a good thing and worth some drawbacks.

  67. "try gentoo!" by globaljustin · · Score: 1

    I appreciate the insight, genuinely, but I have to comment on this:

    They have detailed api docs at their website. If you're a developer and can't read api docs then you've got other problems.

    You mean this thing, right: http://api.jquery.com/

    Saw this once posted in a Gentoo/Linux discussion here on /. back in ~2001, posted to a self professed 'noob' who wanted to learn about Linux,

    "Hi, I used to be like you and I suggest trying Gentoo. Gentoo/Linux is very well supported with all the necessary documentation online for you to download"

    You can't **make** JQuery be 'easy for a geek off the street to use' just by referring me to some website and telling me any developer will find it useful in using JQuery.

    I'm trying to make a website that lets users design their own tshirt. Yes it's been 'done' and examples are out there (customink.com, zazzle.com, etc) but they all suck.

    I know basic HTML and CSS and have ALOT of CLI experience from my academic and IT work.

    I get the concepts.

    Now, given what I know, what would this 'API docs that any developer could read'...what would they tell me about *IF* I could even use JQuery to make what I want?

    I can't believe the old 'read the docs' trope is still around....

    --
    Thank you Dave Raggett
    1. Re:"try gentoo!" by Kielistic · · Score: 1

      There are api docs, millions of tutorials and active communities that will help people out. What more could a "noob off the street" demand? I do not mean to be insulting but there is only so much the internet can do. Another of the benefits of the jQuery library is that it is widely documented, known, and discussed. That makes it easy to pick up for self-learners.

      Of course you can use jQuery to do what you want. Or at least parts of what you want. I would recommend learning the library on lesser projects though. That will give you a better idea of what to do and what is and isn't possible. You're trying to run before you can walk. A novice isn't going to pick up a new technology and out-do the current champions. You may find that their suckiness stems from certain limitations of the platform.

    2. Re:"try gentoo!" by globaljustin · · Score: 1

      Of course you can use jQuery to do what you want. Or at least parts of what you want.

      that's fine...see, and I really want you to understand this, this next part you explain the whole problem:

      I would recommend learning the library on lesser projects though. That will give you a better idea of what to do and what is and isn't possible.

      never...taking the time to learn then make a program with JQuery just to **decide** if I should use it?

      that's ridiculous...I don't care if that's what all developers do, I'll never work like that...that's like if I build a house just to see if the my floor joist should made of 2x4's or 4x4's...

      it's insane, I don't want any part of it in my professional life

      --
      Thank you Dave Raggett
    3. Re:"try gentoo!" by Kielistic · · Score: 1

      No, it's actually more like expecting you to have built a box, a chair, a shed. Anything before building something as huge as a house. Or do you think you can just pick up a hammer one day a build a house? How the hell else are you going to learn something without actually using or doing it? You have to "**decide**" what you're going to use on your own; no one else can do it for you. That requires research, learning and making an informed decision. How is a web development library supposed to do that for you?