aspose file tools*
The moose likes Java in General and the fly likes What it means when someone says that Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "What it means when someone says that "it is too much expensive operation"" Watch "What it means when someone says that "it is too much expensive operation"" New topic
Author

What it means when someone says that "it is too much expensive operation"

Rohit kumar sharma
Greenhorn

Joined: Apr 19, 2010
Posts: 16
Hello Users,

I would like to know what it means when some one says that it is too expensive opearation.Like While chossing data structres over LinkList and Arraylist it is generally insertions at begining will be less expensive in arraylist as in LinkedList.
I know that they are talking about Memory consumption and milliseconds requires to do an opearions.I was wondering in todays world when RAM is avialable at such at cheap rates then why would any programmer would too much about the resources utilised.

Thanking you


rohit kumar sharma
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11229
    
  16

Mobile devices don't always have tons of spare memory, so for apps running there, it can be a consideration.

And there are applications where millisecond delays can mean the difference between success and failure - a missile guidance system, or a nuclear reactor shutdown procedure. Yes, these are extreme examples and (thanksfully) somewhat rare, but they ARE real examples.

also...perhaps there is an operation that takes one millisecond to run, but it needs to be called a billion times...


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
dennis deems
Ranch Hand

Joined: Mar 12, 2011
Posts: 808
Focusing on memory is too narrow a scope for the concept of "expensive". Expensive means consuming more resources than we would prefer. The resource in question could be memory, but often we are talking about the time necessary to complete the task. Sometimes we're referring to bandwidth. Our application may depend on a remote service; calling that service might be expensive because our bandwidth is limited, or it might be expensive because the request takes a long time to serve. A database call could be expensive if we have a lot of logic and joins in our SQL, or if we're doing locking and managing transactions. We have to consider server resources in addition to just what the application needs to run locally.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Beware of people who say that something is an "expensive operation" and expect that to end the conversation. Actually the next thing to ask is "Expensive compared to what?" It's all very well to say that it's "expensive" to get a row from a database, but if you don't have a cheaper alternative, and you need to get that data, then you're just going to have to pay up and get the data.

And if there are alternatives, then assigning them values on one particular metric (say, amount of memory used) and choosing the one with the smallest value (e.g. least amount of memory used) isn't always the best choice either. There may be another metric (say, amount of run-time required or difficulty for beginning programmers to understand the code) in which other alternatives may be a better choice. In this case you have to decide which of the competing metrics is more important in this particular case. And there is not necessarily a single answer to the question, either. Often you can change the assumptions, or the environment, or even the requirements to make the choice easier.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60992
    
  65

Challenging "that would be too expensive" also helps reveal those who use that to mean "I like my own idea better".


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38340
    
  23
Rohit kumar sharma wrote: . . . is generally insertions at begining will be less expensive in arraylist as in LinkedList. . . .
Who told you that? It looks incorrect.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

That's another thing -- people write code based on rumours they have heard from other people, and sometimes things get mixed up in the process.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What it means when someone says that "it is too much expensive operation"