Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

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

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
lowercase baba
Posts: 13013
66
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 26910
82
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Challenging "that would be too expensive" also helps reveal those who use that to mean "I like my own idea better".
 
Marshal
Posts: 74354
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Marshal
Posts: 26910
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic