Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rohit kumar sharma
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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
 
fred rosenberger
lowercase baba
Bartender
Posts: 12203
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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...
 
dennis deems
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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".
 
Campbell Ritchie
Sheriff
Pie
Posts: 50277
80
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic