The Artima Developer Community
Sponsored Link

C++ Community News Forum
The Problem with Programming

212 replies on 15 pages. Most recent reply: Dec 8, 2006 6:12 AM by James Watson

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 212 replies on 15 pages [ « | 1 ... 8 9 10 11 12 13 14 15 | » ]
James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: The Problem with Programming Posted: Dec 1, 2006 9:58 AM
Reply to this message Reply
Advertisement
> if the price to pay to solve this
> problem means that my applications will consume a little
> bit more memory, I'll gladly sign off on the purchase a
> few more memory sticks.

There's an unmentioned disconnect here. You and I are saying 'a little' more memory is needed. But they are saying that extra memory needed is very significant. There are two feasible explanations: We have different ideas about what a 'little' memory is or we disagree fundamentally about the memory usage of Java.

I think it's the latter because a MB or two is not going to matter on any reasonably modern server or desktop hardware.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: The Problem with Programming Posted: Dec 1, 2006 10:02 AM
Reply to this message Reply
> My mistake. I'm not sure what BI is (Business
> Integration? Can you name a few examples?)

Business Intelligence. Data mining, data warehousing etc.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: The Problem with Programming Posted: Dec 1, 2006 10:27 AM
Reply to this message Reply
> And you can't "gladly sign off on the purchase a few more
> memory sticks" if you are selling your software to the
> customers; that works only for internal development.

Ha! Tell that to Microsoft.

Nemanja Trifunovic

Posts: 172
Nickname: ntrif
Registered: Jun, 2004

Re: The Problem with Programming Posted: Dec 1, 2006 10:40 AM
Reply to this message Reply
> > And you can't "gladly sign off on the purchase a few
> more
> > memory sticks" if you are selling your software to the
> > customers; that works only for internal development.
>
> Ha! Tell that to Microsoft.

:) I should have added - unless you have a monopoly.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: The Problem with Programming Posted: Dec 1, 2006 10:50 AM
Reply to this message Reply
> > > And you can't "gladly sign off on the purchase a few
> > more
> > > memory sticks" if you are selling your software to
> the
> > > customers; that works only for internal development.
> >
> > Ha! Tell that to Microsoft.
>
> :) I should have added - unless you have a monopoly.

It was a flip answer but I see management buying software that requires more memory or specialized hardware all the time.

Really, though, memory is cheap and if someone can provide a much less expensive solution that requires a more memory, it's pretty foolish for the customer to choose the more expensive product in most cases.

indranil banerjee

Posts: 11
Nickname: indranilb
Registered: Feb, 2004

Re: The Problem with Programming Posted: Dec 1, 2006 10:57 AM
Reply to this message Reply
> > > > And you can't "gladly sign off on the purchase a
> few
> > > more
> > > > memory sticks" if you are selling your software to
> > the
> > > > customers; that works only for internal
> development.
> > >
> > > Ha! Tell that to Microsoft.
> >
> > :) I should have added - unless you have a monopoly.
>
> It was a flip answer but I see management buying software
> that requires more memory or specialized hardware all the
> time.
>
> Really, though, memory is cheap and if someone can provide
> a much less expensive solution that requires a more
> memory, it's pretty foolish for the customer to choose the
> more expensive product in most cases.


The title of this topic is the Problem with Programming. Finally we are getting on topic. The mindset that the customer can just buy more hardware is a problem.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: The Problem with Programming Posted: Dec 1, 2006 11:02 AM
Reply to this message Reply
> The title of this topic is the Problem with Programming.
> Finally we are getting on topic. The mindset that the
> customer can just buy more hardware is a problem.

Great slogan, now back up it up for a meaningful statement.

indranil banerjee

Posts: 11
Nickname: indranilb
Registered: Feb, 2004

Re: The Problem with Programming Posted: Dec 1, 2006 11:15 AM
Reply to this message Reply
I mean, Ive seen Swing applications eat 80MB of memory in a steady state forcing users to have separate dedicated PCs for one application.

I've seen top of the range J2EE servers crash with OutOfMemory exceptions.

This is what Stroustrup was talking about, systems that are somehow barely made to work at the absence of any quality.

My examples are Java, but of course it can happen in any language. Just want to point out Java is nothing like a silver bullet.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: The Problem with Programming Posted: Dec 1, 2006 11:42 AM
Reply to this message Reply
> I mean, Ive seen Swing applications eat 80MB of memory in
> a steady state forcing users to have separate dedicated
> PCs for one application.
>
> I've seen top of the range J2EE servers crash with
> OutOfMemory exceptions.

That is a pointless anecdote. Are you arguing that no C++ program has ever exceeded the memory available? Are you aware that OutOfMemory exceptions don't mean there isn't any more memory available from the OS? I can make pretty much any real Java application crash with an OutOfMemoryException. All you have to do is lower the maximum heap size until you starve it out.

> This is what Stroustrup was talking about, systems that
> are somehow barely made to work at the absence of any
> quality.
>
> My examples are Java, but of course it can happen in any
> language. Just want to point out Java is nothing like a
> silver bullet.

I never made any case that Java was a magic bullet. In fact I think a lot of the perceived performance issues with Java are caused by developers that think that it is. Moreover, that has nothing to do with what I was talking about. If a customer has the choice between buying two basically equivalent software packages that are say, $50K or $40K + $2K for some more memory, they are stupid if the pick the first one. Or if all things other things being equal, they pick a less robust or less scalable solution over one that requires forking over little bit more for more memory, they are stupid.

No one is going to say there is an infinite memory available but to argue that it's a major problem to use a little bit more memory to accomplish a task is just nonsense.

Here's a real programming problem: developers who focus on unnecessary optimizations instead of making their code bullet-proof. If a program doesn't work, it doesn't matter how small it's footprint is.

indranil banerjee

Posts: 11
Nickname: indranilb
Registered: Feb, 2004

Re: The Problem with Programming Posted: Dec 1, 2006 11:59 AM
Reply to this message Reply
>
> That is a pointless anecdote. Are you arguing that no C++
> program has ever exceeded the memory available? Are you
> aware that OutOfMemory exceptions don't mean there isn't
> any more memory available from the OS? I can make pretty
> much any real Java application crash with an
> OutOfMemoryException. All you have to do is lower the
> maximum heap size until you starve it out.
>

As I said this can happen in any language. And I'm talking about a WebLogic server that had been tuned by BEA consultants. The problem was a coding error, a memory leak which can still happen in GC languages.

>
> I never made any case that Java was a magic bullet.

Some people do, and the tone of some posts on this thread seem to imply it.

> I think a lot of the perceived performance issues
> with Java are caused by developers that think that it is.

Agreed.

> Moreover, that has nothing to do with what I was talking
> g about. If a customer has the choice between buying two
> basically equivalent software packages that are say, $50K
> or $40K + $2K for some more memory, they are stupid if the
> pick the first one.

True. But Ive seen so many applications that have been built with no regard to memory footprint and CPU utilisation. And it sucks.

> No one is going to say there is an infinite memory
> available but to argue that it's a major problem to use a
> little bit more memory to accomplish a task is just
> nonsense.

Not something I suggested.

> Here's a real programming problem: developers who focus on
> unnecessary optimizations instead of making their code
> bullet-proof. If a program doesn't work, it doesn't
> matter how small it's footprint is.

No I agree with Stroustrup's analysis of the real problem.

<quote>
On the other hand, looking at "average" pieces of code can make me cry. The structure is appalling, and the programmers clearly didn't think deeply about correctness, algorithms, data structures, or maintainability. Most people don't actually read code; they just see Internet Explorer "freeze."

I think the real problem is that "we" (that is, we software developers) are in a permanent state of emergency, grasping at straws to get our work done. We perform many minor miracles through trial and error, excessive use of brute force, and lots and lots of testing, but--so often--it's not enough.
</quote>

Cameron Purdy

Posts: 186
Nickname: cpurdy
Registered: Dec, 2004

Re: The Problem with Programming Posted: Dec 1, 2006 12:23 PM
Reply to this message Reply
> There's an unmentioned disconnect here. You and I are
> saying 'a little' more memory is needed. But they are
> saying that extra memory needed is very significant.
> There are two feasible explanations: We have different
> t ideas about what a 'little' memory is or we disagree
> fundamentally about the memory usage of Java.

> I think it's the latter because a MB or two is not going
> to matter on any reasonably modern server or desktop
> hardware.

James, for processes that are spun up in quantity and that are short-lived, Java's footprint (CPU and memory) as implemented by the JIT and Hotspot style JVMs is unacceptable. That is an area that "compiled" languages (in the traditional "emitting and linking of native code" meaning) have a huge, obvious and understandable advantage.

Java, too, is a compiled language (there are several different JVM vendors that use this approach), but as a compiled language it has never caught on in the market.

Java is particularly good at long-running (say a minimum of 10 seconds and a maximum of 10 months) processes. At less than 10 seconds, a good chunk of the work is spent in the JVM implementation itself spinning up, and in very long-running applications, Java is still not so completely stable that I would trust a single JVM to run forever. (That's obviously one of the reasons why we keep managing to sell Java clustering software.)

There is no one-size-fits-all, but (IMHO) Java covers the middle 98% better than the other options that I have experience with. C/C++ coincidentally is pretty good at both ends (software that needs to run until the machine is shut off, and software that needs to start up, run and go away within a fraction of a second).

And to all the comments about not having used C++ in ten years, that is a valid criticism for me personally, as I no longer code in it (for probably 6 or 7 years now), although I do work with projects that are built in C++ (such as the C++ version of Coherence that we're building.)

Peace,

Cameron Purdy
http://www.tangosol.com/

Cameron Purdy

Posts: 186
Nickname: cpurdy
Registered: Dec, 2004

Re: The Problem with Programming Posted: Dec 1, 2006 12:32 PM
Reply to this message Reply
> I mean, Ive seen Swing applications eat 80MB of memory in
> a steady state forcing users to have separate dedicated
> PCs for one application.

80MB is nothing. I have swing applications running right now using over 250MB of RAM on my 3 year old notebook.

Of course I have several of those running, and both Firefox and Outlook are giving them a run for their money in terms of memory utilization.

Yes, software built today using Java (and most software built today using C++ or any other language) uses an obscene amount of memory when measured in 1980s numbers.

> I've seen top of the range J2EE servers crash with
> OutOfMemory exceptions.

I would love to have a thread just on the problems related to OOMEs. They are deterministically unrecoverable (i.e. recoverable but only non-deterministically) unless you use transactional style semantics in coordination with your exception handling. This is a topic that I quite enjoy :-)

> This is what Stroustrup was talking about, systems that
> are somehow barely made to work at the absence of any
> quality.

Using lots of memory is not the absence of quality, unless quality was defined up front as (among other things) using only a small amount of memory.

The applications that I use that gobble up hundreds of megabytes of memory are very welcome to do so, because they do massive amounts of tedious and repetitive work for me. Every time I type a keystroke in IntelliJ IDEA, I consume more memory and CPU cycles than existed in aggregate in 1960. And I am so happy to have those cycles coming out of my already-depreciated-off-the-books CPU and RAM, instead of me having to do those things myself.

To me, that is a wonderful form of quality, even though it may seem relatively expensive in terms of resource utilization.

> My examples are Java, but of course it can happen in any
> language. Just want to point out Java is nothing like a
> silver bullet.

Absolutely true. I would dare say that I am the first to say that there is no such thing as a silver bullet. No silver bullet. Yes, I would dare say that ;-)

As engineers, we choose among the lessers of many evils. (Thankfully we are not forced to choose among the _lessors_ of many evils.)

Peace,

Cameron Purdy
http://www.tangosol.com/

indranil banerjee

Posts: 11
Nickname: indranilb
Registered: Feb, 2004

Re: The Problem with Programming Posted: Dec 1, 2006 12:52 PM
Reply to this message Reply
>
> Absolutely true. I would dare say that I am the first to
> say that there is no such thing as a silver bullet. No
> silver bullet. Yes, I would dare say that ;-)
>

I thought I was the first, an hour before you.

> (Thankfully we are not forced to choose among the
> _lessors_ of many evils.)
>

You mean Oracle & BEA? ;-)

Cedric Beust

Posts: 140
Nickname: cbeust
Registered: Feb, 2004

Re: The Problem with Programming Posted: Dec 1, 2006 12:56 PM
Reply to this message Reply
> My examples are Java, but of course it can happen in any
> language. Just want to point out Java is nothing like a
> silver bullet.

Great, because nobody made such a claim here.

Show me someone who claims they found a silver bullet and I'll show you a fool (or a dead werewolf).

--
Cedric
http://beust.com/weblog

Cameron Purdy

Posts: 186
Nickname: cpurdy
Registered: Dec, 2004

Re: The Problem with Programming Posted: Dec 1, 2006 2:32 PM
Reply to this message Reply
> You know better than anyone else that the general issues
> of caching are not primarily a language thing. Neither
> Java nor C# make this a no-op or you would be out of
> business. There are garbage collectors for C++. There are
> caching frameworks for C++, so those tens of thousands of
> lines of code have already been written for reuse. You
> know very well, that garbage collection makes the most
> frequent and most simple cases easier, but it doesn't
> solve all the problems connected to the management of
> cached resources.

In this case, I was referring specifically to the massive amount of memory management that I had to do to avoid leaks for long-lived objects whose "scope of use" was defined completely externally. That is the type of problem that a garbage-collecting environment (let's not focus on the language for a second) can make very simple to deal with.

> Java takes that
> power away from us and that's one reason why the memory
> consumption of many Java apps is so outrageous. That's why
> the garbage collector needs to use processor cycles and a
> largeish memory cache to manage a huge number of heap
> allocated objects that should really have been allocated
> on the stack.

First, I do agree that Java (language, environment) takes power away, but what power does it take away? It takes away the power to excplitly use the stack, explicitly free allocations (and with objects having the corresponding call to a destructor made synchronously), and to explicitly pack memory in the same manner as one could efficiently do in C++. In the case that I was working with, I could "retrieve" a half million rows of data (from a hard-coded test driver) and realize a virtual "set" of data in memory to manage those retrieved results, and I could do that in a very few MB of memory (i.e. for the structures themselves). In Java, the same would be no less than 8MB, since each "row" would have to be a separately allocated object, and if that internally had any object state, it would be at least 16MB or 24MB (one or two objects respectively). So when you are dealing with large "arrays of structs", or things that benefit from explicit stack allocation, then Java is much less efficient (both space and time) than C++, and yes that will directly contribute to GC cycles being burnt (500,000 actual objects to manage instead of a hand-full of pointers representing block-allocated regions to hold 500,000 row structures).

A few points to bring us back to reality, though:

1) The approach in C++ can be much more efficient -- that is true. However, many applications written in C++ will use "new" roughly the same number of times that the application would have used it in Java, because (IMHO, from my own experience) it's hard work to do large-scale optimizations like the one I described.

2) VMs are getting better at using stack allocation. With a little foresight into the VM/language design, even pointers and arrays of structs (two things that Java for example is a non-player with) would be possible, but not so much as language dictates as much as natural VM optimizations.

3) 99% of objects could probably be stack-allocated. I had no problem with that in C++, and VMs for language like Java will likely have no problem with that in the future. The problem is the other 1%, which accounts for much of the complexity in large systems built with languages like C++.

> Using Java for software that processes a lot of data in
> memory is simply not productive. It's much easier to
> optimise memory consumption with C/C++ and there is a
> whole range of software where optimisation of memory use
> is crucial.

We do applications with tens and hundreds of gigabytes of data in memory, and we do it today in Java. It is not _easy_ in Java (we use distributed computing to accomplish it, by partitioning it over a grid-based finite state machine).

> There aren't many widely used DBMS or BI
> engines written in Java, and that's for a reason.

Yes, because there were great DBMSs long before Java existed. They are not written in C++, but in C, which is what the primary systems language was when they were written.

As far as BI goes, quite a bit is done in Java, but in many cases it is done in C++, which is what the primary systems language was when they were written.

> Java is unfortunately somwhere in the middle. It's
> a bad systems programming language because it takes so
> much control over resources away from you. And it's a
> mediocre applications language because it doesn't have
> many features for high level abstraction that languages
> like Python do have, AND most surprisingly, it has
> absolutely awful string processing capabilities.

I generally agree. Java isn't quite a systems language (too high level) and isn't quite an apps language (too low level). Likewise, C++ was never an apps language (way too low level) but made a decent systems language.

I do enjoy Java and think it (not just the language, but the VM approach and the wide range of libs) is a good fit for that "middle 98%" of programming. OTOH I'm not emotionally tied to Java, so I have no problem if something better replaces it. (And sorry Todd, that probably won't be Smalltalk. ;-)

Peace,

Cameron Purdy
http://www.tangosol.com/

Flat View: This topic has 212 replies on 15 pages [ « | 8  9  10  11  12  13  14  15 | » ]
Topic: Pantheios 1.0.1 full release approaching; beta 17 just released Previous Topic   Next Topic Topic: John Ousterhout on What Limits Software Growth

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use