3 ms·
I have another gripe with these kinds of immutability / FP praising articles: The assumption that this must be faster, because multicore. As an example, many if
by m_mueller 9y ago
I have another gripe with these kinds of immutability / FP praising articles: The assumption that this must be faster, because multicore. As an example, many if not most of scientific applications (for which Haskell wants to position itself) are memory bandwidth bounded, not CPU bounded. These applications also deal with Gigabytes of data for each timestep, applied over dozens if not hundreds of kernels. So we're talking about thousands to tens of thousands of functional updates over data objects, each on the order of Gygabytes. The way this is dealth with efficiently in many cases is by doing pointer swapping - after each timestep, or even for intermediate kernels, the old output becomes the new input and the old input is overwritten by the new output. Swapping allows this to be an O(1) operation. Allocating new memory at each kernel launch for the output would absolutely kill the performance - we're talking one to two orders of magnitude here. Even if an FP compiler comes along that is able to optimize this, if this ever breaks I have zero trust that it will be a simple thing to figure out why the compiler doesn't do what I wanted, and at that point I'd rather just program it procedurally. To my knowledge, game programming is pretty much the same thing, so these usecases are rather wide spread.
I think there must be a (probably not yet invented) language somewhere that would allow me to write computations in immutable FP style, either as pointwise operations (i.e. stencils), or as matrix operations, but allows me to pass in some information that directly instructs the backend what it should do with the memory. I.e. I want to be able to program my own memory pools and link pointers to memory slots needed for the computations. Maybe that part could even be done using visual programming, akin to linking up GUI elements to properties in XCode: Let the compiler figure out where a memory slot is needed, do a dependency analysis for the memory slots and show graphically what slots are linked to what input and output. Then, let me add constraints to that linking and recompute a new solution whenever I move something around. The next step would be to do a performance model for each processor and figure out the best solution using machine learning, but let me actually see what the solution is without me having to go look at assembly (which, frankly, for FP frontends seems near impossible since it has even less to do with the frontend code than if you compile down something like C or Fortran).
- Recurecur 9y agoExactly. I've actually been giving this a fair amount of thought, as it also relates to "GC for everything", another obstacle for real time programming (soft or hard). I like many things about the FP approach, especially in terms of reasoning about the code. I just think the computer science community needs to focus on basically what you're advocating, immutable recycling alongside of garbage collection. It seems to me that this is a fairly easy problem really, and things should move to more of a mixed memory handling model, where one could use one or more of manual memory management, recycling, or GC as needed. FP language scala-native is providing both manual management and GC already, for instance...
- m_mueller 9y agoThank you. Yes, well, from the CS people I usually just get blank stares. "What did you say, you prefer Fortran"? I feel like there's a big divide between engineering and CS. The latter would rather never care about anything to do with hardware. IMO the real innovation usually comes at the intersection of hardware and software - like the recent boom of neural nets. Those things are known since the 80ies and then promptly dropped because the hardware wasn't ready, until someone 30 years later took the time to make a good CUDA library and make it work fast enough to be useable. Meanwhile the CS community focuses on adding more abstractions until no-one can figure out the hardware implementation anymore. Sorry for the grumpyness, guess my mood isn't the best today...
- tome 9y ago> Haskell wants to position itself Haskell isn't really a thing that could "want" to "position itself".