Browse thread
[Caml-list] C++ STL and template features compared with OCaml parametric polymorphism and OO features
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2004-09-27 (16:51) |
From: | Brian Hurt <bhurt@s...> |
Subject: | Re: [Caml-list] C++ STL and template features compared with OCaml parametric polymorphism and OO features |
On 28 Sep 2004, skaller wrote: > Yes, because it costs nothing, which is much cheaper > than the virtual dispatch: This is wrong. It does cost something- it costs code bloat, because now instead of a single copy of the comprehension, you have a whole bunch of copies, one for each time you call the comprehension. This increases cache pressure, and increases the cache miss rate by the whole program, slowing the program down. Note that a cache miss that goes to main memory is 100-350+ clock cycles on modern CPUs. I can do a heck of a lot of work in that time. Note that inlining has the same problem. > No dynamic dispatch is required here. The templates > works with C functions, pointers to C functions, > and function objects. This is the advantage of templates, but it comes at a cost. -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford Brian ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners