Skip to main content
added 202 characters in body
Source Link
mowwwalker
  • 1.2k
  • 2
  • 12
  • 20

All the languages I know of would execute something like:

i = 0
while i < 100000000
    i += 1

..and you can see it take a noticeable amount of time to execute.

Why though, do languages do this? The only effect this code will have is taking time.

edit: I mean inside a function which is called

function main(){
    useless()
}
function useless(){
    i = 0
    while i < 100000000
        i += 1
}

All the languages I know of would execute something like:

i = 0
while i < 100000000
    i += 1

..and you can see it take a noticeable amount of time to execute.

Why though, do languages do this? The only effect this code will have is taking time.

All the languages I know of would execute something like:

i = 0
while i < 100000000
    i += 1

..and you can see it take a noticeable amount of time to execute.

Why though, do languages do this? The only effect this code will have is taking time.

edit: I mean inside a function which is called

function main(){
    useless()
}
function useless(){
    i = 0
    while i < 100000000
        i += 1
}
Tweeted twitter.com/#!/StackProgrammer/status/215528275055882240
Source Link
mowwwalker
  • 1.2k
  • 2
  • 12
  • 20

Why are effect-less functions executed?

All the languages I know of would execute something like:

i = 0
while i < 100000000
    i += 1

..and you can see it take a noticeable amount of time to execute.

Why though, do languages do this? The only effect this code will have is taking time.