Also note that many typically functional style concepts (cons) aren’t all that great in a multi-core setting either as Guy Steele points out in his talk (http://www.infoq.com/presentations/Thinking-Parallel-Programming).

Easier-to-use effect systems might be a big part of the solution. Perhaps an effect system could be used for type interference and type checking as well.

]]>Although I have to disagree that “object.Method” is preferable to “Method object”. Even conceptually, it’s nonsensical for single-receiver objects to support binary methods. The preferred-receiver paradigm just breaks down too quickly because selecting overloads based on multiple arguments is just necessary.

That said, the syntactic convenience of being able to place the verb after the subject is very nice, as C#’s LINQ extensions demonstrate. But Haskell can do this as well with it’s `function` quotation syntax.

]]>As has been suggested above, there is a difference between STARTING with a sorted sequence (as this example does) and actually sorting a list that wasn’t in sequence to begin with. Repeating this, by starting with a random sequence and THEN ordering it gives the opposite result (output and modified script):

Unsorted, Sequential List : 0.1790

Shuffled, Sequential List : 0.2650

Unsorted, Random List : 0.1820

Sorted, Random List : 0.2640

—————————————————————————

Final results: UNSORTED list loops FASTER than re-ordered list

both sorting & shuffling RE-ORDER the list & SLOW looping

—————————————————————————

# Script to test whether looping is faster through and unsorted or a sorted list

# Final results: UNSORTED list loops FASTER than re-ordered list

# both sorting & shuffling RE-ORDER the list & SLOW looping

import time

import random

# The original test is WRONG

# – the original list is an UNSORTED list of sequential integers

# (see below: this in NOT the same as a SORTED list of random integers

a = [i for i in range(1000000)]

sum = 0

t1 = time.time()

for i in a:

sum = sum + i

t2 = time.time()

print (‘%-30s: %.4f’ % (‘Unsorted, Sequential List’, t2-t1))

a = [i for i in range(1000000)]

random.shuffle(a)

sum = 0

t1 = time.time()

for i in a:

sum = sum + i

t2 = time.time()

print (‘%-30s: %.4f’ % (‘Shuffled, Sequential List’, t2-t1))

# The CORRECTED test starts with an UNSORTED list of RANDOM integers

# – then the list is sorted and looping is timed again

# The unsorted list (of a random sequence) processes faster

a = []

for i in range(0, 1000000):

a += [random.randint(0, 1000000)]

sum = 0

t1 = time.time()

for i in a:

sum = sum + i

t2 = time.time()

print (‘%-30s: %.4f’ % (‘Unsorted, Random List’, t2-t1))

a.sort()

sum = 0

t1 = time.time()

for i in a:

sum = sum + i

t2 = time.time()

print (‘%-30s: %.4f’ % (‘Sorted, Random List’, t2-t1))

print(”’

—————————————————————————

Final results: UNSORTED list loops FASTER than re-ordered list

both sorting & shuffling RE-ORDER the list & SLOW looping

—————————————————————————

”’)