Slashdot Mirror


Time to Get Good At Functional Programming?

prone2tech writes "From an article at Dr. Dobb's: Chipmakers have essentially said that the job of enforcing Moore's Law is now a software problem. They will concentrate on putting more and more cores on a die, and it's up to the software industry to recraft software to take advantage of the parallel-processing capabilities of the new chips. As is argued in this article, this means becoming proficient in parallel functional programming. The bad news? Getting good at functional programming is hard, harder than moving from iterative Pascal or Basic or C coding to object-oriented development. It's an exaggeration but a useful one: When you move to FP, all your algorithms break.'"

620 comments

  1. Convince your boss. by narcberry · · Score: 5, Funny

    You mean oo isn't the only option?

    --
    Modding me -1 troll doesn't make me wrong.
    1. Re:Convince your boss. by fyngyrz · · Score: 5, Interesting

      Another question you might ask yourself is, are you going to let the CPU designers push you into a programming paradigm you are not effective in? Personally, I can see a machine being quite useful with say, 16 or 32 cores just because these machines do more than one thing at a time. But I'd much rather see them speed the cores up than endlessly multiply the number of them. There is a *lot* of room left to do this. Three D architectures offer more connectivity than is currently being used, and both the number and type of one-cycle instructions within a CPU can be increased until the summary is "all of 'em", which I doubt they're going to ever get to, orthogonality can be increased until again, the answer is that all instructions are available to the same degree for all registers and addressing modes no matter what. Compilers like broad orthogonality (and so do assembly programmers, not that there are a lot of us left.)

      If CPU designers run off towards the horizon making many-core designs, what if no significant number of people follow them there? Which... frankly... pretty much seems to be the case. I've an 8-core machine, and just about the only things that actually use those cores together are the easy ones: graphics and waveform encoding/decoding. Aperture sure enough uses all my cores in a well-balanced fashion and can build a JPEG in a snap; but that's a far cry from my web browser doing the same thing while trying to render a page.

      I'm just saying that the direction the CPU folks have chosen lately doesn't have to be the direction we actually end up going, and there are points in favor of this as the best choice.

      Just some thoughts.

      --
      I've fallen off your lawn, and I can't get up.
    2. Re:Convince your boss. by Anonymous Coward · · Score: 0

      Multi-Core is a way to go. And its easy to write software for it.

      OpenMP anyone?

      #pragma omp parallel for
      for(int i=0; i10000; i++)
      { //split work between CPUs
      }

    3. Re:Convince your boss. by Zironic · · Score: 5, Insightful

      Well, the problem is that no matter how much you bash an algorithm with a functional language you can't magically make a sequential task into a parallel one.

    4. Re:Convince your boss. by danwesnor · · Score: 3, Funny

      But I'd much rather see them speed the cores up than endlessly multiply the number of them.

      Your idea is not feasible because it screws up too many marketing campaigns. Please revise your idea and run it through sales before submission to management.

    5. Re:Convince your boss. by Chandon+Seldon · · Score: 5, Insightful

      Well, the problem is that no matter how much you bash an algorithm with a functional language you can't magically make a sequential task into a parallel one.

      Thing is, you probably have a parallel task that was already bashed into a sequential one.

      Most real-world problems are parallel problems. Even the ones that aren't (say... compiling a file in C) you can usually run a lot of instances of in parallel.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    6. Re:Convince your boss. by cleatsupkeep · · Score: 4, Interesting

      Actually, the reason for this is because of the heat consumption. As the power of a chip grows, the heat consumption grows much faster, and more cores are a much better way to get more speed with less power consumption and heat.

    7. Re:Convince your boss. by Anonymous Coward · · Score: 0

      if you won't program it we'll pay someone else who will. as i see it, they're going to do some weeding of the coder garden. are you going to prosper or are you going to be seen as a weed?

      cpu manufacturers will easily push you more than you can ever push them. don't even try to think you're hard in their shadow.

    8. Re:Convince your boss. by Anonymous Coward · · Score: 2, Interesting

      Lots of tasks could be done in parallel.

        * Voice recognition
        * Image recognition
        * File search
        * Text search
        * Find&Replace
        * virus scanning
        * video games

      The better question is: How many CPU intensive applications run best with sequential execution?

      I think the list is pretty small.

      ----

      All this talk about functional programming is just hype. We have had multithreading for a LONG LONG time. Until now multithreading a simple search would have been pointless, multiple threads on a single cpu? absurd. As multiple cores becomes more standard I think we will re-evaluate many common programming practices and in fact see that doing them in parallel is very natural.

    9. Re:Convince your boss. by Anonymous Coward · · Score: 0

      Agreed. It even makes wonders for encryption algorithms! For instance my implementation of SHA-1 should be able to compute the different parts of the result in parallel. Now I only have to reverse the base algorithm (arg)... It's just a matter of time...

    10. Re:Convince your boss. by exley · · Score: 3, Insightful

      Another question you might ask yourself is, are you going to let the CPU designers push you into a programming paradigm you are not effective in?

      This to me sounds like laziness. "But parallel programming is HARD!"

      But I'd much rather see them speed the cores up than endlessly multiply the number of them. There is a *lot* of room left to do this.

      Please elaborate on this further, because what you wrote that follows is all rather vague to me. Making cores faster means higher clock speeds and/or improved architectures. As far as clock speeds go, apparently, chip designers feel like they are running up against physical limitations that are making this difficult. And when it comes to improved architectures, what quite possibly the #1 thing that has been done over the years to improve performance? Increase parallelism. Pipelining, superscalar architectures, multi-threaded single cores, VLIW, etc.

    11. Re:Convince your boss. by Anonymous Coward · · Score: 0

      Yes, but even serial tasks can be parallelized through pipelining if they can be decomposed into smaller independent tasks.

    12. Re:Convince your boss. by triffid_98 · · Score: 3, Interesting
      The reason this happens in the real world is because you generally need lots of X, be it a road, or babies, or whatever. If you just need one (unique inputs to create a singular unique output) often you can't optimize it using multiple cores, though I suppose you could still do the equivalent of superscalar branch prediction and result tables(for fixed input sets) the like.

      More CPU horsepower is the obvious choice for non-bus limited operations, but things are starting to get expensive there, so I welcome a few extra cores. The real question is if Intel and AMD will save some cash from their MMC(massive multi-core) projects and deliver a more sensible number of faster cores. You just can't depend on a given user's programs being set up to run efficiently in parallel.

      Thing is, you probably have a parallel task that was already bashed into a sequential one. Most real-world problems are parallel problems. Even the ones that aren't (say... compiling a file in C) you can usually run a lot of instances of in parallel.

    13. Re:Convince your boss. by countach · · Score: 1

      "are you going to let the CPU designers push you into a programming paradigm you are not effective in?"

      No we shouldn't. However, functional programming IS a very effective method, or at least it often is.

    14. Re:Convince your boss. by Anonymous Coward · · Score: 0

      And let me guess, only H1B Indians have the necessary qualifications and experience?

    15. Re:Convince your boss. by Chandon+Seldon · · Score: 5, Insightful

      The real question is if Intel and AMD will save some cash from their MMC(massive multi-core) projects and deliver a more sensible number of faster cores. You just can't depend on a given user's programs being set up to run efficiently in parallel.

      I'd much rather have 64 fast cores than 16 slightly faster (but horribly power-inefficient) cores, and that's really the tradeoff that you're talking about. All of the reasonable ways of throwing transistors at getting faster straight-line code execution have already happened. Hell, even the unreasonable ones have been implemented, like fast 64-bit division units.

      Intel and AMD have the choice of releasing dual-core processors that are 5-10% faster than last years, or they can release 4/6 core processors for about the same transistor budget. The multi-core processors are better for almost everyone - there's no way to get a 5x speedup out of a 10% faster processor.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    16. Re:Convince your boss. by Hooya · · Score: 5, Insightful

      The way I look at it is that we are resigned to do only certain things with a computer since, up until now, the computers we have created are only good at a certain class of problems. They suck donkey balls on most of other interesting things that are immensely useful. Take optimization problems - there is an insane amount of applications that we currently don't think of since, like i said before, we've resigned our hopes in being able to tackle those.

      For example, I would love to get parallel computations figure out my 'optimal' tax returns. Have my GPS calculate optimal routes - the routes I get now are pretty crappy etc.

      My point to all this is that most of the problems that look like they are one-input-one-output aren't really that. It's just that over the last 50 or so years, we've learned to model them as such out of sheer necessity.

    17. Re:Convince your boss. by lysergic.acid · · Score: 4, Interesting

      personally, i think in terms of commodity computing, we don't really need to squeeze any more power out of the CPU than we've already got. use fully pipelined superscalar architectures, perhaps multithreaded dual or quad cores (for high-end workstations) and VLIW to maximize ILP efficiency. even at current processor speeds, 99% of the applications people (especially casual computer users) use have bottlenecks elsewhere (like memory & disk I/O speeds, internet bandwidth, user response time, etc.).

      for the really resource-intensive stuff, like image/video/audio processing, cryptography, 3D graphics, CAD/engineering applications, scientific modeling, processing/manipulating financial data, etc. you would be much better off using a specialized dedicated vector coprocessor (as opposed to a general-purpose scalar processor that commodity CPUs tend to be). this way you can have a relatively low-power (and low clock rate) CPU for processing common SISD instructions that constitute 99% of all computing tasks, greatly cutting the cost of consumer and pro-sumer systems. and by using highly specialized coprocessors to handle the heavy lifting, those applications can be processed more efficiently while using less power (and at lower clock speeds) than trying to get a general-purpose scalar CPU to do the same work.

      that is why GPGPUs are generating so much interest these days. it just so happens that most of the really processor-intensive applications consumers run greatly benefit from stream processing. game developers have long taken advantage of dedicated vector coprocessors with highly-specialized instruction sets and architecture made specifically for 3D gaming. DSPs with specialized architectures are also commonly used for hardware-accelerated video encoding, audio processing, etc. and now companies like Adobe are also seeing the advantages to using specialized vector coprocessors for their resource-intensive applications rather than having the CPU handle it.

      and, honestly, how many different kinds of processor-intensive applications do most users run on a regular basis? if you're a graphic designer, your main processing power concern is only in relation to 2D/3D graphics. if you're an audio engineer or musician, then you're only going to use audio-related resource-intensive software. likewise, if you're a cryptographer/cryptanalyst, you probably won't ever run any audio editing software or 2D graphics software. therefore, it makes sense to pair moderately powered general-purpose scalar CPUs up with a powerful & highly specialized vector coprocessor like a GPU/DSP/Stream Processor/etc.

    18. Re:Convince your boss. by Secret+Rabbit · · Score: 2, Interesting

      You're cherry picking your data there (compilers, etc). To see what's out there, we must look at want is commonly done and if those things can benefit from parallel processing (and I see lots and lots of places, including the browser, where things could go parallel).

      When we do that, we notice that what goes on in the gaming industry, soon becomes standard everywhere else. And both modern platforms, the PS3 and XBox 360 (I'm not including the Wii as Nintendo has different goals that having bleeding edge tech.) have multi-core processors. Radically different architectures, but multi-core none-the-less. We are also seeing this, and have been for a while, multi-core entering the desktop.

      This isn't a coincidence. Moore's law has effectively ended for individual processors. Anything that might go against that is nothing more than a *very* short term dodging the inevitable. Multi-core is the only thing that is going to see our computers get faster. This does make it a software problem. And a problem it is.

      Why? Because for the longest time threading has been available, but basically no-one has been teaching it nor developing better techniques to do it. So, we have grossly under experienced/under trained people out there that are now having to deal with the reality of the situation. This is going to cause some initial problems and lots of people are going to bitch about it. But, that is relatively short term.

      The gaming industry will work out many of the problems and will share a lot of that information. Insomniac Games is a good example of this. But, there will still be growing pains. But, it shouldn't be perceived as anything else but growing pains.

    19. Re:Convince your boss. by Locutus · · Score: 1

      multi-threading on OS/2 rocked and made many OS/2 applications very responsive to user actions and this was on old Pentium computers. Multi-threading died when Windows 95 shipped and OS/2 was sidelined.

      Not to mention that Microsoft has always liked procedural APIs because they get to write the rules and everyone must follow their APIs. Functional programing just sounds like more of the same old procedural stuff like RPC and Microsoft's object-like way of protecting from being abstracted out of existence by OO methodologies.

      I wonder if Windows is any better at threading these days? In the late 90s, Warp 4 was 2x faster doing threading than Windows NT was on the same hardware. And I remember how MS tried to build the Windows 95 UI as a heavily threaded application and it brought the system to a crawl. So, maybe the way Microsoft designed the kernel and their compiler, they can't do threading very well and want to do separate process based stuff as in this _functional programming_ scheme. Are there any open source gurus and kernel people pushing for this functional stuff? It does seem like hype when threading takes care of spreading processor usage across cores and has been around for a long long time. OS/2 had it in v2.0 in 1991-ish and might have had it in v1.x code too. Solaris got it in the mid 90s. Other OS's probably had it too, Windows just sucked at it and Microsoft own software hardly used it in the 90s.

      LoB

      --
      "Anyone who stands out in the middle of a road looks like roadkill to me." --Linus
    20. Re:Convince your boss. by ZosX · · Score: 2, Insightful

      My thoughts exactly. I can think of a multitude of possible applications that we have yet to tackle simply single core processors were not up to the task of computing the large data sets efficiently.
      So many applications have been relegated to high-performance computing. Such as weather prediction, 3d rendering, chaos math, simulation, etc. Software has been been outpaced to what hardware is capable of (games notwithstanding) for some time now. Even this single core athlong64 3000 i'm using is about 100x faster than the 486 I used to think was blazing, and yet, the best we have is new versions of the same programs with layer upon layer of feature creep added in to the point where Word on the 486 ran about as well as Word on the mini super computer.It amazes me how many applications aren't multithreaded. Even on a single core, you could at least still work on something while the program also executed some task or job in the background. So man applications force you to just sit and wait on some infuriating task bar.
      We need more multithreading period.

    21. Re:Convince your boss. by fuzzyfuzzyfungus · · Score: 1

      Is a serial task really a serial task if it can be decomposed into smaller independent tasks?

    22. Re:Convince your boss. by setagllib · · Score: 1

      He means that if you need to do a bunch of serial tasks on a number of inputs (say, decode/filter/encode a bunch of videos), you can have the decoder, filter and encoder all running in parallel on different streams of videos. However in general it's just easier to run N parallel streams where N is at least as much as the core count. Pipelining has its uses but my example isn't one of them.

      --
      Sam ty sig.
    23. Re:Convince your boss. by geoskd · · Score: 1

      Most real-world problems are parallel problems. Even the ones that aren't (say... compiling a file in C) you can usually run a lot of instances of in parallel.

      True, but modern smart compilers do a remarkable job of putting the software back into a parallel configuration, Hence the term "optimizing compiler." Granted, they tend to do this on an instruction level basis, but the concepts are no different at the thread level and beyond.

      -=Geoskd

      --
      I wish I had a good sig, but all the good ones are copyrighted
    24. Re:Convince your boss. by dhasenan · · Score: 2, Insightful

      This to me sounds like laziness. "But parallel programming is HARD!"

      That's probably a better argument than fighting the CPU designers. If parallel programming is hard, it's more expensive to create parallel programs. They'll take longer to write. It'll take longer to implement new features for them. It'll take more money to maintain them. All that seems like a good reason to avoid parallel programming.

      On the other hand, if someone comes up with a new parallel programming paradigm that's slightly more difficult than procedural/object-oriented programming, but offers these benefits -- or if this exists already -- it'll make sense to switch to that paradigm as your performance needs increase.

    25. Re:Convince your boss. by mechsoph · · Score: 2, Insightful

      As the power of a chip grows, the heat consumption grows much faster

      That doesn't make sense. The power used by the chip will exactly equal the heat generated by the chip due to the law of conservation of energy.

      more cores are a much better way to get more speed with less power consumption and heat.

      Ok, that sounds reasonable.

    26. Re:Convince your boss. by Chandon+Seldon · · Score: 5, Interesting

      Granted, they tend to do this on an instruction level basis, but the concepts are no different at the thread level and beyond.

      That's not really true. Supporting instruction level parallelism is reasonably straightforward - you just analyses the per-instruction data dependencies and output things ordered in such a way that the hardware instruction scheduler can do it's thing. There's only one problem - optimally ordering a set of instructions is NP-hard. So if you want to do a good job ordering 5 instructions you're fine, 15 instructions is obnoxious, and 150 instructions is basically impossible.

      Further, instruction level re-ordering doesn't change the basic algorithm. If you're compiling a heapsort routine, the re-ordered instructions are still going to implement heapsort. And heapsort doesn't parallelize well. Maybe you could build logic into your compiler to detect heapsort and automatically replace it with parallel quicksort, but that doesn't help you when you run into a non-sorting routine.

      Realistically, programmers have to write parallel code for many-processor platforms. It's not amazingly difficult (given reasonable training and a reasonable set of tools), but it is different. But it's not something that's going to go away when the gcc guys / java team / VS.NET team implement some clever optimization.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    27. Re:Convince your boss. by triffid_98 · · Score: 1
      My point is that 16 slightly faster ones are more useful given the state of programming today. Normal people are not running 16 cpu bound processes at any given moment. It would be great for optimization if that were the case, but generally it's not.

      I agree that we're quite unlikely to see exponential increases in speed anytime soon but incremental ones are certainly feasible.

      If GPU technology has taught me anything, it's that you can make gamers pay $700 for a graphics card and $200 for a new 600watt power supply as long as they're getting their shiny things fix, so power efficiency doesn't matter for the desktop market, laptops and servers being a different story.

      I'd much rather have 64 fast cores than 16 slightly faster (but horribly power-inefficient) cores, and that's really the tradeoff that you're talking about. All of the reasonable ways of throwing transistors at getting faster straight-line code execution have already happened. Hell, even the unreasonable ones have been implemented, like fast 64-bit division units.

    28. Re:Convince your boss. by Chandon+Seldon · · Score: 2, Interesting

      It's true that standard hash algorithms are generally serial in nature. Luckily, you can use well-tested hash algorithms to build hash trees and get the same security properties with excellent parallelism. Some modern hash algorithms are even designed for tree modes to support parallel computation.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    29. Re:Convince your boss. by TheKidWho · · Score: 2, Informative

      It makes perfect sense if you consider that when he says "power" he wasn't referring to power consumption, but processing speed.

      aka Heat consumption increases faster than power does.

    30. Re:Convince your boss. by mechsoph · · Score: 1, Offtopic

      Power is a technical term with a specific meaning, and any self-respecting nerd should know that. If you're talking about something else, you'd better qualify the term.

    31. Re:Convince your boss. by Anonymous Coward · · Score: 0

      Oh ffs...can you really say that with a straight face? Do you honestly not see the immense benefit of true multitasking?

      Your statement equates to a pilot refusing to use all the sensors on the instrument panel because 'his eyes work just fine'. Not only that, he brilliantly deduces...but, if enough like-minded pilots refuse as well, maybe the jet designers will just stop working on better/more sensors altogether and focus on ensuring the pilot has a clear view. =P

    32. Re:Convince your boss. by Chandon+Seldon · · Score: 2, Informative

      My point is that 16 slightly faster ones are more useful given the state of programming today.

      Realistically, most code that will scale to 16 cores should scale to 64 cores. The real problem is code for 1/2 cores not scaling to 8+ cores. Once 8+ cores are common, this problem will quietly vanish as no-one clings to the 1/2 core solutions anymore. You can already see this to a large extent in server applications.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    33. Re:Convince your boss. by smellotron · · Score: 2, Interesting

      Normal people are not running 16 cpu bound processes at any given moment.

      You don't have to be CPU-bound to benefit from extra cores. More cores means less OS-driven task switching, since all of the active processes can be isolated. The result is (slightly) lower latency for everything involved.

      Plus, you're underestimating the obvious parallel processes on a machine. Right now I have around 50 Firefox tabs open. I'm struggling to close them fast enough (I tend to hang onto amazon.com pages and whatnot), but what if I was using a browser that separated that into 50 separate processes (instead of the Firefox approach, which is to hang whenever I open too many Youtube windows)? They're all periodically vying for CPU time when their Ajaxified Web 2.0 Timer goes off and re-downloads crap.

    34. Re:Convince your boss. by plasmacutter · · Score: 1

      Actually, the reason for this is because of the heat consumption. As the power of a chip grows, the heat consumption grows much faster, and more cores are a much better way to get more speed with less power consumption and heat.

      and what about optical chips?

      --
      VLC FOR MAC IS DYING! IF YOU DEVELOP, PLEASE SAVE IT!!
    35. Re:Convince your boss. by TheLink · · Score: 0

      I think it should be pretty clear enough to anyone familiar with English and technology.

      He said "power _of_ a chip", so it means processing power.

      He didn't say power used by the chip.

      Power consumption was only mentioned in the next paragraph, that's clearly the other meaning of power.

      While there is a relationship between information processing and power usage, he would be saying some rather different things before I'd think he's talking about that.

      --
    36. Re:Convince your boss. by Anonymous Coward · · Score: 0
      "are you going to let the CPU designers push you into a programming paradigm you are not effective in?"

      Boo-hoo software-boy. The hardware people have had to keep up with every brain fart from the software fantasy brigade to support your bloated, inefficient, resource-intensive and buggy crap code.

    37. Re:Convince your boss. by sveiki_neliels · · Score: 1

      Multi-Core is a way to go. And its easy to write software for it.

      Sure. Try it for real applications. OpenMP is great, when parallelism is possible and dependences can be removed or encapsulated.

      Parallel programming is exceedingly difficult for most general purpose software. What's more, there is a plethora of much-used legacy software that needs conversion to take advantage of parallel architectures.

      Even worse, a number of processor manufacturers are moving towards simplifying the cores and putting more of them on. So sequential code will run worse than before.

      --
      New slang when you notice the stripes, the dirt in your fries.
    38. Re:Convince your boss. by shutdown+-p+now · · Score: 3, Informative

      For a more lower-level example, almost any kind of query over some data set is an inherently parallelizable operation. This includes virtually all usages of list comprehensions, map and filter in Python, for example.

    39. Re:Convince your boss. by Knuckles · · Score: 1

      Have my GPS calculate optimal routes - the routes I get now are pretty crappy etc.

      Really? The ones I get turn out to be pretty optimal most of the time. I mean, sure, there might be other ones that save 5 minutes on a 4 hour drive, but whatever.

      --
      "When I first heard Daydream Nation it quite frankly scared the living shit out of me." -- Matthew Stearns
    40. Re:Convince your boss. by Anonymous Coward · · Score: 0

      Well, you're touching on the truth here, but it's not a matter of being "resigned"; it just happens that there are strict mathematical issues. Certain types of problems scale extremely poorly as the size of the data set increases. Lots of optimization problems fall into that class of difficulty. The linear speedup gained from parallel processing isn't sufficient to 'catch up' to the really bad ones.

      Your GPS map is actually a famous example of this, and it's been known for a few hundred years. It's a variant of the Traveling Salesman problem, and your GPS gives you iffy but "good enough" results because calculating the truly optimal solution is difficult enough that crazy people use CPU-years of supercomputer cluster time to solve it for fun.

    41. Re:Convince your boss. by renoX · · Score: 1

      GPS routes?

      Are you sure that's not because you're judging the routes that the GPS gives you according to criteria that the GPS either don't have or that you don't agree with?

      More CPU power won't help in this case..

    42. Re:Convince your boss. by cnettel · · Score: 1

      What about them? You will still need to emit and absorb light at some points, and the basic thesis here is that the number of discrete switches (no matter whether they are semiconductor transistors or something else) will grow much faster than the sequential speedup.

    43. Re:Convince your boss. by foobsr · · Score: 0

      algorithm

      Probably there is the crux, 'algorithm' implying a certain set of "problem spaces".

      Ponder about 'the creative algorithm', an 'arts algorithm' or a 'body movement algorithm', mix in some process oriented thinking and revise your idea of 'causality'.

      CC.

      --
      TaijiQuan (Huang, 5 loosenings)
    44. Re:Convince your boss. by Haeleth · · Score: 1

      All this talk about functional programming is just hype. We have had multithreading for a LONG LONG time.

      We've also had functional programming for a LONG LONG time. Like multithreading, it's not used much because there are easier ways of writing programs. All the FP hype is about is the claim that FP makes multithreading easier, so the combination of the two may be a good idea compared to trying to use just one or the other.

    45. Re:Convince your boss. by SoapBox17 · · Score: 1

      And when it comes to improved architectures, what quite possibly the #1 thing that has been done over the years to improve performance? Increase parallelism. Pipelining, superscalar architectures, multi-threaded single cores, VLIW, etc.

      All of those things you said are transparent to the programmer. Except for multi-threaded single cores (which is just a separate issue engine for the same underlying execute engines, so its like a dual front end for the same back end, a sort of precursor to multi-cores) ; and VLIW, which any decent compiler can take advantage of without the programmer caring.

      Multicore, on the other hand, requires you to get rather fancy with synchronization in imperative languages or, as the article suggests, moving to a completely different paradigm.

    46. Re:Convince your boss. by The+Snowman · · Score: 0

      I am running Vista on a Q6600 and it runs fine. But so does Linux, or anything else I throw at it. The UI seems to be quite responsive compared to earlier versions of Windows, but again I am not sure if it is due to the process speed or the fact that I have four processors.

      I think operating systems need to focus on managing resources efficiently, no matter how many CPUs, and let the user-space applications focus on blazing performance. If you have a large number of cores, say 16+ on a desktop system, who cares if your OS is properly synchronizing and managing read requests to the hard drive? How do you even know? Should it matter to the end user? I say no. But when your game is crawling along or it is taking forever to edit video or whatever, people will notice and wonder why it is so slow on a multi-core system. Those are the applications that need to take advantage of multiple cores. The operating system just needs to know how to schedule threads and processes over many cores, which is a problem we have already solved.

      --
      24 beers in a case, 24 hours in a day. Coincidence? I think not!
    47. Re:Convince your boss. by EsbenMoseHansen · · Score: 1

      For example, I would love to get parallel computations figure out my 'optimal' tax returns. Have my GPS calculate optimal routes - the routes I get now are pretty crappy etc.

      My point to all this is that most of the problems that look like they are one-input-one-output aren't really that. It's just that over the last 50 or so years, we've learned to model them as such out of sheer necessity.

      Your GPS route is a most likely an A* algorithm, or a variant of it. There is certainly the possibility of using 4-6 cores on that efficiently, but I don't really see how to use 1000 efficiently.

      But perhaps, 1000 is not really necessary. If so, we should concentrate on creating good, lock-free data structures such as queues, heaps and vectors, and put them into commonly available libraries.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    48. Re:Convince your boss. by Anonymous Coward · · Score: 0

      Please elaborate on this further, because what you wrote that follows is all rather vague to me.

      But explaining myself is HARD!

    49. Re:Convince your boss. by Anonymous Coward · · Score: 0

      If GPU technology has taught me anything, it's that you can make gamers pay $700 for a graphics card and $200 for a new 600watt power supply as long as they're getting their shiny things fix, so power efficiency doesn't matter for the desktop market, laptops and servers being a different story.

      I'd say that at least half the desktops are NOT used by gamers. Power efficiency isn't an issue for a spoiled pfy getting "free" electricity in his parents basement, agreed... but I sure did take it into account when buying my desktop workhorse. I found you can cut energy usage by a lot, for the same price, while not losing horsepower.

      I also helped set up a computer room of 20 desktops in a local community center, and power cosumption was a serious issue. For some of us it was about the power bill, for some about the enviromental footprint, but either way, "power efficiency doesn't matter for the desktop market" only holds true for that part of the dekstop market that we could describe as "gaming rigs".

      Once you get out of your basement into the real world you'll notice there's more people in the world than your online frag friends or guild members...

    50. Re:Convince your boss. by some-old-geek · · Score: 1

      Most real-world problems are parallel problems. Even the ones that aren't (say... compiling a file in C) you can usually run a lot of instances of in parallel.

      Programming, or compiling programs, is a very tiny subset of real-world problems. Most real-world problems are boring, single-threaded, input-process-output problems.

    51. Re:Convince your boss. by bwcbwc · · Score: 1

      Well, actually that's only true because the CMOS semi-conductor architecture only disperses substantial amounts of power during the clock transition state (voltage going up or down). So power dissipation is proportional to clock frequency (the number of transitions per second). There are other historic semi-conductor architectures that essentially have constant power requirements (like TTL), but these were essentially abandoned in the 1980's because at the clock speeds then prevalent, CMOS was incredibly more power-effecient. TTL probably wouldn't hack it nowadays even at high frequencies, but perhaps it's time to take another look at how the actual basic circuits are designed to see if they can be implemented more efficiently for high clock rates.

      --
      We are the 198 proof..
    52. Re:Convince your boss. by russotto · · Score: 1

      Take optimization problems - there is an insane amount of applications that we currently don't think of since, like i said before, we've resigned our hopes in being able to tackle those.

      Because they tend to be NP-complete (or even PSPACE-complete); even massively parallel machines only reduce complexity by a constant factor. So approximate algorithms are going to continue to be the way to go there.

    53. Re:Convince your boss. by Anonymous Coward · · Score: 0

      Hey man OS/2 fanboys are a dying breed... you must be one of the last survivors... the rest of them died from boredom... from repeating the same shit for over a decade... face it... OS/2 is dead and buried... and won't resurrect.

    54. Re:Convince your boss. by Draek · · Score: 1

      Another question you might ask yourself is, are you going to let the CPU designers push you into a programming paradigm you are not effective in?

      Another question you might ask yourself is, are you going to avoid utilizing a new, powerful technology simply because you can't use it effectively *now*? I for one won't, I'd rather learn how to do functional programming well than simply say "screw it, I'm going with a single CPU for the rest of my life". Plus from what I've been learning of Lisp it's not hard, it's just different.

      Personally, I can see a machine being quite useful with say, 16 or 32 cores just because these machines do more than one thing at a time. But I'd much rather see them speed the cores up than endlessly multiply the number of them. There is a *lot* of room left to do this.

      There's also a lot of room left to put extra cores, and for easily-parallelizable algorithms the former is easier and faster. Plus, it's one step closer to the programmer's ideal of 100% efficiency for the "just throw more hardware at it!" philosophy ;)

      If CPU designers run off towards the horizon making many-core designs, what if no significant number of people follow them there? Which... frankly... pretty much seems to be the case. I've an 8-core machine, and just about the only things that actually use those cores together are the easy ones: graphics and waveform encoding/decoding. Aperture sure enough uses all my cores in a well-balanced fashion and can build a JPEG in a snap; but that's a far cry from my web browser doing the same thing while trying to render a page.

      Does your computer struggle trying to render a webpage? mine certainly doesn't, and it's only a 2-core machine. Plus, correct me if I'm wrong, but isn't drawing vector graphics easily parallelizable? and in that case, more cores would mean less drawbacks for world-wide adoption of .SVG, which also removes plenty of headaches from web developers. Win-win.

      I'm just saying that the direction the CPU folks have chosen lately doesn't have to be the direction we actually end up going, and there are points in favor of this as the best choice.

      Given that now even the cheapest of the cheap Intel CPUs are dual-core (IIRC), I'd say that the direction we're actually going *is* multi-core, it's just that us programmers haven't quite caught with it yet. Hence the recent (well, not really, it started a few years ago) interest in functional programming.

      --
      No problem is insoluble in all conceivable circumstances.
    55. Re:Convince your boss. by Nelson · · Score: 1

      I'm just saying that the direction the CPU folks have chosen lately doesn't have to be the direction we actually end up going, and there are points in favor of this as the best choice.

      You should start your own company and put Intel out of business...

      Seriously though, you have no idea what you're talking about. It is incredibly difficult to continue to just make single cores faster. For the last couple decades as it is they've been doing things to exploit parallelism closer to the instruction stream (really, that's all superscalar CPUs do, work on multiple instructions at the same time) parallelism is the only way to go to continue to improve performance. We simply cannot ramp clocks up and continue to shrink dies.

    56. Re:Convince your boss. by DuckDodgers · · Score: 1

      There is a relatively small but active community of open source functional programming languages. The big names (for this relatively small group) are Scheme, Haskell, ML and Ocaml, and Erlang. Lisp and the new open source JVM language Scala also support functional-only programming styles. So does Microsoft's language F#. (But Lisp, Scala, and F# can be used in non-functional ways.)

      There are some great discussions on the advantages of functional programming. Here's one on the Haskell website: http://www.haskell.org/haskellwiki/Introduction Another one is this paper on the subject: http://www.md.chalmers.se/~rjmh/Papers/whyfp.pdf

      I am not very experienced with functional programming at all. But if I understand it correctly, one of the ways functional programming makes parallel processing easier is the fact that variables are immutable. That is, variable values can't be changed once they are assigned.

      So if you want to do a String reverse in a functional style with immutable variables, it could be (Java):
      public String reverse(String s) {
      if (s == null || s.length() < 2) return s;
      else return (s.substring(s.length() - 2, s.length() - 1) + reverse (s.substring(0,s.length() - 2);
      }

      That's awkward an inefficient in Java, but you hopefully see how it works. A lot of the difficulties with parallel programming come from having multiple threads accessing and changing shared mutable (changeable) variables. You have to coordinate access carefully or there can be big problems. With immutable variables, that particular source of bugs does not exist.

    57. Re:Convince your boss. by svirre · · Score: 1

      "both the number and type of one-cycle instructions within a CPU can be increased until the summary is "all of 'em""

      Why spend silicon area on instructions that are rarely used? The performance gains will be neglible. For very complex instructions, making them seem single cycle (No instruction actually executes in a single cycle in deeply pipelined CPUs), you need to deepen the pipeline, which impacts your performance when you must flush the pipe.

      Increased orthogonlaity will reduce code density, which either must be offset by ever larger caches and more memory bandwidth. You likely get more throughput by optimizing the instruction set for density rather than orthogonality.

      Also it strikes me that most software I see that is actually CPU bound is mostly trivially paralellizable. I am sure the exceptions are numerous, but for the broad market this seems correct.

      As for the difficulty of doing parallel development, try recruiting hardware designers. Hardware is all parallel.

    58. Re:Convince your boss. by svirre · · Score: 1

      Most general purpose software isn't CPU bound, so who cares if it is hard to parallelize, it won't benefit anyway.

      Only CPU bound apps need to be considered for parallelization.

    59. Re:Convince your boss. by Chandon+Seldon · · Score: 1

      Most real-world problems are boring, single-threaded, input-process-output problems.

      This simply isn't true. Many real-world *programs* are implemented that way, but that's a side effect of the hardware platform rather than something required by the problem statement.

      But even if you were right, you'd still be asking the wrong question. Only problems best solved by CPU-bound programs really matter here. Among those, it's difficult to come up with examples that don't admit to parallel implementations (hence compiling C programs) and even harder to come up with examples that don't give you parallelism anyway in practice (as C compilers do).

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    60. Re:Convince your boss. by VoidEngineer · · Score: 2, Interesting

      Fyi, you need an evolution algorithm to set up a population of A* algorithms to effectively use the 1000 processors. The evolution algorithm then sets the routes up to basically compete with each other, and mixes-and-matches different routes, looking for the most fit one. It's a fairly well understood bit of computer science, and scales effectively.

      And for what it's worth, evolution algorithms and genetic algorithms are going to be all over the place in 5 or 10 years, because they can handle 1000 or 10,000 cores without any problems. They're sort of like 'meta-algorithms' for parallelizing a linear algorithm. The only requirement is that the linear algorithm has to be set up to compete with other copies of itself. So you then have to deal with a bunch of stuff like encoding populations of potential answers, creating mutation and crossover operators, defining selection thresholds, and creating competition scenarios.

      The most difficult part, in many respects, is creating an intuitive user interface for all of it.

    61. Re:Convince your boss. by aminorex · · Score: 1

      You would be amazed at how much of "compiling a file in C" can be done in parallel. The fact that you've always thought of it in sequential terms and been taught about it exclusively in sequential terms does not make it an inherently sequential task. Not only the sequential order of operations but also many or most data dependencies are artificially imposed: The same result can often be derived using alternative, shallower, dependency partial orders.

      --
      -I like my women like I like my tea: green-
    62. Re:Convince your boss. by cleatsupkeep · · Score: 1

      I understand why my post was confusing, but I was referring to processing speed in GHz or MHz. Power was a poor choice of words there. Sorry for confusion. However, if we replace power with processing speed, my post will be correct.

    63. Re:Convince your boss. by Anonymous Coward · · Score: 0

      what if I was using a browser that separated that into 50 separate processes

      Nit: Tasks. Not processes. Processes are less efficient than threads and the only argument for using processes instead of threads is "we're too lazy to do it right"

    64. Re:Convince your boss. by Locutus · · Score: 1

      one of the things I head added massive amounts of friction between the Microsoft software people and the IBM software people regarding OS/2 was that Microsoft wanted to OS to be designed specifically to make the foreground application more responsive at the kernel level while the IBM guys wanted a small fast OS kernel and a scheduler which was fair across the board.

      We saw what that did to multi-process applications and loading the Microsoft OS up with a few processes. System crashes and very poor multi-tasking. OS/2 rocked even where there were dozens of server and background processes pulling at the CPU and the only big pain was that single input queue issue the GUI had and even that was mitigated by 1994/Warp 3 IIRC.

      Microsoft just has a tough time letting the designers make the kernel a kernel and therefore making the OS more stable and efficient. They are marketing top heavy and tons of junk keeps getting mangled into the bowels of the OS. Keeping thing mostly separated is what now make Linux so stable and much easier to patch and fix as needed.

      But still, those large apps doing alot of image manipulations need threads to keep the UI useful while things are going on in the background. When you know somethings going to take a few minutes to compute, it really makes it nice when the user can work on the next task.

      LoB

      --
      "Anyone who stands out in the middle of a road looks like roadkill to me." --Linus
    65. Re:Convince your boss. by Anonymous Coward · · Score: 0

      "This to me sounds like laziness. "But parallel programming is HARD!""

      You could just as easily invert that; from a certain pragmatic point of view, this is like the hardware designers saying "but hardware design is HARD! We'll just do [easier thing] and let you software guys figure it out yourselves!"

      The obvious flaw in the hardware designer logic here is that software does not exist to serve hardware - hardware exists to run software. Previous additions to hardware didn't come about because the hardware companies decided that's what they would offer the programmers. What comes immediately to mind is one time where Intel tried to dictate hardware to the programmers. This got us the Itanium, which failed in part because it didn't meet the needs of the real world.

      Blindly throwing 80 of the same type of CPU core we have today into one package will probably likewise stumble and fail; today's CPU architecture isn't *really* designed to be that massively parallel, and relying on more complicated software to cover for it is an ugly hack that won't work all that well. At the very least, we'll need to revamp memory architecture and caching to resemble something more like what the supercomputers do, and we'll probably need hardware support for CPU core process/memory affinity - THEN the OS guys will have the tools to rewrite the deepest guts of the dark art of scheduler code, and THEN the more everyday programmer will have the tools to begin effectively welcoming our new ubercore overlords.

    66. Re:Convince your boss. by earthbound+kid · · Score: 1

      Speed of light: 3 x 10^8 m/s
      Reasonable chip size: 1cm
      Ask uncle Google about "(300 000 000 (m / s)) / (1 cm)"

      Response: 30 gigahertz

      We will never see another 10x speed up on the basis of clockrate. Forget the heat thing (although that's also a killer), clockrate is dead, dead, dead.

    67. Re:Convince your boss. by Platinumrat · · Score: 2, Interesting

      Well there is one industry that is currently going the other way, just because of the limitations of CPU technology. That industry is railway signalling. Traditionally they have designed their algorithms and process based on the premise that everything is done in parallel. They then implemented their programs on a massively parallel processing systems. Have you ever seen a Signalling Interlocking. It's made up of 1000s or more individual relays. Thing is, even though switching times for relays are many orders of magnitudes slower than Solid state devices, I've never seen a Computer Based Interlocking operate as quickly as a Relay Based Interlocking. The reason.... because we've taken an essentially parallel process and implemented it on a serial processing device. In fact it's a little worse than that, because of the safety issues involved. With the parallel processing model you could verify safety quite simply, due to the simple processing model of each processing unit. With the serial model, it is difficult for software engineers to verify safety, since everything shares the same address space and I/O mapping, so extra checks and balances need to be put in place. I used to think railway signalling was a very conservative field until I read the OP. Now I'm not so sure. :P

    68. Re:Convince your boss. by Locutus · · Score: 0

      That just shows an example of what can be done in Java and labeling it awkward. You made no sale for what would make functional programming better. Are you saying that because you can not, in functional programming, do what you showed in the string reverse that it is therefore better?

      And just because Windows developers have a difficult time with multi threading programming, is it better to create a whole new programming paradigm? OS/2 programmers were not some special breed or anything and they seemed to handle this issue very well over 10 years ago.

      It seems very strange to me that without promoting multi-threading, someone or group found that it's better to spin developers in a different direction. There just seems to be way too much of a marketing swing to this. IMO.

      LoB

      --
      "Anyone who stands out in the middle of a road looks like roadkill to me." --Linus
    69. Re:Convince your boss. by philipgar · · Score: 1

      Sure, you could try expanding the instruction set, and reach the point where a single instruction can do the work of 5-10 instructions. . . . Unfortunately doing this will likely reduce your operating clock frequency by a factor of 5-10, while increasing power and area by a similar ratio. Net gain, next to nothing. Plus of course, now instructions end up taking up 5-10 times as much storage space.

      The problem is that all reasonable methods for improving the performance of single threaded code in convential ISAs requires changing the programming paradigm (backwards compatibility is still more important than power/performance). The first method people used was pipelining the processor core. This worked, and let chipmakers ramp up the clock frequency. However, it has limited gains. For one, there is a limit to how deep you can pipeline your work, because at the bare minimum your clock cycle has to be the speed of a latch, and one degree of logic (otherwise you're not doing anything in a single pipe stage and/or can't store the results). We reached the point where we couldn't feasibly increase the pipelining depth, and increasing it further pushed up the clock speed a little bit, but didn't actually improve performance (think Pentium 4). What else can be done ? Well, one idea that's been used for a while is executing multiple instructions at a time. We're doing this, modern processors can execute 3-4 instructions in a single clock cycle, of course they average around 1...

      We could try going further with this idea, but limit studies have shown that their is no feasibly way to gain considerable performance out of current codes by looking at more instructions simultaneously. There is just a lack of parallelism available in single instruction streams. Secondly, memory and branch prediction greatly reduce the performance that a wide superscalar can achieve. Even a branch predictor that only misses one out of a thousand instructions is missing too frequently to obtain high performance on an 8-16 wide core.

      The next logical steps are extensions to the ISA. This is being done, but still requires better compilers. SSE2 etc can greatly speedup vectorizable codes. Of course, the compilers fail here normally, and the only reason this gives a speedup is because it involves people specifically coding for a parallel architecture.

      There are other methods being investigated to achiever higher performance, however all of them involve a new programming paradigm to some extent. Personally, I don't think functional programming is the answer. It might be part of an answer, and it might help with some stuff, but it's just an unnatural way to express statements. More explicitly parallel languages like verilog might become more common, however these are much harder to use than traditional programming languages.

      What needs to change is the overall way we think about programming. We're taught to take problems and express them serially. Doing anything else is unnatural in most languages. Serial programming allows determinism in the code, and as we go forward, we need to reduce our need for determinism, or first split up an application into parts that can be performed deterministically, and parts that don't need to be. This will help with improving parallelism. Additionally, we need far better debug tools. Running multiple instances of GDB trying to trace threads just doesn't hack it. This will also require far greater unit testing in code development.

      The good news however is that many applications don't need to be faster. They are fast enough as they stand, and only small sections need to be accelerated. The vast majority of code is for special case conditions that are rare anyhow, so we need ways to accelerate the cores of applications without worrying about the rest. As we go forward I think this will become an increasingly popular option. It won't be easy, and at a high level, applications need to be restructured to support greater parallelism. Whether we'll see parallelism a

    70. Re:Convince your boss. by TemporalBeing · · Score: 2, Interesting

      OpenMP is great...

      True. OpenMP is great. But it's not the only solution.

      OpenMP, MPI, and all are pretty much only useful if you are programming for a multi-computer (not multi-core, or multi-proc) environment - e.g. supercomputer.

      When dealing with just one computer and either multi-proc or multi-core, there's a much simplier solution: locks. Works great with doing multi-threaded and even multi-processed programming.

      Most programs would simply benefit from having a second thread. (Ever wonder why your program's interface hangs? Usually because it's only one thread and it's in a processing loop and not updating the GUI. A second thread solves that.)

      And multi-document programs (e.g. FF, IE, etc.) benefit by having 1 main thread, and another for each document. (Thread, Process, take your choice. Either way...it benefits.)

      But you also have to remember - your program is not the only program on the system. So additional cores that you are not using can be provided to a different program so it can run in parallel, thus making the computer more useful for the user - and let them do more, faster - even if its not with your program.

      --
      Truth is like the sun. You can shut it out for a time, but it ain't goin' away. - Elvis Presley (source: imdb.com)
    71. Re:Convince your boss. by Anonymous Coward · · Score: 0

      Someone could design an algorithm that, given an n-core chip, uses n-1 cores to calculate a way an executing program can use 1+ cores to execute, regardless if the result is achieved faster. Now we're getting somewhere!

    72. Re:Convince your boss. by Anonymous Coward · · Score: 0

      dude, the parent commenter didn't say they still used OS/2.

    73. Re:Convince your boss. by Anonymous Coward · · Score: 0

      You're insane. Most real-world problems are sequential. Take a payroll calculation for example. First you have the gross pay, then you take out taxes, then you take out contributions, then you take out deferred comp, and whatever's left goes on the pay stub.

      You're just desperate to pound everyone's square pegs into your functional programming round hole. Soak your head until common sense returns.

    74. Re:Convince your boss. by SanityInAnarchy · · Score: 1

      I wouldn't actually count Erlang among them -- at least, not for this discussion.

      Haskell, I believe, can automatically parallize a given function.

      Erlang, on the other hand, requires you to manually spawn "processes" and distribute work for them, and makes this process easy enough that it's really not painful to do yourself. It is vaguely-functional, but more importantly, it's actually an imperative, single-assignment language which is insanely good at message-passing and crunching binary data.

      --
      Don't thank God, thank a doctor!
    75. Re:Convince your boss. by SgrA* · · Score: 1

      I currently have 43 named processes running on my freshly booted XP system, including the cryptic svchost. Adobe and Google background processes, Norton and MS anti-virus, and Iexplorer take up a lot of my total cpu resources. If I could simply assign each one of these resource hogs to a different core, and save one or two for my own personal use, I would be a happy man.

    76. Re:Convince your boss. by shutdown+-p+now · · Score: 1

      game developers have long taken advantage of dedicated vector coprocessors with highly-specialized instruction sets and architecture made specifically for 3D gaming.

      For an interesting perspective on parallelization in general, and FP use in particular, specifically in the game development field, it's worth reading through Tim Sweeney's presentation "The Next Mainstream Programming Language: A Game Developers Perspective". It specifically mentions referential transparency, STM, and Haskell quite a lot :)

      For those who don't know who Tim is - he's the developer mastermind behind the Unreal Engine technology, ever since the very first Unreal game.

      What's even more interesting is that the presentation is 3 years old now. So, on the subject of TFA: yes, it's definitely time, and has been for a while!

    77. Re:Convince your boss. by ancienthart · · Score: 1

      personally, i think in terms of commodity computing, we don't really need to squeeze any more power out of the CPU than we've already got. use fully pipelined superscalar architectures, perhaps multithreaded dual or quad cores (for high-end workstations) and VLIW to maximize ILP efficiency. even at current processor speeds, 99% of the applications people (especially casual computer users) use have bottlenecks elsewhere (like memory & disk I/O speeds, internet bandwidth, user response time, etc.).

      Oh, is this ever true or what! Even with non-commodity computing like quantum chemical calculations, I found during my honours years that the true bottlenecks were:
      1. Use of optimised BLAS libraries to use L1 and L2 caches efficiently, (I nearly had a heart-attack the first time I ran PC-GAMESS on a wine emulator and a 3+ day job on the Linux binary was finished in less than 4 hours on an _emulated_ windows binary.)
      and when I compiled using an optimised ATLAS BLAS library,
      2. Disk access speeds.
      Recently using my modern laptop and optimised ATLAS BLAS, programs like GAMESS usually spend about ~20% of time CPU bound and ~80% disk-drive bound. And this was with a dual-core system. What I wouldn't give for the ability to RAID-0 my laptop's hard-drive(s).

    78. Re:Convince your boss. by Torham · · Score: 1

      OpenMP, MPI, and all are pretty much only useful if you are programming for a multi-computer (not multi-core, or multi-proc) environment - e.g. supercomputer.

      Actually, OpenMP is only for use with shared memory (multi-core/multi-proc) computers.

    79. Re:Convince your boss. by Chandon+Seldon · · Score: 2, Informative

      You're insane. Most real-world problems are sequential. Take a payroll calculation for example. First you have the gross pay, then you take out taxes, then you take out contributions, then you take out deferred comp, and whatever's left goes on the pay stub.

      First, I'm not sure that I would use accounting procedures as my example of a "real world" problem, but whatever.

      There are two more direct reasons why payroll computations aren't the sequential problem you're looking for. First, they're not CPU bound. No-one's saying that it would be so much easier to do a payroll calculations if their CPU were just twice as fast. Second, most companies doing payroll calculations have more than one employee. Sure, the procedure you described is serial - but there's no reason you can't do it for every employee simultaneously in parallel and still get correct answers.

      A similar thing is true for many other problems: One instance is serial and computationally trivial, in order to be computationally expensive you must have many instances, in which case your whole problem is naturally very parallel.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    80. Re:Convince your boss. by dmhayden · · Score: 1

      I disagree. Software programmers followed hardware designers into 64k segments, expanded memory, tiny, small, large and huge pointer, memory overlays and on and on, just because that's what was available. If your competitor's software takes advantage of 20 cores and yours doesn't , you're going out of business.

    81. Re:Convince your boss. by dgriff · · Score: 1
      Most real-world problems are parallel problems. Even the ones that aren't (say... compiling a file in C) you can usually run a lot of instances of in parallel.

      Actually, compiling a file in C is a pretty good example of something that can be broken down into parallel bits. At the lowest level you are reading the file and running the C pre-processor on it. Put that in one thread and pass the output to another. Then your are dividing it up into tokens - put that in another thread. But most importantly, you have (usually) a bunch of functions each of which can be compiled separately from each other.

      There is loads of scope for parallelization.

    82. Re:Convince your boss. by DragonWriter · · Score: 1

      Your idea is not feasible because it screws up too many marketing campaigns.

      Actually, the "speed up cores rather than increase the number of them" was the dominant trend, and the center of most marketing campaigns, up until chip manufacturers absolutely couldn't do it anymore without making chips that melted themselves.

      After tha, when despite the fact that both engineering efforts and marketingt campaigns had been centered around the GHz race, chip manufacturers realized they needed to go somewhere else, and multiplying cores is what worked.

      So saying speeding up cores isn't viable for marketing reasons is completely backwards.

    83. Re:Convince your boss. by pthisis · · Score: 1

      Find&Replace

      This is not easily parallelizable in general, though many trivial cases are (and are common enough to be worth optimizing). But greedy regexes (most common non-static search strings) are notoriously difficult to parallelize.

      --
      rage, rage against the dying of the light
    84. Re:Convince your boss. by Anonymous Coward · · Score: 0

      So I should start thinking about working with 4 mice and 8 keyboard simultaneously?

      App development will need to largely remain single-threaded, for the very fact that there is one display, one keyboard, one mouse.

      Of course, that's not to say that you can hive off some tasks to other threads for the sake of parallelism (eg collision detection and heavy computational tasks), but there is a frighteningly small use for this.

      Would it make sense to make M$ Word multicore? I think not.

    85. Re:Convince your boss. by fyngyrz · · Score: 1

      the best we have is new versions of the same programs with layer upon layer of feature creep

      It's not feature creep. It's slower technologies being used to create the products. Go back to C, use decent programming techniques, and your apps will fly unless they're waiting on resources like the HD (and even that is going away... SSDs, etc.)

      I'm responsible for an app that has hugely appreciated in features, and has not slowed down even a fraction, because the architecture of the app was designed well enough in the first place, and the core technologies chosen (C) such that it flies perfectly happily under all versions of the OS and underlying hardware to date. It ran fine on a 200 MHz 486 with 16 megs of RAM; it bloody well tears up the road on a 3 GHz machine with 4 gigs of RAM. :o)

      --
      I've fallen off your lawn, and I can't get up.
  2. Broken Algorithm BS by marnues · · Score: 5, Insightful

    When you move to FP, all your algorithms break

    If moving to a functional programming language breaks your algorithms, then you are somehow doing it wrong. That line doesn't even make sense to me. Algorithms are mathematical constructs that have nothing to do with programming paradigm. Assuming the language is Turing complete, how is that even possible?

    1. Re:Broken Algorithm BS by marnues · · Score: 5, Insightful

      Christ on a crutch...I didn't even pick up on it the first time around. How can Moore's Law ever be a software issue? I can accept that most people don't care about transistor count, but saying it can somehow become a software issue is just too many steps removed from the original meaning. I love functional programming languages, but this article is hurting my brain.

    2. Re:Broken Algorithm BS by irtza · · Score: 0

      the way I loosely (I guess strict interpretation would likely just lead to a contradiction) interpreted this is that the algorithms are not directly applicable. In other words, you have to pick a new algorithm to accomplish the same job without incurring some form of a penalty. Maybe I'm wrong, but this makes sense in my world... now I await the reply from the folks who can not tolerate deviation from the strictest rules of language. You know, let me make this easy for them: I am going to

      --
      When all else fails, try.
    3. Re:Broken Algorithm BS by sexconker · · Score: 5, Insightful

      While algorithms won't break, you'll certainly have to rewrite a lot of them to take advantage of multiple processors.

      This problem is not new.
      The solutions are out there, and are also not new.

      Article is pure shit.

    4. Re:Broken Algorithm BS by reginaldo · · Score: 5, Informative

      Moore's Law becomes a software issue when we need to change our coding paradigm to use all of the cores on the chip. The hardware holds up it's end of the deal, but we need to develop software that utilizes the hardware correctly.

      That's where FP comes into play, as it allows developer's to develop heavily parallelized code that is also safe and fault-tolerant.

    5. Re:Broken Algorithm BS by Anonymous Coward · · Score: 2, Informative

      No, it makes sense.

      If you want to keep seeing Moore's-law increases in CPU performance, the improvements are no longer going to come from throwing more transistors at single-threaded programs. We hardware engineers are simply out of smart ideas to eke exponentially better performance out of a single instruction stream.

      Instead, we're going to produce chips with more parallelism -- more cores and more threads. But it's going to take a lot of software work (languages, transactional memory, libraries, et cetera) for these improvements to translate to functionally faster computers.

      Hardware is going parallel, like it or not. Software has to change as well.

    6. Re:Broken Algorithm BS by Anonymous Coward · · Score: 1, Interesting

      Turing complete doesn't mean the running times are the same. Your algorithms don't break in the sense that they no longer produce the correct output. They break in the sense that their running time is multiplied by some polynomial function of the input size; i.e. they are broken for practical purposes.

    7. Re:Broken Algorithm BS by thermian · · Score: 1

      How can Moore's Law ever be a software issue?

      It can't be. What we have here is hero worship. A simple statement made in a magazine that few people read has been elevated to the status of eternal truth.

      Moore's law is a hardware thing, and has been applied to more and more improbable situations in recent years. I suspect this is because many people in computer science feel envious of the laws other disciplines enjoy. Computer science has few of its own, and of those few, this is the most often quoted.

      Any transposition to software is without merit. Therefore any line of reasoning using this as a basis is irredeemably flawed.

      It is true that the multi core 'revolution' means we have to change our ways. I'm in the midst of a total re-write of my open source product for this very reason. However my choice of language has been determined by suitability to the problem, not fluffy nonsense about Moore's law and it isn't a functional language.

      --
      A learning experience is one of those things that say, 'You know that thing you just did? Don't do that.' - D. Adams
    8. Re:Broken Algorithm BS by Jhyrryl · · Score: 1

      I believe the intent of the statement is that all of your patterns break. For example, as TFA points outs, in functional programming expect to use "Recursion as the primary tool for iteration."

      Any of your programming patterns that use loops would instead use recursive function calls.

      --
      Jhyrryl
    9. Re:Broken Algorithm BS by Anonymous Coward · · Score: 5, Informative

      It's true that Moore actually said the transistor count doubles every 18 months. However, for a long time, an immediate corollary of Moore's Law was that software doubled in speed every 18 months, which is essentially why Moore's Law as important. I think what they author is trying to say is that in order for this corollary to remain true, people must learn to write parallel software. It is much easier for a compiler to get an FP running in parallel than a sequential program (SP) running in parallel. Hence, those who can write in FP languages will be better suited to write the software of tomorrow than whose who can only write in SP languages.

    10. Re:Broken Algorithm BS by DoofusOfDeath · · Score: 2, Informative

      If moving to a functional programming language breaks your algorithms, then you are somehow doing it wrong.

      Easy. Pure functional programming doesn't permit side-effects. Algorithms that perform I/O at various points in the algorithm can't easily be expressed in languages like that.

      Also, although some popular functional languages like ML and Erlang have hacks to get around this, purely functional programming doesn't like a function modify global state. Without those hacks in the language, algorithms that require in-place modification of arrays (such as some sorting algorithms) can't be expressed at all in those languages. (You can modify the algorithms to not do in-place modifications of arrays, but then that's not the original algorithm any more.)

    11. Re:Broken Algorithm BS by Sancho · · Score: 2, Interesting

      Moore's law dealt specifically with hardware. To say that "Moore's law is now a software problem" shows as much of a misunderstanding as attributing "any mention of Nazis causing someone to immediately lose the argument" to Godwin's Law[1].

      It's reasonable to suggest that increasing the speed at which software runs will start requiring learning multi-threaded programming techniques, but to say that software will allow Moore's Law to continue is incorrect.

      The idea that performance will increase at the same rate as doubling of transistors is attributed to a colleague of Moore. I have not heard of a moniker for this "law."

      [1] Godwin's law states that as a USENET thread increases in length, the probability of a comparison to Hitler or a Nazi goes to 1. Godwin's law states nothing about the thread ending or about a winner or loser.

    12. Re:Broken Algorithm BS by DiegoBravo · · Score: 3, Insightful

      >> How can Moore's Law ever be a software issue?

      In a sense, it can be: if we start rewriting Java/C#/VB apps in assembler, I'm pretty sure the performance will at least double each year, and we can forget about those cores for good.

    13. Re:Broken Algorithm BS by Anonymous Coward · · Score: 0

      I'll try to describe the intent ...

      The chip and hardware people are starting to acknowledge that they are running into limitations of heat dissipation, physics and materials science - these limitations ( while not impossible or even forever) are putting a crimp on how new chips are tracking with the predictions that Moore made.

      These people have also generalized Moore's law enough that they focus in on "computing power" rather than "transistor count".

    14. Re:Broken Algorithm BS by Free+the+Cowards · · Score: 3, Interesting

      Think of it as being "Moore's law is now also a software problem".

      In the past, Moore's law meant that you could buy new hardware and have your stuff go way faster without any further work.

      Now, Moore's law mainly means that you get more parallelism. Without software work, this means that your stuff runs at the same speed it used to. Thus software also needs to change in order to obtain the benefit.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    15. Re:Broken Algorithm BS by dubbreak · · Score: 0, Offtopic

      (the) Article is pure shit.

      I could have sworn I saw a few kernels of corn and a peanut or two in there.

      --
      "If you are going through hell, keep going." - Winston Churchill
    16. Re:Broken Algorithm BS by Esvandiary · · Score: 0

      However, for a long time, an immediate corollary of Moore's Law was that software doubled in speed every 18 months, which is essentially why Moore's Law as important.

      That's true until you consider May's Law, which states that software efficiency halves every 18 months to make up for it.

      ... And it's a depressingly true-to-life law.

    17. Re:Broken Algorithm BS by Ihmhi · · Score: 4, Interesting

      Well we've been using the same basic single-core architecture for the last, what, 30 or 40 years? Now programmers have a much bigger challenge in front of them - taking a program and make it work in a new environment.

      I don't honestly believe there's been much in the way of innovation in the programming world for a while. Sure, you might have new coding languages that can do some things better than others or process it a different way, but don't they all operate on the same basic principle? Now programmers are faced with a complete paradigm change - the old style of programming isn't going to cut it 10 years from now when everything from your computer to your coffeemaker has a multi-core processor.

      Engineers deal with stuff like this all the time. More than a few programmers use the term "software engineer". It's finally time for them to prove they can live up to that name and innovate.

    18. Re:Broken Algorithm BS by Anonymous Coward · · Score: 0

      May's Law is a very humorous and practical doctrine, and to which I have but one objection, namely, that it is not true. Look at what you could do with computers 50 years ago, and look at what you can do with them today. It's obvious that we are getting more out of the increase in transistor count.

    19. Re:Broken Algorithm BS by FredMenace · · Score: 2, Insightful

      The idea is that it's still easy to add more transistors, but no longer easy to make them run faster. That is why they are moving to multiple cores - they can add three (or even 15) cores far more easily (and using much less energy and putting off much less heat) than they can make a single core run at twice the clock rate.

      Moore's law still exists in hardware, but it's manifested in a different way than it had been until a few years ago, due to physical limitations that don't appear to be going away any time soon. But software needs to adjust for those changes to benefit us in the real world.

      Of course not all individual tasks can be sped up with parallelization, but many tasks, and the overall computing experience, probably can be.

    20. Re:Broken Algorithm BS by Anonymous Coward · · Score: 2, Insightful

      You may be right. It just might double in speed (though not every year, just once), but the number of bugs will increase 1000-fold.

    21. Re:Broken Algorithm BS by rxan · · Score: 1

      Moore's law is just that the number of transistors will double in chips every X years. I don't think it says anything about the power the CPU produces or how it produces it (number of cores, and frequency per core).

      So Moore's law isn't anyone's problem but the hardware people. If fact it wasn't even a law, just an observation that Moore made at the time and it happened to continue.

      It's the hardware people who have created a problem for us programmers by increasing the number of cores instead of increasing the frequency of each core.

    22. Re:Broken Algorithm BS by Goaway · · Score: 1

      Algorithms are mathematical constructs that have nothing to do with programming paradigm. Assuming the language is Turing complete, how is that even possible?

      Because Turing only says what is possible, not what is efficient.

      And many, many algorithms are designed around mutable state. Pure functional programming doesn't have that. You can implement something which emulates mutable state, but it will be incredibly inefficient.

    23. Re:Broken Algorithm BS by jlarocco · · Score: 4, Informative

      Moore's Law becomes a software issue when we need to change our coding paradigm to use all of the cores on the chip.

      Moore's law states that the number of transistors on a chip will double every two years. By definition it's a hardware problem.

      Obviously, utilizing those transistors is a software problem, but Moore's law doesn't say anything about that.

      The article sucks. The author seems to know FP about as well as he knows Moore's law.

    24. Re:Broken Algorithm BS by Free+the+Cowards · · Score: 1

      It is true that Moore's Law was much more limited in scope than people generally take it to mean, as you indicate. It's usually taken to mean not only the law itself (increasing transistor counts) but the benefit that comes from that law. Used to be that the benefit was essentially automatic. You bought a new computer, loaded your software on it, and it was all twice as fast. That's not happening anymore, so the task of extracting a benefit from Moore's Law is falling on both software and hardware now. That's all it was trying to say.

      This adversarial attitude floating around in these comments that the hardware engineers have "created" the problem is bizarre. It's not like they all got together one day a few years ago and decided that increasing clock speeds was too hard and so let's not do it anymore. They're hitting fundamental limits which is why they're heading for more explicit parallelism rather than simple clock speed increases. It's not like they have a choice about it.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    25. Re:Broken Algorithm BS by ShieldW0lf · · Score: 1

      Seems to me that putting a server cluster in a single box doesn't really seem much more complex to program for than a server cluster in a rack is. Those with skills in building distributed internet applications should be well positioned to take advantage of the "avalanche of cores".

      --
      -1 Uncomfortable Truth
    26. Re:Broken Algorithm BS by jfmiller · · Score: 1

      Rule fro parallel functional programming:

      • All data is immutiable
      • All function must be pure (without side effects)
      • No Shared State

      This means no loops! Most algorithms that are stated in imperative form take a non-trivial amount of effort to restate in functional form. The only saving grace is that the opposite is true as well, and a lot of things are hard in imperative languages become ridiculously easy in functional ones. The bad news: q-sorts and Fibonacci become easy while User Interface gets a lot harder.

      --
      Strive to make your client happy, not necessarly give them what they ask for
    27. Re:Broken Algorithm BS by ClosedSource · · Score: 2, Interesting

      It's rather funny that you say that the same hardware architecture has been used for the last 30 to 40 years and then observe that there hasn't been any innovation in the software world "for a while".

      Multicore isn't an innovation, it's a product of a lack of innovation in the hardware world.

    28. Re:Broken Algorithm BS by narcberry · · Score: 1

      I'll engineer it, once there is a new radial option in my IDE.

      --
      Modding me -1 troll doesn't make me wrong.
    29. Re:Broken Algorithm BS by Anonymous Coward · · Score: 0

      Engineers deal with stuff like this all the time. More than a few programmers use the term "software engineer". It's finally time for them to prove they can live up to that name and innovate.

      The problem with making parallel algorithms is not new. We have know since the 70's that parallel algorithms are orders of magnitude more difficult to debug and test. In fact there is a whole branch of model checking devoted to checking for limited set of concurrency issues.

      Most software engineering techniques rely heavily upon testing to provide quality assurances. With parallel algorithms, testing provides almost not guarantees because of the combinatorial explosion in the test cases that you will need to test all the timing paths. And no, engineers don't deal with stuff like that all the time because if they did they simple would fail get the job done correctly.

    30. Re:Broken Algorithm BS by DiegoBravo · · Score: 1

      >>> though not every year, just once), but the number of bugs will increase 1000-fold.

      Of course that full year is needed for debugging...!

    31. Re:Broken Algorithm BS by Locutus · · Score: 1

      yup, it became a software problem when moores law required duplicating cores instead of making cores faster. It was pretty obvious that something was up back when Intel couldn't get its CPUs clocking over 1.5GHz and had to resort for splitting up functionality and clocking up some parts while other parts clocked at the 1.5GHz range. They have passed that now with SoI and by die shrinkage but the fact remained, they hit a wall. The only way to keep Moores law from falling was to double the core, then quadruple, etc.

      It's now a software problem because multi-threading applications died with OS/2 in the mid 90s. Windows developers don't do it if at all so someone invents a new process based multi-processing scheme and labels it "functional programming". Yet another hassle to deal with the inadequacies of the Microsoft OS design... owwww, let's all rush to learn it. NOT. How about we bring back CORBA, that'll spread the load across CPU cores too.

      LoB

      --
      "Anyone who stands out in the middle of a road looks like roadkill to me." --Linus
    32. Re:Broken Algorithm BS by Locutus · · Score: 1

      developers need to find some of the old OS/2 books and start multi-threading their applications. When I see the hourglass on a 4GH dual core I think to myself WTF was the developer of this app thinking. For some reason, multi-threading died when OS/2 was knocked out in the mid 90s. From then on, application developers had very little to work with as far as multi-threading goes or nobody made that an issue. Most all OS/2 apps were very nicely multi-threaded and usage on even old hardware showed smooth operation under load because of it.

      Who created this functional programming buzz anyways and why hasn't anyone asked why they aren't talking about multi-threading? Something seem fishy or those covering this stuff are just doing PR work for someone.

      LoB

      --
      "Anyone who stands out in the middle of a road looks like roadkill to me." --Linus
    33. Re:Broken Algorithm BS by FlyingBishop · · Score: 3, Insightful

      I think Moore's law somewhat implies that those transistors will be used. It suggests an increase in computational power to parallel the number of transistors, and if the transistors go unused, they effectively do not exist.

      By the same token, I'll believe that FP is the way of the future when I see it. Don't get me wrong - in a lot of ways I like functional programming. Recursion is so much more straightforward than iteration. However, tasks that can be completed with an iterative polynomial-time algorithm often end up exponential when recursive. Of course, a bit of tail recursion and you can deal with that, but some things aren't easily tail recursed (I believe that is what TFA means by all your algorithms break.) And really, when it comes right down to it, tail recursion is just contorting an iterative approach to look recursive.

    34. Re:Broken Algorithm BS by Anonymous Coward · · Score: 1

      Or you can just use Haskell or any other pure programming language with monads, which allow you to express imperative algorithms in a pure language. Basically, it comes out to switching to "imperative mode" with access only to that information and the returns the result. The code for quicksort (one such sorting algorithm) could probably be written such that the branches only get access to their half of the array, so the compiler knows it is safe to parallelize if it wants to. Also, although modifying state is not allowed, replacing the only reference to an object with a modified version is often used in functional programming and the compiler should usually have not trouble telling that it can convert that to a plain imperative update.

    35. Re:Broken Algorithm BS by jellomizer · · Score: 1

      Functional Languages tend to deal more with recursion. Procedural languages deal mostly in loops. I am not saying you can't do recursion in procedural languages (you can) also you can do loops in functional languages however when you move from one language to an other. A good programmer will change their methodology to match the preferred coding styles of the language. When I code in C/C++ I keep my variables lower case. When I code in Vb I mix Upper and lower case. In some languages I will not use some prefix and others I will. So you have a algorithm that goes in a loop to do its work. WHen you go functional you need to think of a recursion method of giving the same result. thus changing your algorithm

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    36. Re:Broken Algorithm BS by Timothy+Brownawell · · Score: 1

      Most software engineering techniques rely heavily upon testing to provide quality assurances.

      I'm not sure such a lack of proper design really counts an "engineering".

      With parallel algorithms, testing provides almost not guarantees because of the combinatorial explosion in the test cases that you will need to test all the timing paths.

      That means that you're doing it wrong. It should at all times be clear what data is owned by what thread. Race conditions should be designed out and the code reviewed for adherence to the design, or you could use one of the languages that don't have a way to express race conditions.

      And no, engineers don't deal with stuff like that all the time because if they did they simple would fail get the job done correctly.

      And because they're legally required to know what they're doing.

    37. Re:Broken Algorithm BS by Anonymous Coward · · Score: 0

      You oppose "sequential programming" to functional programming, and actually use the term "SP languages" (as in "sequential programming languages") in opposition to functional programming languages and you get rated insightful?

      Maybe instead of guessing you should actually read a bit about functional programming (and programming in general). Might learn something.

    38. Re:Broken Algorithm BS by Anonymous Coward · · Score: 0

      Maybe that should be replaced with:

      "Keeping up with the predictions made by Moore's law is now a software problem".

      Of course, it was never a purely hardware or software problem. Still isn't. But that's not the point the article's trying to make. It's about the growing importance of programming in increasing computer performance.

      Programmers have been able to get away with sloppy programming habits (witness the rise of bloatware and Microsoft). Now it's going to have to get leaner and meaner.... and, more to the point, more parallelizable (something functional languages like Erlang were designed for).

      Programmers should be excited about the growing importance of programming, not cowed by it. Take the challenge. Learn something new. The world will be a better place for it.

    39. Re:Broken Algorithm BS by rxan · · Score: 1

      I'm not saying they intentionally created a problem, either. But a problem it is for programmers right now.

    40. Re:Broken Algorithm BS by Phantom+of+the+Opera · · Score: 1

      I ran OS/2 and was impressed. Don't forget BeOS, another OS that was designed around multi processor boxes.

      This isn't anything fancy and new. These ideas have been around for a long time.

    41. Re:Broken Algorithm BS by iminplaya · · Score: 1

      Look at what you could do with computers 50 years ago...

      I pine for the things we could do without a computer 50 years ago. Like buy a quart of milk.

      --
      What?
    42. Re:Broken Algorithm BS by jbolden · · Score: 3, Insightful

      It isn't recursion vs. iteration but rather pure vs. environmental (i.e. mutable variables) that make parallelism safe.

    43. Re:Broken Algorithm BS by Locutus · · Score: 1

      that's right, BeOS was also very much a heavy user of multi-threaded applications. IIRC, the multi-threading was throughout the kernel too and what made it so responsive.

      I was quite upset when Palm purchased the company and did nothing with the OS. Not to mention completely failing to make a decent OS for the Palm devices.

      BeOS was cool and I just loved that video cube demo and the simulated paper book page turning demo. An awesome OS but it too was blocked by PC OEMs who signed contracts restricting them from being able to install any other OS but Microsoft's.

      LoB

      --
      "Anyone who stands out in the middle of a road looks like roadkill to me." --Linus
    44. Re:Broken Algorithm BS by jbolden · · Score: 0

      Monadic methods (for things like mutable arrays) don't allow you to be parallelism safely. You have to pick here, you can have parallelism via. purity or ease of conversion via. mutability.

    45. Re:Broken Algorithm BS by Anonymous Coward · · Score: 0

      When I say sequential programming languages, I mean languages like C, Java, Fortran, and so on. Sorry if I have the terminology wrong, pal. You can fill me in on the kosher term for this sort of language, if you'd be so kind.

      In terms of reading about functional programming, I've read SICP and done a many of the exercises. Maybe instead of guessing, you should refrain from assuming everyone else is a moron. Might learn some humility. But that's just one man's opinion.

    46. Re:Broken Algorithm BS by Anonymous Coward · · Score: 0

      Well, if he's talking about pure-functional programming (i.e. programming without side-effects), most algorithms break. You can't do I/O, change data structures, or even increment variables. The advantage is that the computations are easily parallelized and always thread-safe, and cacheable. If memory and threads are cheap, that's a great way to go.

      Of course you can take all those functional constructs and use them in OO languages like C# and Python, but then it's harder to parallelize because there's no guarantee that any particular operation won't have a side-effect. Still, this is the way to go because all your old algorithms work, and new ones can easily be written parallelizable.

      dom

    47. Re:Broken Algorithm BS by trickotomy · · Score: 1

      second that

    48. Re:Broken Algorithm BS by kumanopuusan · · Score: 1

      It isn't strictly true that programming paradigms have nothing to do with algorithms. Due to the vagueness of the term algorithm, there's plenty of room for misunderstanding. However, if you interpret the word algorithm as meaning a finite sequence of explicit instructions, it isn't meaningful to talk about an algorithm in a pure functional language. This is true of any declarative language, by definition.

      It isn't just sophistry either. The best solution of a given problem will vary wildly between a procedural implementation and a functional one.

      Take a naive recursive definition of the Fibonacci sequence as an example (F(n)=F(n-1)+F(n-2)). In a pure functional language, the compiler is free to use memoization to achieve O(n) in running time and stack usage, whereas in a procedural language the same definition will be O(2^n). An algorithm that uses explicit looping is more appropriate for a procedural implementation. (This ignores the constant time solution that may be available depending on the domain of the function and the floating point precision available.)

      There is plenty reason to criticize /. summaries, but I think that in this case your criticism in unfounded. Any algorithm that makes explicit use of mutable variables, looping or side effects cannot be implemented as-is in a purely functional programming language.

      --
      Use of the words "good", "bad" or "evil" is almost invariably the result of oversimplification.
    49. Re:Broken Algorithm BS by Rakshasa+Taisab · · Score: 1

      You've been living under a rock if you think there's not been any innovation in the software world...

      What you might be missing is that 'practical usage' of these innovations depend more on necessity than novelty, and that it takes decades for those innovations to mature enough to take a proper role in the industry.

      --
      - These characters were randomly selected.
    50. Re:Broken Algorithm BS by ratboy666 · · Score: 1

      Monads are incredibly inefficient?

      --
      Just another "Cubible(sic) Joe" 2 17 3061
    51. Re:Broken Algorithm BS by Weedlekin · · Score: 1

      "This isn't anything fancy and new. These ideas have been around for a long time."

      I have a book called "Parallel Program Design: A Foundation" by Chandy and Misra that was printed in 1988, and there isn't much in it that was new then, so it has indeed been around for a fair while.

      --
      I'm not going to change your sheets again, Mr. Hastings.
    52. Re:Broken Algorithm BS by swilver · · Score: 1

      I don't see any problem at all. Everything that worked on a single core will also work on a multi core system. The language is largely irrelevant, because 99% of the code written is actually not worth optimizing at all. The 1% that might be worth optimizing (something which depends on how much data that needs to be processed) can easily be written multithreaded even in the most mundane of languages... if someone didn't do it for you yet in some kind of library.

      Just because functional programming is supposed to work better with multi-cores, doesn't mean you have to write every mundane piece of trash code (ie, code that does nothing worth optimizing) in it. Who cares if some event handler (responding to some user action) could have been written multi-threaded if the total runtime is on the order of microseconds? The bottleneck is often the user, there's no sense in optimizing any of that code and thus no sense in writing it in a specific language either.

    53. Re:Broken Algorithm BS by Weedlekin · · Score: 1

      "we've been using the same basic single-core architecture for the last, what, 30 or 40 years? "

      This may be true of personal computers, but it's far from being the case with computing in general, where parallel systems were already sufficiently established by the 1980s to produce not only a variety of formal design methodologies, but also computer languages that embodied one or more of them, e.g. Occam, which was based on Communicating Single Processes algebra.

      --
      I'm not going to change your sheets again, Mr. Hastings.
    54. Re:Broken Algorithm BS by Stephan+Schulz · · Score: 2, Informative

      However, tasks that can be completed with an iterative polynomial-time algorithm often end up exponential when recursive. Of course, a bit of tail recursion and you can deal with that, but some things aren't easily tail recursed.

      That is not so. Recursion is more general that iteration, and if you make use of that extra expressive power, you can get higher-complexity algorithms. But then these algorithms would be just as complex if implemented with iteration and an explicit stack, or whatever data structure is needed.

      The canonical example where iteration is linear and naive recursion is exponential is the computation of the Fibonacci series. But the simple iterative algorithm is by no means obvious - or, on the other hand, a linear-time recursive algorithm is not significantly harder to come up with.

      Problems that are not easily tail-recursive are also not easily solved with simple iteration.

      --

      Stephan

    55. Re:Broken Algorithm BS by Goaway · · Score: 1

      If you think they aren't, show me an example of using monads to represent side-effect programming effectively while allowing parallelization of the task.

    56. Re:Broken Algorithm BS by maxume · · Score: 1

      If you figure that Moore was a big honcho at Intel, and that the pace of advancement in integrated circuits is somewhat dependent on the amount of money being directed at that advancement, you may start to think that Moore's law continuing was more than an accident.

      --
      Nerd rage is the funniest rage.
    57. Re:Broken Algorithm BS by bwcbwc · · Score: 1

      Actually, the "old" style of programming is new again. You just have to go back farther in time. The PC programming paradigm of just coding things with generic performance tweaks, and ensuring that the logic flow works won't hack it. Now you'll actually have to understand the architecture of the system that you're compiling to and optimize your algorithms for the number of cores and the memory architecture.

      This gives the advantage to the old programmers who had to do things like fit a BASIC compiler into a 4k memory space.

      At least most OS's already have a task management API to provide a crude level of management.

      --
      We are the 198 proof..
    58. Re:Broken Algorithm BS by maxume · · Score: 1

      The bad news isn't that bad; just build an imperative gui and have it pass off computation to the functional code. Building a responsive gui on a single core certainly seems possible today, it will probably continue to be so.

      --
      Nerd rage is the funniest rage.
    59. Re:Broken Algorithm BS by ErrantKbd · · Score: 1

      When you move to FP, all your algorithms break

      If moving to a functional programming language breaks your algorithms, then you are somehow doing it wrong. That line doesn't even make sense to me. Algorithms are mathematical constructs that have nothing to do with programming paradigm. Assuming the language is Turing complete, how is that even possible?

      For one thing, the implementation of your algorithms must change to compensate for the lack of destructive updates in the functional paradigm.

      See "Purely Functional Data Structures" by Okasaki for more info.

      In particular, your data structures must all become 'persistent' under the functional paradigm (as opposed to 'ephemeral' under an imperative implementation).

      This means that, when you update a list or tree using the functional paradigm, you must create a copy of the original data structure that reflects the update, while keeping the original structure unchanged.

      It sounds simple but in many cases this is not trivial.

      For example, simple things like list concatenation, which in the imperative world can be done in O(1) time using pointers, is not so easily done under the functional paradigm. Concatenation of lists can only be achieved in O(1) *amortized* time using the functional paradigm and the Banker's Method, and this only after essentially representing the lists as trees and incorporating lazy evaluation in the algorithm design.

    60. Re:Broken Algorithm BS by ChienAndalu · · Score: 1

      Compilers are very good these days. Your cunning plan will come to a halt in 3 or 4 years max.

    61. Re:Broken Algorithm BS by bob.appleyard · · Score: 1

      Used to be that the benefit was essentially automatic. You bought a new computer, loaded your software on it, and it was all twice as fast.

      The original article by Moore formulated it in terms of cost:

      In 1965, Moore examined the density of transistors at which cost is minimized, and observed that, as transistors were made smaller through advances in photolithography, this number would increase at "a rate of roughly a factor of two per year".

      Wikipedia, citing ftp://download.intel.com/museum/Moores_Law/Articles-Press_Releases/Gordon_Moore_1965_Article.pdf. Emphasis added.

      As you have said, this means that computers have been getting faster. But look at the other side of the equation.

      You can get a decent computer for next to nothing, and put it in your toaster, or your hat, or wherever you like -- computing is now ubiquitous. I mean how much is an ARM processor these days? 10 cents apiece? You could rig it up to a board and have a full hat controller to, say, control the hat's pigment for a few dollars (of course that pigment system might cost you a bit).

      What is interesting is that, while people have been trying to call anything following an exponential curve in technology as being "Moore's Law," things that Moore actually discussed, and form part of the law, and which are always talked about (here anyway), are almost never associated with Moore's Law.

      --
      How dare you be so modest!! You conceited bastard!!
    62. Re:Broken Algorithm BS by dkf · · Score: 1

      It's true that Moore actually said the transistor count doubles every 18 months.

      The full statement of Moore's Law takes into account the price. What this means is that either you're getting faster processors, more processors, or cheaper processors. Or some combination of them, of course.

      Expect to see more ubiquitous computing. Expect to see more parallel computing. Expect to see things get a bit faster. And expect to see programmers grumbling that the hardware people aren't doing their work for them, of course...

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    63. Re:Broken Algorithm BS by Skal+Tura · · Score: 1

      No, because if the software was written correctly in the FIRST place, speed would increase.

      Parallel task, parallel solution.

      Oh, and before you even start: There was multi-cpu platforms ages ago, even on consumer level (but not on consumer budget) you could get multi-cpu setup some 10years ago, based on x86 architecture, and even windows supporting out-of-the-box.

      Imho, it's even easier to write parallel solutions to parallel problems than it is to bash it into a sequential solution, on languages supporting relatively easy parallelism (=threads, processes, whatever)

      Once again, Moore's law = "Density of transistors will double every 18months", inherently hardware law, and does not take any kind of part into the utilization off the transistors. Hell, you could even arrange them in somekind huge loop doing nothing sane on the hardware level if you wanted to. It doesn't even say that speed will double in 18months, but that's the practical interpretation of it, while it is incorrect, it is relatively close.

    64. Re:Broken Algorithm BS by DiegoBravo · · Score: 1

      Enough for passing the post to quantum computing right?

    65. Re:Broken Algorithm BS by definitely · · Score: 1

      The hardware holds up it's end of the deal

      The chip makers are just saying "instead of one chip, here are two chips ... joined, and we -technically- have held up Moore's prediction" and now it's the programmer's job to deal with the performance issues. 'Doubling' transistor count this way has always been available, but doesn't hold up the spirit of performance. What is needed are compilers/OSs (together) to perform a task correctly on n processors, not manually rewriting all software.

    66. Re:Broken Algorithm BS by Free+the+Cowards · · Score: 1

      That's simply ridiculous. Back when essentially nobody had more than one CPU core in their PC, writing PC software to be massively multithreaded just because you had a "parallel task" would have been utterly stupid. Such code would be more complicated, more bug prone, and slower. So why should it have been created?

      You're correct that multi-CPU setups have existed for a long time. However, the proportion of users which had them was so close to zero as to make no difference. Even for those which did have them, the vast majority had only two CPU cores, and multithreaded programming to take advantage of two cores is way different from the 16+ that are predicted as being the norm in just a couple of years.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    67. Re:Broken Algorithm BS by Anonymous Coward · · Score: 0

      To make a Haskell program run, your code has to be carefully fit together. There are FEWER ways to accomplish your task. But, this is by design. It's hard to prove correctness of a program without referential transparency and without limiting the bad things you can do as a programmer. No pointer arithmetic please.

      With imperative languages like Java, you can bang your code with a proverbial hammer to make it work. Elegance is appreciated but easily side stepped.

      I think we are seeing a tug and pull to get computer science to be a true engineering profession. There are so many poorly prepared and unimaginative programmers out there building things that we would love to trust (voting machines?) -- maybe it's time to force them to write good (and verifiable) code.

    68. Re:Broken Algorithm BS by bar-agent · · Score: 1

      You don't have to outrun the bear, you just have to outrun the bear long enough to pass the baton.

      --
      i'd hit it so hard, if you pulled me out you'd be the king of britain [bash.org]
    69. Re:Broken Algorithm BS by cunina · · Score: 1

      Without addressing your point directly, I will point out that there used to be hardware architectures specifically optimized for functional programming - Lisp machines, basically. They were mostly used in academia and military simulations, and they gave a very impressive improvement over traditional computers when doing FP. So programming style and hardware aren't independent concerns, regardless of Turing completeness.

    70. Re:Broken Algorithm BS by Skal+Tura · · Score: 1

      Actually you are wrong.

      Case example, a 3D application like a game, this is what you have:
        * Sound & Music
        * 3D Graphics rendering
        * Input devices
        * Timing (of animations etc.)

      Those are the main tasks, i found out personally it's way easier to implement in threads, my case was an demoscene 64k intro. If you don't know what that is ... How sad, demoscene guys are the ones pushing envelope year in & year out! Basicly a short real time animation. At demoscene we've seen real time photorealistic raytracing back in the 90s already, albeit very simple scene, but it was photorealistic and real time.

      It was way easier to implement the render calculation tasks, music and timings in separate threads, yes, that's only 3 threads, but it is some future proofing, and it was quite small codebase (64k stands for 64kbytes).

      That way i got to ensure absolute precision over the animation precision, jitter free music etc.
      Nevermind the fact that i didn't have to give RAT'S ASS of my attention to make sure i were juggling between tasks.

      Other case example:
        Graphical multiple file WGET style:
          The instances of getting the files, each on separate threads and the GUI.

      Yet another case example from *** DOS-ERA ***, yes, that's right, i've implemented multi-threading style things even under DOS:
        Music particularly, playing on the background, jitter free undepending on the task the remainder of the app was doing. I admit, i didn't code the music player, it was free to use, might've even been open source. (Give me a break for not coding it myself: i were 11-12 back then)

      There are a multitude of tasks which are simpler when multithreaded.
      One today's example is Second Life bots, it's just so much wiser to implement multithreading for each individual task of the system, multithreaded callbacks etc. and performance rockets skyhigh. That being said, some tasks like teleporting is done on thread blocking style (blocks the current sequential block of code) to avoid trouble.

      Nevermind that performance increases were attainable with single core, single CPU setups as well, even with very computationally heavy tasks such as Seti@Home (performed some benchmarks about 5yrs back).

      Inter-thread communication can be a walk in the park on many cases aswell.

    71. Re:Broken Algorithm BS by Free+the+Cowards · · Score: 1

      You got three threads out of it. You lost out on any further speed increases past 3 cores, and 4 cores is becoming pretty common now. 8 core machines are not difficult to find, and will be common in another year or so. Am I to conclude that your software was not written correctly in the first place as you claimed? Keep in mind that the question is not how to make software take advantage of today's machines, but rather how to make software take advantage of tomorrow's 16+ core machines.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    72. Re:Broken Algorithm BS by MadMidnightBomber · · Score: 1

      I heard that in Haskell integers do not obey the triangle inequality, and ML doesn't support the multiplicative identity.

      --
      "It doesn't cost enough, and it makes too much sense."
    73. Re:Broken Algorithm BS by pthisis · · Score: 1

      If moving to a functional programming language breaks your algorithms, then you are somehow doing it wrong. That line doesn't even make sense to me. Algorithms are mathematical constructs that have nothing to do with programming paradigm. Assuming the language is Turing complete, how is that even possible?

      First, a Turing complete language can't implement everything a computer does, and I'd argue that the vast majority of the programs people actually use rely on a lot of features outside of Turing computability. Vi keyboard macros are Turing complete (and there there are some cool examples of implementing URMs, Turing tapes, etc in them), but you can't play an mp3, locate the mouse cursor or display an bitmap with them without outside assistance. Those aren't functional problems, but they are real-world computing problems; it's not uncommon for certain steps in your program to be "move the mouse cursor", "look at the user input", "make a network request", etc that aren't Turing-computable and are often non-functional.

      Second, strict functional programming absolutely limits algorithms--if an algorithm has side effects, it isn't functional. An algorithm is just a series of steps to accomplish a task, and might start off by initializing a global variable to some value and then incrementing it within various methods. That algorithm certainly isn't functional by any reasonable definition.

      More to the point, a heapsort isn't easily parallelizable. Unlike quicksort or merge sort, it is both in-place and has a worst-case run time of O(n log n). It also requires a data change at the bottom layer that affects higher layers (a side effect, the swap function), which makes it difficult to come up with a functional version of.

      That's a solved problem (though it was far from trivial), but the functional version isn't easy to parallelize. I suspect that even if it were, if you know that you're going to be running on large multicore machines then you'd be better off with another sort algorithm. That doesn't mean that heapsort was "wrong", it means that different architectures benefit from different algorithms.

      --
      rage, rage against the dying of the light
  3. Why would the Algorithm break? by Zironic · · Score: 3, Interesting

    I don't see why an algorithm would break just because you're changing language type, the whole point of an algorithm is that it's programming language independent.

    1. Re:Why would the Algorithm break? by koutbo6 · · Score: 4, Informative

      With functional programming languages make a rather restrictive assumption, and that is all variables are immutable.
      This is why functional programs are more suited for concurrency, and this is why your sequential algorithms will fail to work.

      --
      You speak London? I speak London very best.
    2. Re:Why would the Algorithm break? by Nedmud · · Score: 2, Informative

      In practice, algorithms are generally programming language independent *within the set of imperative languages*. They are almost always written as a series of steps. And that's why they don't apply directly to functional languages.

      I just checked Knuth's definition, and he lists: finiteness, definiteness, input, output and effectiveness as the requirements for an algorithm. All of these translate with more or less effort into the functional programming landscape.

      As an example, I have seen the quicksort algorithm written something like:

      sort(l) =
              if l == [] then []
              else with (lowers, equals, highers) = partition(l) in
              sort(lowers) + equals + sort(highers)

      (The original was in Haskell which as you can see I am no longer proficient in.)

      So I think I agree that "all your algorithms will break" is exaggeration.

    3. Re:Why would the Algorithm break? by Zironic · · Score: 1

      There is nothing that prevents you from implementing sequential algorithms in a functional language.

    4. Re:Why would the Algorithm break? by DragonWriter · · Score: 1

      With functional programming languages make a rather restrictive assumption, and that is all variables are immutable.

      This doesn't break algorithms. It just changes the way a particular algorithm will be expressed in code. Any functional language will provide a way to create and access a mutable storage cell, though it may be more programming work to do so than it would be in a language where that was the normal use of a variable.

    5. Re:Why would the Algorithm break? by techno-vampire · · Score: 2, Informative
      ..all variables are immutable.

      You mean to say that in a functional programming language, variables aren't? A paradox, a paradox, a most delightful paradox!

      --
      Good, inexpensive web hosting
    6. Re:Why would the Algorithm break? by koutbo6 · · Score: 1
      indeed .. thats why functional languages are useful. The claim made in the article is that this is merely and exaggeration:

      Getting good at functional programming is hard, harder than moving from iterative Pascal or Basic or C coding to object-oriented development. It's an exaggeration but a useful one: When you move to FP, all your algorithms break

      If you can get passed the idea that you only have immutable variables, you can do pretty much anything you usually do in other sequential languages. The algorithms are identical at an abstract level.
      If however your algorithms are more concrete and you tend to think about variables when developing them, you are in for a hard time.

      --
      You speak London? I speak London very best.
    7. Re:Why would the Algorithm break? by Chandon+Seldon · · Score: 4, Informative

      You mean to say that in a functional programming language, variables aren't? A paradox, a paradox, a most delightful paradox!

      Functional variables are like mathematic variables - they're variable in that you may not have discovered their value yet, but once you discover their value it stays the same for the current instance of the problem. For the next instance of the problem (i.e. the next call to the function), you're talking about a different set of variables that potentially have different values.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    8. Re:Why would the Algorithm break? by koutbo6 · · Score: 1

      indeed .. but thats what I called them for a lack of a better term. I can't remember what the proper term is for a variable in a functional language.
      If you read joe Armstrong's book on programming erlang, I believe he uses the term "variable" since it is what most programmers are used to.

      --
      You speak London? I speak London very best.
    9. Re:Why would the Algorithm break? by Anonymous Coward · · Score: 2, Interesting

      The reason quicksort is quick is that in a language with modifiable random-access arrays, partitioning can easily be done in-place (without having to copy the array). You can't do that in functional programming.

    10. Re:Why would the Algorithm break? by johanatan · · Score: 1

      Yea but if you did that, you'd be missing the point. That's like using C++ as if it were C. You're really missing the elegance of the language/paradigm when you do that.

    11. Re:Why would the Algorithm break? by pla · · Score: 1

      I don't see why an algorithm would break just because you're changing language type, the whole point of an algorithm is that it's programming language independent.

      More to the point, why would your choice of programming paradigm have a significant impact on parallelization of algorithms? They all have equal computational power, and differ only in the style of expressing your intent.

      If anything, current CPUs best match the imperative model (and more cores of a similar design won't change that); But they only do so out of popularity - If functional programming didn't count as a complete bitch to implement with no benefits over imperative or OO, CPUs would export a more functional-friendly ISA.

      And for the record, I can code adequately in Tcl... And given a choice, I'd choose C(++/#/whatever) for any task (Even intended recursion - In that, on Von Neuman architecture, the nonrecursive form of any given algorithm will outperform the recursive version).

    12. Re:Why would the Algorithm break? by Zironic · · Score: 1

      I thought that implementing a recursive algorithm in C was begging for the program to eat your entire memory.

      Anyhow, I think the point is that it's much easier to write parallel code in a functional language since everything is a function and each function should be independent enough to run in it's own thread.

    13. Re:Why would the Algorithm break? by Goaway · · Score: 1

      Nothing, except practicality.

    14. Re:Why would the Algorithm break? by grumbel · · Score: 1

      More to the point, why would your choice of programming paradigm have a significant impact on parallelization of algorithms?

      A functional languages allows you what you want to do, an imperative languages allows you to express how you want to do it. The former gives the compiler much more power to optimize, while the later leaves very little room for optimization compiler and leaves the grunt work to the programmer. The reason for this is that a functional language doesn't have side effects, without side effects code evaluation can be spread across multiple CPU and evaluated out of order, the result is guaranteed to be always the same. In an imperative language the order of evaluation is specified in the code itself and it can't be evaluated out of order, since there is no way to guarantee that the result would be the same.

    15. Re:Why would the Algorithm break? by Goaway · · Score: 1

      And once you create that, you lose the multiprocessing advantage you had, and you might as well have used a imperative language in the first place.

    16. Re:Why would the Algorithm break? by Anonymous Coward · · Score: 0

      With functional programming languages make a rather restrictive assumption, and that is all variables are immutable.

      The assumption that variables are (globally) mutable is the restrictive assumption -- teeming with special cases and undefined behavior -- a relic from the days when variables were just names for memory addresses.

      A variable is conceptually much more than that (and had been since well before K&R C). A variable is merely a syntactic placeholder for a value in an expression. Having a variable change its value in the middle of evaluating an expression is like changing what "it" refers to in a sentence: "The dog ran off with its bone, and it is going to get buried".

    17. Re:Why would the Algorithm break? by jfmiller · · Score: 1

      "Erlang: the language where variables don't assignments can't and loops never do."
          -- Jim Weirich, RubyConf08

       

      --
      Strive to make your client happy, not necessarly give them what they ask for
    18. Re:Why would the Algorithm break? by Anonymous Coward · · Score: 0

      I can't remember what the proper term is for a variable in a functional language.

      I've always heard "identifier."

    19. Re:Why would the Algorithm break? by MikeBabcock · · Score: 1

      A complex algorithm written in each C, Python, Assembler, Lisp and Haskell will probably look different in each situation and that's not including knowledge of the underlying hardware the programmer may have (leading to code refactoring for threads and such).

      The implementation of an algorithm is highly dependant on the language used.

      --
      - Michael T. Babcock (Yes, I blog)
    20. Re:Why would the Algorithm break? by flux · · Score: 1

      Well, C++ has constant variables too, no?

      Actually the term "binding" is often used in functional languages. However, the term "variable" can also be understood to be entirely meaningful there. By 'varying' the variable (an identifier in the code you are looking at) simply doesn't have the same value always (say, between every time a function is being called), compared to a constant that would always stay, well, constant.

      For example in the code fragment:

      int foo(const int i) { .. }

      the value i varies although it can never be mutated.

      I'm thinking trying to write an algorithm in C++ using just constant variables gives you some idea how to write functional algorithms; but the language isn't quite suitable for it, with the lack of lambda functions (yes, those are coming!) and true garbage collection.

    21. Re:Why would the Algorithm break? by flux · · Score: 1

      Clean has in-place modification of arrays which doesn't break referential transparency, thanks to uniqueness typing. So you can still go and implement the same algorithm. You can mutate an array given you only have one instance of it.

      You can also describe the computation required to perform the sort in-place, and let the runtime system do the impure evaluation of the algorithm for you, in-place. Sort of what Haskell lets you do with monads.

    22. Re:Why would the Algorithm break? by Zironic · · Score: 2, Insightful

      If you're writing an algorithm in a programming language you're doing it wrong.

    23. Re:Why would the Algorithm break? by cdfh · · Score: 1

      Functional variables are like mathematic variables - they're variable in that you may not have discovered their value yet, but once you discover their value it stays the same for the current instance of the problem.

      The above is only true for non-strict functional languages. Strict functional languages require the value to be known at the time of binding.

    24. Re:Why would the Algorithm break? by Chandon+Seldon · · Score: 1

      The above is only true for non-strict functional languages. Strict functional languages require the value to be known at the time of binding.

      It's still true for strict functional languages, in the degenerate sense that before a variable is bound you haven't discovered its value. Which is basically the same as for a non-strict language, except that in the strict language the order of evaluation is the same as the order that the code is written down.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    25. Re:Why would the Algorithm break? by cdfh · · Score: 1

      Ah, my apologies, I misinterpreted your original comment. I thought you were talking about the time during the program's execution that a variable is evaluated, rather than the semantics of a variable's value.

    26. Re:Why would the Algorithm break? by mechsoph · · Score: 1

      If anything, current CPUs best match the imperative model (and more cores of a similar design won't change that); But they only do so out of popularity - If functional programming didn't count as a complete bitch to implement with no benefits over imperative or OO, CPUs would export a more functional-friendly ISA.

      I think they tried to do that in the 80's with the lisp machines. Turned out that a RISC chip would run high-level code faster than the custom hardware, and it would also run C much faster.

      In that, on Von Neuman architecture, the nonrecursive form of any given algorithm will outperform the recursive version

      That's why reasonable languages optimize tail recursion. Then you can just write the recursive form when it is more clear than the iterative form.

    27. Re:Why would the Algorithm break? by Anonymous Coward · · Score: 0

      > The former gives the compiler much more power to optimize, while the later leaves very little room for optimization compiler and leaves the grunt work to the programmer.

      And given how much compilers just suck only the latter one will give really good performance.
      Unless of course the programmer sucks even more or doesn't have the time to do it right, which admittedly might be most of the time.

    28. Re:Why would the Algorithm break? by TuringTest · · Score: 1

      And once you create that, you lose the multiprocessing advantage you had, and you might as well have used a imperative language in the first place.

      Not at all. You can use monads, a design pattern to encapsulate away the side-effects and retain the multiprocessing advantage. You can't do that with a library in an imperative language, which is side-effect-aware by design.

      --
      Singularity: a belief in the "God" idea with the "demiurge" relation inverted.
    29. Re:Why would the Algorithm break? by Goaway · · Score: 1

      Monads can encapsulate away the side-effects, but unless you show me a solid example of it I sincerely doubt that they can both be properly efficient and retain the multiprocessing advantages.

    30. Re:Why would the Algorithm break? by nusuth · · Score: 1

      So please do me a favor and write a purely functional doubly linked list. Any abstract equivalent of a doubly linked list that can add or remove an element after a given element or before a given element in constant time without requiring any additional memory will also do. This is a honest inquiry. I gave up on Haskell because I couldn't find a simple way to write a purely functional equivalent to a doubly linked list and I would be delighted to know that it is possible without monads.

      --

      Gentlemen, you can't fight in here, this is the War Room!

    31. Re:Why would the Algorithm break? by Anonymous Coward · · Score: 0

      if you're needlessly pedantic you're really doing it wrong

    32. Re:Why would the Algorithm break? by koutbo6 · · Score: 1

      FP is just another tool in a programmer's tool box. If you tend to think imperatively, and want total control over data structures and access time, then either an imperative language will be a more appropriate tool for your problem.
      Or you fall into the description of the article where it is hard to break out of the imperative thinking process to be able to effectively use FP languages. There just might be another way to solve your problem without using doubly linked lists.

      --
      You speak London? I speak London very best.
    33. Re:Why would the Algorithm break? by Anonymous Coward · · Score: 0

      This is why functional programs are more suited for concurrency, and this is why your sequential algorithms will fail to work.

      This sentence is meaningless. An algorithm is a mathematical formula. It won't fail to work because of your concrete environment, it is either true (successfully performing the wanted computations) or false (containing one or multiple errors).

      And it's quite simple to translate an iterative program into a functional one (but the result won't necessarily have good properties if the transformation is naive)

    34. Re:Why would the Algorithm break? by TuringTest · · Score: 1

      I'm not that well versed in monadic efficient parallel code, but there seems to be people out there who thinks it's possible. What is exactly the reason why do you doubt it? Continuation-based implementations of FP programs can be very efficient.

      --
      Singularity: a belief in the "God" idea with the "demiurge" relation inverted.
    35. Re:Why would the Algorithm break? by colinrichardday · · Score: 1

      But in some mathematical uses, such as algebraic identities and definite integration, variables have more than one value.

    36. Re:Why would the Algorithm break? by DragonWriter · · Score: 1

      Yea but if you did that, you'd be missing the point.

      Right, I don't disagree with that. What I'm saying is the algorithm doesn't "break" because you are using an FP language. You can usually do a fairly direct tranlation of the implementation from another language, or you can do a more idiomatic implementation in the new language, but any algorithm you can use in any other language can be implemented in an FP language.

      There may be times when the best algorithm for on in an FP language isn't the best algorithm otherwise (there may be several, e.g., O(n) algorithms available, and the one that has the smallest constant multiplier may change from language to language -- or even from language or library implementation in the same language -- or the expression of one of two equally-performant algorithms may be far simpler in one language, where the other simpler in the other language.)

    37. Re:Why would the Algorithm break? by DragonWriter · · Score: 1

      And once you create that, you lose the multiprocessing advantage you had, and you might as well have used a imperative language in the first place.

      That depends on the role of the cell in the algorithm; you most likely lose some, but not all, of that advantage.

      Its true that the best algorithms for parallelization may not be the same as the best algorithms not considering parallelization; that doesn't mean FP breaks existing algorithms.

  4. Amdahl's Law by Mongoose+Disciple · · Score: 5, Insightful

    Question is, how realistic is that?

    Amdahl's Law also tells us tells us that the amount that parallelization can speed something up is ultimately limited by the parts that can't be done in parallel.

    1. Re:Amdahl's Law by Tenek · · Score: 5, Informative

      And Gustafson's Law tells us that as the problem size increases the non-parallelizable portion of the program will shrink.

    2. Re:Amdahl's Law by blair1q · · Score: 1

      If something can't be done in parallel, maybe it can be pipelined.

      Or you can reserve one CPU to do the non-parallelizable, non-pipelineable parts, while the rest are working on the next parallel/pipelined task.

      Treating the processors as heterogenous, with the ability to make homogenous subsets, is the key to getting nearer to unit efficiency from a multiprocessing system.

    3. Re:Amdahl's Law by Anonymous Coward · · Score: 2, Informative

      Yes.

      But furthermore, saying that FP "solves" the multithreading problem is intellectually dishonest. FP proponents like to pretend that because FP programs are intrinsically parallelizable, you don't have to worry about it: the magic compiler or runtime will do it for you. Wrong. The difficulty of multithreaded programming is not to use threads, it's how to do it efficiently. Sure, if the problem is sorting 1 billion ints, you'll multithread from the top of the recursion, and that'll be quite efficient, but anyone can do the same trivially in any language. But the real problem start when you got to schedule multiple heterogeneous tasks, and FP has no intrinsic answer to that.

      As for the legendary reliability that Erlang fans love to point out, I'm glad we got an example at last. Ericsson AXD-301. How? "No shared state and a sophisticated error-recovery model" he says. Yeah, right! It's a f*cking switch! How about custom hardware built like a tank, with predictable failure modes, and specs (protocols) that haven't changed in 10 years (at least). Give me a break, it's not exactly difficult to get plenty of nines in those conditions!

    4. Re:Amdahl's Law by funkatron · · Score: 5, Funny

      And funkatron's law tell us that as problems size increases you'll move into management and give the problem to someone else.

      --
      "Welcome to our world. We are the wasted youth. And we are the future too." Yes, I know these are stupid lyrics.
    5. Re:Amdahl's Law by Goaway · · Score: 1

      Why would that be true?

    6. Re:Amdahl's Law by mooingyak · · Score: 1

      The more you're doing, the more of what's being done can be done at the same time.

      Sounds reasonable.

      --
      William of Ockham had no beard. The most likely explanation is that it was chewed off by squirrels every morning.
    7. Re:Amdahl's Law by Samah · · Score: 5, Funny

      And Godwin's Law says that functional programming was developed by Hitler for the Nazis.

      --
      Homonyms are fun!
      You're driving your car, but they're riding their bikes there.
    8. Re:Amdahl's Law by Goaway · · Score: 1

      The more you're doing, the more it's going to be interconnected and not possible to do at the same time.

      Sounds reasonable too.

    9. Re:Amdahl's Law by pmadden · · Score: 1

      And John Gustafson recently stated "The only people who said Amdahl's Law wasn't true were the PR people at Sandia, and a couple of managers who should have known better. Never the people who did the work." Check the video discussion, with Amdahl, Gustafson, and a couple of other folks.

      If you see a white horse, it does not imply that all horses are white. If see an algorithm that scales, it does not imply that all algorithms will scale.

      Some applications will map to 1000 cores nicely, but not all of them. Thinking Machines, Inmos, MasPar, BBN, and dozens of other companies have found this out the hard way. Intel and AMD also seem intent on finding this out the hard way. Of course, the smart thing to do is to ignore five decades of well documented history, and pretend that this is the first time anyone has tried parallel computing; it's much more fun that way.

    10. Re:Amdahl's Law by 14erCleaner · · Score: 1
      And don't forget [url=http://en.wikipedia.org/wiki/Parkinson%27s_law]Parkinson's Law[/url]: work expands to fill the time allotted to it.

      This helps explain Windows Vista.

      --
      Have you read my blog lately?
    11. Re:Amdahl's Law by mooingyak · · Score: 1

      More difficult to do at the same time maybe. Impossible to do at the same time? Not too likely.

      --
      William of Ockham had no beard. The most likely explanation is that it was chewed off by squirrels every morning.
    12. Re:Amdahl's Law by Mongoose+Disciple · · Score: 1

      The difficulty of multithreaded programming is not to use threads, it's how to do it efficiently.

      This has seemed true in my experience, as well. Further: multithreaded programming inherently introduces an extra set of gotchas, such as race conditions.

      Which isn't to say that a programmer can't correctly navigate around the problems of multithread/core programming, or that there aren't cases in which doing so is very rewarding -- but I tend to think that, for the foreseeable future, doing it right for non-trivial problems will remain something of an esoteric skill, like knowing when to write key bits of a program in assembler to achieve higher performance than your compiler will give you. In other words, fantastically useful and powerful in the right case, but not something most programmers will need to or maybe even should apply.

    13. Re:Amdahl's Law by CBravo · · Score: 1

      Plugging myself (again): I wrote a small research article about heterogeneous architectures which proves there is a method to determine which part of the job requires fast processing (either raw speed or functional optimalization by the processor). It required the job to be partitioned (to Kahn process networks) and profiled but you can think of more dynamic optimalisations.

      By the way: priority is not a term to use. Its premise is that there is a shortage of processors to schedule on. If you have a heterogenenous environment with a lot of processors, you never have a shortage (just a lot of bad choices to make).

      --
      nosig today
    14. Re:Amdahl's Law by shutdown+-p+now · · Score: 1

      The difficulty of multithreaded programming is not to use threads, it's how to do it efficiently.

      I would say that it is the second difficulty. The first difficulty is how to use threads in such a way as to not break things. Manual thread synchronization is a notoriously difficult problem for many reasons, and that difficulty grows nonlinearly as complexity of the task increases.

    15. Re:Amdahl's Law by Goaway · · Score: 1

      Either way, everything said so far has been entirely baseless assumptions. Amdahl's law is logically strict and based on direct mathematical deductions. This "Gustafson's law" is based on nothing but wishful thinking.

    16. Re:Amdahl's Law by some-old-geek · · Score: 1

      And experience tells us that most business problems are solved with single-threaded solutions.

    17. Re:Amdahl's Law by SuperMog2002 · · Score: 1

      And Quirk's Exception says that your attempt to end this thread will fail.

      --
      Sunwalker Dezco for Warchief in 2016
    18. Re:Amdahl's Law by colinrichardday · · Score: 1

      That wasn't Hitler, it was Konrad Zuse.

    19. Re:Amdahl's Law by Evanisincontrol · · Score: 1

      And Gustafson's Law tells us that as the problem size increases the non-parallelizable portion of the program will shrink relative to the entire program itself .

      </correction>

  5. Scheme by Rinisari · · Score: 4, Funny

    (have I (feeling ((become popular Scheme) again)))

    1. Re:Scheme by smittyoneeach · · Score: 1

      au_contraire :: String -> String
      au_contraire "Scheme" = "Haskell"

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    2. Re:Scheme by Bespoke · · Score: 1

      I take it that Scheme was designed by Yoda?

    3. Re:Scheme by orkybash · · Score: 1

      Anyone else feel compelled to count the parentheses on that? :) (Props for getting it right!)

    4. Re:Scheme by Anonymous Coward · · Score: 0

      If this is the syntax, they should really make a functional programming language called Yoda

    5. Re:Scheme by howlingmadhowie · · Score: 1

      (setq yoda 'scheme) (defun designed (maker product) (if (equal maker product) "designed it was")) ;; proud emacs nerd :) scheme and lisp both use (operator arg1 arg2 ... argn) notation.

    6. Re:Scheme by Anonymous Coward · · Score: 0

      considering there are no operators in your joke, then the order makes no difference with in the parentheses so you should have written them in the proper grammatical order.

    7. Re:Scheme by fgb · · Score: 1

      Does this mean Yoda was a Schemer? It all makes sense now!

  6. it's always a good time to try functional by cats-paw · · Score: 5, Interesting

    It's been said in the comments on slashdot many times. Learning functional programming techniques will improve your programming skills. There are many good functional languages out there, and many have imperative features for ease of transition. No functional will not solve all of your problems, but it will give you that most valuable of all lessons, how to think about a problem _differently_.

    You don't need an excuse, start today.

    --
    Absolute statements are never true
    1. Re:it's always a good time to try functional by Duhavid · · Score: 2, Interesting

      What language would you recommend for an OO programmer to start with?

      --
      emt 377 emt 4
    2. Re:it's always a good time to try functional by LaskoVortex · · Score: 5, Interesting

      You don't need an excuse, start today.

      The excuse is: it's fun. But if you do start, choose the right language for the job. Python for example seems good for fp, but was not designed for the task. Don't choose a language that simply supports functional programming. Choose a language that was designed specifically for functional programming. You'll be happier in the long run when you don't run into limitations of the language you choose.

      My 2c.

      --
      Just callin' it like I see it.
    3. Re:it's always a good time to try functional by TheRaven64 · · Score: 5, Informative

      Python for example seems good for fp

      Last time I heard this, I checked, and the python developers were refusing to commit tail-recursion optimisation patches because it 'made debugging too hard'. Since most functional algorithms are tail-recursive, you will blow your stack very quickly without this. It's even in GCC, meaning that C is better suited to functional programming than Python.

      --
      I am TheRaven on Soylent News
    4. Re:it's always a good time to try functional by NinthAgendaDotCom · · Score: 1

      Oh man, thanks for warning me. I don't want to blow my stack at the office. Think of the mess and the embarrassment.

      --
      -- http://ninthagenda.com/
    5. Re:it's always a good time to try functional by LaskoVortex · · Score: 1

      What language would you recommend for an OO programmer to start with?

      Scheme

      --
      Just callin' it like I see it.
    6. Re:it's always a good time to try functional by blair1q · · Score: 2, Informative

      s/stack/wad

      dang newbies

    7. Re:it's always a good time to try functional by Chandon+Seldon · · Score: 1

      What language would you recommend for an OO programmer to start with?

      Scheme or Standard ML would be good places to start. One of the key points of learning a functional language, if you think of yourself as an "OO programmer", is being able to look at problems and come up with solutions that *aren't* OO, so try to avoid looking for a functional / OO hybrid language until you're comfortable with functional problem decomposition.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    8. Re:it's always a good time to try functional by fishbowl · · Score: 1

      I would suggest XSLT, because it has obvious real-world applications that make the endeavor of learning it not just an academic one.

      I would also recommend taking a few simple algorithms and implementing them in Haskell, ML and Scheme. I would also suggest doing the same thing in, say, C or Perl but limiting yourself to a pure functional model.

      One of the most enlightening courses I took dealt with lambda calculus as its own idiom, distinct from applications to computer science, but the material would make for some awfully dry recreational reading.

      --
      -fb Everything not expressly forbidden is now mandatory.
    9. Re:it's always a good time to try functional by johanatan · · Score: 1

      Haskell

    10. Re:it's always a good time to try functional by rk · · Score: 1

      You can do tail recursion optimizations implemented in pure Python. They're not speedy at all (If you want speedy, write in C/C++, Java, or something), but they keep recursive functions from filling the stack. It would be better if it were implemented in the environment, but you can make it work.

    11. Re:it's always a good time to try functional by nschubach · · Score: 1

      It's not really a "programming language" as much as it is a scripting language right now, but I've been digging into Ruby (not rails) and I like what I see so far.

      --
      Every time I start to have faith in humanity, I ruin it by driving to work between 7 and 8 am.
    12. Re:it's always a good time to try functional by j1m+5n0w · · Score: 4, Informative

      I would say Haskell, but I think that's the language everyone should learn, so I'm biased. The typeclass system provides for some of the functionality of object oriented programming.

      If Haskell scares you, Ocaml is another good choice. It's a multi-paradigm language with an emphasis on functional programming, but it also allows you to use mutable state wherever you like (whether this is a good thing or not is a matter of some debate). It even has some traditional object-oriented programming features, but they tend not to get used much in practice.

      If you care about performance, they both have decent native-code compilers. My impression is that Ocaml is a bit faster for single-core tasks, but Haskell's parallel programming features are much better.

    13. Re:it's always a good time to try functional by Fulcrum+of+Evil · · Score: 1

      how is there a difference? Ruby is an OO/functional language. Who cares what it runs on?

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    14. Re:it's always a good time to try functional by Anonymous Coward · · Score: 0

      Haskell is a barrel of laughs. I was taught it as a First Year at Un. of Edinburgh by one of the creators (Phil Wadler) - maybe it was the way it was taught, but it seemed like such a cool language at the time...

    15. Re:it's always a good time to try functional by Goaway · · Score: 2, Informative

      Ruby is nowhere near a functional language. It's imperative as anything else.

    16. Re:it's always a good time to try functional by CodeBuster · · Score: 1, Informative

      with the addition of lambda expressions, anonymous delegates (which provide closures as you functional people call them), and anonymous types C# is well on its way to becomming an effective language for functional style programming. If you don't believe that then don't take my word for it, but instead check out Confessions of a Used Programming Language Salesman (warning PDF), by Erik Meijer of Microsoft Research who talks about his background in Haskel and how that has translated into his work at Microsoft and C# and the .NET Framework (ver 3+) and while some here on Slashdot may accuse me of being a shill for Microsoft, only the most dedicated Microsoft basher could fail to see the value that is to be found in C# and .NET (which is a big and often unseen part of why Microsoft is still breathing right now).

    17. Re:it's always a good time to try functional by Anonymous Coward · · Score: 1, Informative

      You're talking about F#. Simon Peyton-Jones (the Haskell developer, PhD, functional language researcher) works for Microsoft now. I don't know what on specifically, but he is in the same working group as F#'s designer.

    18. Re:it's always a good time to try functional by sentientbrendan · · Score: 1

      A lot of people will point you to lisp dialects such as scheme. Unfortunately, the *only* thing you will get from scheme is functional programming.

      Another important concept that's actually very relevant to real world programmers is type safety. Generics, templates, etc, are inspired by languages like SML, and it's a good idea to try SML to get a feel for how type safety and genericism is supposed to work.

      Also, you may notice at some point using SML, that type safe languages don't have null, which is something the guys who wrote Java were never told.

    19. Re:it's always a good time to try functional by lawpoop · · Score: 1

      I'm interested in really learning functional programming. Is clojure a real funcional language? What are some you would recommend?

      --
      Computers are useless. They can only give you answers.
      -- Pablo Picasso
    20. Re:it's always a good time to try functional by Anonymous Coward · · Score: 0

      Use scheme because of the wizard book.

    21. Re:it's always a good time to try functional by Anonymous Coward · · Score: 0

      Since you specifically mentioned OO, I would recommend Lua, its a imperative language with some functional constructs that are fairly well used both for normal tasks and to create a OO style. At the very least, you can see how they compare before you try to wrap your mind around a actual functional language (which can take some time... functional is not like imperative at all (yes, I call OO imperative)).

    22. Re:it's always a good time to try functional by vrmlguy · · Score: 1

      What language would you recommend for an OO programmer to start with?

      Any language will work to start with, just commit to not using assignment statements. Twenty years ago, I was a FORTRAN programmer who got introduced to LISP. I decided to try rewriting some of my programs without assignments. Since FORTRAN didn't allow recursion, there were lot of places where I got stuck, but it was surprising how I was able to get done. And I seem to recall that the programs were easier to debug, since there were fewer places where data could get clobbered. It should be easier these days since modern languages support functional programing, you just need the self-discipline to stick to that style.

      Hint: any place that you want to make an assignment, turn the rest of the block into a function and pass the value as a parameter. If you have a loop, try coding it as a reduce-type algorithm; it's mentally easier than turning it into a recursive algorithm and it maps well to massively parallel architectures. Python somehow got a lot of functional stuff added in when Guido wasn't paying close attention (http://www.artima.com/forums/flat.jsp?forum=106&thread=98196), so it's a great language to play with.

      After that, follow the suggestions in the article. Learn Scala, F#, Erlang or Haskell. Get a copy of Mathematica. Have fun, and you'll learn a lot.

      --
      Nothing for 6-digit uids?
    23. Re:it's always a good time to try functional by FlyingBishop · · Score: 1

      RTFA - Haskell, Erlang.

      My first language, not counting BASIC snippets as a kid, was Scheme. I'm also an Emacs user, so I know a good bit of Lisp. They're both fun languages, Haskell and Erlang look a bit more useful though. (Though I don't know a thing about them.)

      I can say that if all you've used is C++, Java, Python, etc., Scheme will blow your mind.

      You might also look into Prolog or some such, though those are really logic programming, they're also worth looking into (though I'm not sure the concepts really translate as well to programming in C++.)

    24. Re:it's always a good time to try functional by jbolden · · Score: 1

      Haskell. Because it is so different you will be forced to break the habits you need to break.

    25. Re:it's always a good time to try functional by SQLGuru · · Score: 1

      I think another technique that will benefit people as they shift to a more parallel mode of thinking is to consider how SQL statements process logically. A single instruction can be written that will manipulate millions of rows....whether done iteratively or in parallel.

      update TableT
      set ColumnA = ColumnA * ColumnB
      where ColumnC = "Red"

      The other point about it is that the database engine takes care of the parallelism, the programmer doesn't have to. Languages that run in VM's of some sort or another can do some of the "paralleling" for us without us having to jump into another language.

      Layne

    26. Re:it's always a good time to try functional by CodeBuster · · Score: 1

      As long as F# continues to be compiled as CLR instructions then it is very likely that any features that start out in F# and are not already analagous in C# will migrate over. Although it may not be possible to capture fully all of the features of a purely function language designed for that purpose, C# has really started picking up speed in the 2.0 release and the 3.x versions have really added some really great features in relatively short order (lambda expressions and LINQ really are a godsend). Also, because .NET Assemblies are cross compatible, even when written in different languages, it should be possible to write an F# library where functional implementations make the most sense and then call into it from your C#, VB.NET, or managed C++ code.

    27. Re:it's always a good time to try functional by howlingmadhowie · · Score: 1

      yeah. it's annoying that they didn't introduce better support for lambda in python 3.0 :(

    28. Re:it's always a good time to try functional by ardor · · Score: 1

      (If you want speedy, write in C/C++, Java, or something)

      Or OCaml, Haskell, Lua.

      --
      This sig does not contain any SCO code.
    29. Re:it's always a good time to try functional by m50d · · Score: 1

      Tail recursion is a performance hack, and python's not about those. If you really want it, I think some of the alternative implementations have it (the official cpython isn't the only one). Claiming C is better suited to FP is pure trolling.

      --
      I am trolling
    30. Re:it's always a good time to try functional by shutdown+-p+now · · Score: 1

      What language would you recommend for an OO programmer to start with?

      In general, Objective Caml is pretty nice in that it has all the wrappings of a typical FP language - immutability, first-class functions, currying, ADTs, pattern matching, type inference and so on - but it's not "pure FP", and so it lets you escape to the familiar realm of mutable values, loops, and OOP when you start feeling intimidated (or when it's simply more suitable to the task). It should be noted though that OO and FP are not contradictory - so long as your objects are immutable, all FP techniques are fully applicable, but you still get encapsulation and OO-polymorphism.

      If you are a .NET programmer, then you may want to jump ahead to F#. It's essentially OCaml with somewhat smoother syntax and the original structural object model torn out and replaced by .NET object model (and a few other neat features, such as lazy sequence generators, user-defined patterns for pattern matching, and units of measurement integrated into the type system). Its advantage is, obviously, that you have the full .NET class library at your disposal, and that it has a pretty good Visual Studio integration already (with code completion, visual debugging etc). It's also a pragmatic investment of your time as F# is slated to become an officially supported (by MS) .NET language in VS2010 timeframe.

      If you are a Java programmer, you might want to consider Scala. It's less functional than either OCaml or F#, and more OO'ish, but it gets most of the basics, and it's easier to move from it to something else. Its advantages are pretty much the same as for F#, if you s/.NET/Java/. It also has decent IDE support for both Eclipse and NetBeans.

      If you just want to learn the theory, and do not want to be distracted by the non-FP stuff, then go for Haskell. It's the most popular pure FP language today, with plenty of tutorials, samples, and books. Be careful, though - while the basics are easy, there is a lot of pretty advanced stuff in Haskell, especially when you get past the '98 language spec and to what the compilers support these days. It's very much a research platform for new things in programming language design, particularly in the realm of type systems, so as you dig deeper you will find a lot of stuff that is very hard to wrap your head around.

    31. Re:it's always a good time to try functional by DancesWithBlowTorch · · Score: 1

      Simon is still working on and in Haskell.
      However, he has been working closely with Don Syme, the creator of F#. And yes, F# rocks. It's an absolutely beautiful language. Easy to learn (for a functional language) and with an extremely clean syntax. I do scientific computing, and I use it for everything now. (Except for plots, which I still do in Python).

    32. Re:it's always a good time to try functional by Anonymous Coward · · Score: 0

      You should choose a purely functional language like Haskell or Clean.

    33. Re:it's always a good time to try functional by TheRaven64 · · Score: 1
      Tail recursion is a programming idiom very common in functional languages. Tail recursion optimisation means that if you implement a tail recursive algorithm then its memory usage is O(1), not O(n). In functional programming you don't have imperative control structures, so you do something like a an event loop as (pseudocode):

      mainloop(State) ->
      X := nextEvent(),
      State := handleEvent(State, X),
      mainloop(State).

      Without tail recursion optimisation, this will cause a stack overflow after just a few thousand loops. With it, it will work safely. This is why all functional languages implement tail recursion optimisation, while Python does not. With GCC or LLVM (or a few other C compilers), C also supports this optimisation, and therefore this programming style.

      Claiming that Python is good for functional programming is something that you would only do if you have never written a line of code in a pure functional language.

      --
      I am TheRaven on Soylent News
    34. Re:it's always a good time to try functional by david.given · · Score: 1

      I've never been able to get my head around writing idiomatic functional code, and that was despite being taught Haskell at university --- I know the language, I just can't do anything useful with it! I'm just too much of a procedural programmer, and that's something I regret.

      I did try OCaml a little while back, reasoning that because it supports mutable state, it would be easier to learn. It was. I ended up writing procedural code in it, which rather defeated the whole point. It's a nice language, but I don't think it's suitable for learning functional style.

      Haskell's the best option that I know of, but the syntax is rather weird to anyone who's used to languages like C or Java. Are there any other lazy, strict functional languages that aren't descended from the ML family that I should look at?

    35. Re:it's always a good time to try functional by m50d · · Score: 2, Interesting

      Please. If you're writing that condescendingly I'd wager I've written more ML than you've written code full stop. The example you give is an extremely unnatural way of doing a loop control structure, and in a language that has more normal flow control there is truly no need for it. That one doesn't have to go through the contortions you do to get regular flow control in a pure functional language in python doesn't make it unsuitable for functional programming; on the contrary, it makes it the best language for functional programming. Once you've rewritten a perfectly clear function to a convoluted version using an accumulator so that you can get reasonable performance doing something that wouldn't require any of that in a slightly less dogmatic language, it quickly loses its appeal.

      --
      I am trolling
    36. Re:it's always a good time to try functional by PybusJ · · Score: 1

      If your OO experience is in Java then I would suggest you take a look at Scala. It compiles to the JVM and has good support for functional programming, but also supports your familiar OO techniques and interoperates with the huge amount of java code out there.

      I'd still suggest you play with Haskell (probably the most pure functional language that's widely available) while you learn; it's fun and will really make you think about programming problems differently -- even if you never produce a line of production code using it.

    37. Re:it's always a good time to try functional by Anonymous Coward · · Score: 0

      Concurrent clean. Its syntax is remarkably similar to Haskell, has a native and intuitive IDE, is very quick to compile and produces optimized binaries. Also, sooner or later you will do some IO and Clean's uniqueness typing is easier to grasp than Haskell's monads. But the IDE and the compiler is buggy and it is very hard to google for documentation when the keyword is "clean".

    38. Re:it's always a good time to try functional by Anonymous Coward · · Score: 0

      Finally, someone who knows what they are talking about!

    39. Re:it's always a good time to try functional by Skal+Tura · · Score: 1

      Where to start is the question, coming from Web Dev background with some C, Visual Basic and C# experience.

      What languages are out there? Where to go for some introductory tutorials etc.?

    40. Re:it's always a good time to try functional by BerntB · · Score: 1

      Are you really claiming that it is not a win to have tail recursion for traversing a list, tree or any bunch of complex data structures in a functional language?! (Didn't Python also lack continuations?)

      --
      Karma: Excellent (My Karma? I wish...:-( )
    41. Re:it's always a good time to try functional by QuestionsNotAnswers · · Score: 1

      Except if you care about Unicode support. Last I looked Haskell and O'Caml require the programmer to use special libraries for Unicode.

      --
      Happy moony
    42. Re:it's always a good time to try functional by bar-agent · · Score: 1

      I'm interested in really learning functional programming. Is clojure a real funcional language? What are some you would recommend?

      Depends on if you want to sink or swim. If you want a relatively easy learning curve, I suggest Dylan. I've heard that Scala is also approachable.

      Lisp, Scheme, Haskell, Ocaml, and Erlang will make your head explode. But if you survive, you'll eventually grow a replacement head.

      --
      i'd hit it so hard, if you pulled me out you'd be the king of britain [bash.org]
    43. Re:it's always a good time to try functional by m50d · · Score: 1
      Are you really claiming that it is not a win to have tail recursion for traversing a list, tree or any bunch of complex data structures in a functional language?!

      It's not a win. It's a nice feature, sure, and I'd like for python to have it, but it is not my any means necessary when python has more easily comprehensible ways of doing the same thing. Just as map and filter are nice, but I don't at all mind python toning them down in favour of list comprehensions, which are a better way of doing the same thing.

      (Didn't Python also lack continuations?)

      Of course it has continuations; they're expressed slightly differently to how you see them elsewhere, but they're there all the same.

      --
      I am trolling
    44. Re:it's always a good time to try functional by BerntB · · Score: 1

      Sorry, but for being taken seriously with a big claim like that, you need to start with some very good references. Not letting people ask multiple times. Otherwise, you sound mostly like a fanboy.

      --
      Karma: Excellent (My Karma? I wish...:-( )
    45. Re:it's always a good time to try functional by badkarmadayaccount · · Score: 1

      I think that's because Haskell is a dataflow language.

      --
      I know tobacco is bad for you, so I smoke weed with crack.
    46. Re:it's always a good time to try functional by j1m+5n0w · · Score: 1

      I did try OCaml a little while back, reasoning that because it supports mutable state, it would be easier to learn. It was. I ended up writing procedural code in it, which rather defeated the whole point.

      Ocaml was a nice transition language for me. I got used to ML syntax and functional programming ideas, but I could fall back on imperative concepts if I got stuck. This book helped a lot to show how to get stuff done in a number of different styles.

      Haskell's the best option that I know of, but the syntax is rather weird to anyone who's used to languages like C or Java. Are there any other lazy, strict functional languages that aren't descended from the ML family that I should look at?

      There may be, but none that I'm familiar with. Syntax you can get used to if it's consistent; that's one reason I prefer haskell to ocaml, the former (in my view) has a better thought out syntax. (Ocaml's revised standard form seems to be a lot better than the default syntax, but the existence of a whole cottage industry in the ocaml world around camlp4 scripts to modify the syntax should be an indication that something is wrong.)

      That said, there are some common coding idioms in haskell that I've just never gotten used to. The "$" operator I have come to appreciate, but "." just seems confusing. I think the best approach if you're writing code from scratch is to just use whatever syntax seems the most straightforward at the time, and ignore whatever you don't need to get the job done.

      If you're still willing to give haskell a go, I'd recommend "The Haskell School of Expression" as a pretty good book on doing things in a functional way. It's perhaps a less good book if you don't want to write just pure code, but want to understand IO, state, and monads in depth as well (for which "Real World Haskell" is perhaps a better choice).

  7. incoming pedant by cansado · · Score: 1

    i'm a great programmer, but i don't think i'm good enough to increase the number of transistors on an IC.

    1. Re:incoming pedant by smellotron · · Score: 1

      i'm a great programmer, but i don't think i'm good enough to increase the number of transistors on an IC.

      Ah, you must use vi.

  8. Multi Threaded programming by Samschnooks · · Score: 1
    Quotes from TFA:

    The answer is that FP languages store state in function parametersâ"that is, on the stack. ....

    Everything is a function.

    I think of FP programming as if it were a multithreaded program with some threads having their own core. I write threaded programs didn't use global variables, OK, maybe a semaphore, but nothing like variables. I don't see what the big deal is. I don't think this is going to cause programmers as many problems as he is saying.

    1. Re:Multi Threaded programming by pablodiazgutierrez · · Score: 4, Insightful

      Parallel algorithms are fundamentally different from sequential ones. Take sorting. No multi-threading is going to help you if you keep implementing quicksort. While many problems are inherently parallel and it is easy to undo their serialization, several others will turn into bottlenecks. I am almost done with my Ph.D. and still I haven't received a proper education in parallel algorithms. It'll take a whole new generation of CS teachers to make the grand paradigm shift.

    2. Re:Multi Threaded programming by MojoRilla · · Score: 4, Informative

      No multi-threading is going to help you if you keep implementing quicksort.

      Huh? Quicksort is pretty easy to parallelize, due to its divide and conquer nature: it splits its list into sublists and recurses on those sublists.

    3. Re:Multi Threaded programming by Anonymous Coward · · Score: 0

      You just disproved his entire thesis

    4. Re:Multi Threaded programming by beelsebob · · Score: 1

      No multi-threading is going to help you if you keep implementing quicksort.
      Really? You mean I can't split the list, and then quicksort each half on a different CPU, and repeat ad-nauseum until all CPUs are busy?

      Of note, functional programming gives me that parallelism without any effort on my part at all.

    5. Re:Multi Threaded programming by m_frankie_h · · Score: 1

      I agree with your point, thingh not with the example you gave.

      Incidentally, quicksort _is_ easily parallelizable:

      qsort([]) -> []; % of course

      qsort([P | A ]) ->
                      A1 = [ X || X = P ],
                      P = self(),
                      spawn(fun() -> P ! {a1, qsort(A1)} end ),
                      spawn(fun() -> P ! {a2, qsort(A2)} end ),
                      A1sorted = receive
                              { a1, A1s } -> A1s
                      end,
                      A2sorted = receive
                              { a2, A2s } -> A2s
                      end,
                      A1 ++ [ P ] ++ A2.

      I am sending lots of large messages, so this might be slow, but you could do this in place, just sending bounds of the intervals to be sorted.

    6. Re:Multi Threaded programming by Anonymous Coward · · Score: 0

      As far as I know, quicksort is an excellent example of what can be done easily in FP languages. Haskell example (from http://en.literateprograms.org/Quicksort_(Haskell)):

      qsort :: Ord a => [a] -> [a]
      qsort [] = []
      qsort (p:xs) = qsort lesser ++ [p] ++ qsort greater
              where
                      lesser = [ y | y <- xs, y < p ]
                      greater = [ y | y <- xs, y >= p ]

      Basicly, this code takes the first element p of the list and calls a recursive qsort on all elements larger than p. Each time a recursive call to qsort is called, a new thread could be launched. This yields a high level of parallelization. Of course there has to be some limit to the number of threads, as you wouldn't want millions of threads when sorting millions of elements. The point is that the task is easily parallellized.

    7. Re:Multi Threaded programming by maraist · · Score: 1

      Huh? How is quicksort non parallelizable? It and merge sort can have n/8 possible parallel threads using divide and conqor. mergesort can farm out threads initially then slowly merge in smaller number of threads (the bottleneck) while quicksort needs to pivot first (the bottleneck) then rapidly farm out threads.

      The problem is that the memory load becomes killer. If the mem blocks are cache-aligned when partitioned then you can get away with threads == the number of cores. You definitelydon't want to encounter MESI (sp?) cache coherance locking among other things.

      --
      -Michael
    8. Re:Multi Threaded programming by Anonymous Coward · · Score: 0

      It's not? Try delegating each recursive call to a separate thread.

      Perhaps you meant heapsort, which is inherently sequential.

    9. Re:Multi Threaded programming by Anonymous Coward · · Score: 0

      No multi-threading is going to help you if you keep implementing quicksort.

      Others disagree

    10. Re:Multi Threaded programming by Anonymous Coward · · Score: 0

      From wikipedia...

          Like mergesort, quicksort can also be easily parallelized due to its divide-and-conquer nature.

    11. Re:Multi Threaded programming by gooneybird · · Score: 1

      Perhaps, the problem of sorting needs to be looked at differently and ask the question: why is there a need to sort to begin with? - maybe the process that created the items to be sorted should be parallelized and each of those processes are responsible for deciding the sort order.. "There is no spoon..."

  9. Formal Methods Initiative by Janek+Kozicki · · Score: 4, Insightful

    This reminds me about the /. article "Twenty Years of Dijkstra's Cruelty", just a few days ago.

    Problem boils down to fact that programming is in fact a very advanced calculus. And writing a program is 'deriving' it. As in reaching a correct formula with a proof that it's correct. That's how software should be written anyways. And functional programming will only make it *simpler*, not harder.

    --
    #
    #\ @ ? Colonize Mars
    #
    1. Re:Formal Methods Initiative by sexconker · · Score: 1

      What's cal coo lus?

    2. Re:Formal Methods Initiative by Creepy+Crawler · · Score: 1

      If we're talking about mathematical analysis and transformations, yeah.. We need provable software. Complex math is formulas and it just makes sense to implement them in a provable way.

      However a lot of programming is GUI code, button code, action code and other niceties. Yeah, we need the pretty buttons, but they should have no bearing in the nuts and bolts of our program.

      --
    3. Re:Formal Methods Initiative by Anonymous Coward · · Score: 1, Interesting

      And functional programming will only make it *simpler*, not harder.

      I hear this sentiment quite frequently, but only from grad students and professors that specialize in the area of compilers/programming languages. The rest of us, who suffer through these courses only to fulfill a requirement, are firmly convinced these peers are quite deluded.

    4. Re:Formal Methods Initiative by Tablizer · · Score: 1

      I hear this sentiment quite frequently, but only from grad students and professors that specialize in the area of compilers/programming languages. The rest of us, who suffer through these courses only to fulfill a requirement, are firmly convinced these peers are quite deluded.

      It is indeed difficult to tell who is trying to justify their existence by hyping shit and what is a real trend.

      My best guess is that *some* parts of code for certain niches, such as gaming, will require parallel specialists. However, in a good many biz apps the network is the bottleneck, not the CPU; or SQL processing, which is already parallel-able in most cases if the DB vendor codes for it. Thus, it may merely be an up-and-coming specialty, but will not replace *most* programming actually done.
       

  10. Question by Anonymous Coward · · Score: 3, Interesting

    So a quick question before I go and master FP...does the compiler automatically compile the code that can be done in parallel in the proper "way", or do I have to specify something?

    Also, if I rewrote an app written in an imperative language to a FP one like Haskell, would I see a that much of a difference on a multi-core processor?

    1. Re:Question by Timothy+Brownawell · · Score: 1

      So a quick question before I go and master FP...does the compiler automatically compile the code that can be done in parallel in the proper "way", or do I have to specify something?

      I would imagine that this depends on the language and compiler you use.

      Also, if I rewrote an app written in an imperative language to a FP one like Haskell, would I see a that much of a difference on a multi-core processor?

      That depends on a great many things, including the quality of the compilers, your skill at writing code into the different languages, and the nature of the particular app.

    2. Re:Question by Zironic · · Score: 2, Interesting

      The way it should work is that if you're implementing a pararell algorithm like merge sort http://en.wikipedia.org/wiki/Merge_sort it should just go and get a new processor core each time you make a recursive call.

    3. Re:Question by johanatan · · Score: 1

      'Should' and 'do' are not the same though. Even Haskell (which *should* do these things automatically) does not. You still essentially have to specify a little 'tag' to say 'parallelize this'. It's a lot less verbose than the equivalent parallel_for in C# or C++, but still not as automatic as I'd like.

      I'm not sure if other FP languages/compilers do this, but it is certainly possible in theory (and the Haskell guys are working on it too I think).

    4. Re:Question by Chandon+Seldon · · Score: 1

      The way it should work is that if you're implementing a pararell algorithm like merge sort http://en.wikipedia.org/wiki/Merge_sort it should just go and get a new processor core each time you make a recursive call.

      How do you implement that so that for N processors each call after the Nth isn't horribly inefficient? Sometimes you want a new thread, sometimes you don't, and if you can figure out how to tell the difference with static analysis before you know about the target machine...

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    5. Re:Question by johanatan · · Score: 1

      Depends on the language and compiler. It is certainly possible in theory, but I don't yet know of any language/compiler which does it.

      And, it wouldn't so much be the compiler exclusively that does this, but rather some co-operation between it and the runtime.

    6. Re:Question by Zironic · · Score: 1

      In theory creating a new thread each time shouldn't be horribly inefficient, if it is then it's the operating systems fault.

    7. Re:Question by Chandon+Seldon · · Score: 1

      In theory creating a new thread each time shouldn't be horribly inefficient, if it is then it's the operating systems fault.

      I'm pretty sure that a system call will always be drastically more expensive than a function call.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    8. Re:Question by johanatan · · Score: 1

      P.S. It doesn't have to be a recursive function call either--any old function can be executed on any old core with pure (side-effect free) FP.

    9. Re:Question by Zironic · · Score: 1

      Well ye, I was only mentioning recursive calls because the specific algorithm was recursive.

    10. Re:Question by johanatan · · Score: 1

      Ahh, I see. :-)

    11. Re:Question by Estanislao+Mart�nez · · Score: 1

      GP is talking out of the wrong orifice.

      Functional language compilers and runtime systems don't have the ability to magically guess how to parallelize your computations in a way that actually helps performance. Yes, in principle it could construct a dependency graph of the subcomputations that the program has to perform, and execute as much of that in parallel, but that in practice would mean more time spent in thread synchronization than on computation.

      You still have to write your programs to specify where you need parallelism, and choose those places wisely. Where functional programming wins for parallelism is on two areas:

      1. In a parallel world, immutable data structures are way easier than mutable ones.
      2. Functional programming has a big emphasis on using functional combinators to transform data structures, instead of using loops like imperative programmers often do. This means that in the places where an imperative program usually has a loop, a functional program has functions like map, filter, reduce, and so on, that specify what to do instead of how to do it. Because of this, when you identify a place in your functional program where parallelism would help, it's comparatively easy to write similar functional combinators that do their work in parallel.
    12. Re:Question by lachlan76 · · Score: 1

      There's also the issue of moving memory around, though I'm not sure exactly how this works with multicore processors (I'm pretty sure that you can't have more than one core working on some part of the cache).

    13. Re:Question by hasdikarlsam · · Score: 1

      Haskell mixes greenthreads with OS threads to make this a lot less expensive (for N cores, N+1 OS threads, any number of greenthreads), but it's still a lot more costly than a simple function call. To a zeroth approximation, fifty times more expensive or so, maybe.

      Still, that does mean you can use CSP instead of state machines at no extra cost (kinda have to; haskell does not expose select/poll. You won't need it.), you just can't parallelize *every* possible call. And data-parallel haskell (still experimental) is making the rather tiny cost of annotating algorithms like that even smaller, essentially letting you mark everything that can be parallelized and letting the runtime system decide whether it should be.

    14. Re:Question by hasdikarlsam · · Score: 1

      With a purely functional language like Haskell (well, when not using stateful monads), all the shared data is read-only; cache coherency is then not an issue, as it only activates when you modify data.

      There are of course modifiable parts of memory, but in haskell those are per-thread - the stack and the nursery. No coherency issues there.

    15. Re:Question by hasdikarlsam · · Score: 1

      3. With data parallel haskell, the system can decide at runtime how much of an algorithm to parallelize, and where, vastly decreasing the mental effort of parallelization.

    16. Re:Question by mhelander · · Score: 1

      So the answer, in other words, is pretty much: "no".

  11. Slowly getting there by Anonymous Coward · · Score: 0

    Fortunately, people are also getting better and better at the comparably diffficult task of writing good books about FP. ;-) See the new book on Haskell.

    1. Re:Slowly getting there by K.+S.+Kyosuke · · Score: 2, Funny

      Hmm, strange, I thought I had logged on. You gotta love web apps. :]

      --
      Ezekiel 23:20
  12. Break? How? by grumbel · · Score: 1

    I don't quite see why algorithm should break. I would say the opposite is true, functional languages allow you to write an algorithm down much more clearly and compactly, leading to fewer bugs and better code.

    The problem I have with functional programming is more that most programming isn't about clear well specified algorithms, but about routing UI events around, connecting framework components and simple batch processing, i.e. areas where functional programming doesn't provide an obvious advantage.

    And of course functional programming doesn't make your algorithms magically parallel, it can help sometimes, but there is still plenty of manual work involved.

  13. Moore's Law? by DragonWriter · · Score: 2, Insightful

    Chipmakers have essentially said that the job of enforcing Moore's Law is now a software problem.

    How is maintaining the rate of increase in the number of transistors that can be economically placed on an integrated circuit a software problem?

    1. Re:Moore's Law? by perlchild · · Score: 1

      More like "we can't make data transfers fast enough to supply moore's law, so your software will have to use less of them". Having more parallel algorithms means they can seem to respect Moore's Law(which is good, their shareholders are happy). When in fact, it was an approximation in the first place, and probably should have said "you will route twice as much information through the chip in the same amount of time every 18 months." The paraphrase is mine, because outside of specific problems, having more transistors might be good, but what you really care about is the amount of arbitrary, problem-specific data you can push through your chip. I posit that the new GPU fad is based at least in part on the attraction of having pipelines dedicated to processing vector-based data at high speeds, and related to this.

    2. Re:Moore's Law? by Anonymous Coward · · Score: 0

      Chipmakers have essentially said that the job of enforcing Moore's Law is now a software problem.

      How is maintaining the rate of increase in the number of transistors that can be economically placed on an integrated circuit a software problem?

      Okay, so Moore's law deals with making transistors smaller. So what you could do is have the exact same chip, remanufacture it with a smaller process, crank up the clock and call it a day. Computer architects got a free ride, until that stopped working, so they had to go in and use processor architecture to speed up the chips with things like caching, pipelining, and branch prediction. Programmers so far, have gotten a free ride.

      Fast forward to a few years ago, and clock rates essentially stopped--computer architects hit a brick wall--so instead of tightening up the steps, they went parallel and now we have dual and quad core chips. It's still okay now to only make use of one of them, but in a few years when there are 1024 cores and your program only uses 1, then it better not be a very time sensitive program. No more free ride for programmers.

      Functional programming encourages the right things for parallelism that imperative programming doesn't. Things are no longer a set of steps to be done sequentially, but a set of calls and recursive calls to functions that can be dispatched to the available cores on your processor.

    3. Re:Moore's Law? by TapeCutter · · Score: 1

      Moore's 'law' is not a 'law' but rather an insightfull observation about the rate of evolution in processor technology. Processors have now evolved to where the metric used to make the original observations is less becoming meaningfull. Kinda like measuring the evolution of muli-cellular life by counting the number of cells in an organisim.

      --
      And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
    4. Re:Moore's Law? by gr8_phk · · Score: 1

      Chipmakers have essentially said that the job of enforcing Moore's Law is now a software problem.

      How is maintaining the rate of increase in the number of transistors that can be economically placed on an integrated circuit a software problem?

      If software can't utilize those added transistors to do something useful, then people will not pay for the extra transistors and the chip will not be economically viable. I thought you had a point until I thought for a few seconds.

    5. Re:Moore's Law? by Anonymous Coward · · Score: 0

      It's not. The article is ginked.

    6. Re:Moore's Law? by Torodung · · Score: 1

      How is maintaining the rate of increase in the number of transistors that can be economically placed on an integrated circuit a software problem?

      Utilising them efficiently is the software problem. Otherwise, the doubling rate becomes rapidly pointless. About twice as pointless every two years, according to the popular theory.

      What I am hearing, from the mouths of the noble chipmakers, is fear of obsolescence. They're claiming that they should be allowed to continue to make chips almost exactly as they have for the past two decades, and turn a profit from it, without really innovating. It is somebody else's problem to find a way to make their silicon wafers useful, valuable, and by extension, profitable.

      They might do better to paint their new sixteen to sixty-four core processors pink and erect an SEP field. Then maybe nobody will notice that they're "mostly useless."

      --
      Toro

  14. It's just hype by Anonymous Coward · · Score: 0

    Some things are easy to parallelize because they don't need mutable shared data (known as embarassingly parallel problems), other things are hard because they do need it.

    Functional programming prohibits using mutable data... so parallelization in FP is easy, but not because FP actually makes anything easier - it's because the only things you can do in FP are the embarassingly parallel problems.

    1. Re:It's just hype by mevets · · Score: 1

      It's not just hype; Church's hypothesis asserts that lamda calculus and turing machines are equivalent. I have a slightly different problem with 'fp is the answer' in that fp implementations that do not support lazy evaluation are so slow in practice to be useless. Lazy evaluation, which is approximately caching, monitors the dependencies between entities, thus limits re-evaluation to just what might have changed. I don't really see how this relationship management can be implemented effectively without 'mutable storage', which resurrects all the problems with more conventional programming models.

  15. Perl by Anonymous Coward · · Score: 0

    If you think perl is unreadable, wait till you read FP code.. it's even more compact and complicated than perl one-liners

  16. Function is easy by TheRaven64 · · Score: 3, Insightful

    The biggest problem with functional languages tends to be their type systems (I'm looking at you, Haskell). A functional language with a nice type system, like Erlang, is easy to pick up. And the example I picked totally at random, Erlang, also happens to have CSP primitives in the language, which makes parallel programming trivial. I've written code in it and then deployed it on a 64-processor machine and watched it nicely distribute my code over all 64 processors. If you program in a CSP style (which is easy) then your code will exhibit 1000-way parallelism or more and so will trivially take advantage of up to this many processes.

    And, actually, object orientation is a good option too. Alan Kay, who defined coined term, defined it as 'simple computers [objects] communicating via message passing' - sounds a lot like CSP, no? The main difference is that OO is usually implemented with synchronous message passing, but you can implement it with asynchronous messaging (actor model) then you have something almost identical to CSP. You can also add this implicitly with futures. I've done this in Objective-C for Etoile. Just send an object an -inNewThread message and any subsequent message you send to it is passed via a lockless ring buffer to the other thread and executed. We use it in our music jukebox app, for example, to run the decode in a separate thread from the UI. Implementing it in the language, rather than the library, means you can do it more efficiently, so this by no means replaces Actalk or Erlang in the general case, but modern processors are fast serial processors so it makes sense to program much larger chunks of serial code on these systems than Erlang or Actalk encourage.

    --
    I am TheRaven on Soylent News
    1. Re:Function is easy by Anonymous Coward · · Score: 0

      CSP? I think you mean CPS (Continuation Passing Style).

    2. Re:Function is easy by johanatan · · Score: 1

      And actually MS windows is a good option too. Just use 'PostMessage' instead of 'SendMessage' and run all windows in separate processor-bound threads. :-)

      And, yes, I'm joking. That would be a pain to manage.

    3. Re:Function is easy by Timothy+Brownawell · · Score: 1

      CSP? I think you mean CPS (Continuation Passing Style).

      Communicating Sequential Processes

    4. Re:Function is easy by Anonymous Coward · · Score: 0

      > The biggest problem with functional languages tends to be their type systems (I'm looking at you, Haskell)

      Haskell's type system is one of the major things that makes Haskell better than most other languages, because it catches tons of errors at compile-time and is very versatile. For example, monads which can be used to model almost any type of computation(for example building a prolog-like logic combinators or implementing an exception system) are just a clever usage of Haskell's type-system( and not built into the language specifically). Thus it allows for a very high level of abstraction. Try implementing exceptions in Java as a library!
      Once you get your program past the type-checker it usually works, unless one misunderstood the algorithm itself.

    5. Re:Function is easy by bar-agent · · Score: 1

      Haskell's type system is one of the major things that makes Haskell better than most other languages, ... Once you get your program past the type-checker it usually works, unless one misunderstood the algorithm itself.

      Heh. I've heard that same thing said about Ada.

      --
      i'd hit it so hard, if you pulled me out you'd be the king of britain [bash.org]
  17. I'm a functional programmer, but... by Anonymous Coward · · Score: 1, Funny

    I can't find a job. So don't worry, your non functional programming will lend you jobs at least fro another 30-50 years.

    1. Re:I'm a functional programmer, but... by windsurfer619 · · Score: 1

      I guess that makes you a non-functional programmer, huh?

  18. Sounds like a cop-out to me! by Jane+Q.+Public · · Score: 1

    If they want people to use their goddamned chips, then THEY can bloody well develop the necessary software tools.

    Buying a 16-core chip that does not have adequate software support is like buying a cadillac in a part of the world that has no gasoline. Most people won't do it!

    My suggestion is: boycott. Just don't buy the damned things until there IS adequate software support. (There isn't yet, even for 4-core chips!)

    Then watch the chipmakers jump to hire lots of programmers!

    1. Re:Sounds like a cop-out to me! by sexconker · · Score: 1

      But if you don't buy the hardware, who will write the software? And without any cars, who will open a gas station?

      Man, that was an easy one.

    2. Re:Sounds like a cop-out to me! by sumdumass · · Score: 1

      Christ, what are you doing? Trying to get intel and AMD to beg the government for bail out money too? Imagine all the people without jobs if the go down......

    3. Re:Sounds like a cop-out to me! by AlXtreme · · Score: 1

      Just don't buy the damned things until there IS adequate software support. (There isn't yet, even for 4-core chips!)

      I don't know about your OS, but mine distributes processes just fine across multiple cores. Perhaps it's time for you to upgrade from DOS?

      --
      This sig is intentionally left blank
    4. Re:Sounds like a cop-out to me! by Jane+Q.+Public · · Score: 1

      Mac OS X 10.5, which is of course based on BSD. Or Windows if I want, in a VM. Or Ubuntu.

      I doubt VMWare Fusion will do distributed processing very well but I really don't know.

      That's not really the point though. Even most multi-threaded or multi-process software today is really not written to run very well across multiple cores. That requires thread and process scheduling and synchronization that most programmers are not used to doing.

      Which was MY point: we need low-level firmware or something that handles this sort of stuff more automatically. (It will never be completely automatic, because the hardware does not know our intentions as programmers.) But it should be a lot MORE automatic than it is now; most programmers do not want to hassle with low-level threading operations, and (rightly) don't think they should have to. After all, that's what machines are for!

  19. Oh noes! by TypoNAM · · Score: 3, Funny

    Lisp! NO!!!!!!!!!!!!!!!!

    Rolls over and dies...

    (added to make filter happy)

    --
    This space is not for rent.
    1. Re:Oh noes! by flynt · · Score: 1

      Hating Lisp says more about you than it does about Lisp.

      http://www.paulgraham.com/icad.html

    2. Re:Oh noes! by Anonymous Coward · · Score: 0

      That's a mean filter. Not even computer programs should take joy in death.

    3. Re:Oh noes! by Anonymous Coward · · Score: 0

      > (added to make filter happy)

      The filter likes Lisp? No wonder it's a lameness filter...

  20. XSLT is functional by kbrasee · · Score: 1

    So I think I'll just switch from Java to that.

  21. Breaking algorithms by DragonWriter · · Score: 1

    The bad news? Getting good at functional programming is hard, harder than moving from iterative Pascal or Basic or C coding to object-oriented development.

    I suppose its hard for someone whose done lots of lots of programming and none of it in a functional style, much less a functional language, and who is used to artifacts of other languages as if they were fundamental elements of programming.

    It's an exaggeration but a useful one: When you move to FP, all your algorithms break.

    Algorithms don't break. The algorithms that have a simple, concise realization in an FP language may not be the same ones that do so in, e.g., C, and the implementation of an algorithm, even one that is similarly easy in the FP language and C, may be very different, but changing programming paradigms doesn't do anything remotely like breaking algorithms.

  22. Suggested reading. by DoofusOfDeath · · Score: 4, Informative

    I've recently gotten into FP. I started with Erlang and then branched into ML and Haskell. In case you're interested, here are the best books I've encountered for each language:

    Programming Erlang

    Programming Haskell

    ML for the Working Programmer

    Also, I'd definitely recommend starting with Erlang, because the Programming Erlang book made for a very easy introduction to functional programming.

    1. Re:Suggested reading. by Anonymous Coward · · Score: 0

      >

      ML for the Working Programmer

      Did you mean: me for the working programmer?

      NOOOOO!

    2. Re:Suggested reading. by autophile · · Score: 2, Informative

      There is also a very nice free intro to Erlang and functional programming in general, specifically for the procedural programmer: Thinking in Erlang

      --
      Towards the Singularity.
  23. FP not the problem by Todd+Knarr · · Score: 1

    The big problem won't be moving to FP. The big problem will be that many common programs simply aren't massively parallel. If your job doesn't involve many parallel tasks, you can't take advantage of multiple cores in it.

    Of course, you don't have to move to FP to take advantage of multiple cores. You just need to move to multi-threaded programming. I've been doing that for 20 years now. It takes a different approach to breaking down problems into implementable units, that's all. Certain algorithms are easier to expess in a functional language, but that's more a matter of the algorithm than multi-threaded vs. single-threaded. And multi-threaded is hard. It's not a matter of the language, it's a matter of having to remember that other things may have their fingers in your data, or of designing things so they don't. That's what gives most programmers fits, and I don't see FP making that any easier because it happens before you've gotten to the code.

    1. Re:FP not the problem by anon+mouse-cow-aard · · Score: 1
      agree that FP is not the problem. but folks are blowing the parallelism issue way out of proportion by talking about multithreading and such. There are many opportunities for parallelising things that are easy wins.

      take something like the gimp. There are lots of bits of image processing that can be trivially parallelized. All you need to do is tile the image out, and stitch the results together at the end. Data transfer... just make every transfer a separate job/process/program. You really don't need an uber multi-threaded multi-gizmo downloader. You want a single threaded tool that follows the download, and sends update messages, as it progresses, and exits when it's done. A separate program handles posting the messages to the client. Each download has it's own likely blocking read process. It's far simpler, and trivially intuitive to break many things down into simple tasks communicating asynchronously.

  24. Look at LabVIEW by pbrooks100 · · Score: 2, Informative
    1. Re:Look at LabVIEW by Falstius · · Score: 1

      Stupid pain in the ass Labview. If I had wanted to draw I would have stayed in kindergarten. I recently put together an interface and did it in Labview so that the undergrads who will eventually maintain it won't sully their diapers. It is great for toy projects and people who prefer to spend hours dragging around lines and pushing boxes instead of any time thinking.

    2. Re:Look at LabVIEW by pbrooks100 · · Score: 1

      The original poster was talking about learning new skills to take advantage of multicore and parallel programming. LabVIEW has been multithreaded and multicore capable for guite a long time. Don't blame your inability to understand graphical/dataflow programming or a flawed undergrad program on LabVIEW. With so much whining, Maybe you should still be in nursery school, typing A-B-C on the keyboard and wearing the diapers...

  25. It will be solved in other ways by Cthefuture · · Score: 1

    While I think every programmer worth their salt should know at least one functional language, I think the ALGOL-like (or C-like if you will) imperative languages will continue to dominate. I believe they work more like the human mind. More like the way we do elementary math. I think we will just get better compilers and libraries that will help with the parallelism.

    Another thing that is interesting is that scripting languages and virtual machines really seem to be the future for programming. The problem is currently very few of these languages even support threads, let alone anything more sophisticated.

    --
    The ratio of people to cake is too big
  26. "multicore paradigm shift" is nonsensical hype by Anonymous Coward · · Score: 0

    man pthread_create(3) and quit pretending the sky is falling.

  27. Which is more likely? by That's+Unpossible! · · Score: 5, Insightful

    A. Many programmers start writing or re-writing their code in functional programming languages.

    or

    B. Programmers continue writing to their platform of choice, e.g. .NET, Java, etc., and the guys writing the virtual machines do the heavy-lifting, making the VM execute more efficiently with multi-cores?

    I'll go with B.

    Apple is already proving this. Mac OS X Snow Leopard will have a lot of this built-in. Read about "Grand Central."

    --
    Ironically, the word ironically is often used incorrectly.
    1. Re:Which is more likely? by Anonymous Coward · · Score: 0

      Um, is .NET or Java in Snow Leopard? The Java-Cocoa interface was deprecated a couple of releases ago.

    2. Re:Which is more likely? by Silver+Gryphon · · Score: 2, Interesting

      Corollary to B:

      Visual Studio 2010 will make parallel and multithreaded programming easier to accomplish. Essentially, instead of just
        for(x=0;x1000;x++) dosomething();
      you'll have
        parallel_for(x=0;x1000;x++) dosomething();
      and 2-1000 threads will kick off at once. I'm sure there can be thread pooling, locking, etc., but if the code is segmented well enough then parallel programming for 32 cores is probably not that traumatic for 90% of the world's code needs. Get into some high performance stuff or time-critical code, and you're probably already past the point where VS2010's new parallel code library is interesting.

    3. Re:Which is more likely? by Anonymous Coward · · Score: 0

      Corollary to B:

      Visual Studio 2010 will make parallel and multithreaded programming easier to accomplish. Essentially, instead of just

        for(x=0;x1000;x++) dosomething();
      you'll have

        parallel_for(x=0;x1000;x++) dosomething();
      and 2-1000 threads will kick off at once. I'm sure there can be thread pooling, locking, etc., but if the code is segmented well enough then parallel programming for 32 cores is probably not that traumatic for 90% of the world's code needs. Get into some high performance stuff or time-critical code, and you're probably already past the point where VS2010's new parallel code library is interesting.

      The "parallel_for (params)" library call aren't slated for VS 2010. The beta is slated for 2011 (sp1), it'll take about a year to get it polished enough for the VS QA (library>>app) working with ATI/NVidia...

    4. Re:Which is more likely? by furball · · Score: 1

      Snow Leopard's implementation of B isn't a freebie. You're still going to have to recognize where parallelization could happen and rewrite that part of the algorithm to be functional in nature. The run time isn't going to figure out what can be made parallel and do it for you from your existing code. In fact, you'll have to use a whole new construct to make it possible.

    5. Re:Which is more likely? by Anonymous Coward · · Score: 0

      Well it depends the heavy lifting is relative. The issue is that you cannot avoid to program multithreaded decently even if the heavy lifting of multithreading is done by the VM guys. If you can remember how hard it was perceived by many to program swing because suddenly they had to use worker threads to push their background processing in then you can see how hard it will be that this paradigm will become the norm instead of the exception.

      Also you cannot avoid to learn how to parallelize certain problem classes so that they can perform better on massive parallel CPUs.

      I think this shift will go on slowly and will take several years, and my guess is, that most of the java programs nowadays will live happily on the new architectures since many of those guys at least to a certain extent know how to utilize parallelism. The hardest one to move over will be the C++ guys.

      But one thing will be hard for both classes of programmers, utilizing SIMD... That is a problem class not touched by a lot of people.

      If pure functional programming languages finally again will arise is questionable, after all if you drill down to the core of those languages, they are a step back to the 60s all the clutter has been added on top of them to make big systems managable! After all except maybe for smalltalk you can reduce most modern languages down to the function construct, but then you would omit namespaces, procedures, objects methods, and those constructs are there for a reason! And the reason is to make big software systems more managable!

    6. Re:Which is more likely? by shutdown+-p+now · · Score: 1

      The "parallel_for (params)" library call aren't slated for VS 2010. The beta is slated for 2011 (sp1), it'll take about a year to get it polished enough for the VS QA (library>>app) working with ATI/NVidia...

      Actually, yes, it will be in VS2010. The feature list announced for VS2010 includes both PLINQ (parallel programming for .NET), and PPL (parallel programming for C++). They've also specifically supported C++0x lambdas in VC10 for PPL; which is why the correct code snippet is actually this:

      Concurrency::parallel_for(0, 1000, 1, [&](int i) { dosomething(); });

    7. Re:Which is more likely? by shutdown+-p+now · · Score: 1

      You forgot about one more:

      C. The guys writing platforms (.NET & Java) will introduce more functional constructs into existing languages, and provide library-level solutions to parallelize them efficiently. Case in point is C# 3.0 and PLINQ.

      Today (VS2008):

      var result = xs.Where(x => SomeExpensiveCalculation(x) == 0)).Aggregate((x, y) => x + y)
       
      Next year (VS2010):
       
      <ecode>
      xs.AsParallel().Where(x => SomeExpensiveCalculation(x) == 0)).Aggregate((x, y) => x + y)

      They're also providing a similar API for C++, only that one is STL-centric.

      I think that, overall, it's the most pragmatic approach, and is most likely to succeed in short term. In long term, we'll have to live and see; perhaps stuff like STM will take over.

    8. Re:Which is more likely? by 16384 · · Score: 1

      you'll have parallel_for(x=0;x<1000;x++) dosomething();

      We already have this, it's called OpenMP. Your example would be something like

      #pragma omp parallel for
      for(x=0;x<1000;x++) dosomething();

    9. Re:Which is more likely? by david.given · · Score: 1

      Essentially, instead of just

        for(x=0;x1000;x++) dosomething();
      you'll have

        parallel_for(x=0;x1000;x++) dosomething();

      Yeah, they stole that from Occam, 25 years ago...

      SEQ i = 0 FOR 1000
          doSomething()

      PAR i = 0 FOR 1000
          doSomething()

      It was a good idea then, and it's still a good idea now, but C/C++ isn't really designed for this sort of thing --- Occam discourages global state, for example, and makes it very easy to have processes communicate via CSP (message passing) which means you very rarely need to use locks in Occam. As you say, most non-trivial uses of parallel_for() will still be a lot of work.

      (Those who do not study the lessons that obsolete programming languages teach us are doomed to... er... C, I expect.)

    10. Re:Which is more likely? by Anonymous Coward · · Score: 0

      The "parallel_for (params)" library call aren't slated for VS 2010. The beta is slated for 2011 (sp1), it'll take about a year to get it polished enough for the VS QA (library>>app) working with ATI/NVidia...

      Actually, yes, it will be in VS2010. The feature list announced for VS2010 includes both PLINQ (parallel programming for .NET), and PPL (parallel programming for C++). They've also specifically supported C++0x lambdas in VC10 for PPL; which is why the correct code snippet is actually this:

      Concurrency::parallel_for(0, 1000, 1, [&](int i) { dosomething(); });

      Really? Wow, I was just talking out my ass looking for a funny mod :) Thanks for the info.

    11. Re:Which is more likely? by Anonymous Coward · · Score: 0

      Scala is based on the JVM. F# on .NET, Erlang has it's own platform. So you can have A. and B.

      Leading to the choice: Should I use A. and B. or only B.?

  28. Sounds like BYTE magazine in 1985 by Stuntmonkey · · Score: 4, Interesting

    Look at the table of contents of this BYTE magazine from 1985. In a nutshell it said the same thing as this article: Functional languages are the great hope for solving the parallel programming problem. Only then the languages were different: Hope, Linda, and Prolog were among them.

    My response back then was to get excited about FP. My response now is: Where is the proof? Can anyone name a single instance where a functional paradigm has yielded the best measured performance on a parallel computing problem? In other words, take the best functional programmers in the world, and pair them up with the best tools in existence. Can they actually create something superior, on any problem running on any hardware? This is a very low bar, but until it's demonstrated FP will be confined mostly to the lab.

    IMHO the path forward is to treat parallel programming like just another optimization. As we know, the vast majority of your code doesn't need to run fast, and you get most of the performance benefit by optimizing small bits of code that really matter. I suspect the same thing will happen with parallel programming: In a given application only a few areas will benefit much from parallelism, and these tasks will probably be very similar across applications. Graphics rendering, large matrix math, video encoding/decoding, and speech recognition would be examples. People will treat these as special cases, and either develop special-purpose hardware (e.g., GPUs), or libraries that encapsulate the nitty-gritty details. The interesting question to me is what is the best runtime model to support this.

    1. Re:Sounds like BYTE magazine in 1985 by Shados · · Score: 1, Informative

      Functional programming isn't faster in a multi-core environment per say. What makes it better for multi-core programming, is that through functional programming, it is easier for a non-human entity (read: the compiler) to defer your -intent- from your code. Once the compiler, and more so, the runtime, know your intent, it can do the heavy lifting to make your code work in parallel, which is easier than the alternative (manage and spawn threads on your own, the efficiency of which depends on the hardware, so you'd always have to test how many core are present, how many are available at under which load, etc...no fun).

      So by moving some stuff on to functional programming, we can tend work on compilers and frameworks/runtimes that will take said code, and do whats best on the given platform to make it go fast, which, while possible, is much much more difficult using procedural.

      An example off hand is Microsoft's Parallel LINQ. LINQ is just fancy syntax sugar over functional programming., and it lets you turn, by adding basically one method, any LINQ code to parallel code, adjusting itself to current system load and amount of cores. mylist.Select( o => DoSomething(o)) simply becomes mylist.AsParallel().Select( o => DoSomething(o)), and poof, you're now calling DoSomething on every element of mylist, in parallel, spreading the load as well as possible.

      Now this is a simple example, and there IS equivalent syntax sugar to turn a normal For loop in parallel code... but with functional programming, you can push it further.

      Thats all there is to it.

    2. Re:Sounds like BYTE magazine in 1985 by gomoX · · Score: 2, Interesting

      Functional Programming is not a buzzword that is supposed to be better at paralellism. When coding in a stateless fashion (what FP is all about), function reduction can be split transparently across many computers. There are no locks, no funny semaphores and mutexes, no deadlocks, no nothing. It just works, because of its uncoupled nature of "no side effects, ever".

      There is one kind of early optimization that is not premature: architectural optimization. If you design your whole system to be synchronous, you trade off scalability for simplicity. If you design your whole system around the imperative paradigm, there will be a significant amount of work involved in making things work in parallel environments. There is no amount of later optimization that will fix this kind of architecture issues.

      Functional design is an architectural decision.

      --
      My english is sow-sow. Sowhat?
    3. Re:Sounds like BYTE magazine in 1985 by Anonymous Coward · · Score: 0

      Object orientated programing is the answer!

      Or at least, my twisted idea of OOP that made it very, very, very painful to learn ANY OOP language for a long, long, long time.

      Each object runs as itself, and independent. Yes, the actor model of parallel-whatever, applied to objects. Sure, you could complain that now strings cant be objects, and I say, whats wrong with non-OO string operations?

    4. Re:Sounds like BYTE magazine in 1985 by Prune · · Score: 1

      Huh? Prolog is not at all a functional language.

      --
      "Politicians and diapers must be changed often, and for the same reason."
    5. Re:Sounds like BYTE magazine in 1985 by arevos · · Score: 4, Informative

      My response back then was to get excited about FP. My response now is: Where is the proof?

      Whether functional programming is the best paradigm to use for parallel computing is undecided. But it does have a couple of advantages over imperative programming.

      First, imperative programming specifies the order of evaluation, whilst functional programming does not. In Haskell, for instance, an expression can essentially be evaluated in any order. In Java, evaluation is strictly sequential; you have to evaluate line 1 before line 2.

      Second, imperative languages like Java favour mutable data, whilst functional languages like Haskell favour immutable data structures. Mutability is the bane of parallel programming, because you have to have all sorts of locks and constraints to keep your data consistent between threads. Programming languages that do not allow mutable data don't have this problem.

    6. Re:Sounds like BYTE magazine in 1985 by Anonymous Coward · · Score: 0

      Can anyone name a single instance where a functional paradigm has yielded the best measured performance on a parallel computing problem?

      Some of the most scalable xmpp servers, ejabberd and facebook's chat for example, are written in erlang.

    7. Re:Sounds like BYTE magazine in 1985 by jfmiller · · Score: 1

      Erikson, Erlang, Telephone Switches. QED.

      --
      Strive to make your client happy, not necessarly give them what they ask for
    8. Re:Sounds like BYTE magazine in 1985 by gr8_phk · · Score: 1

      Whether functional programming is the best paradigm to use for parallel computing is undecided. But it does have a couple of advantages over imperative programming.

      First, imperative programming specifies the order of evaluation, whilst functional programming does not. In Haskell, for instance, an expression can essentially be evaluated in any order. In Java, evaluation is strictly sequential; you have to evaluate line 1 before line 2.

      Second, imperative languages like Java favour mutable data, whilst functional languages like Haskell favour immutable data structures. Mutability is the bane of parallel programming, because you have to have all sorts of locks and constraints to keep your data consistent between threads. Programming languages that do not allow mutable data don't have this problem.

      First, in a functional language the runtime has to make a decision that other languages specify - order of evaluaion. If order doesn't mater, a sequential language can start multiple threads too. Second, you can have immutable data in conventional languages too. Just don't modify variables. I don't think either of these details are what draws people FP.

    9. Re:Sounds like BYTE magazine in 1985 by Anonymous Coward · · Score: 0

      Google MapReduce?

    10. Re:Sounds like BYTE magazine in 1985 by phr1 · · Score: 1

      Since as long as you're running on the same hardware, you use the same instruction set regardless of what higher level language you program in, yeah, there will probably always be optimizations available in assembler that aren't available in HLL's. The question is how much extra work are you willing to do to get at them. Functional programming languages (FPL's) like Haskell are simply higher level languages than imperative languages like C or Java. Here is a Haskell program to print the sum of the squares of the first million integers, using multicore parallelism: print $ psum [| x*x | x http://www.cse.unsw.edu.au/~dons/blog/2007/11/29 Again, yeah, you could do that with Posix threads but it would be hellish by comparison. And we haven't even talked about the STM (Software Transactional Memory) library, which lets you share data between threads without messing around with locks (the compiler's type system automatically makes sure the sharing is thread safe). Check out the book http://book.realworldhaskell.org/ (text is online) for more info about this. Note it doesn't include the DPH stuff which is very new.

    11. Re:Sounds like BYTE magazine in 1985 by beelsebob · · Score: 1

      Can anyone name a single instance where a functional paradigm has yielded the best measured performance on a parallel computing problem?
      Certainly. Google invented the MapReduce language specifically because it allowed them to get speed out of parallelisation.

    12. Re:Sounds like BYTE magazine in 1985 by Anonymous Coward · · Score: 0

      First, imperative programming specifies the order of evaluation, whilst functional programming does not. In Haskell, for instance, an expression can essentially be evaluated in any order. In Java, evaluation is strictly sequential; you have to evaluate line 1 before line 2.

      Evaluation in Java need not be strictly sequential. It has to preserve 'as-if sequential' semantics, but the compiler, JIT and CPU are free to reorder instructions that are not data-dependent.

    13. Re:Sounds like BYTE magazine in 1985 by jbolden · · Score: 1

      Can anyone name a single instance where a functional paradigm has yielded the best measured performance on a parallel computing problem?

      Absolutely. Google's ability to analyze large blocks of the internet, decompose and index is being done using FP. They are way above anyone else in this matter.

      Another easy example is YAWS which was written by one guy in about 6 weeks. Outperformed Apache for speed / concurrent connections by a factor of 20.

    14. Re:Sounds like BYTE magazine in 1985 by arevos · · Score: 1

      First, in a functional language the runtime has to make a decision that other languages specify - order of evaluaion. If order doesn't mater, a sequential language can start multiple threads too.

      Yes, you can manually put in threads in an imperative language, but a sufficiently smart compiler can do this for you in a functional language.

      For instance, let's say you want to find the sum of the square roots of a sequence. In an imperative language, you'd write something like this:

      def sum_roots(xs):
          y = 0
          for x in xs:
              y += sqrt(x)
          return y

      Evaluation order is fixed by the language; the sqrt of the first item in the list is calculated first, then the second item in the list, and so on. To make this algorithm concurrent we'd have to manually go in and alter the code to support this.

      Conversely, in a functional language:

      sumRoots [] = 0
      sumRoots (x:xs) = (sqrt x) + (sumRoots xs)

      Here the evaluation order is not defined. We could evaluate the end sqrt calculation first, or assign the first 5 sqrt calculations to one thread, the next 5 to another thread and so on. Which sqrt is calculated first is entirely up to the compiler.

      Second, you can have immutable data in conventional languages too. Just don't modify variables.

      And how many conventional languages have a standard library that is optimized for immutable data structures? For instance, if I have an immutable HashTable in Java, and I want to add a new value to it, I have to create a copy of my existing HashTable. This is obviously very inefficient.

      Conversely, functional languages have data structures that are designed to be worked with immutably. New data structures can be created from old ones, not by copying their data wholesale, but by referencing their data in a way that's similar to how version control systems work. You don't need to maintain a copy of every past version; you just need to keep a list of changes.

      Obviously you could get some of the benefit of this simply by using a conventional language with some third party library that gives them efficient immutable data structures. But once you do this, you're basically half way to functional languages anyway, and you lose all of the syntax sugar that dedicated functional languages have for working with immutable data.

    15. Re:Sounds like BYTE magazine in 1985 by SpinyNorman · · Score: 1

      First, imperative programming specifies the order of evaluation, whilst functional programming does not.

      Yes, but there's nothing to stop you from building parallel processing libaries such as pthreads, OpenMP, CUDA or MapReduce using imperative languages - the semantics of your code are up to you. This seems to be a much more useful and practical way to take advantage of parallel hardware - keep the familiarity of the languages you know and then pick from a smorgasborg of parallel execution libraries as fits your needs. Relegating parallelism to libraries also has the advantage of freeing you from the limitations of the compiler... say that your Haskell compiler is able to generate "multi-threaded" code for multi-core processors, that's very nice, but what if you really want to spread your computation over multiple nodes in a cluster, or you want to use the power of your GPU-CPU video card to accelerate your application? Presumably you could write Haskell libraries to do this, but how is that much different from doing the same in C/C++ instead?

    16. Re:Sounds like BYTE magazine in 1985 by Hobbes_2100 · · Score: 1

      Can anyone name a single instance where a functional paradigm has yielded the best measured performance on a parallel computing problem?

      MapReduce?

      Granted, I'm answering a slightly different question: where has FP proved to be a very useful paradigm for solving an important problem. I won't make any claims about optimality.

    17. Re:Sounds like BYTE magazine in 1985 by arevos · · Score: 1

      This seems to be a much more useful and practical way to take advantage of parallel hardware - keep the familiarity of the languages you know and then pick from a smorgasborg of parallel execution libraries as fits your needs.

      The problem with this approach is that you wind up having to coordinate your threads and locking manually (such as in pthreads), or you wind up programming in a way that's only a stone's throw away from functional programming anyway (such as MapReduce).

    18. Re:Sounds like BYTE magazine in 1985 by Anonymous Coward · · Score: 0

      whilst

      Please stop using this word.

    19. Re:Sounds like BYTE magazine in 1985 by Anonymous Coward · · Score: 0

      First, imperative programming specifies the order of evaluation, whilst functional programming does not. In Haskell, for instance, an expression can essentially be evaluated in any order. In Java, evaluation is strictly sequential; you have to evaluate line 1 before line 2.

      All languages partially specify the order and most leave part up to the compiler.

      in imperative programming

      a = x()*y() + z();

      The compiler is free to call x y and z in any order.

      in functional programming

      g(f(x))

      The compiler has to evaluate f before g.

    20. Re:Sounds like BYTE magazine in 1985 by Anonymous Coward · · Score: 0

      Whether functional programming is the best paradigm to use for parallel computing is undecided. But it does have a couple of advantages over imperative programming.

      First, imperative programming specifies the order of evaluation, whilst functional programming does not. In Haskell, for instance, an expression can essentially be evaluated in any order. In Java, evaluation is strictly sequential; you have to evaluate line 1 before line 2.

      Logically not physically. The Java VM may (and does) execute instructions in order it 'feels' like, conditional on being logically equivalent. Hence the Java memory model to define rules for local caching etc.

      Second, imperative languages like Java favour mutable data, whilst functional languages like Haskell favour immutable data structures. Mutability is the bane of parallel programming, because you have to have all sorts of locks and constraints to keep your data consistent between threads. Programming languages that do not allow mutable data don't have this problem.

      However best practice certainly favour immutable data (e.g Josh Bloch's Effective Java)

    21. Re:Sounds like BYTE magazine in 1985 by Estanislao+Mart�nez · · Score: 1

      sumRoots [] = 0
      sumRoots (x:xs) = (sqrt x) + (sumRoots xs)

      Here the evaluation order is not defined. We could evaluate the end sqrt calculation first, or assign the first 5 sqrt calculations to one thread, the next 5 to another thread and so on. Which sqrt is calculated first is entirely up to the compiler.

      I think your example is very flawed. The compiler can't easily make the kind of analysis to drastically reorder or regroup this computation.

      Let's simplify your example for a minute by dropping the roots bit. So we just have a sum function:

      sum [] = 0
      sum (x:xs) = x + (sum xs)

      Now, when the system has to compute the value of sum [1..5], it basically has to compute the value of the following expression: (1 + (2 + (3 + (4 + 5)))). Unless the compiler recognizes that addition is commutative and associative, there is only one order in which it can reduce that expression to the final answer: from the inside to the outside. This is because your claim that "the evaluation order is not defined" isn't quite true. There is a well-defined partial order of value dependencies in a functional program, and any execution of the program must respect that partial order.

      Sure, in the case of that one example, you could write a compiler that recognizes that + is commutative and associative. The problem now is that doesn't help you when you're dealing with other functions.

      The correct solution here, IMO: you want to have a higher-order function, let's call it reduce, over lists that takes three arguments: a two-argument function (like +), an identity element for that function, and a list of values that are accepted by that function. The contract of reduce is that it will order and group the elements of the list in an undefined, implementation-dependent order, and then combine them with the function given. So here are three valid implementations of reduce:

      reduce1 fn id [] = id
      reduce1 fn id (x:xs) = fn x (reduce1 fn id xs)

      -- this one has identical order to reduce1
      reduce2 = foldr

      -- this one uses the opposite order to reduce1 and reduce2
      reduce3 = foldl

      Now, since the contract of reduce says that the order and grouping is undefined, that means that the only way to guarantee that you'll get the same answer with different implementations of reduce is to pass it an associative and commutative function, like +. It also means that if you write a bunch of code today using a sequential version of reduce, and you take care to respect the contract of the function, tomorrow you can replace any one of those uses with another function with the same contract, but which parallelizes the work.

      Short version: no, the compiler can't figure out what to parallelize very well at all.

    22. Re:Sounds like BYTE magazine in 1985 by bar-agent · · Score: 1

      Mutability is the bane of parallel programming, because you have to have all sorts of locks and constraints to keep your data consistent between threads.

      People say this, but why is locking even necessary?

      It seems to me that most values that a program accesses are only used by a single thread for its specific activities. So why is the paradigm "threads share all data?" Locks are an explicit way to disallow cross-thread mutation, but why not do that by default and require an explicit construction to allow cross-thread mutation?

      I think that should be standard practice!

      --
      i'd hit it so hard, if you pulled me out you'd be the king of britain [bash.org]
    23. Re:Sounds like BYTE magazine in 1985 by arevos · · Score: 1

      I think your example is very flawed. The compiler can't easily make the kind of analysis to drastically reorder or regroup this computation.

      Let's simplify your example for a minute by dropping the roots bit.

      Yes, I agree that dropping the root calculations results in an expression that is not easily paralellisable unless you know that addition is commutative. However, if you have an expression like:

      ((sqrt 1) + ((sqrt 2) + (sqrt 3)))

      Then the order in which you evaluate the sqrts obviously doesn't matter, and it wouldn't be hard for the compiler to automatically create three threads for each sqrt calculation.

      That said, I didn't mean to imply that functional evaluation was a panacea for parallel programming, merely that it can help.

    24. Re:Sounds like BYTE magazine in 1985 by zmower · · Score: 1

      Didn't you mention Ada earlier?

      Variables can be limited to the scope of tasks. Or pools of tasks can manipulate data scoped to packages. And for cross-task mutation there are entries (i.e. message passing) or protected types (i.e. locking) or pragma Atomic (if you're brave).

      Not to mention generics that don't make your head explode. And Ada 2005 finally added object.Method notation.

      --

      Sig pending!
  29. example by bcrowell · · Score: 4, Interesting

    As an example of the learning curve, I wanted to learn a little OCaml. I played around with this insertion sort example. I used it to sort a list of 10,000 integers, and it took 10 seconds, versus <1 second in C with linked lists. Not too horrible. But changing it to 100,000 integers made it die with a stack overflow, so I'm guessing that its memory use goes like n^2. However, it's not at all obvious to me from looking at the code that this would be the case. I think if I wanted to do a lot of OCaml programming I'd have to develop "FP Eye for the Straight Guy." Probably if you wanted to make it perform better on big arrays you'd want to make it tail-recursive, but it's not totally obvious to me from the code that it's *not* tail-recursive; although the recursive call isn't the very last line of code in the function, it is the very last thing in its clause...?

    I know of at least one well known OSS project in Haskell, written by a very smart guy, that is really struggling with performance issues. I wonder whether bad performance is to FP as null-pointer bugs are to C. Sure, a sufficiently skilled programmer should theoretically never write code that will dereference a null pointer, but nevertheless my Ubuntu system needs a dozen security patches every month, many of which are due to null pointers, buffer overflows, etc.

    1. Re:example by Anonymous Coward · · Score: 2, Informative

      it's not totally obvious to me from the code that it's *not* tail-recursive; although the recursive call isn't the very last line of code in the function, it is the very last thing in its clause...?

      The key is in the recursive expression:

      head :: insert elt tail

      This is not tail recursive because we can't reuse the current stack frame for the recursion - we have a local variable, head, which we need to keep around until *after* the recursive call returns.

      Tail recursion is quite easy to spot, because the expression will have the recursive call ("insert") at top level. In other words, it would have to look something like this:

      insert (head::acc) elt tail

      where acc is some kind of accumulator.

    2. Re:example by jfmiller · · Score: 1

      Please Google "tail recursion".

      --
      Strive to make your client happy, not necessarly give them what they ask for
    3. Re:example by Anonymous Coward · · Score: 0

      If _anything_ gets called after the recursion, it's not tail recursive. In other words, and a c-ish syntax:

      return foo (a) + 1

      is not tail recursive because it has to go back from foo(a) to add that +1

    4. Re:example by jbolden · · Score: 1

      The key to avoiding those sorts of mistakes is to write your code in terms of a single modifier and a fold. Those examples are designed to teach syntax and basic ideas performance is an intermediate topic in FP.

    5. Re:example by russotto · · Score: 1

      Googling 'tail recursion' produces a page which says at the end "Did you mean 'tail recursion'"?

    6. Re:example by bcrowell · · Score: 1

      The key to avoiding those sorts of mistakes is to write your code in terms of a single modifier and a fold.

      What's a good book to learn this kind of thing from?

    7. Re:example by Anonymous Coward · · Score: 0

      Note that Haskell would convert this function to an equivalent tail-recursive form automatically.

      Ironically, the O(n.log(n)) sorting algorithms are typically both easier to implement and more efficient in functional languages than the O(n^2) algorithms.

      From an efficiency perspective, the main thing to remember is that lists are not arrays. In particular, insertion or retrieval of an arbitrary element are O(n) compared with O(1) for arrays. If you use lists as if they were arrays, you get an extra n in your time complexity, i.e. something which should be O(n) becomes O(n^2), etc.

      OTOH, if you can make an algorithm work efficiently with lists, the result will likely have much better cache coherence than something which relies upon "random" access (when "RAM" is at least one order of magnitude slower than your cache, calling it "random-access" memory is somewhere between inaccurate and blatantly untrue).

  30. Functional Perl is a good way to start by filmmaker · · Score: 1

    I read a book not too long ago called Higher Order Perl, which highlights how natural functional programming in Perl is. That's right. Perl has pretty nice syntactical support for functional programming, too. The object-oriented stuff is bolted on, clumsily, in my opinion. But functional Perl is just as natural as imperative Perl. I've been writing Perl for eight years, although much less in the last few years, but this familiarity makes the transition from imperative (or what most programmers actually do, which is combine imperative and OOP styles, esp. in languages where the OOP part is bolted on, like Perl and PHP) to functional pretty simple. I had meant to use functional Perl as a stepping stone to OCaml and Haskell. But now I'm having too much fun with functional Perl...there's just no way this can end well... =D

    1. Re:Functional Perl is a good way to start by jbolden · · Score: 1

      Higher Order Perl is a good book and it teaches some nice techniques. But the book is about getting 5% of the FP benefits in Perl. You are missing a ton and working too hard to get the benefits. What is a neat technique in Perl becomes second nature in FP languages and you get many more features of the type that are in that book.

  31. parallel algorithms, mutable data, and STM by j1m+5n0w · · Score: 4, Insightful

    While pure functional code isn't allowed to manipulate mutable, shared state, functional languages often provide some mechanism to mix "pure" and "impure" (stateful, imperative code).

    In the haskell world, there is the IO monad, which is sort of a sandbox where anything is allowed. Functions within the IO monad (often called "IO actions") are allowed to invoke other IO actions or call pure code, but the reverse is not true; pure code cannot invoke an IO action. Also, due to laziness, pure functions that were passed an unevaluated "thunk" as an argument might trigger deferred IO, but this is (usually) transparent to the programmer.

    So far, this doesn't sound any better than a pure imperative language, but there is also an STM monad (for software transactional memory) which is like pure code except that you're allowed to access shared mutable data through a restricted API. STM is based on the idea that if two processes race and manipulate the same shared data structures at the same time, the conflict can be detected by the run time system, which can stop and replay the transaction one after the other.

    The reason STM transactions can be safely replayed by the run-time system is that the language guarantees that the STM transaction doesn't have any hidden state somewhere, that might cause problems if the transaction were replayed. This is not a guarantee you can make in C, C++, Java, or any other popular language that I am aware of.

    Note 1: It is possible for STM transactions to livelock if they continually conflict and are replayed, so you can still shoot yourself in the foot. However, it does make avoiding certain other problems much easier.

    Note 2: I'm not really a haskell guru, so everything above should be taken with a grain of salt. Real World Haskell has a chapter on STM, which is the basis of my current understanding (I haven't yet had cause to use STM in any program I've written.)

    1. Re:parallel algorithms, mutable data, and STM by Anonymous Coward · · Score: 0

      Monads is a hard concept to understand.

    2. Re:parallel algorithms, mutable data, and STM by j1m+5n0w · · Score: 3, Informative

      Monads is a hard concept to understand.

      I agree. I don't understand them very well, but fortunately one can make use of them without a complete understanding. For many programs, it suffices to understand that if you want to do IO, you need to do it within the IO monad (often in the IO action "main" which is equivalent to "int main() {...}" in C).

      This doesn't mean you have to write whole file parsers in monadic fashion, which is what I thought until I actually had occasion to write a file parser in Haskell, and found that I could write the parser as a pure function that accepts a string and returns the parsed data structure. Then, in main, I just read the file in with hGetContents (which takes a filename and returns a string) and then pass that string to my pure file parser.

      This would seem horribly inefficient for large files; what if there isn't enough memory to store the whole file as a string? But here, laziness comes to the rescue. The actual file IO doesn't happen until the file parser starts reading in the string. My pure function churns along, oblivious to the fact that it's causing deferred IO in the background, simply from forcing the evaluation of the string's value.

      This is, perhaps, not a very great insight into the nature of monads, but I thought I would share my experience, and if not enlighten then at least show that one can write normal programs in a fairly straightforward manner without being fully enlightened.

    3. Re:parallel algorithms, mutable data, and STM by Anonymous Coward · · Score: 1, Interesting

      i/o of all sorts has been my stumbling block with fp. Like many programmers I learned a fp language to give me new ways of thinking about problems - and that's all to the good, but when it comes time to actually do anything other than computation I go right back to C. functional language mechanisms for i/o seem like needlessly complex ways of doing the *exact* same thing you'd do in an imperative language.

    4. Re:parallel algorithms, mutable data, and STM by phr1 · · Score: 1

      IO in Haskell is done with values called "actions" which can be viewed as state transformers on the real world (in fact their datatype is a function taking a "RealWorld" value and returning another one). So the value (print "hello world") is a function into which you (figuratively) enter a state of the world in which you're looking at a blank screen, and the function gives back a state where your screen says "hello world".

      So what happens if that function tries to do something sneaky, like save a copy of the input state and let you re-use it to "go back" in time? The answer is that the data types surrounding I/O actions are organized in a way that prevent you from getting access to that "value", sort of like private instance variables in Java. Monads are simply a class of data types that make it convenient to express that kind of abstraction, and also to write what looks and acts like imperative code when you want to, even though it's still functional under the skin. People get confused by thinking monads somehow implement the I/O. Rather, they just describe datatypes used by the runtime system, that implement those I/O state transformer actions.

    5. Re:parallel algorithms, mutable data, and STM by j1m+5n0w · · Score: 1

      There's definitely a big learning curve. In haskell, a lot of the things you'd normally do with loops can be achieved through standard library functions, but you have to know a lot of functions to get anything done.

      Bad analogy: C is like DOS, whereas Haskell is like Linux. In DOS you could do just about everything there was to do with about 8 commands (cd, edit, md, rd, dir, del, copy, move). On my current ubuntu box, there are 1931 programs in /usr/bin. Of course, I don't need to know them all to get stuff done, but it helps to know more than 8.

      So, instead of iterating over a data structure with a loop, you use maps and folds. It's a different way of doing things.

      IO is a particular stumbling block for many who would learn Haskell. IO itself isn't really any trickier than it is in any other language, but to do IO you also need at least a rudimentary understanding of the whole monad thing. I think the only solution is to find one of the several good books on programmin in haskell. (Real World Haskell just came out, and is focused particularly on making useful programs that interact with, say, files and databases.) From my experiences, Haskell IO makes a lot more sense than it did when I started. It seems like a lot of work initially, but it's nice to be able to look at a several thousand line program you wrote and not have calls to read and write, and mutable global variables everywhere.

    6. Re:parallel algorithms, mutable data, and STM by shutdown+-p+now · · Score: 1

      If you think monads were hard to understand, try arrows (which are a generalization of monads). Note that this isn't just theory - there are many Haskell libraries that use arrows already for different tasks, including such mundane ones as XML parsing.

    7. Re:parallel algorithms, mutable data, and STM by Anonymous Coward · · Score: 0

      That's a very useful explanation.

  32. SemiStupidQuestion. by sumdumass · · Score: 1

    This is probably a stupid question but,

    Shouldn't it be possible for the operating system to provide a milticore framework-layer that will allow normal single core algorithms and applications to run in a quasi virtual mode by splitting or taking advantage of the paralel processing and reporting it back as if a single processor?

    I mean if it could be done on a low enough level, and I believe most operating system provide that level by taking over the processing control from the BIOS, but it should be possible to create a sort of layer that would take advantage of the multiple cores directly allowing old school programs to function as normal but seeing the advantage of multiple cores. I'm sure it would be slower then a true multi-threaded application but would the overhead make it worse then a regular application that can only take care of one processor?

    I probably used quite a few terms wrong in that. That is why I am asking, I don't pretend to be an expert here. Anyways, I was thinking that if it was a framework, then small alterations could be made to implement the ability and that too could limit exactly how much differently an application could run and thereby eliminate some of the problems in the process. My guess is the problem would be getting information back before the subsequent instruction had returned in which a modified scheduler could help with. But then again, I don't know.

    1. Re:SemiStupidQuestion. by Free+the+Cowards · · Score: 0

      There is no known method for taking a serial program and parallelizing it in an automated fashion. What you propose would be great but nobody knows how to do it.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    2. Re:SemiStupidQuestion. by Fulcrum+of+Evil · · Score: 1

      Shouldn't it be possible for the operating system to provide a milticore framework-layer that will allow normal single core algorithms and applications to run in a quasi virtual mode by splitting or taking advantage of the paralel processing and reporting it back as if a single processor?

      No. What you asked for is an auto-parallelizer hunk of code, which we don't have, at least, not in any useful way.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
  33. take it from a computational physicist by Anonymous Coward · · Score: 0

    Not all tasks can be made parallel. Monte Carlo simulations, or any task that requires knowing the outcome of the previous task is not able to be made parallel.

    1. Re:take it from a computational physicist by colinrichardday · · Score: 1

      Why do Monte Carlo simulations need to be sequential? Just use a parallelizable random number generator.

    2. Re:take it from a computational physicist by Ambitwistor · · Score: 2, Insightful

      He's probably talking about Markov chain Monte Carlo, not the simple Monte Carlo where you just draw random numbers. You can run a bunch of Markov chains in a parallel manner with no communication, so MCMC is perfectly parallelizable in that sense. However, that often doesn't help you, since the main problem is usually a slowly mixing chain. Running N poorly-mixed chains isn't much better than running one. What you'd really like is to speed up a single chain. There are parallel MCMC algorithms out there that try to swap members from parallel chains to speed up each individual chain, but they're not always worth the effort.

    3. Re:take it from a computational physicist by jbolden · · Score: 1

      Actually quite frequently they can be made parallel. It often turns out that the previous case is needed but not the initial. That is I can generate case 200 as a simple function on the value 199. Then generate 201 using the same function... right through to 399. Then all that has to happen is I get the value for 200 and it binds 399.

  34. "Hard" is not the problem by unity100 · · Score: 1

    In a lot of industries many people are doing very hard jobs and making world go around. its not the problem.

    the problem is feasibility. up to this point, from what it seems, mainstream computer users and even non-niche I.T. world didnt have the need for multi cores' increased performance. what do they do daily runs on existing stuff already.

    and if multi core programming takes longer time, which is the main cost in programming and development projects, its a no go. huge time, small efficiency gain that little number of people care about -> infeasible.

    check out games. its one of the most cutting edge areas of mainstream computer usage, and what ? crysis uses 2 cores and its still the most loaded game in demand for performance. how many 4 core games are there ? none ?

    there.

    this may work for supercomputing, and then again a niche part of it, but i dont see it for mainstream computer usage or i.t. industry work.

    1. Re:"Hard" is not the problem by Shados · · Score: 1

      Devil May Cry 4 on PC will use 4 cores (actually, the performance difference between dual core and quad is quite extreme, and I beleive its designed to use more than 4). It doesn't change the validity of your argument, but just saying there ARE some :)

  35. Thermodynamic computing by CustomDesigned · · Score: 5, Funny

    Pure functional programming removes all side effects. This make memory optimization (critical to efficient multiprocessing) much easier. It also makes garbage collection easier - but that is pretty much canceled by an increase in garbage.

    But beyond functional programming is thermodynamic computing. This starts with functional, but requires all operations to be reversible. Ideally, the total electrons are conserved - you can never clear a bit - just exchange bits (and of course more complex operations like add, mul, etc - but all reversible and charge conserving). Of course real hardware will still need to make up for losses, but power consumption and heat go way down.

    The fascinating thing is that thermodynamic programming requires a pool of known 0 bits and known 1 bits. As the algorithm progresses, you can't just throw away results you aren't interested in - you collect the unwanted results in an entropy pool. Eventually, you run out of known bits, and need to clear some entropy bits in order to continue. This takes lots more power (like erasing a flash block). The analogy to real world entropy is striking.

    1. Re:Thermodynamic computing by Gorobei · · Score: 4, Funny

      It is sad this was moderated "funny" rather than "interesting"

    2. Re:Thermodynamic computing by DoubleReed · · Score: 1

      Er... wha?

      The idea of "not wasting" precious electrons inside your CPU is seriously out there technology. Like, Warp Drive and Teleporters out there.

      Let's take an asynchronous AND for example. Here is how it works:
      1- two logical inputs connect to each of two transistors (2 PMOS, 2 NMOS; 2 positive on, 2 negative on)
      2- the positive on transistors are connected between high voltage and the output; the negative on transistors are connected between ground and the output
      3- the positive on transistors are in series; if both inputs are high, then they will "turn on" closing the connection between output and the high voltage source
      4- the negative on transistors are in parallel; if either input is low, then one or the other transistor will "turn on" closing the connection between output and the ground source

      So, between every step of logic the electrons are flushed clean through the system. The "input" electrons actually have no path to the output.

    3. Re:Thermodynamic computing by Plutonite · · Score: 1

      I'm afraid to tell you that in this house we are not going to obey the laws of thermod.. oh crap.

    4. Re:Thermodynamic computing by CustomDesigned · · Score: 2, Informative

      Cutting edge, yes. But not warp drive.

      http://www.cise.ufl.edu/research/revcomp/

    5. Re:Thermodynamic computing by Creepy+Crawler · · Score: 1

      I dont know who modded you funny, because it's not in the least.

      However, it is very interesting that reversible programs are gaining traction.. Let us hope that reversible CPU's are also coming soon.

      Side note for those who do not understand: The heat in our CPU's has been equated to the entropy in the die itself. Numbers are continually thrown away and recalculated then thrown away. These numbers, represented as information, do not just "go away", as they represent quanta of heat (work, if you will). With enough work emitted as entropy, we have heat emanated from the core. A reversible CPU could literally step back through the equation and recover the energy it used in processing with no heat loss.

      Here's a good link to get you started.

      --
    6. Re:Thermodynamic computing by MindStalker · · Score: 1

      Thermodynamic computing is necessary for DNA or other chemical based computing. Its also a preferable method of quantum computing.

    7. Re:Thermodynamic computing by Anonymous Coward · · Score: 0

      Anytime a transistor dumps a charge to ground, That's a loss. Didn't SciAm cover this subject (lossless computing) 20 years ago?

    8. Re:Thermodynamic computing by smellotron · · Score: 1

      You know... I can't tell if you're blowing smoke up my ass, or if you're telling me something that is Truly Awesome.

    9. Re:Thermodynamic computing by TeatimeofSoul · · Score: 1

      The analogy to real world entropy is striking.
      That's because it is real world entropy. Even if you're just thinking
      about such a process (in detail - with all the ones and zeroes), that's
      real world entropy too.

      Entropy is a measure of disorder in any form, and can therefore not be
      'bound' by any abstraction layer.

    10. Re:Thermodynamic computing by TheLink · · Score: 1

      Yes that's how it works in most electronic stuff now.

      When a bunch of precious electrons get "wasted" after representing a 1 or 0 (and get flushed or whatever), they generate heat.

      Heat is a big problem with many electronic devices nowadays.

      So some people think that by not wasting those electrons where possible, you generate less heat.

      That's what he was talking about.

      --
    11. Re:Thermodynamic computing by ChunderDownunder · · Score: 1

      Indeed, isomorphic algorithms could be quite useful for software transactional memory.

      But then I flunked high school physics, so (s)he lost me when starting to talk about entropy.

    12. Re:Thermodynamic computing by nusuth · · Score: 1

      He is not making that up. But the amount of heat generated by irreversibility of the computation in a 3 GHz CPU executing a 64 bit instruction(+data) per cycle, using 20 internal steps per bit per instruction is 3E-21*3E9*64*20 watts. That is about 5 billionth of the said CPU's power budget. Draw your own conclusions.

      --

      Gentlemen, you can't fight in here, this is the War Room!

    13. Re:Thermodynamic computing by Eternauta3k · · Score: 1

      Bollocks
      Although I vaguely recall that this kind of operations are necessary for quantum computing

      --
      Yeah. Would you choose a neurosurgeon who pokes around people's brains in his spare time? I wouldn't.
    14. Re:Thermodynamic computing by Anonymous Coward · · Score: 0

      But beyond functional programming is thermodynamic computing. This starts with functional, but requires all operations to be reversible.

      And don't forget aerodynamic coupling. That's when the programmer gets so frustrated he tosses the laptop out a window.

    15. Re:Thermodynamic computing by maxume · · Score: 1

      The universe gets offended when things change, so things can't be changed all the way back. You can draw a circle and change things back inside the circle, but you will have to change things outside the circle even more in order to complete the changes inside the circle.

      --
      Nerd rage is the funniest rage.
    16. Re:Thermodynamic computing by Informative · · Score: 1

      Why was this insightful comment modded funny?

    17. Re:Thermodynamic computing by DoubleReed · · Score: 1

      Thank you to you and the others who challenged me on about this. You have caused me to learn something new today :-).

      What is actually being done though is a bit different than what I interpreted GP to be saying. Talking about needing to keep the number of 1's and 0's constant. That makes me imagine a system in which charge just flows from the gate of one transistor to the gate of another.

      This is not anything anyone has proposed. I stand by my assertion that technology where transistors are not directly closing the connection between either a positive or negative source.

      Take a look at the pdf here. There are a couple of circuit diagrams for different types of "Adiabatic" circuits. (I put adiabatic in quotes, because these are not adiabatic in the thermodynamic sense that GP was discussing, just very low power.) Adiabatic Circuits Paper
      Those circuits are of the same family as what I describe in my original post. The main difference is that the positive and negative sources are functions rather than constant.

      It is an interesting idea. I don't think even this is practical though, for a simple reason. Clock skew is one of the biggest problems in modern circuit design. For this to work, you need to have this perfectly smooth wave that passes over one logic stage after another so that each one generates the output while generating minimum heat, and stays on just long enough for the input to be received by the next stage.

      But, hey it would be really neat.

      Also, just to reiterate. This will have zero impact on programming. There is nothing here about conserving 1's and 0's. That is Star Trek stuff.

    18. Re:Thermodynamic computing by Snufu · · Score: 0

      It is sad this was moderated "funny" rather than "interesting"

      Wasn't it Clarke who said: "Any sufficiently advanced technology is indistinguishable from funny?"

    19. Re:Thermodynamic computing by spectecjr · · Score: 1

      Hmmm... I'm not sure I buy the exchanging bits idea. If it was that easy, you could store all bits in the system as pairs of bits (one 0, one 1), and just exchange those whenever you needed to for a result. The problem is that there's a switch in there which determines which bit you're using out of the two at any time, and that switch needs to be flipped as well. Now if that little switch needs less energy to change than the states of the bits, then you've got a net win, but I'm not sure I buy it.

      Memristors are going to be the more interesting development, I think.

      --
      Coming soon - pyrogyra
  36. If you want to find a job learn to type by Anonymous Coward · · Score: 0

    "...at least fro another..."

  37. I wish the Itanic hadn't been such a horrible chip by Omnifarious · · Score: 1

    Because it had a good solution to this problem. Basically it presented the compiler with the opportunity to launch several parallel operations.

    That's where this problem should be solved. Convincing all the software people to change how they do things to make up for the inability of the hardware people to design good hardware isn't the way to solve the problem.

    The Itanic (erm some people might call it the Itanium) had an architecture that was ostensibly designed to fix this. But in reality it was a horrible failure for a number of reasons that I think had more to do with Intel's hubris and temporary failure to realize that good marketing is no subsitute for good engineering in the 2002-2006 timeframe.

    Though, I also think that a reason for its failure is that radical new chip architectures basically require Open Source software to succeed because otherwise you have to get too many proprietary software vendors on board to porting their software. For example, the port to the x86_64 architecture was essentially complete about 2.5 years ago for Linux and still isn't really done for Windows.

  38. I suppose I should by mmu_man · · Score: 1

    finish my port of XEmacs to BeOS and Haiku, and update the define of B_MAX_CPU_COUNT from 8 to 256 :)

  39. Except (X)Emacs isn't really thread friendly by mmu_man · · Score: 1

    sadly :-(

  40. type systems by j1m+5n0w · · Score: 1

    The biggest problem with functional languages tends to be their type systems (I'm looking at you, Haskell).

    I would say rather that the nice thing about Haskell is its type system. I haven't programmed in Erlang, so I can't compare the two, but I find type inference and strong type checking make for easy refactoring, not a whole lot of unnecessary typing, and very robust code.

  41. why FP is helpful for parallel tasks by j1m+5n0w · · Score: 2, Informative

    And multi-threaded is hard. It's not a matter of the language, it's a matter of having to remember that other things may have their fingers in your data, or of designing things so they don't. That's what gives most programmers fits, and I don't see FP making that any easier because it happens before you've gotten to the code.

    Many functional languages do not allow the program to manipulate shared state, which removes that whole class of problems; information sharing is limited to letting the run time system fork threads and copy function arguments and return values back and forth.

    However, if you really do need shared mutable state (and there are plenty of algorithms that do), in Haskell there's software transactional memory, which provides a restricted API for manipulating shared mutable state with the STM monad. Since the code within an STM transaction is not allowed to cause side effects or access any shared mutable state outside of STM, the runtime system is able to stop and replay transactions whenever it detects conflicts. This is one area where FP actually can make things easier, by enabling the same sorts of operations you might do in an imperative multithreaded program, but doing it in a much safer way.

    And, if you don't need shared mutable state, sometimes parallelism can be achieved just by replacing "map" with "parMap" in the right places and recompiling with the appropriate options. It doesn't get much easier than that.

    1. Re:why FP is helpful for parallel tasks by Todd+Knarr · · Score: 1

      That's a standard concept for multi-threaded programming in any language, though. I was doing it in C back when fork() actually let you modify your siblings' (and parent's) memory. It's even taught in every basic programming course: avoid global variables, stick to local variables only so you don't have to worry about side effects and synchronization. So why hasn't this taken the world by storm at any point in the last 30 years?

      Hint: look at the data requirements of large sets of interesting programs.

    2. Re:why FP is helpful for parallel tasks by cdfh · · Score: 1

      parallelism can be achieved just by replacing "map" with "parMap" in the right places

      Also useful is just using par to do a pure evaluation in the background.

      a `par` b `seq` (a + b)

      Will evaluate a and b in parallel, and then sum them.

    3. Re:why FP is helpful for parallel tasks by j1m+5n0w · · Score: 1

      It's even taught in every basic programming course: avoid global variables, stick to local variables only so you don't have to worry about side effects and synchronization. So why hasn't this taken the world by storm at any point in the last 30 years?

      Because sometimes global variables are really convenient, and the compiler for most languages doesn't force the programmer to write the program the right way.

      It's certainly not impossible to write correct parallel C code, but the fact that it's easy to write incorrect code means that a lot of parallel C programs are incorrectly written. Or the programs call libraries that were written by someone who didn't need thread safety for their application.

      The difference between C and the Haskell STM monad is that the latter enforces the constraint that your code can't be mutating any global state except that which is accessed through the STM api. If you try to write to a global variable, the program won't compile because you're not in the right monad to be able to do that.

      The extra protection that STM enforces might come at some run-time costs; there may be cases where the programmer knows that a certain operation is safe, but must still pay for the STM overhead regardless. There are situations where C really is the right language for doing parallel computation, but C does tend to be high-maintenance simply because it lets programmers do dumb things. And even if you write perfect code, you may have to work with programmers who don't, and you might dependencies on libraries that you don't necessarily know if they're thread-safe or not. Rather than expecting everyone to be perfect, it seems to me safer and easier (in this case, at least) to use tools that have fewer ways they can be used incorrectly.

      Sometimes C is a defensible choice, but if you just want to write a program quickly and have it work without a lot of testing and debugging, Haskell might not be a bad option.

    4. Re:why FP is helpful for parallel tasks by Todd+Knarr · · Score: 1

      The "right" way often isn't. For instance, take a Web-analytics server (which I know well, having written one). You have shared data in the 1.5-2 gigabyte neighborhood. It should be pretty obvious that you can't give each thread their own copy of that structure. More importantly, every thread must update entries in that data structure. If they don't, then the thread that handles the next request won't have the updates from this thread to work with. You won't be able to hand the entire sequence of page hits off to a single thread to handle, since page hits are independent in HTTP and the browser doesn't (or at least can't be assumed to) maintain a single connection for the entire sequence. At the same time, the whole program's the poster child for massively parallel programming: an extremely large number (2000 or more per second) of transactions that can be in large part handled independently, it's only at the very end when they store their results that they hit a shared data structure. Languages like Haskell would be ideal for it, except that they impose unacceptably high overhead for things that need to be done for the program to function. So we end up doing it in C. It's not the best tool for the job, it's merely the only tool that lets you get the job done (where the job is defined not just by the processing but also by being able to do it fast enough to keep up with the required traffic volume using a small enough number of cheap enough machines to fit within budget).

      NB: one comment I've made about developing software: "You don't pay me the big bucks to know it all. You don't pay me even for knowing exactly which kind of wrench, screwdriver etc. to use on which figurative bolt in the software machinery. You pay me to know when to chuck the wrenches and take an E-Z-Out and a tap to that sucker. And when not to.".

    5. Re:why FP is helpful for parallel tasks by j1m+5n0w · · Score: 1

      You have shared data in the 1.5-2 gigabyte neighborhood. It should be pretty obvious that you can't give each thread their own copy of that structure. More importantly, every thread must update entries in that data structure. If they don't, then the thread that handles the next request won't have the updates from this thread to work with.

      I realize that some parallel tasks need to share mutable data; that is, in fact, what STM is for. To use STM, (as I understand it, I'm no expert) you just store your mutable state inside of TVars, which are generic containers that can hold any normal value as long as it's well typed (Ints, Lists, Tuples, More TVars, etc...). In the case of your web analytics server, I imagine you might construct a hash table out of a large array of TVars indexed by, perhaps, some hash of the client's IP and port number. All of the threads on the machine have access to the array (which is just a pure immutable global variable), but to read or write to any individual TVar element, the thread has to call readTVar or writeTVar, which can only be called within atomic transactions within the STM monad.

      If two threads race and, say, one writes to a TVar that's being read by another thread in another transaction, the runtime system responds by re-executing the conflicting transactions.

      One could reasonably claim that this doesn't sound a whole lot like functional programming anymore, but the clever thing about STM is that the runtime system can safely replay transactions because they aren't allowed to cause any side effects outside of the TVars managed by STM. There aren't many programming languages that can make a guarantee like that.

      There might be other valid reasons for not using Haskell in this sort of system (file descriptor exhaustion if they're not being garbage collected fast enough, lack of a parallel garbage collector, slower than C in general, higher memory use, difficulty in finding qualified developers, etc...) but you seem to be arguing that Haskell wouldn't work in your case because it can't share state between threads, which isn't the case.

  42. that hasn't materialized, though by Trepidity · · Score: 4, Interesting

    Auto-parallelization of functional programs has been proposed for decades now, and every attempt has fallen on its face as the overhead has killed any gains. Current parallel FP research isn't even putting that much effort into auto-parallelization, because most PLs researchers consider it a dead end---taking a random FP and evaluating all its thunks in parallel as futures, or some similar mechanism, is not going to solve the problem.

    Instead, most of the current research is in programmer-level primitives for designing and specifying inherently parallel algorithms. There is some of this in both the FP and non-FP communities.

    1. Re:that hasn't materialized, though by Anonymous Coward · · Score: 0

      See:

      http://www.sac-home.org/

  43. Poppycock by Anonymous Coward · · Score: 0

    Poppycock. functional programming is a different axis to parallelism. Functional purity makes extraction of implicit parallelism easier, but what's by far the most successful parallel paradigm in use today on the largest, most complex problems on earth in the HPC field?

    Explicit Message passing between processes. And that works just fine on multicore chips (consider the shared memory an optimisation allowing message passing by reference). Why? Humans seem to have a knack for it, maybe some built-in "wetware support" because we're social apes that have to model apes talking to eachother to get along.

    It's notionally less simple than some models, but it seems to me it takes years of compsci training for someone to actually prefer anything else to MPI in practice

  44. No, it's still a hardware problem by ClosedSource · · Score: 1

    The old practice of getting customers to buy new chips or PCs because it would immediately improve the performance of their existing applications will no longer be possible.

    From a business perspective, that's going to be more of a problem for chip makers than software companies. In fact, if applications start acting up because their multi-threaded design didn't consider multiple cores, it's the new PC that will be blamed by the typical customer, not the software (e.g. "I bought this new multicore PC and now my applications aren't working right. Don't buy these machines until they get the bugs out")

    Despite any theoretical beliefs, we haven't seen enough real-world applications converted to be multicore aware to know what (if any) improvement in performance will be seen.

    For many applications there may not be a good business case for rewriting legacy software.

  45. No, look at the scope by omb · · Score: 4, Insightful

    First, the scope for mono-processors is now strictly limited and we _will_not_ see x2/18 months again, there may be x10 to x100 possible within this basic technology but thats just a few Moor's law cycles; second, the (commercial) problems, as described elsewhere, involve the solution of partial differtial (Heat, Navier Stokes, Elasticity) Equations or Stochastic Simulations --- all of which are inherently clusterable, but not gridable).

    It is the cache coherency and memory bandwidth problems with existing architectures that are the problem. We need better low latency data transfer and significant improvement in auto-parallelism technology in compilers.

    It should be clear that there has been very little serious investment in basic compiler technology and that is now needed. Academics have realised this but it takes time. The bandwidth issues are solvable else-when with more transistors.

    Finally, we have a variety of programming paradigms OO, Functional & procedural and more each of which has a problem niche.

    One thing we will certainly have to get away fom is the idea that 'legacy' code can carelessly be re-written in the flavor of month interpreted language eg Java, C#, Perl, Python or Ruby. You can write 95% of your code in a programmet friendly language. But the critical sections need to be in C, FORTRAN or Assembler and need to be very carefully optimized. That can give you x100 on the same architecture.

    1. Re:No, look at the scope by mechsoph · · Score: 2, Insightful

      You can write 95% of your code in a programmet friendly language. But the critical sections need to be in C, FORTRAN or Assembler and need to be very carefully optimized. That can give you x100 on the same architecture.

      Your completely right that Perl, Python, and Ruby are pigs. Java looks a little like it was dropped on its head as a child. I don't know much about C#; it tastes too much like MSWindows for me to touch it.

      While different programmers have different tastes in friends, modern functional languages actually have compilers that produce code competitive with C, and a garbage collector can be a performance advantage for some use cases (faster thread-local allocation and greater sharing of data structures). But for some things, ie most numerical code, you're right that you just can't beat a static language like C or Fortran.

    2. Re:No, look at the scope by shutdown+-p+now · · Score: 2, Interesting

      Finally, we have a variety of programming paradigms OO, Functional & procedural and more each of which has a problem niche.

      We have also seen the merging of those paradigms over the years. Every mainstream language today, with the exception of C, has some form of OOP. Every mainstream language either has or is getting (e.g. C++0x lambdas) first-class function values - with the unfortunate (for Java) exception of Java, now that Neal Gafter has moved from Google to Microsoft. Many languages are introducing lazy sequences and libraries centered around them (Scala, LINQ, Python 3000) Also related is syntactic sugar for list comprehensions (Scala, Python). Then, there are languages that are specifically designed to be combined OO/FP - Scala, OCaml, F#.

      Actually, it's worth learning FP today solely for this reason. FP has found its way into mainstream by piggybacking on top of existing OO solutions. For example, if you want to be a good C# or VB programmer today, you have to learn LINQ - and that is all about FP. You may not even be fond of it yourself, but there will be code written using it, and you'd better understand it well enough to be able to maintain and extend it!

    3. Re:No, look at the scope by AlecC · · Score: 1

      But even so, we could use multiple cores to speed those legacy machines up, Java, for instance: runs interpretatively until you have executed a block a certain number of times then "JIT" compiles it for a speed-up. But on a multicore machine, you should start other cores compiling in parallel with the interpreter so that you get to the compiled speedup sooner, and it can start prospectively downloading all the jars you need instead of waiting until you try and execute them and stalling.

      Even with traditional languages, multicore needs a different approach. If you have a block of code which is small enough to fit into L1 cache, or possibly L2, then with an extra core it is "free" - it adds nothing to execution time. Rather than stopping to garbage collect, a garbage collector in an otherwise unused core can be optimising your heap all the time - for "free". Of course, the design of such a garbage collector is tricky - but it is a one-off design that will speed up every program that runs on the system.

      You are right that current languages are badly designed for multicore. But look at the way in which the ghastly x86 CPU architecture has seen off far more elegant Risc architectures: a turbo-charged pig can, history shows, defeat an unimproved thoroughbred.

      Twenty five years ago, I got the development system for an early approach to parallelism, Occam. This is old enough that it loaded, slowly, off 8-inch floppies. But unlike all the other software at the time (it was running on RT-11), it used internal parallelism since it was written in itself. Which meant that it came up and started working while the floppies were still clanking away loading the rest of the program. We need to treat main memory today as that system treated disk - as slow-access backing store.

      --
      Consciousness is an illusion caused by an excess of self consciousness.
    4. Re:No, look at the scope by maxume · · Score: 2, Informative

      How much does it really matter? How much of the Java code out there needs to be a great deal faster (on say, a percentage basis)? Of the Java code that does need to be faster, how much of it is not embarrassingly parallel? For people who are doing actual computation for a living, the percentage is probably pretty high, so they will benefit from improved tools, but for most code that is aimed at a user, simply enforcing better coding practices will probably improve responsiveness more (and users are a lot more concerned with perceived speed than actual speed).

      I would guess the highly parallel code will end up being treated a lot like assembler, where most people ignore it, some people use it where they know they will benefit from it, and a remaining small group of people obsess over using it for everything.

      --
      Nerd rage is the funniest rage.
    5. Re:No, look at the scope by synthespian · · Score: 1

      Just because a language has lambda or map does not make it functional. Not a bit. This is a huge misunderstanding of what constitutes FP. FP is about referential transparency.

      --
      Main difference between the BSD license and the GPL license: one is from California and the other is from Massachusetts
    6. Re:No, look at the scope by shutdown+-p+now · · Score: 1

      One thing I hope we can agree is that today, the definition of "functional programming" is blurry. The one that you stick to is certainly valid, but it's not the only one, and, quite likely, not very practical - it would mean that languages that are normally and traditionally perceived as FP, such as pretty much the entire ML family, including SML and OCaml, are not functional.

    7. Re:No, look at the scope by shutdown+-p+now · · Score: 1

      For the record, here is one of the few LtU arguments that happened on that subject - you might find it an entertaining read.

    8. Re:No, look at the scope by hxnwix · · Score: 1

      we _will_not_ see x2/18 months again

      I've heard this at least once a year since 1989. I think I'll keep budgeting to upgrade my pc every couple years, thank you.

      It is the cache coherency and memory bandwidth problems with existing architectures that are the problem

      Multicore designs do much to address this. Intel's latest core integrates a memory controller and supports sharing L3 cache across cores.

      It should be clear that there has been very little serious investment in basic compiler technology and that is now needed

      What sort of basic improvements would qualify? Automatic vectorization and parallelism? Recent years brought us that, and the technology continues to improve. Take Intel's latest compiler for a spin - they update it regularly.

      While a little doubt can't hurt, there's no reason to lament lack of advance when so much continues to improve so fast... Dry those tears and take a nap; by the time you wake up, the state of the art will have advanced.

    9. Re:No, look at the scope by omb · · Score: 1

      Sorry, look at the Berkeley paper and you will see we have been significantly behind Moors law since 2004, and the performance increase rate is slowing, and it isnt going to get better.

      Intel _had_ to fix their memory bandwidth problem, which strangled their performance, to sell any server chips into the current market, but sadly AMD's hyperchannel dosnt have the bandwidth to cope with (Open)MP interchanges past 32/128 cores.

      We need fundamental work on compiler optimization for commonly manufacturable high multicore architectures. This is much more than a kludge to GCC or ICC and Intel dont have a big enough team. This is a classic case for the Bazar!

      People building airplanes, managing oil fields, simulating climate, designing fusion reactors and trying to price CDIs based on morgage debt would like solutions today or tomorrow.

      The fact that scalable throughput eg map-reduce, gridables gets better dosnt help them, but at least those guys are getting where they want to go.

    10. Re:No, look at the scope by StarsAreAlsoFire · · Score: 1

      http://acs.lbl.gov/~hoschek/colt/

      "For example, IBM Watson's Ninja project showed that Java can indeed perform BLAS matrix computations up to 90% as fast as optimized Fortran. "

      Given how terrible FORTRAN is to use, the number of bugs NOT introduced into the code by writing X in Java instead of FORTRAN is worth the performance hit. Which is to say, (#&@ FORTRAN, go straight to ASM.

      Is the newest FORTRAN even a real language yet? ( e.g. you can't write a FORTRAN compiler using FORTRAN ).

      God I hate Fortran.

      "CS without FORTRAN and COBOL is like birthday cake without ketchup and mustard." ( seen here on /. )

    11. Re:No, look at the scope by mechsoph · · Score: 1

      That's nice, but we already have a highly optimized, debugged, and widely deployed matrix library in Fortran. Why not just call it from our higher level languages?

      Personally, I use BLAS with some C++ sugar on top. Mixing Fortran, C, and C++ is actually pretty trivial since they don't feel the need to wall themselves off from the rest of the world like Java; it's even easier to call C from Lisp the contortions Java makes you go through. Also, since Java lacks operator overloading, and realtime garbage collection isn't quite there yet, I don't see how it would be an improvement, or even a possibility for the Controls work I do.

      Is the newest FORTRAN even a real language yet? ( e.g. you can't write a FORTRAN compiler using FORTRAN ).

      Fortran is Turing Complete, so yes. Also, wikipedia says that Pascal was first implemented in Fortran.

    12. Re:No, look at the scope by StarsAreAlsoFire · · Score: 1

      Oh agreed. Existing, tested software is a Very Good Thing.

      Java of course walls itself because writing native code in Java is the antithesis of what Java is about. My point was only that for new projects where YOU are writing the optimization bits, if Java isn't fast enough, you should be jumping straight to pure C ( no STL even ) or ASM. Fortran is a pointless in-between step.

      The not-a-real-language statement arose from F77s lack of recursion. But then, as addicted to the GOTO statement as Fortran is, it's not so hard to unroll a recursive function. Thanks for pointing out that Pascal was written in Fortran, it made me go look up why I left university with the impression of 'major missing functionality'. Turns out I was just bitter ;~)

      I haven't touched any Fortran after 90. The university experience with the language was just too painful. It might be better now. But Java isn't slow anymore, and hasn't been for quite a while now, either. Now it just uses massive amounts of memory :~)

      Obviously if you prefer C++, C or any other compiled language, the whole Java aspect is pointless. I just get annoyed when people repeat the Java is slow myth - in that regard I should have responded to OMB's post, not yours. Especially since I would be stunned if someone could take optmized Java code and speed it up a 100X by re-implementing it in even ASM. I would be stunned if one could speed it up by a factor of TWO.

    13. Re:No, look at the scope by mechsoph · · Score: 1

      Java of course walls itself because writing native code in Java is the antithesis of what Java is about.

      Yes, and their solution is usually far more painful than the problem.

      you should be jumping straight to pure C ( no STL even ) or ASM. Fortran is a pointless in-between step.

      Actually, for numerical code, fortran for awhile would outperform C because it was easier for a compiler to auto-vectorize fortran. I think auto-vectorizers have gotten smarter now, so there may not be much of a difference making the main reason to choose one language over the other is probably mostly aesthetic. Of course, I've never done any significant amount of fortran, so those aesthetic reasons may be pretty compelling.

      But Java isn't slow anymore, and hasn't been for quite a while now, either. Now it just uses massive amounts of memory :~)

      So very true...

    14. Re:No, look at the scope by badkarmadayaccount · · Score: 1

      Uhhh, yeah. C isn't faster, nor is FORTRAN, at least on parallel architectures. Don't even talk about assembly. What is needed is a ground-up optimized language for parallel processing, like Fortress. Otherwise, I agree about the memory problems - we need bandwidth and low latency, not volume. I think it's called the memory wall, BTW.

      --
      I know tobacco is bad for you, so I smoke weed with crack.
  46. We need hardware garbage collection by 5pp000 · · Score: 1

    While I do think FP is going to be a big help with multicore, a problem I haven't heard anyone talking about is that when you have several cores allocating heavily, it's going to be a lot of work to clean up after them. I think we're going to need hardware garbage collection, or at least hardware support for GC. It will be nasty and complex because of the concurrency, but I just don't see how else we're going to deal with the allocation rates.

    Hardware GC is not new: the Lisp Machines had it, though of course it wasn't concurrent. Everything old is new again...

    --
    Your god may be dead, but mine aren't!
  47. What? The Moore's Law???! by LanceUppercut · · Score: 1

    The Moore's Law has absolutely nothing to do with software. The Moore's Law states that the economically optimal level of integration doubles each set period of time. There's absolutely no way software can fit into this picture. Another ignorant but creative interpreter of Moore's Law, apparently...

  48. Compiler Technology by omb · · Score: 1

    At the cost of replying to myself:

    Academic and other work has often focused on language design with incremental language facility addition eg C -> C++ -> (java, C#) or Dr.N Worth's Pascal, Modula-x.

    This is the exact opposite of what we need, we have C as a given, and we need to make the code generated for parallelisable cases _much_ better.

    1. Re:Compiler Technology by Eli+Gottlieb · · Score: 1

      Actually academic research work tends to focus on revolutionary languages built from a fundamental core based on their innovative features. Then industry proceeds to completely ignore these languages because they don't bare enough resemblance to the status quo.

  49. An brief introduction to functional programming by sentientbrendan · · Score: 5, Insightful

    >>When you move to FP, all your algorithms break

    >If moving to a functional programming language
    >breaks your algorithms, then you are somehow
    >doing it wrong. That line doesn't even make sense
    >to me. Algorithms are mathematical constructs
    >that have nothing to do with programming
    >paradigm. Assuming the language is Turing
    >complete, how is that even possible?

    You are confused about the definition of an algorithm, and the significance of Turing completeness.

    First of all, an algorithm is a *way* of doing things with an associated complexity specification (a mathematical description of how long it will take to run often denoted like O(n)).

    Two turing equivalent machines don't necessarily support the same algorithms, although they will always have *equivalent* algorithms that get the same job done. HOWEVER, those algorithms don't necessarily have the same complexity. For instance, on turing machine A a sort might be done in O(n^2) while on turing machine B a sort can only be done in O(n^3).

    To be functional means to be stateless. If you don't have state, then all sorts of algorithms become much more expensive. Notably, it's impossible to do a quicksort in a functional language, although other less efficient sorts may be done. Some people respond to that by saying that you can just buy a faster computer if you want to run functional algorithms; however, anyone with a decent computer science education knows that this can't solve differences in assymtotic complexity.

    NOTE: quicksort (which cannot be done functionally) does not have better worst case (big O notation) complexity than mergesort (with can be done functionally), but it does have best average case and takes advantage of the underlying machine implementation much better. In some ways it is a bad example, but most people are familiar with sorting, whereas few people are familiar with dynamic algorithms.

    The reason that functional programming languages exists goes back to Church and Turing. Church invented lambda calculus, and Turing invented Turing machines. Both are computationally equivalent in their power.

    Turing machines have state, and are essentially a description of a hypothetical machine. Lambda calculus, is well, a calculus. It is functional in nature and has no state.

    Not surprisingly, real world computers look more like turing machines than they do Lambda calculus evaluating machines. Also, virtually all programming languages are built around state manipulation, since that's what the underlying hardware has to do.

    The idea of a functional programming language is to emulate the lambda calculus on a rough approximation of a Turing machine. Technically it's possible for any Turing equivalent machine to emulate any other. However, since the two machines are so different, this makes things dog slow. Again, faster computers don't solve this problem because there is an assymtotic difference in complexity, not a constant factor difference.

    1. Re:An brief introduction to functional programming by bombshelter13 · · Score: 2, Informative

      Quicksort in 2 lines of Haskell: qsort [] = [] qsort (x:xs) = qsort (filter (= x) xs) Impossible?

    2. Re:An brief introduction to functional programming by cdfh · · Score: 1
      The code you probably meant is:

      qsort [] = []
      qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)

      This algorithm does not do in-place partitioning of the array, and so requires two iterations over the array. In addition, it does not use a sensible pivot selection. To what extent this algorithm can be considered "quicksort" is debatable. I believe the GP is refering to the in-place partitioning varient of quicksort, which requires mutable arrays, or a very clever compiler. Mutable arrays are present in Haskell, but, if I recall correctly, not as efficient as in C (although, they are still O(1) access).

    3. Re:An brief introduction to functional programming by Anonymous Coward · · Score: 0

      NOTE: quicksort (which cannot be done functionally)

      Huh, what? http://www.haskell.org/haskellwiki/Introduction#Quicksort_in_Haskell

    4. Re:An brief introduction to functional programming by Lars512 · · Score: 1

      To what extent this algorithm can be considered "quicksort" is debatable.

      You can also perform quicksort on a linked list in C. The algorithm isn't different, just the underlying data structure. The haskell implementation above operates on something akin to a linked list.

      It sorts in O(n log n) time for randomized input, and O(n^2) worst case. It uses the method of separating values around a pivot. These things roughly define quicksort, not a particular C imperative algorithm, or particular underlying data structures such as arrays.

    5. Re:An brief introduction to functional programming by Anonymous Coward · · Score: 0

      I'm confused. Why do you claim quicksort can't be done in a functional programming language? Here is a version in ML:

      fun part(pivot, L, left, right) =
          if L = nil then (left,right)
          else
              if hd L > pivot then
                    part(pivot, tl L, left, hd L :: right)
              else
                    part(pivot, tl L, hd L :: left, right);

      fun qsort(L) =
          if L = nil then nil
          else
            let
                val (left,right) = part(hd L, tl L, nil, nil)
            in
                qsort(left) @ [hd L] @ qsort(right)
            end;

    6. Re:An brief introduction to functional programming by cdfh · · Score: 1

      not a particular C imperative algorithm

      The question I was posing wasn't regarding a C implementation, but rather whether the quicksort algorithm's definition includes the partitioning method. On reflection, I suspect you are right, and that an implementation does not need to use in-place partitioning to be considered quicksort. Hoare's original paper explicitly describes the in-place algorthim, with an alternative for computers which do not have an exchange(ptr, ptr) function (which also seems to compute a new array having only done one iteration of the given array, rather than performing two iterations, as the Haskell algorithm does).

    7. Re:An brief introduction to functional programming by ^Case^ · · Score: 3, Informative

      Notably, it's impossible to do a quicksort in a functional language

      Some Haskell guy seems to disagree.

    8. Re:An brief introduction to functional programming by Anonymous Coward · · Score: 0

      OK, so why is it so hard to create a hybrid language? If, essentially, some problems cannot be converted to functional equivalents without incurring massive complexity, and as a result cannot be trivially parallelised, why not just do those tasks sequentially like we've always done? It makes no sense at all to move to a new paradigm that demolishes the advantages of the old paradigm when the whole things is running on top of hardware that can execute the old version perfectly well too.

    9. Re:An brief introduction to functional programming by Anonymous Coward · · Score: 0

      Adding to the other "huh? here it is in my favorite functional programming language..." comments: here's a quick and dirty quicksort in Scheme:

      (define (pivot compare x ls left right)
          (cond
              [(null? ls) (append (qsort compare left) (list x) (qsort compare right))]
              [(compare (car ls) x)
                (pivot compare x (cdr ls) (cons (car ls) left) right)]
              [else (pivot compare x (cdr ls) left (cons (car ls) right))]))

      (define (qsort compare ls)
          (if (null? ls)
                  null
                  (pivot compare (car ls) (cdr ls) null null)))

      ; usage: (qsort '(5 4 6 3 7 2 8 1 9)) yields '(1 2 3 4 5 6 7 8 9)

    10. Re:An brief introduction to functional programming by shutdown+-p+now · · Score: 1

      OK, so why is it so hard to create a hybrid language?

      It's not hard, and there are plenty of them:

      From the list above, OCaml is presently production-quality, and used rather widely. It also has a good performance profile, rivalring C/C++ with carefully written code. Of the others, the fastest-growing seems to be F# (mostly because Microsoft announced that they're making it into "Visual F#" and likely including it into Visual Studio 2010 alongside C# and VB as the third out-of-the-box .NET development language). Scala has a pretty large following in the Java land, so much so that some call for freeze of Java language spec for the sake of stability, and moving onto Scala for further language development.

      Also, most modern dynamic languages (Perl, Python, Ruby, JavaScript) have many functional traits, and so do quite a few mainstream static ones (C#, VB).

    11. Re:An brief introduction to functional programming by omuls+are+tasty · · Score: 1

      It's not the "real" quicksort as it doesn't sort in-place.

      On a related note, GP made an incorrect remark on the performance of quicksort and mergesort. Mergesort has a worst-case performance of O(n*log n); quicksort of O(n^2), so worst-case performance of quicksort is rather dismal. However, it is usually the fastest sorting algorithm in practice, because the "bad" inputs are rare so it achieves an average-case performance of O(n * log n), but with much smaller constants hidden by the O notation than mergesort, making it quicker.

    12. Re:An brief introduction to functional programming by Anonymous Coward · · Score: 0


      qsort [] = []
      qsort (x:xs) = qsort (filter (= x) xs)

      Where exactly is the state?

    13. Re:An brief introduction to functional programming by hasdikarlsam · · Score: 1

      It's a good thing Haskell allows you to mix impure algorithms that do in-place modifications with your pure ones, then, or even add mutation "under the hood" via laziness.

      Of course there's tradeoff for either approach - parallelization becomes harder, or the algorithm gets harder to understand - but it's certainly *possible*, and I've written in-place quicksort on arrays both ways.

    14. Re:An brief introduction to functional programming by Anonymous Coward · · Score: 0

      qsort [] = []
      qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)

      Haskell is a purely functional language. The above is an implementation of quicksort.

    15. Re:An brief introduction to functional programming by synthespian · · Score: 1

      When you put it all together like that in front of you, you sorta realize we are in a new era, whether developers know it or not.

      "They're here..."

      --
      Main difference between the BSD license and the GPL license: one is from California and the other is from Massachusetts
    16. Re:An brief introduction to functional programming by shutdown+-p+now · · Score: 1

      When you put it all together like that in front of you, you sorta realize we are in a new era, whether developers know it or not.

      "They're here..."

      Oh yes, they're here, and there's more to it than meets the eye on the first glance. Microsoft is pretty big into pushing FP these days, though they do it pretty slowly; nonetheless, those .NET developers who read the blogs, watch Channel9, and generally keep track of the way things are going, cannot help but notice that the phrase "functional programming" can be seen and heard more and more in that corner of the world. Try Googling for microsoft "functional programming", and see what it gives - about half of that is about F#, as could be expected, but look at the other half. For example, this FP primer - note that it is an MSDN article that is part of the .NET class library documentation that ships for both C# and VB.

      And that is pretty serious. The biggest problem of FP was its relative obscurity, because there was no big player behind it pushing it as an industrial-strength solutions. There was a bunch of academics, a few curious hackers, and some bright people who built their start-ups on exploiting FP strength. Now... we'll have to wait and see, but I'm very optimistic about these developments.

    17. Re:An brief introduction to functional programming by Anonymous Coward · · Score: 0

      > it's impossible to do a quicksort in a functional language

      Nonsense. Here it is in ML.

      fun quicksort nil = nil
          | quicksort(h::t) = let val (low,high) = split(h,t)
                                    in append(quicksort(low), (h::quicksort(high)))
                                    end
      and split(x,nil) = (nil, nil)
          | split(x,(h::t)) = let val (k,m) = split(x,t)
                                  in if h < x then ((h::k),m) else (k,(h::m))
                                  end

    18. Re:An brief introduction to functional programming by Anonymous Coward · · Score: 0

      Quicksort cannot be done functionally? That's clearly nonsense:

      http://en.literateprograms.org/Quicksort_(Erlang)

      And I quote:

      "We describe several different implementations of the quicksort algorithm in Erlang. All of these implementations operate on lists."

  50. Re:Functional Programming Is a Red Herring by MarkusQ · · Score: 4, Informative

    You seem to have some serious misunderstandings here.

    1. Pure functional programming removes all side effects.

      Yes, at the expense of a copy-everything in sight, use zillions of message channels,

      Uh, no. By removing side effects functional programming removes the need to copy anything. If I'm trying to evaluate f(X) + g(X) for some complicated X, f, and g by evaluating f(X) and g(X) in parallel and adding the results, I don't need two copies of X because I know that neither f nor g will modify it. That's the whole point.

    2. FP is not just counterintuitive and hard to learn but it is also non-deterministic, meaning that it is not well-suited to mission critical systems.

      It only seems counter intuitive if you've swallowed the procedural programming paradigm and adopted it as your own to the point where you've forgotten how counter intuitive "X = X + 1" seemed at first.

      And saying it's non-deterministic is just nuts. Sure, you could add non-deterministic semantics to any language, but there's nothing inherently non-deterministic about functional programming. In fact, I think you'd typically have to work a lot harder to make a functional language non-deterministic.

    3. FP is a continuation of the same process/thread mentality that has gotten the industry into this mess in the first place.

      FP has nothing to do with threads, apart from the fact that functional programs could be executed by a large number of threads in parallel (or independent cores, or...?) without changing the outcome. And what exactly is the mess we're in? I can't think of another industry that has succeeded so spectacularly in such a short time.

    4. "enfatuated" isn't a word.
    5. The blog you link to proposes a solution that is arguably worse on every issue you raise.

    And so on...did I just feed a troll?

    --MarkusQ

  51. Sthorry bosth, jutht learning a new language by Culture20 · · Score: 1

    Lisp, for real men.

  52. an interesting point! by sentientbrendan · · Score: 1

    However, there are some real world reasons why people don't always prove their algorithms, and almost no one uses functional languages.

    First, most programming problems in the real world are so intellectually tedious that proving the correctness of their algorithms would be waste of time. Many algorithms *should* be proven, but consider how much of you code is just boilerplate, and doesn't really do anything algorithmically interesting. Usually around 99%.

    Second, functional programming doesn't allow state manipulation, so a lot of algorithms can't be done in them.

    1. Re:an interesting point! by phr1 · · Score: 1

      1. In fact everyday programmers do prove things about their programs all the time. Not every last detail of the semantics (that is very difficult) but they rely very heavily on type safety, which is enforced either by a static type system (like in Java or Ada) or by automatic runtime checks (languages like Python). Languages like C, which have leaky type systems AND no runtime checks, are generally full of bugs that end up getting exploited by viruses. Almost every security bug we hear about, and the spam botnet that arises from the exploit, is caused by some type error (usually unchecked array overflow) in a C or C++ program. Functional languages (not exactly inherently, but more as a cultural matter among the designers) treat type systems as lightweight theorem proving schemes. So Haskell's type system is FAR more advanced than what you'll find in something like Java.

    2. Re:an interesting point! by lennier · · Score: 1

      "but consider how much of you code is just boilerplate, and doesn't really do anything algorithmically interesting. Usually around 99%."

      That right there is telling you something.

      If you're writing a hundred times more code than you need to, and you know it, then you're seriously using the wrong language. Probably one that doesn't have macros.

      --
      You are not a brain: http://books.google.com/books?id=2oV61CeDx-YC
    3. Re:an interesting point! by sentientbrendan · · Score: 1

      That's a good point about type systems being able to prove things about a program. However, you got some important details wrong.

      First of all, this does not apply to duck typed languages like python. Python provides a form of type safety, but it is a different sort than statically typed languages that prove their correctness when they compile. There's nothing known a priori about the type correctness of python.

      I'm not saying it's a bad language, in fact, I think it's a great language, but it isn't in the right class of languages to get the sort of benefit you are talking about. The benefit that safe dynamic typing brings is it prevents memory corruption and buffer overflows (like you mentioned) which are a separate concern from program correctness.

      Also, you mentioned Java as a strongly typed language. This is not true. Java has prevalent use of casts and null, both of which break static type safety. Java provides *dynamic* type safety for null and casting, unlike C++, but that isn't enough to get the kind of a priori guarantees that we are talking about.

      In a truly type safe language, if you have a variable of type T, then any operation f defined for T will execute on any object of type T, o.

      So f(o), or o.f() in object oriented terminology will always be defined.

      However, in Java if o is null, o.f() will fail with a null safety exception.

      Null is actually a holdover from C which does not appear in truly type safe languages. See the language SML for an example.

      Also, in Java prior to release 1.5, there were many situations where the programmer was forced to perform dynamic casting. Dynamic casts violate type safety because they apply a type at runtime to an object that is not known a priori to hold that type.

      Java 1.5 helped to remedy this situation, but that this was ever a problem demonstrates that Java was not designed from the ground up for static type safety. Generics are very old, the only reason that they weren't included in 1.0 was because the type system for the original java wasn't thought through very well.

  53. Compiling C in parallel by MarkusQ · · Score: 1, Insightful

    Even the ones that aren't (say... compiling a file in C) you can usually run a lot of instances of in parallel.

    Actually, I can see a whole lot of potential parallelism in compiling C. (Think map-reduce).

    --MarkusQ

    1. Re:Compiling C in parallel by Ken_g6 · · Score: 1

      (Think map-reduce).

      There's the rub. Thinking in terms of map-reduce is hard.

      --
      (T>t && O(n)--) == sqrt(666)
    2. Re:Compiling C in parallel by jbolden · · Score: 2, Funny

      Not in a functional language, particularly a pure one. This just ends up looking like map/fold or cata and ana morphism calls.

    3. Re:Compiling C in parallel by dhasenan · · Score: 1

      "Actually, I can see a whole lot of potential parallelism in compiling C. (Think parallelism)."

      That's about what you said.

      To give some more useful examples:

      - Each compilation unit can be compiled in isolation, assuming you have certain information about the referenced code. (Granted, this is C, so the compilation units are pretty large.)
      - You can assemble a fair bit of information about each section of code -- enough to parallelize much of the conversion to IR -- in parallel. You will need to block on other processes at times, though.
      - Each function can be optimized in isolation.

      Preprocessing, I think, hasn't been easy to parallelize -- I don't think distcc does it.

    4. Re:Compiling C in parallel by Anonymous Coward · · Score: 0

      There's the rub. Thinking in terms of map-reduce is hard.

      And? Programming in general is hard. Many people employed in the software industry are, in fact, incapable of doing it properly; see thedailywtf.com for plenty of evidence. If some new paradigm comes along and forces all the copy-and-paste "pls email me teh codes" idiots to give up and find jobs more appropriate to their mental capacity, like flipping burgers, then all the better.

    5. Re:Compiling C in parallel by Anonymous Coward · · Score: 0

      Well, a rough version of this already gives pretty significant speedups:
            make -j 2

      Usually the bottleneck is IO, and it is helpful to have several processes running simultaneously so the waiting on the IO is minimized.

      On my 2 core machine, a 4-minute compilation shrunk to 1 minute.

    6. Re:Compiling C in parallel by DuckDodgers · · Score: 1

      incapable of doing it properly

      Very, very few people employed in the software industry are truly incapable of doing their work properly.

      The real problem is people in the software industry who are unwilling. Unwilling to accept suggestions. Unwilling to read about different solutions to the problems they solve. Unwilling to discuss new ideas. Unwilling to spend even a little time reading websites or technical books to get better. It doesn't matter if their problem is arrogance, and they think they know everything they need; or insecurity, and they're afraid to reveal what they don't know; or laziness, and they just don't care to take the effort to get better.

      The difference between a good or bad novice software developer is largely a question of raw talent. The difference between a good or bad experienced software developer is largely a question of emotional maturity. If you think you already know everything, you can't improve.

      I write all this because I'm doing pretty well as a senior developer with plenty of production code with a pretty low bug rate. I think I'm doing okay, although I know I still have plenty more to learn (among other things, I want to be competent at functional programming just for fun - and I find it exceedingly difficult to grasp). Quite honestly, most of the code I wrote in my first few years as a software developer was atrocious nonsense, some of it well worth prime spots on thedailywtf.com. If I could learn to be better, then almost anyone can do it.

    7. Re:Compiling C in parallel by MarkusQ · · Score: 1

      "Actually, I can see a whole lot of potential parallelism in compiling C. (Think parallelism)."

      That's about what you said.

      *laugh* Not quite, but I can see how you could take it that way.

      What I was thinking was that you wanted to go massively parallel you could split the source up into lots of chunks and do various transformations on them, then combine the results. Repeat with the AST.

      Preprocessing, I think, hasn't been easy to parallelize -- I don't think distcc does it.

      It should be possible to do a whole lot with speculative parallelism.

      Suppose lines are categorized like so: (A) passed unchanged through the preprocessor, (B) entirely consumed by the preprocessor as part of a definition, (C) internally modified as part of a macro expansion, (D) something more complicated. It's my contention that most lines wouldn't fall in class (D). In fact, I'd say that if you assumed (A) and then (in parallel) tested for (B), (C), or (D) with minimally disruptive ways of handling (B) and (C) you'd gain enough to pay for the rare, more expensive cases of (D) and still come out ahead.

      --MarkusQ

    8. Re:Compiling C in parallel by synthespian · · Score: 4, Insightful

      Bull. An industry like software doesn't depend on talent alone. If all the engineering disciplines relied on talent, we'd be in the stone ages.

      The real issue is that there are shitloads of people in the software business who either have grown up knowing nothing at all but the imperative paradigm or that know about FP but think it isn't really useful or think is just the stuff os masturbatory braniacs.

      As to any claims somebody would make of being a supercoder, I would be highly skeptical. The software industry is plagued be delays and bugs. Security bugs in Linux and Windows have become the norm. People have grown up thinking it's as natural for a computer to get a "virus" as it is for you to catch a cold.

      Many a good people have worked hard on theories and products to produce safer code, but they are largely ignored, except in industries where it is critical (military, aviation, etc.). The average developer is an ignoramus.

      --
      Main difference between the BSD license and the GPL license: one is from California and the other is from Massachusetts
    9. Re:Compiling C in parallel by pthisis · · Score: 1

      - Each compilation unit can be compiled in isolation, assuming you have certain information about the referenced code. (Granted, this is C, so the compilation units are pretty large.)
      - You can assemble a fair bit of information about each section of code -- enough to parallelize much of the conversion to IR -- in parallel. You will need to block on other processes at times, though.
      - Each function can be optimized in isolation.

      Of course, compilers are moving toward analyzing multiple files (ideally entire programs) at once to improve their optimization, which is somewhat at odds with parallel multicore compilation. e.g. optimizing functions in isolation isn't good enough for many modern optimization techniques.

      --
      rage, rage against the dying of the light
  54. Python FP by wigaloo · · Score: 1

    The article doesn't mention that you can do functional programming in python. For someone who uses python already, is there any reason to try haskell etc (i.e., beside just the interest in learning another language)? Python use is pretty widespread these days.

    1. Re:Python FP by misleb · · Score: 1

      While imperative languages often have some functional aspects, they're not "pure." And functional programming is all about purity. :-) Just because I can do things like "map" in Ruby or python doesn't make the language functional. One problem that Python has as far as functional programming is that it doesn't optimize tail recursion. Which is very common in functional languages.

      You should try to learn Haskell if you ever get a chance. I'm about 2 weeks into it and it is blowing my mind coming from Ruby and Python. Normally I can pick up languages pretty easily, but this.... this is just insane. It is like learning to program all over again. You aren't getting the full experience if you're just using a few functional aspects of a imperative language.

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
  55. Re:Python FP -- only slightly like real fp by phr1 · · Score: 2, Informative

    Python has some features inspired by FP languages including Haskell, but is not anything like real functional programming. Haskell is far more powerful and serious, but also a heck of a lot more difficult to use. Python has a "practicality beats purity" mantra; you could think of Haskell as "purity strikes back".

    Stuff Haskell gets you:

    Serious native-code compiler whose output can beat compiled C code for some programs (and does darn well on average, see the Alioth shootout)

    Ability to use multi-core parallelism, with a library module that treats shared memory as a transactional database, allowing use of shared data between threads while getting rid of all the lock management headaches of languages like Java. This can work because Haskell's functional purity guarantees that the threads won't clobber each other except under circumstances precisely controlled by the library.

    Data parallelism allowing computations of list comprehensions to automatically be done in parallel on multiple CPU's

    Rigorous type system (nothing like the broken ones like in C or Java that you might be used to) lets you express complex invariants in your datatypes so that errors can be caught by the compiler. This greatly decreases the amount of runtime debugging required.

    I could go on, but you get the idea.

    Good tutorial: http://learnyouahaskell.com/

    More detailed book (full text online): http://book.realworldhaskell.org/

    Haskell has a very steep learning curve compared with other languages (or "unlearning curve", as some put it, since you have to forget everything you knew), but learning it (a still ongoing process for me) is one of the most interesting and mind-expanding things I've ever done as a programmer.

  56. Depends on which formulation of Moore's Law. by Ungrounded+Lightning · · Score: 1

    The Moore's Law has absolutely nothing to do with software. The Moore's Law states that the economically optimal level of integration doubles each set period of time. There's absolutely no way software can fit into this picture.

    Another form of Moore's law is that it's price/performance that doubles in some set period of time. Up to about now the two have tracked, but now they're starting to diverge.

    Their gripe is that single-chip gate counts have gotten large enough that they're bigger than a single core. You can't find anything interesting to do with many of the gates. So the "economically optimal level of integration" becomes multicore processors. But to use them effectively you have to modify your programming style - otherwise you end up with the performance of a single core, which didn't go up in proportion to the POTENTIAL performance of the gang of cores.

    Thus the two formulations keep tracking only if you go to parallelizable coding techniques. If you stay with serial coding only the price/performance formulation falls off the exponential curve.

    --
    Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
  57. 1985 vs.2008 - no more free speedup by alispguru · · Score: 2, Interesting

    The difference between 1985 and today is the end of the free lunch in clock rates. 1985 was roughly the middle of the last great clock rate stall - during the shift from minicomputers to micros, Moore's Law expressed itself not as speedup, but as decrease in cost per bit/gate.

    Then we entered the great die-shrink and clock rate increase era, where for about 20 years processors really did get twice as fast every 12-18 months. Why expend the effort to bury a problem in parallel hardware when you can see faster serial hardware coming over the hill?

    Clock rates have stalled again, and we're reaching physical limits for our current fabrication methods and physical chip designs. We're seeing renewed interest in functional programming because it looks like a way to make use of parallel hardware safely compared to imperative coding. Traditional coding methods are easier to understand, and are probably more efficient when they work, but...

    how fast do you want the wrong answer?

    --

    To a Lisp hacker, XML is S-expressions in drag.
  58. OpenMP makes parallel programming simple by Agent+ME · · Score: 1

    OpenMP makes it simple to write code that takes advantage of multiple threads, and it's supported by gcc 4.x, Visual Studio (just not the Express editions I think), and other compilers.

  59. The algorithms really do break by phr1 · · Score: 4, Informative

    Let's say you have a few thousand (name, address) pairs and you want to be able to quickly look up a name to get the corresponding address, to add new names, etc. In imperative programming you'd probably use one of the mainstay data structures of CS 101, the good old hash table. To add a new name, you hash it and go and poke that address in the table to record the entry.

    Well remember that stuff about values in functional programming being immutable? Right, no hash tables in functional programming. You'd instead use something like an AVL tree or red-black tree, that let you create a completely new structure that shares most of its content with the old one, except that the new one has this extra node. Of course FP language libraries come with modules for making those structures, and in practice you can use them at the API level sort like how you used to use hash tables, but they are completely different underneath, and if you want to program them yourself you are going to have to learn a lot of very basic techniques from scratch all over again. Chris Okasaki's book "Purely Functional Data Structures" is a good place to learn about this stuff in detail.

    Even more basic: the good old "for" loop, which updates an index variable each time through. Whoops! You can't update the index in a functional language, so there's no "for" loop. You instead use recursion, or a "higher order function" (function that operates on other functions). So instead of

          for (i = 0; i < n; i++) xs[i] = f(ys[i])

    You'd write something like

          ys = map f xs

    ("map" takes a function f and a list of values xs, applies the function to each item in the list, and gives you back a new list). There is also a "list comprehension" syntax that you might know from Python:

          ys = [f(x) | x <- xs]

    but for complicated functions you end up having to use higher order functions and recursion explicitly. You really have to think a lot harder to program 20 lines of Haskell than 20 lines of C. But those 20 lines can do an order of magnitude more.

    (Aside:) In case you were wondering, yes, you can implement traditional hash tables and other mutable structures in functional languages, and there are times when it's necessary, but it's comparatively a pain in the ass and you give up some of the advantages that had you programming functionally in the first place. Here is an article about someone's experiences switching from a mutable structure to a functional structure in a large program, and the headaches the functional structure solved:

    http://www.cs.tufts.edu/~nr/pubs/zipcfg-abstract.html

    1. Re:The algorithms really do break by Eli+Gottlieb · · Score: 1

      And that is why you don't code in a pure-functional language. Instead you use an impure functional language like OCaml that allows the use of mutable data structures in functional algorithms. That does slightly reduce the amount of parallelism you can get out of the algorithm implementation, but you still gain over a purely imperative language.

    2. Re:The algorithms really do break by phr1 · · Score: 1

      I think most would consider Haskell to be a purely functional language even though it has some types that are implemented with mutable data for efficiency under the surface. For example, the ST monad is implemented with a mutable cell, unlike the State monad which is purely functional. In reality they do the same thing, you could implement ST's semantics using State, it would just be slower. Same thing with STArray and so forth. I actually haven't used ST so far, but I'm still a relative Haskell newbie. I have the impression that Ocaml is easier than Haskell for imperative programmers to get accustomed to, but I haven't tried it. Haskell certainly has its notorious learning curve. But, it seems to be the focus of quite a bit more interest and development activity than Ocaml these days.

    3. Re:The algorithms really do break by Eli+Gottlieb · · Score: 1

      If by "interest and development activity" you mean "buckets of code written to force otherwise-simply paradigms and ideas into Haskell's pure-functional world" yeah.

  60. Answer: No by Cassini2 · · Score: 1

    I think FORTRAN is going to stay the untouched leader in the fast and easy to program supercomputer / parallel mathematical simulations market. C is a very close second. Simply put, every supercomputer manufacturer makes sure its FORTRAN and C code is very quick, because that is what most of the customers use. I can't see Haskell competing in the supercomputer market / parallel processing market yet.

    The next question is: Is Haskell going to be used in your next GUI based application that has a really processing intensive back end? Well functional programming is about finding a nice easy to program way to abstract and hopefully eliminate the serial aspects of your program. GUI code is about as serial as it gets. Users find it very confusing when programs pop up dialog boxes in parallel. This means a fundamental language-independent tension will exist in your program between the serial GUI code and the parallel back end code.

    I don't think a good solution for the "easy parallel programming problem" is on the market yet. I would appreciate suggestions, because I am looking. I think Microsoft missed a big opportunity with .NET. Microsoft released a new programming architecture, but they omitted ground-up support for NUMA, supercomputing, and parallel processing architectures. The next big jump in computing will be the language that can smoothly harness various computing configurations ranging from single-core/single-computer to multi-core/multi-computer with no gaps in between.

    Google may be the closest to the "parallel computing solution". They use Map-Reduce on server farms and then structure the program in a client/server architecture. Thus the client can have a procedural GUI, and the server can run parallel code. In Google's case the client is a web browser, and the server is a web server attached to a server farm. Maybe we just have to get used to client-server architectures for any programs running CPU intensive code.

  61. Re:Functional Programming Is a Red Herring by Anonymous Coward · · Score: 0

    The functional programming censorship squad is out in force, I see. LOL. Truth hurts, doesn't it?

  62. No special tools needed! by flnca · · Score: 1

    Parallel programming is being facilitated in every modern OS by providing multithreading and multiprocessing capabilities. The programming language has to do jack with parallelism. That's what all those multithreading APIs are for! Read your system API documentation, then grab your favorite programming language and hack away!

  63. Mmm... functional programming by fortapocalypse · · Score: 1

    10 cls
    20 print "yep, this still sucks"
    30 end

  64. Re:Functional Programming Is a Red Herring by chthonicdaemon · · Score: 1

    "It is counterintuitive because nature does not execute equations to do its thing. The human brain is orders of magnitude more complex than any program in existence and it does not perform equations. Nobody should be forced to use an unnatural notation for computer programming just because mathematicians are enamored with it. A computer is not a function evaluator. The proper context for computing is behavior and it comes from psychology, not mathematics."

    The idea that any notation for computer programming is "natural" is quite funny to me, especially given the amount of time I've spent trying to grok oo. "Natural" is not an absolute -- people differ in their preference for expression. Some sing, some talk, some like music and some like programming. Pretending that the approach that has aligned best with your intuition is the only sensible way of programming a computer is nearsighted at best and pompous at worst. How do you explain the interest in functional programming? Are all these people just "unnaturally" attracted to these bizarre concepts, or have they also found a metaphor that aligns with their preference?

    When you rail against someone with preferences expressed as truths, you are bound to tick off some people.

    Also, when you talk about 'nature not executing equations' -- one of the most interesting things about most of the behaviours we have identified in nature is that they are best modelled using many simultaneous equations. Languages that are designed to model 'the real world' inevitably contain methods of specifying things that should happen simultaneously (have a look at for example Modelica). Almost all the advances we have made in predicting what happens around us to any degree of accuracy has gone via equations or sets of equations. I cannot see how I would get anything done without them. Definitely I cannot think of anything in nature as 'behaviours' in a way that enables calculations. Of course, if this is how it works for you, that's fine, just don't tell me the way I approach the world is totally wrong and unnatural when it works for me.

    --
    Languages aren't inherently fast -- implementations are efficient
  65. Don't bother for work by Anonymous Coward · · Score: 0

    Functional programming will NEVER take off in anything other than niches. It is too unfamiliar / hard / different for java monkeys. Low number of people with knowledge makes replacing people hard for managers, and nobody wants to be stuck with a project with no readly available resources at hand.

  66. This is really about single assignment. by Animats · · Score: 1

    For parallelism, the issue is not functional programming, but single assignment. In a single-assignment language, each variable can only be changed once. Functional programming is one way of achieving this, but it's not the only way.

    The idea is supposed to be that single assignment makes it easy to turn a program into a pipelined form at compile time. It's supposed to make automatic parallelization easier. In practice, compilers for single-assignment languages haven't been overly impressive in performance.

    1. Re:This is really about single assignment. by nbahi15 · · Score: 1

      I guess the reason every compiler uses SSA as an intermediate form is because it delivers such sucky performance. SSA is an intermediate representation of code that facilitates the application of a whole range of optimizations. Potentially, SSA form could be where parallelism is extracted, but the form itself isn't going to give it to you automatically. You are going to need to look for it.

  67. Physics by Anonymous Coward · · Score: 0

    Good luck. As these wafers get smaller and smaller, the biggest limits to making these chips faster and faster are:

    1) Transmission line theory -- since the information is so fast
    2) RC -- the CPU lines have built in parasitic resistance and capacitance.

    In combo the two are deadly:
    CPU puts out a code for the ALU... clock is so fast that before the other end of the line at the ALU has reached the new value, ALU reads what's already on the line. Uh oh! Then with transmission lines, if the data moves at a certain frequency and the ALU and register are a certain distance apart, then it can be mathematically shown that the ALU will never read anything from the register.

    The best way to overcome these right now is to simply throw more wattage at the problem... but that's not exactly a great solution, is it?

  68. Python is terrible for efficient concurrency by Animats · · Score: 1

    Python has terrible problems with concurrency. CPython can't use more than one CPU at all, even in multithreaded programs, because of the infamous "Global Interpreter Lock".

    In Python, there's too much shared global state associated with binding. The dynamism that makes it possible to add a new function to an object during execution means constant access to object dictionaries shared across threads. Python not only has late binding, it has hidden late rebinding; some other thread can modify an object while control is within an object instance. This is rare, and usually avoidable, but because it's possible and can't be detected at compile time, the run time system has to make the worst case checks every time.

  69. Parallel programing is hard. by stonefoz · · Score: 1

    Apparently there isn't a magic fix for this. On a new found whim, I'd decided to look back into functional programing, since perhaps it would better utilize my multi-core machine. You know what I found out, parallel programing is hard. Ocaml, or at least the version I have a build script for, has a race condition in the parallel, make build. Trying to install a language that might do multi-tasking, breaks multi-tasking on install. I give up and go back to reading up on mutex's and trying to wrap my mind around debugging threads.

    --
    I think I just cashed out all my cool points.
    1. Re:Parallel programing is hard. by flnca · · Score: 1

      Threads are really simple if you're using a few simple techniques: Write a simple wrapper class (or lib) around your system's threading API. Make sure startup and cleanup work in a well-defined manner. You can synchronize this by using events (or condition variables on UNIX). Provide a mechanism to signal when a thread shall terminate. The thread tests this signal and leaves processing when it is set. For inter-thread communication, write a simple messaging system (using doubly-linked lists and mutexes). Once you have these simple tools encapsulated in away in a few classes or a small library, writing multithreaded code becomes a piece of cake. Also, make sure that threads only do black-box stuff and are controlled only via messages. HTH

    2. Re:Parallel programing is hard. by stonefoz · · Score: 1

      Do you do any real work with it? Coherent I/O is a bitch. What libraries are thread safe, re-entente, what dumbass hide a static global on line 52582? I was looking forward to a tag in the language that didn't just perhaps mark whether or not things a const, c and hence c++ do a good job at that. More that the language would make what functions where state-less, visible. There's something I need a tutorial for, how to add a "stateless" function modifier for inclusion on the next c/c++ standard. I'm not usually writing this stuff, just know enough to patch things on occasion. "stateless" would be a god sent modifier.

      --
      I think I just cashed out all my cool points.
    3. Re:Parallel programing is hard. by flnca · · Score: 1

      You're right, there's no "stateless" modifier in C++. Interesting idea! If I ever get around to implement a C++ compiler, I'll include it! Implementing it is a piece of cake! :) -- In real world apps, currently the only solution is to use null pointers. If something is a null-pointer, you can regard it as stateless. As soon as something else is assigned to it, it has state. But this requires a lot of discipline in the code, namely that after every deallocation, a pointer is set to null. There are various other techniques that can enhance legibility and stability of code. Clearly, global variables are not among desirable elements. Yup, I did a lot of work with multithreaded code. Sadly, few programmers know how to use it right. On UNIX systems, you can run into a lot of problems with non-thread-safe libraries and signalling problems. Encapsulating such stuff away is always a good idea. Also, programming around system limitations. It's always a good idea not use any system call directly; instead, write a library to encapsulate any issues that are encountered. This also makes the code more easily portable.

    4. Re:Parallel programing is hard. by Weedlekin · · Score: 1

      "Coherent I/O is a bitch"

      Anything that uses shared resources is a bitch because of the the potential for race conditions and deadlocks, and the fact that very few computer subsystems or peripherals are inherently parallel in and of themselves means that some threads in non-trivial applications will end having to contend with other threads for shared resources at some point, unless of course they're using an OS that manages resource contention issues automatically, i.e. not one of the mainstream offerings on the sorts of computers most of us are expected to program for.

      --
      I'm not going to change your sheets again, Mr. Hastings.
    5. Re:Parallel programing is hard. by loufoque · · Score: 1

      How is const not a good stateless modifier?
      Of course, it's up to you to decide what your object should allow when constant. It's up to you to maintain the right invariants and semantics, which are what modeling resources and values as objects is for.

      The good practices of C++ are to *not* use pointers, only perform resource reclamation in destructors (which means setting the pointer to null after freeing is useless, since the pointer doesn't exist any more), and not use useless "empty" states when it doesn't make sense, because they're usually dangerous states with limited possibilities (it mostly makes sense only for dynamically-sized collections).
      So you're mostly recommending the worse practices ever.

      To not have stateful objects in C++, simply design them to be immutable or to act as views, which are quite the recommended designs these days.
      It basically makes sense for values to be stateless, but entities should be stateful.

    6. Re:Parallel programing is hard. by flnca · · Score: 1

      How is const not a good stateless modifier?

      In C and C++, constness can be cast away at the programmer's whim (using either a C++ const_cast<> operator or a regular C cast operator). Also, fields declared "mutable" in C++ can be modified even in constant context. That's why "const" is not a "stateless" modifier in C and C++.

      Of course, it's up to you to decide what your object should allow when constant. It's up to you to maintain the right invariants and semantics, which are what modeling resources and values as objects is for.

      Sadly, formal object modelling isn't used by many companies. Most corporate code is more akin to spaghetti code. The more people have worked on it, the greater the mess you'll find when you look at it.

      The good practices of C++ are to *not* use pointers, only perform resource reclamation in destructors (which means setting the pointer to null after freeing is useless, since the pointer doesn't exist any more),

      Setting member variables to 0 in a destructor for instance is important to avoid memory corruption and to detect when a pointer is accessed after an object is already destroyed. If there's even the slightest chance of a dangling pointer (or reference, for that matter), it's always good to set things to sane values before leaving a function. Otherwise, the slightest programming error can corrupt swathes of memory.

      In the light of multithreading, some programmers do not understand that they MUST NOT access memory from two threads at once. That leads to horrible forms of spaghetti code when they try to program around crash scenarios. This leads to programs that crash differently with timing variations. That's why it is important to use mutexes correctly in multithreading code.

      That's why setting pointers to null pointers can become critical in detecting programming errors.

      and not use useless "empty" states when it doesn't make sense, because they're usually dangerous states with limited possibilities (it mostly makes sense only for dynamically-sized collections).

      WTF are you talking about?! The usage of state information is always highly application dependent.

    7. Re:Parallel programing is hard. by loufoque · · Score: 1

      Note that what I've been saying is not necessarily parallel programming oriented.
      I don't really see how making objects stateless brings any direct help to parallel programming; sure, that means concurrent read accesses are allowed, but that doesn't parallelize the code.

      From the post of the original poster, he probably meant code that does not modify its input, which is known as pure functions.
      The reason there is no such standard keyword is because such a thing would only be useful to the optimizer, hence it is only to be an attribute.

      In C and C++, constness can be cast away at the programmer's whim (using either a C++ const_cast<> operator or a regular C cast operator). Also, fields declared "mutable" in C++ can be modified even in constant context. That's why "const" is not a "stateless" modifier in C and C++.

      It is a feature of the type system.
      Like all features of the type system, you can always choose to get around them in C or C++.
      But that is your choice.

      Moreover, it makes perfectly sense in some scenarios to implement an object with stateless semantics with state under the hood, for example in the case of lazy initialization. Of course that means you have to make sure you initialize your object only once even in concurrent situations, but people that do that sort of thing know enough to take care of that.

      Sadly, formal object modelling isn't used by many companies. Most corporate code is more akin to spaghetti code. The more people have worked on it, the greater the mess you'll find when you look at it.

      RAII is the only good way to program in C++, the end.
      If you don't follow it, your code is simply utter exception-unsafe leaky crap.
      Coding in C++ is about dealing with resource ownership (one of these resources being objects in memory), ownership being attached to some object.
      Spaghetti code is not permitted by the standard idioms.

      Setting member variables to 0 in a destructor for instance is important to avoid memory corruption and to detect when a pointer is accessed after an object is already destroyed.

      As I already told you, the pointer doesn't exist anymore once the destructor has been called.
      It cannot be accessed anymore. It is just useless to modify its value.

      If there's even the slightest chance of a dangling pointer (or reference, for that matter), it's always good to set things to sane values before leaving a function. Otherwise, the slightest programming error can corrupt swathes of memory.

      There are different scenarios for dealing with references to resources:
      - either you own the resource (you're responsible for destruction whenever you don't need it anymore, and usually you don't allow aliasing at all, your resource is strictly private)
      - either you alias a resource owned by someone else and are guaranteed to outlive it (you just have a regular pointer or reference, this is mostly useful for views or the like)
      - either you co-own a resource along with other objects, which means the resource still lives till everyone doesn't need it anymore (you have a shared_ptr)
      - you want to alias a resource but have a way to know it has been reclaimed. I personally never found an use for it outside of breaking cycles in shared ownership scenarios that use reference counting.

      Usually, a program only needs to deal with the two first scenarios: shared ownership is not needed unless you really want to share state or perform some memory usage optimizations by avoiding duplicates of the same object in memory.
      Since communication between threads usually means using shared (or global) state, and since that means using specific ownership mechanisms, those spots are fairly obvious in the code.

      In the light of multithreading, some programmers do not understand that they MUST NOT access memory from two threads at once. That leads to horrible forms of spaghetti code when

    8. Re:Parallel programing is hard. by flnca · · Score: 1

      I don't really see how making objects stateless brings any direct help to parallel programming; sure, that means concurrent read accesses are allowed, but that doesn't parallelize the code.

      Stateless objects do not have state, and hence are similar to real constness (which is isn't guaranteed in C++). In a concurrent scenario, yes, concurrent reads would be possible without the need of a mutex semaphore. In a team development setting, true constness with no loopholes would guarantee that a modification cannot interfere with object state.

      Stateless as in "undefined value" would have advantages in some settings. Sadly, C++ doesn't provide that either.

      But that is your choice.

      In a team setting, programming guidelines need to be established and followed; but some companies don't want that.

      Spaghetti code is not permitted by the standard idioms.

      But it is permitted by the compiler. And hence, you have no guarantees against it. Spaghetti code is a reality of real-word projects, a nightmare that too often comes true ...

      Many companies don't even have internal documentation for their projects ("the source is the documentation"), and the source-code is ever-changing.

      That's why companies are moving away from the "problematic" C++ to C#, for instance. Not that they'd realize that you can write spaghetti code in any language ...

      Setting member variables to 0 in a destructor for instance is important to avoid memory corruption and to detect when a pointer is accessed after an object is already destroyed

      As I already told you, the pointer doesn't exist anymore once the destructor has been called. It cannot be accessed anymore. It is just useless to modify its value.

      You're very wrong about this. Simply disassemble some code that accesses memory after it is freed, and not only does the compiler not complain about it, but it also generates code that faithfully accesses the pointer to the memory that has already been freed.

      Say, you have used the "new" operator to allocate an object of class X and assigned it to a pointer variable called "px". A debugger or printf()-statement or whatever you choose outputs the pointer variable as "0xbfec00", for instance. Now you call the delete operator on "px". Then, you output the pointer again, and ... surprise, surprise, you'll still see "0xbfec00" in the "px" variable. That's why it is a good idea to set it to "0" especially when there's a risk that the variable might be reused later on.

      In the light of multithreading, some programmers do not understand that they MUST NOT access memory from two threads at once. That leads to horrible forms of spaghetti code when they try to program around crash scenarios. This leads to programs that crash differently with timing variations. That's why it is important to use mutexes correctly in multithreading code. That's why setting pointers to null pointers can become critical in detecting programming errors.

      Sorry, but I don't really see the link between null pointers and concurrency. Moreover, concurrent reads certainly are valid with most concurrency memory models.

      Null pointers are crash triggers for badly-written programs. That's called "crash accelerator". If some multithreaded code unprotectedly accesses objects that are already freed, an exception is caused immediately, instead of continuing processing until the condition escalates.

      You seem to be indulged in theory ... I can tell you that no theory is going to protect you against the realities of real-world applications, especially if you aren't working alone.

      If you've ever debugged an application for two weeks straight, just to find out that some moron has accessed memory after it was already freed, th

    9. Re:Parallel programing is hard. by loufoque · · Score: 1

      Ok, let's give an example to you about that pointer that cannot be accessed.
      This is of course a fairly useless object (albeit if you add move, swap and inplace construction support, it then becomes quite useful).

      template<typename T>
      struct scoped_obj
      {
              scoped_obj(const T& t) : ptr(new T(t)) {}
              ~scoped_obj() { delete ptr; }

              scoped_obj(const scoped_obj&) = delete;
              scoped_obj& operator=(const scoped_obj&) = delete;

              T* operator->() { return ptr; }
              const T* operator->() const { return ptr; }

      private:
              T* ptr;
      };

      Incredibly enough, once the destructor of scoped_obj has been called, there is no way to access ptr anymore. So there is no reason to set it to null.
      Writing ~scoped_obj() { delete ptr; ptr = 0; } would just be silly.
      Understand that simple point now? And since C++ code should follow RAII, resource reclamations should look like this (be done in destructors).

      WTF are you talking about?

      It is clear you understand very little of what I'm talking about, which is probably linked to your complete lack of modern C++ knowledge, so I'll just stop there.
      It seems your problem with C++ is that it doesn't refuse bad code at compile-time. Well, I wish you good luck with programming then. Even Haskell is no panacea on those terms.

    10. Re:Parallel programing is hard. by flnca · · Score: 1

      Ok, let's give an example to you about that pointer that cannot be accessed. This is of course a fairly useless object (albeit if you add move, swap and inplace construction support, it then becomes quite useful).

      template<typename T>
      struct scoped_obj
      {
      scoped_obj(const T& t) : ptr(new T(t)) {}
      ~scoped_obj() { delete ptr; }
      scoped_obj(const scoped_obj&) = delete; // syntax error!
      scoped_obj& operator=(const scoped_obj&) = delete; // syntax error!
      T* operator->() { return ptr; }
      const T* operator->() const { return ptr; }
      private:
      T* ptr;
      };

      Incredibly enough, once the destructor of scoped_obj has been called, there is no way to access ptr anymore. So there is no reason to set it to null. Writing ~scoped_obj() { delete ptr; ptr = 0; } would just be silly.

      Ah, so writing:

      struct A {
      int b;
      inline A() { b = 0; }
      inline A( const A& a ) { b = a.b; }
      };

      A aa;
      scoped_obj<A>* a = new scoped_obj<A>( aa );
      delete a;
      (*a)->b = 135;

      would not result in a problem? *scratches head*
      Methinks you've overlooked something.

      Understand that simple point now? And since C++ code should follow RAII, resource reclamations should look like this (be done in destructors).

      Yeah, yeah, the principle is okay, I didn't doubt that. And I didn't doubt your C++ skills until now.

      It is clear you understand very little of what I'm talking about, which is probably linked to your complete lack of modern C++ knowledge, so I'll just stop there.

      I suspect it's just the other way around.

      It seems your problem with C++ is that it doesn't refuse bad code at compile-time. Well, I wish you good luck with programming then. Even Haskell is no panacea on those terms.

      Well, I've fixed bugs written by people like you, and frankly, I wouldn't want to be on the same team with you. You've got a lot to learn.

    11. Re:Parallel programing is hard. by loufoque · · Score: 1

      As you can see, you're doing delete outside of a destructor.
      It is clear from your code you understood nothing of the ownership issues I took time to explain to you. You also probably didn't read up on RAII or exception-safety, since your code is not conforming to those principles, and is thus garbage.

      By the way, in modern C++, you simply never use raw pointers that are not views outside of low-level implementation details, and views are to be treated carefully.
      Even, I personally recommend not to use raw pointers at all to avoid confusion and use resettable references instead for views.

      Now don't go and write some other bogus code that indeed does delete in the destructor. That is not sufficient to be good code.
      You may only delete something you're the sole owner of. That is why ownership is so important and different ownership policies need different implementation mechanisms.

      The "= delete" you consider to be a syntax error is a feature of the new yet-to-be-finalized C++ standard (known as C++0x) which allows deleting of member functions that are defined by default.
      Indeed, in that case, the default copy constructor and assignment operator are erroneous since they do not copy the underlying resource. Redefining them is possible, but I chose here to make the object non-copyable and non-assignable for the sake of simplicity.
      The way to do that in C++03 is usually to redeclare them and make them private, not providing the definition. I thought you might not understand such basic techniques, so I chose to use a way that conveyed the intent better.

    12. Re:Parallel programing is hard. by flnca · · Score: 1

      As you can see, you're doing delete outside of a destructor. It is clear from your code you understood nothing of the ownership issues I took time to explain to you. You also probably didn't read up on RAII or exception-safety, since your code is not conforming to those principles, and is thus garbage.

      It's an example of real-world garbage, in a shortened form. That's the whole point. In the real world, many programmers don't know anything about the principles you're talking about. And that's the problem!

      You appear to live in an ivory tower.

      The "= delete" you consider to be a syntax error is a feature of the new yet-to-be-finalized C++ standard (known as C++0x) which allows deleting of member functions that are defined by default.

      I already suspected that, but it's still considered to be a syntax error by the compiler I'm using, GCC 4.3.2.

      It also doesn't conform to the current ISO C++ standard.

      You cannot write code that uses fantasy features of yet-to-be-defined standards.

      That makes you appear as dislodged from reality as in some other statements you made.

      I chose here to make the object non-copyable and non-assignable for the sake of simplicity.

      In fact, that class appears to be very wacky. If I ever came across such code, I would rewrite it for clarity.

      I've written my first auto-pointer classes in 1996, and automatic container classes (for stack-based usage) even earlier.

      The way to do that in C++03 is usually to redeclare them and make them private, not providing the definition. I thought you might not understand such basic techniques, so I chose to use a way that conveyed the intent better.

      Instead you used a piece of fantasy code for a fantasy compiler. How smart! Now you're the epitome of a C++ programmer!

    13. Re:Parallel programing is hard. by loufoque · · Score: 1

      Deleting default constructors and operators is already in some compilers, such as GCC 4.4, which is indeed not stable yet.

      The fact that most people write bad code in a language (i.e. they use a bad dialect) is no good reason not to write good code in that language.
      Because such bad code exists doesn't necessarily mean you have to make your code around it.

      In fact, that class appears to be very wacky. If I ever came across such code, I would rewrite it for clarity.

      I already said it was fairly useless and what it needed to become very useful. It's just a few lines to show you what RAII is like, because whatever you might boast it was obvious you needed to be given an example.
      Making it really useful would require using rvalue references and variadic templates. ZOMG some other new features not in the current standard! (which can somehow be emulated in C++03, with some well-known shortcomings)

      I've written my first auto-pointer classes in 1996

      Which was necessarily defective. std::auto_ptr sucks hard, that's why it's being deprecated.
      std::unique_ptr, its replacement, is better, but still not perfect in my opinion since it takes a pointer and not an object; this is useful for dealing with legacy code or APIs but modern code shouldn't require construction to perform ownership transfer like this. (it being dangerous is why the constructor has been made explicit in the first place)

      Instead you used a piece of fantasy code for a fantasy compiler. How smart! Now you're the epitome of a C++ programmer!

      When talking about what code should be like I'd rather use the ideal solutions, even if few compilers implement them, rather than ugly workarounds.

    14. Re:Parallel programing is hard. by flnca · · Score: 1

      The fact that most people write bad code in a language (i.e. they use a bad dialect) is no good reason not to write good code in that language. Because such bad code exists doesn't necessarily mean you have to make your code around it.

      In principle, that might be true; However, in practice, when working for an employer, you have to make compromises. Like adding code to prevent long unnecessary debugging sessions. (That's a good idea even when you're just coding for yourself; It can save a lot of time.)

      I already said it was fairly useless and what it needed to become very useful. It's just a few lines to show you what RAII is like, because whatever you might boast it was obvious you needed to be given an example.

      Well, as I already said, I've been employing those principles for over 12 years already.

      I've written my first auto-pointer classes in 1996

      Which was necessarily defective. std::auto_ptr sucks hard, that's why it's being deprecated.

      Well, you haven't seen my auto pointer classes. They are totally unrelated to the STL.

      Besides, in 1996, the STL was nothing more than a proposal, and there wasn't even a usable implementation.

      std::unique_ptr, its replacement, is better, but still not perfect in my opinion since it takes a pointer and not an object;

      The purpose of such classes is to provide automatic cleanup for pointers. Hence, only a pointer makes sense in that case.

      When talking about what code should be like I'd rather use the ideal solutions, even if few compilers implement them, rather than ugly workarounds.

      That's your choice, but it makes you seem more like a language lawyer than a programmer. Seeing the practical side of things is paramount to programming however. You're doing yourself no favour.

  70. Re:I wish the Itanic hadn't been such a horrible c by flnca · · Score: 1

    A chip like Itanium requires parallelizing compilers. These do exist, but often cost a lot of money. Languages like Occam have builtin language features for parallelism, but even a multithreading library like pthread could be inlined by the compiler. It's all a matter of compiler design, that's why Itanium wasn't very populer, because there are only few compilers. CS students should be tought how to write HLL compilers, so that more people know how to do it and aren't afraid of it. It's really simple if you look underneath the apparent complexities. For instance, a recursive-descendant compiler is easier to implement by hand than a table-driven compiler. Tools like lex and yacc should be banned from compiler theory lessons. These are things that only increase the apparent complexity for the student. In fact, writing compilers is extremely simple if you know how; a good book has been "BCPL - The Language and Its Compiler", because it contained portions of a hand-written compiler. Lexical analyzers and syntax analyzers are very easy to implement. Basically, a BNF or EBNF already describes the layout of the syntax analyzer if its implemented in a recursion. I successfully implemented a number of compilers for specialized languages without even a CS background, just by writing solid recursive code.

  71. Re:Functional Programming Is a Red Herring by mechsoph · · Score: 1

    Erlang and Lisp have been around for years. If FP was the answer, it would have happened already. The only reason it hasn't happened is because reality keeps kicking FP in the ass.

    Functionaly languages haven't taken off in a large part because garbage collectors have only rather recently become "good enough."

    FP is not just counterintuitive and hard to learn...

    Your right that many programmers seem to have hard time grasping FP.

    ...it is also non-deterministic, meaning that it is not well-suited to mission critical systems.

    Now that's just false. Of course FP languages are deterministic, and try telling the trading companies using Ocaml that FP isn't suited for "mission critical" work. Or tell it to Intel and AMD who use ML and Scheme to verify their processor designs. The only thing close to what your were saying is that GC can introduce unpredictable pause times; not a problem for most apps but a killer for real-time systems. Of course, there's a lot of recent research into real-time garbage collectors with very good results.

    FP is a continuation of the same process/thread mentality that has gotten the industry into this mess in the first place.

    Ok, now I'm convinced that your full of crap.

  72. Fizzbuzz in Erlang? by wisty · · Score: 1

    Can you imagine getting the average programmer to bang out Fizzbuzz in Haskell or Erlang? These guys are flat out finding the "PrintIfFizzbuzz" method on IntegerWithFizzbuzz class in the .Java IDE. Let alone grappling with functional concepts. I'm just saying ...

  73. "everything that has been invented will be..." by plasmacutter · · Score: 3, Insightful

    All of the reasonable ways of throwing transistors at getting faster straight-line code execution have already happened. Hell, even the unreasonable ones have been implemented, like fast 64-bit division units.

    You, and the chipmakers, have apparently become stale.

    There have been claims like this made throughout history. The patent office was closed because of this, bill gates once declared a maximum filesize we'd ever need, and the list goes on and on.

    If today's major chipmakers are too lazy and uncreative to come up with new ideas, then academics and entrepreneurs will come and eat their lunch.

    --
    VLC FOR MAC IS DYING! IF YOU DEVELOP, PLEASE SAVE IT!!
    1. Re:"everything that has been invented will be..." by hitmark · · Score: 1

      and that should happen. welcome to survival of the fittest, economy style...

      --
      comment first, facts later. http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm
    2. Re:"everything that has been invented will be..." by Chandon+Seldon · · Score: 3, Interesting

      There have been claims like this made throughout history. The patent office was closed because of this, bill gates once declared a maximum filesize we'd ever need, and the list goes on and on.

      Sorry, I didn't mean to imply that we had come to the end of invention, even in a small area.

      But all of the effective techniques *that we know about* have been implemented, and the chip makers have been banging their heads on the wall for years trying to come up with new ones. They went to multi-core processors as an absolute last resort, and 5 years later it's probably time for most programmers to accept that and learn to target multi-core platforms.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    3. Re:"everything that has been invented will be..." by Anonymous Coward · · Score: 0

      If you are too lazy and uncreative (by not learning FP) I'll come and eat your lunch.

    4. Re:"everything that has been invented will be..." by I+cant+believe+its+n · · Score: 1

      If you are too lazy and uncreative (by not learning FP) I'll come and eat your lunch.

      I think it is only fair to warn you that today is imperative broccoli-day.

      --
      She made the willows dance
    5. Re:"everything that has been invented will be..." by BradHAWK · · Score: 1

      So by your logic we should be using very fast 8 bit processors?

    6. Re:"everything that has been invented will be..." by Eli+Gottlieb · · Score: 1

      Actually, hasn't work been done in the past few years on producing smaller, more efficient transistors? That would allow the same basic designs to scale further up in processing speed. Sure, it won't make Moore's Law's Corollary for software work forever, but it could provide speedups without having to go multithreaded and run into Amdahl's Law.

    7. Re:"everything that has been invented will be..." by Chandon+Seldon · · Score: 1

      Actually, hasn't work been done in the past few years on producing smaller, more efficient transistors? That would allow the same basic designs to scale further up in processing speed. Sure, it won't make Moore's Law's Corollary for software work forever, but it could provide speedups without having to go multithreaded and run into Amdahl's Law.

      That's Moore's law in action. The problem is that, for a couple years now, smaller transistors has meant many more transistors but only slightly faster transistors. We've been on 3ghz for like 5 years. And the best thing to do with more transistors at the same speed - once you have all the cache you want (and we do) - is to add more processor cores.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    8. Re:"everything that has been invented will be..." by plasmacutter · · Score: 1

      this may be true, but the crux is "that we know about".

      pretty much every major advancement was a result of research and discovery.

      there were people talking about the limits to computers back before the integrated circuit as well.

      --
      VLC FOR MAC IS DYING! IF YOU DEVELOP, PLEASE SAVE IT!!
    9. Re:"everything that has been invented will be..." by Chandon+Seldon · · Score: 1

      Sure, there will likely be advances. But the run up to 2003 or so where every new processor was drastically faster than the previous processor has stopped. And Moore's law hasn't. And the chip makers keep making chips, with more transistors, and with no known way to speed up single-core chips by adding transistors we get multi-core chips.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
  74. My algorythms dont break! by killmofasta · · Score: 1

    I cant believe what I read. Michael Swaine? I have been reading him for decades.

    My algorythms paradidgm always starts with when in doubt, spawn, and let YOUR scheduler figure out wether its on your Core, your chip, FU, on your board or your network, or your local cluster/remote cluster...I remember reading Michael Swaine talk about budgeting and bargining processor units, to see which were faster, more efficent:

    To whit: Both distrubuted web services, distCC image rendering and distrubuted database services, ALL can be set up on a "processing economy" to get a job divided, parelelled, and processed. Richard Feynman was able to do this with punched card jobs at Los Almos.

    Its just with running with such gross schedulers as Windows has, no one is interested anymore in efficency, except as an academic excercise.

  75. Unlambda is going to be the new language of choice by Yoik · · Score: 1

    UNLAMBDA is going to have a new Life! I never really liked reusability anyway.

  76. Fortress... by Anonymous Coward · · Score: 0

    What about the approach taken by the language Fortress?

    If the entire community has to move to a different paradigm, would it ever happen? I guess not.

    People want to keep coming up with ways of fleecing the customer, keep them generally employed and apparently occupied, where each customer is only another link in a predatory chain like the biological food chain.

  77. Why some languages don't catch on. by TheLink · · Score: 2, Interesting

    IMO another reason functional languages haven't taken off is because most lack decent (and well documented) _standard_ libraries for doing many common things, and even if there are decent libs there's typically no way to know which is the standard one to use.

    Between picking a programming language that is powerful (expressive/concise) for all the code you have to write (insert random FP language here) and picking a programming language that is powerful for all the code you don't have to write (perl, python etc), I'd pick the latter in most cases.

    Even if an FP language is 2x more concise than perl for a given task (AFAIK it isn't), without lots of decent libs, you usually have to write a lot more code.

    The more code you have to write, the more code someone else later on has to read and understand. And worse the more code that has to be documented and maintained.

    Standard libraries are important, even if they are only defacto standards because if you use a standard library, even if it's buggy, when an experienced programmer looks at your code, they know what the lib does (and hopefully its bugs), so they only need to read your code, they don't have spend time looking at the lib.

    Whereas if you were writing your own custom libraries, or using one of 100 possible libraries (with no defacto standard) out on the internet, the person taking over or helping out will have to spend extra time trying to debug/understand it.

    Some of the FP languages are catching up in terms of standard libraries, but for many you either have to write your own crap or have to waste lots of time finding and evaluating libraries to see if they are worth using.

    Nobody in their right mind wants to deal with 10 different print commands (ok maybe the php people are different ;) ). So similarly who wants to deal with 10 different database abstraction modules, or 10 different networking libraries, or 10 different signal handling libs? Or worse, having to write and debug from scratch your own lib after spending time to find out the libs out there are crap.

    I'd rather be able to get on with writing the more "interesting" bits ASAP.

    --
  78. Compiling C programs in parallel by Frans+Faase · · Score: 1

    I wonder if compiling eight C programs in parallel on an eight core CPU is faster than compiling them sequential, because one of the performance bottle-neck seems to be in the amouth of data to be read (searching for include files) and written. Not so long ago there was a long discussion on whether it is better to compile C programs separately or simply include them all in one single file.

    1. Re:Compiling C programs in parallel by cnettel · · Score: 2, Informative

      With GBs and GBs of memory, there is no reason that common include files shouldn't get stored in cache. The writes are also miniscule, and contention there would also be a design error. Merging everything in one file is another thing, of course, but that mainly shows how expensive parsing (repeatedly, of include files) is, not the I/O itself.

    2. Re:Compiling C programs in parallel by AttillaTheNun · · Score: 1
      Why not use or design a language that assumes compilation on a multi-core environment?

      C was never designed with parallel compilation in mind.

    3. Re:Compiling C programs in parallel by Chandon+Seldon · · Score: 1

      From personal experience, compiling C program with multiple files is significantly faster on a four core machine than a one core machine.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
  79. Not funny! by Anonymous Coward · · Score: 0

    What the parent says is true! Search "Reversible computing"

  80. Quick, forward your thoughts to intel! by Paul+Jakma · · Score: 2, Insightful

    Apologies (honest) for the sarcasm, but do really think that if the CPU vendors had any useful room left to increase sequential processing performance that they wouldn't use it? Are 3D layouts out of the research labs yet? Are production fabs for 3D chips feasible?

    I.e. what basis is there to think CPU designers have any choice (for the mid-term) but to spend the transistor income from Moore's Law on parallel processing?

    --
    I use Friend/Foe + mod-point modifiers as a karma/reputation system.
  81. Think of it this way... If you had learned LISP by Colin+Smith · · Score: 1

    Not only wouldn't you have had to re learn a new language every 3 years, every time the current fashions changed, you still wouldn't have to learn a new language to exploit massively parallel systems.

    --
    Deleted
    1. Re:Think of it this way... If you had learned LISP by Anonymous Coward · · Score: 0

      O RLY. So please point out the current Common Lisp implementation that readily supports massively parallel general purpose processor systems.

      Alternatively, an R[56]RS Scheme that readily supports massively parallel general purpose processor systems would be nice too.

      If you point out a library, kindly indicate the difference in learning curve between it for a typical CL or R[56]RS programmer and for a comparable (or even identical) library with bindings in a language like Java, C# or C++.

      (cond ((lovep 'you 'lisp)(honk))(t nil))

      PS: FWIW, people I know use a CSP mechanism among processes with an efficient scheme runtime (e.g. Stalin) or with the ability to exploit libraries in other languages (e.g. Chicken), tied together with a coordinating process written in CL (e.g. Clozure or Allegro or LW). Sure that's not quite "learn[ing] a new language to exploit massively parallel systems", but it involves understanding tradeoffs between the language and implementation of choice, and libraries written in that language vs in other languages (with an FFI and useful bindings), and most especially it involves a roll-your-own coordination layer for managing workload (scatter/gather).

      What do you and your Lisp-using contacts do?

      PPS: Might it be just as useful for people to keep coding their coordination layers in e.g. Objective-C or C++ or Java, and a Map/Reduce like library, where useful is closely related to delivering good enough software on time?

  82. Programmers cannot adapt ? by Anonymous Coward · · Score: 0

    Forth, Lisp, Ada, Prolog ? These are good old concurrent language that proven to be useful ! For 20 years now, Erlang is used in industry, and it's a distributed concurrent fault tolerant programming language, it prooved it's efficiency, so there is no hype about it : http://en.wikipedia.org/wiki/Erlang_(programming_language)

    Oh, and it's the programmers to adapt the new challenges. When multitask arised, they adapted, when Rational Roses made the UML a standart, it was new, the programmers adapted. Why wouldn't be able to adapt to functionnal language, aren't they paid enough ?

  83. Re:Python FP -- only slightly like real fp by jbolden · · Score: 1

    second everything in this post

  84. re: need a new floor. by Anonymous Coward · · Score: 0

    why reinvent the wheel?
    as 99% of programs rely on an
    underlying OS that does all the
    house-keeping (mostly), why shouldn't
    a new multi-core-aware programming language
    force you to "think for the machine"?
    if the programming language is
    good.smart enough, you can keep programming
    the way you did on a single core machine, but
    smartly distributing it to all available
    resources.

    it's like saying " please pile all these
    stones ontop eachother so it is a pyramid"
    instead of "take stone A give it to worker
    crew A and move it to location XY, etc..."

    the challenge isn't (shouldn't be) to write
    multi-core aware assembler code(*), but a
    OS.language that does all the heavy lifting;
    which is aware of all the resources...

    (*) cutting edge and expensive :P

  85. Re:Functional Programming Is a Red Herring by Anonymous Coward · · Score: 0

    And so on...did I just feed a troll?

    No. You replied to someone you disagreed with, which is a rather different thing.

    Get this into your head (and this goes for many others, too): disagreeing with your opinion is not the same as trolling. In fact, even playing advocatus diaboli (which may not even be what the GP was doing) is not the same as trolling, either, not at all, although the outward difference may be too subtle for some to grasp.

  86. It's not that simple by Chousuke · · Score: 1

    There's only so much the VM makers can do for you. The VM can't safely parallelise operations unless your operations are made of small, composable, side-effect free units... and that, my friend, *is* functional programming.

    Of course, many of the parallelisable tasks can perhaps be done "behind" the scenes, not at the VM level, but, say, inside an application toolkit.

    However, it is still up to the implementers to make use of parallel execution; and it's still up to you to do that, too, if your problem is one of those that can benefit from concurrency.

    Not to mention that functional programs are much easier to reason about when writing concurrent programs: If you have a pure function, you only need to be concerned about the values it returns; any concurrency is irrelevant. In a well-structured program, operations with side-effects can be isolated and kept as minimal as possible.

  87. Re:Compiler Technology is wrong answer. by anon+mouse-cow-aard · · Score: 1
    In the 90's in supercomputing,you had no end of research into better compilers to make distributed memory go away. It turned out that, no matter what one tried to do, stuff went a lot faster when folks programmed to the architecture/hardware, explicitly understanding that memory was distributed, than trying to use tools to hide it.

    The availability of multiple CPUs is a fundamental aspect of commodity architectures. If you try to let software people pretend it isn't there, you will get slow, crappy code. people really do need to embrace paralellism, but folks are making it a lot harder than it needs to be. Multi-core just gives us all kinds of flexibility that we never had before. as a straight-forward example, suddenly, the efficiency arguments of monolithic vs. microkernel, where running services with IPC now becomes a lot more exciting.

    At the application level, people need to stop thinking about single programs. It's only natural because people were trained that way, but for the next generation, it will seem odd. Individual programs will be simpler. Forget multi-threading, don't try to build large single applications. This is right up the linux/unix tool based alley. Lots of communicating sequential processes (apologies to Hoare) with individually simple elements, and each component being easy to test individually.

    Build algorithms with loosely coupled, asynchronous communications, and simple components. People get themselves tied into horrible knots because they try to get serialism out of multi-processing, and in doing so, they kill the very thing they are looking for: performance.

    No, you don't need a single log file, 200 log files + dsh & grep will do. No you do not want to serialize writes into queues, just give the queue entries hashed indices, so that inserts don't clash. Etc... It's a bit of a mind flip, but the water is fine.

  88. Re:Functional Programming Is a Red Herring by arevos · · Score: 1

    I don't think so. The reason that you don't have side effects is precisely because everything is copied to message channels.

    What the hell are "message channels", and why would you need them when your data is immutable?

  89. don't bother by speedtux · · Score: 2, Interesting

    When people say that they want to learn "functional programming", they usually mean some functional programming language. Common functional programming languages (OCAML, SML, Haskell, Lisp, Scheme, etc.) are duds when it comes to performance: in principle, they encourage parallel-friendly programming, in practice, they get many basic language design and performance issues wrong.

    It's also silly to rewrite large amounts of code when usually only a small percentage of the code is performance critical. If you need to speed up C code to run fast on a multicore machine, optimize the inner loops. All the "functional programming" you need for that is available right within C in the form of OpenMP. You'll understand OpenMP a little better if you have used a "real" functional programming language, but the concepts aren't rocket science and you can do just fine as a C programmer.

    1. Re:don't bother by moro_666 · · Score: 2, Interesting

      i kind of agree, don't bother about fp.

      the thing is, our applications are today running hundreds of processes in a box, even if you get 256 cores on a cpu, we'll still keep them all busy without a change.

      who ever wrote the logic for the article was probably on coke or smth, seriously, no company with over 50 employees (and hence reasonable salaries for non-owners), will migrate to any functional language any time soon, they can't afford it, they don't have time for it and most of all, they don't want a software that only works due to the knowledge of "those 2 guys" ...

        people want software that a lot of people can understand, people want to hire people that can be replaced (in case they get hit by a train or go over to the competitor). nobody wants "this unique piece of s.it that is 5% faster". welcome to the "enterprise".

        big players just don't care. they want simple solutions that can be extended and handled cheaply. buying an extra box with a network connection behind it is cheap. hiring niche people is expensive as hell.

      enough complained, i think those who have ever worked more than a few years in big companies understood the point already while reading the title or article...

      --

      I'd tell you the chances of this story being a dupe, but you wouldn't like it.
    2. Re:don't bother by Hobbes_2100 · · Score: 1

      (1) Lisp can be used in a functional fashion, but it is not a "pure" functional language.

      (2) Lisp can be optimized to machine detail, just as C is (up to the capabilities of the compilers -- which for most purposes is sufficiently well-done by Lisp compilers). (See the back of Practical Common Lisp by Peter Siebel, I think it is available online).

      (3) Some would argue that writing a program in C is the same sort of pre-mature optimization you refer to. Harken back to the idea of C as glorified assembly code. Solve the same program in Lisp (or another "very" high level language). Profile. Optimize the critical sections (algorithm first, then machine specifics -- which, as I mention in point (1) can be done in Lisp). Voila.

      Of course, many "very" high level languages allow interfacing to C for speed critical sections. So, you could apply the same process from (3) with Perl, Python, etc.

      A better criticism of Lisp is getting your hands on convenient libraries for some common tasks. However, there are good libraries out there.

      For the record, I'm a much better, much more experienced C programmer than I am a Lisp coder.

  90. Re:Function is easy - but irrelevant. by anon+mouse-cow-aard · · Score: 1
    completely agree. FP is really cool and and don't want to take anything away from it, but it completely orthogonal to programming for parallelism. For paralellism. You can use any language, taking to heart using multiple, simple programs in the place of monolithic code hairballs people are used to. It's not a language thing, all you need are a good approach and a method of doing message passing. If you want the dumbest possible message passing & queueing, just put files in directories. Have used files to do asynchronous message passing at rates of several hundred messages per second, in python...

    http://metpx.sf.net/

    Each channel on which messages are received is a process. The receiving process decides what tasks need to be done, and "queues" (hard links the message into an input directory) it for downstream actions. This operation is daisy chained as needed. Each "queue" reader is a separate process. We run with a few dozen receivers, a few hundred senders, and half a dozen filters. so a single application with a few hundred tasks, that scales as we add load (additional load is additional senders or receivers.)

    each process is just a normal python program, individually quite simple. It's multi-core ready, and dead simple. Testing of smaller programs is easier too. Parallelism is not a problem, it makes life easier, provided you approach it properly.

  91. Re:Functional Programming Is a Red Herring by russotto · · Score: 1

    Functionaly languages haven't taken off in a large part because garbage collectors have only rather recently become "good enough."

    Either that, or it's because the lambda calculus has sent more than one geek running screaming off into the night.

  92. Erlang+python by Anonymous Coward · · Score: 0

    What we need is concurrency-proof language like Erlang, merged with the simplicity and stateful object-orientedness of Python

  93. I knew I bought an Erlang book for something by hubrix · · Score: 0

    Now if someone just cleaned up the syntax and became a DHH style, cool guy poster child for it, then we'd be talking.

    --
    Screw realty just hook me up another monitor!
  94. Re:Functional Programming Is a Red Herring by MarkusQ · · Score: 1

    Recursion is inherently non-deterministic,

    I can't find a reading of this claim that isn't utter nonsense. Are you saying that it is inherently impossible to determine the results of any recursive calculation? Or that it is inherently impossible to prove a recursive calculation terminates? Or set a bound on its execution time? 'cause all of these are clearly wrong. Are you claiming that recursive calculations necessarily involve some sort of quantum weirdness? That seems hard to believe.

    So what do you mean?

    --MarkusQ

  95. software problem only? by token_username · · Score: 1

    Those Chipmakers should pay attention to IEEE's opinion. Dealing with memory is a significant problem for processors as the number of cores increase. That sounds like a hardware problem to me.

    Shoving responsibility from software to hardware or from hardware to software isn't going to solve anything. There's things that have to happen on both sides before we can go nuts with the number of cores we put on chips.

  96. No. by E++99 · · Score: 1

    Dice results:
    Haskell -- 8 matches
    Erlang -- 18 matches

    So... the answer is "no".

  97. Real World Haskell? by Anonymous Coward · · Score: 0

    For Haskell, Real World Haskell is probably a better option (more like Programming Erlang, and practical).

    In particular, it talks a lot about multicore programming.

  98. Re:I wish the Itanic hadn't been such a horrible c by Omnifarious · · Score: 1

    Hmm... But compilers already parallelize. All the instructions in a pipeline could be said to be executing in parallel. Compilers already do a bunch to manage that parallelism. The kind of parallelism you get from having multiple ALUs and instruction molecules seems a lot closer to the kind of parallelism that you get from a pipeline than the sort of parallelism that requires you to launch several threads.

    Am I wrong?

  99. Re:Functional Programming Is a Red Herring by TheLink · · Score: 1

    Obviously not enough geeks are garbage collectors, and thus still not good enough.

    --
  100. Re:Functional Programming Is a Red Herring by MarkusQ · · Score: 1

    I'll look past your abusive tone and know it all attitude and just address your main point.

    You claim that it is not possible to bound stack usage in recursive algorithms. This is not true. By requiring tail recursion it can be limited to exactly zero bytes over that used by a non-recursive algorithm. By proper use of accumulators, the vast majority of useful algorithms can be converted to a tail recursive form.

    Even without this, recursion depth is generally bounded by some property of the data structure, and can be limited to the same extent as any other property with a similar dependency. Def Stan explicitly acknowledges this: "recursion should not be used in the implementation. unless strict bounds on the depth of recursion can be defined and hence it can be shown that the permitted memory usage will not be exceeded."

    Note that this isn't any harder (or more stringent) a limitation as the similar requirements on buffer size, queue length, loop termination, etc. all of which can vary in exactly the same way.

    Finally, non-deterministic has a specific meaning, and it isn't the one you seem to be using. Something is non-deterministic if (and only if) it can't be determined in principle, by any one, no matter how clever. You seem to be using it to describe something which is hard to determine by people with your mindset, regardless of how tractable it may be in general.

    There's a big difference between "I can't figure it out" and "it's non-deterministic." Recognizing the former doesn't in and of itself justify asserting the latter.

    --MarkusQ

  101. that tends not to be a big win, though by Trepidity · · Score: 1

    Some of this was tried in the Haskell community, with relatively unimpressive results---a lot of algorithms are mostly sequential, even in a parallel language, and the speedups, especially after futures/whatever overhead, aren't amazing, especially past 2 cores or so.

    That's my understanding of why most current research is on adding primitives that let the programmer specify parallel algorithms at the source level, such as Parallel Haskell's par and seq primitives.

    Basically the automatic reordering the compiler can do doesn't really suffice, at least with any method anyone's figured out so far; to get anything close to a 64x speedup with 64 cores, you really do need the programmer to write parallel algorithms explicitly.

    1. Re:that tends not to be a big win, though by arevos · · Score: 1

      That's my understanding of why most current research is on adding primitives that let the programmer specify parallel algorithms at the source level, such as Parallel Haskell [hw.ac.uk]'s par and seq primitives.

      You're probably right on that score. Though I'd contend that even this being the case, par and pseq are easier to adapt to existing functional algorithms than "new Thread" or "fork" is to imperative algorithms.

      sumRoots [] = 0
      sumRoots (x:xs) = y + ys
        where y = sqrt x
              ys = sumRoots xs
       
      psumRoots [] = 0
      psumRoots (x:xs) = par y $ pseq ys $ y + ys
        where y = sqrt x
              ys = sumRoots xs

  102. Enforcing Murphy's Law??!! by grikdog · · Score: 1

    Oh, Moore's Law. Never mind :-)

    --
    ``Tension, apprehension & dissension have begun!'' - Duffy Wyg&, in Alfred Bester's _The Demolished Man_
  103. Control-flow limitations by nbahi15 · · Score: 1

    I have heard this from the functional programming community, but from my perspective, functional programming is just another threading strategy. The memory disambiguation problem, while real, isn't the limiting factor in the performance of programs.

    If you look at the Wall paper, which was a limit study of instruction-level parallelism, and then the Lam paper, you will see that even with perfect memory disambiguation the amount of parallelism is fairly small. The small size of basic blocks and therefore frequency of conditional branches, is the greatest limiting factor to program performance. Only if you can enlarge basic blocks and/or execute speculatively are you going to see serious improvements on a single processor.

    We know instruction-level parallelism on a single processor isn't large, the problem of writing multi-threaded code for multi-core processors, is identifying sufficiently large chunks of code to parallelize. In other words, where ILP occurs for free by the processor, now the compiler or language must identify the threads to take advantage of multiple cores. Further the compiler or language must wrap this code in threads that the operating system understands.

    The traditional multi-threading technique is where you set a programmer at his computer and tell him parallelize stuff. The functional programmer will certainly identify parts of the code that can be executed in parallel, but I am not sure that is better than any other thread markup. All programmer threading techniques suffer from the fact that a programmer must see the parallelism in their program or algorithms to take advantage of it.

    I believe we are going to see faster software from multi-threading on existing architectures if we find automatic thread identification techniques. Automatic thread identification, like any other compiler optimization, could yield the speed desired, by finding more parallelism in the program than what a human can.

  104. I already functional program in C by nbahi15 · · Score: 1

    Since SSA is Functional Programming there is no need to learn a language like Haskell or Erlang.

  105. Re:I wish the Itanic hadn't been such a horrible c by flnca · · Score: 1

    No, that's largely correct, but it's not that much of a difference. If a compiler knows how to handle parallelism, handling threads isn't much extra overhead. Probably, such compilers (for languages like C and C++) already exist, but are too expensive for most users. I don't know how good GCC is at generating Itanium code, but it has become far better in generating X86 code over the years. That makes GCC increasingly good even for cases in which optimization truly matters. If you look at medium-priced compilers like IBM C Set and IBM Visual Age for C/C++, you can see that even for a 4- to 5-figure sum, you can get pretty good optimizers. The best ones are in the 6- to 7-figure range however (b/c they're sold in small numbers by small companies). Applying every optimization strategy known to mankind in a reliable and robust manner costs a buck or two. That's an area in which GCC needs to be further improved (to make optimizers that always work), but 4.x has become quite good in that respect also. Still, if more people would know how to write compilers, there wouldn't be so many monopolies around.

  106. Re:Functional Programming Is a Red Herring by colinrichardday · · Score: 1

    It is counterintuitive because nature does not execute equations to do its thing. The human brain is orders of magnitude more complex than any program in existence and it does not perform equations. Nobody should be forced to use an unnatural notation for computer programming just because mathematicians are enamored with it. A computer is not a function evaluator. The proper context for computing is behavior and it comes from psychology, not mathematics. A computer program is a behaving machine, that is all. Functions and calculations are just types of behaviors, not the be-all of computing. They should not be the basis of how computers work (that was the problem from the beginning, Babbage and Lady Ada comes to mind). The correct (and highly intuitive) metaphors for programming and processor design are concepts like sensor/effector, stimulus/response, concurrent/sequential, predecessor/successor, etc. These are things that are readily understood by everybody, even kids.

    The idea behind computers is to have them "behave" in ways that are not natural, but artificial. That is why we make them. If we want you "natural" behavior, we could just stick to humans.

  107. The problem IMHO... by McDoobie · · Score: 1

    Right now, the problem is not so much with the tools, but with the paradigm in which the chip makers are operating.

    They are still focused on a parallel "paradigm"(god I hate that word.) that's thirty years old.

    Synchronous processors are, IMHO, a better solution to this than just throwing piles of cores on a die. Look at Project COSA for example. http://www.rebelscience.org/Cosas/COSA.htm

    Something like this would be far more appropriate. Yes?

    1. Re:The problem IMHO... by McDoobie · · Score: 1

      Yeah...replying to my own post. Heh.

      I might also add that while functional languages might work well when dealing explicitly with parallel computing, they really tend to stink at everything else. i.e. Memory managment, device drivers, etc...

      I have yet to see a Functional Language that can create an executable program that's as compact and efficient as it's Imperative counterpart. I'm not looking forward to the days of 100 megabyte device drivers, mandatory garbage collectors and runtime systems, and interpreters that eat up more resources than all the applications on a system combined.

      If the baggy eyed academics care to financially reimburse people for all the extra hardware their gonna need, then by all means let's go for it.

      I hear the FP people screaming that I'm not making a fair comparison. In a strict theoretical sense, that's true. Just as in academia, everything is theoretical. Out here in the real world the tools that I've had to work with haven't been all that impressive. They've been lovely as roses on surface, but as soon as I looked underneath the hood; it was all I could do to keep my composure.

      Now, working with Synchronous Programming tools on the other hand have been a breeze. And they are tools that any functional developer should feel right at home with.(And this is coming from an Ada programmer.)

  108. Convince your wallet. by Ostracus · · Score: 1

    "If GPU technology has taught me anything, it's that you can make gamers pay $700 for a graphics card and $200 for a new 600watt power supply as long as they're getting their shiny things fix, so power efficiency doesn't matter for the desktop market, laptops and servers being a different story."

    Except that the latest crop of video hardware turns that argument on it's head. I can get more horsepower (dual GPU) now and for under $600 than ever before.* Even the $600 PSU isn't needed except for the most loaded, overclocked machines out there. And even that really isn't being done for performance reasons so much as it is economics. e.g buy cheap, overclock. Get the next hardware up for "free".

    *Even IGPs are becoming respectable.

    --
    Shai Schticks:"You don't make peace with friends, you make peace with enemies"
  109. Compiling personality in parallel by Ostracus · · Score: 1

    "The average developer is an ignoramus."

    Which one are you and why should that be exclusive to you?

    --
    Shai Schticks:"You don't make peace with friends, you make peace with enemies"
  110. Fine grained control-flow by anothermuse · · Score: 1

    The traditional multi-threading technique is where you set a programmer at his computer and tell him parallelize stuff. The functional programmer will certainly identify parts of the code that can be executed in parallel, but I am not sure that is better than any other thread markup.

    Perhaps multi-core is an intermediate step towards fine grained parallelism. Self-assembling carbon nanotubes sprayed on with ink-jets may suggest novel approaches to problem solving.

    For instance, take the sorting problem, mentioned earlier in this thread. Instead of a sequence of unsorted numbers, you beam them onto a substrate all at once. Lets say that the substrate contains nodes that are arranged where any two vertically arrange nodes are min-max sorted to two horizontally arranged nodes like so:

    ...node...
    ../....\..
    max....min
    ..\..../..
    ...node...

    Now, with some additional magic of redundancy and spin, a vertically arranged unsorted list could by sorted into a horizontally arranged list in O(N) time (albeit in a N^2 space). There is no separation of CPU and memory. Instead, you have a Cellular Automaton that is arranged along an octahedral lattice.

    So, which language would best describe such a sort? I don't know. It seems that each language is an attempt to express a range of applications within a domain of op codes in the most compact way possible. Perhaps FP will better fit large-grained parallelism. But, I'm not sure what would best express the mindset of FPGA's, cellular automata, and the neural model of McCulloch and Pitts.

  111. Convince your GPU. by Ostracus · · Score: 1

    "When we do that, we notice that what goes on in the gaming industry, soon becomes standard everywhere else. And both modern platforms, the PS3 and XBox 360 (I'm not including the Wii as Nintendo has different goals that having bleeding edge tech.) have multi-core processors. Radically different architectures, but multi-core none-the-less. We are also seeing this, and have been for a while, multi-core entering the desktop."

    You're leaving GPUs out of the equation. It doesn't completely leave out your "multi", but a multi-core CPU isn't the same as a multi-shader GPU. And with IGPs making an appearance in the chip sets GPGPU will become more common.

    --
    Shai Schticks:"You don't make peace with friends, you make peace with enemies"
  112. more cores, now figure out how to use them by drwho · · Score: 1

    Yes, I just got a wonderful new computer for under $200. It's got 216 cores. But they're all pretty small. It's called an Nvidia GTX 260 core 216. It's also a graphics card.

    Which is all very nice until I look around and see that there's not all that much that's been done to optimize tasks for parallel execution, with the exception of graphics. But that's changing, and programmers need to realize this is where performance is going to come from in the future.

    It's funny, though, sitting here running three virtual machines on my desktop on two cores (AMD) and how wonderful it would be if these could utilize the parallelism inherent in virtual machines. I am not expecting that vmware is going to be able to offer me the ability to run 216 instances of linux on my video card, but perhaps in the future some paradigm refinement will allow allocation of cores to problems which will take different courses towards parallelisation, either by creating virtual machines (very restricted and inefficient, but secure and easy) or by having more lightweight structures where the task is simple and repetitive and performance is important. Or even better, know when NOT to use the full GPU. How about knowing when to shut down certain cores, and use the freed resources of heat sink and power to dynamically increase the clock speed of the remaining cores..in such a way then, optimizing the tasks and the hardware both.

    Well if this rambles a bit I am sorry. I am sorta thinking 'out loud'. Maybe I just need to get a blog and not subject slashdot readers to my madness.

  113. FP is not that hard by jknapka · · Score: 1
    1. The idea that simply cramming more transistors on a chip can, in itself, make anything go faster is rather silly. It's obvious that "more transistors" means "more parallelism", whereas "faster transistors" means "more speed". It's just that until recently, the nature of the parallelism was hidden from developers (in pipelines).
    2. Functional programming (and declarative programming in general) isn't intrinsically any harder than other kinds. It may seem harder for programmers who've only done structured and OO stuff. But it's just another way of looking at problems, and once you "get it", it's easy. The trick is, don't worry about what the code does; just think about what it means. In "traditional" languages there's often little difference between those aspects, but in declarative languages there's a huge difference. IMO Prolog is the language that makes it easiest to see this (but I'm biased as Prolog was the first declarative language I learned). Prolog's syntax and semantics are much easier to absorb than, say, Haskell's.
    3. Even in traditional SP languages, the relationship between the code one writes and the CPU's behavior has been getting more and more obscure as the complexity and pipeline depth of processors increases, and in general we don't let this worry us. Programmer time is usually lots more valuable than processor time. So the not-totally-obvious relationship between FP code and efficiency doesn't seem like a huge issue, especially when the code you write is parallelizable more or less for free.
  114. Beyond functional by CustomDesigned · · Score: 1

    I think it was funny because functional programming is already hard enough that adding the reversible requirement seems over the top. In actuality, a reversible computer can run non-reversible code just fine - it would just quickly accumulate "entropy" bits that need to be cleared. Algorithms adapted to reversibility would minimize the "entropy" generated.

  115. Web apps by Anonymous Coward · · Score: 0

    This article seems to ignore the fact that many of our desktop apps are moving to the web. Spreadsheets, email, games, etc are more and more frequently available in web application form. Fortunately, web applications are fairly easy to scale with multi-core chips because each user can be running on it's own thread which occupies a single core. So, the most important apps (webservers, and database servers) are already designed well for dealing with multi-processors.

  116. The programs will just get lazier and crappier by SAABMaven · · Score: 1

    In today's world, any VB6 forms developer is automatically a .NET guru. Drag buttons onto a form, don't bother considering memory usage, declare lots of strings on the fly. The programming, over time, seems to outstretch the availability of cheap hardware produced in China's sweatshops and bought on credit, to keep up. Each new release of just about any system, is more bloated, not better.

    I can't blame them, they know that their project will be outsourced to the Bangalores of the world, and that they will be laid off anyway, so who cares about quality?

  117. Re:Functional Programming Is a Red Herring by Dogtanian · · Score: 1

    It only seems counter intuitive if you've swallowed the procedural programming paradigm and adopted it as your own to the point where you've forgotten how counter intuitive "X = X + 1" seemed at first.

    "X = X + 1" is only misleading because it uses the "=" symbol- normally associated with equality- as the assignment operator.

    If we ignore that side issue, there's nothing inherently confusing about the operation itself. Pascal and COMAL use ":=" (becomes equal to) instead, and I wish that C and all its syntactical derivatives had done something like this instead of using "=" for assignment (possibly with "<>" for inequality to avoid mixing up ":=" and "!=").

    (Ironically, BASIC's restrictions meant that despite using the "=" symbol for both purposes, there was never any confusion because it could only mean one or the other in a given context).

    --
    "Slashdot - News and Chat Sites Deviant". (Click "homepage" link above for details).
  118. my scripts are all multi core by Gunstick · · Score: 1

    when I program unix scripts, I don't do it in perl or php or python. But in good old shell. Preferably ksh (or maybe zsh) but not bash (reply here if you wanna start a discussion on braindead pipe handling of bash).

    Just doing a command line with lots of pipes one after the other automatically creates as many processes as you have pipes. It's beautifully simple.

    In that respect, unix has had the multi core idea since it's beginnings.
    Then came along the monolythic languages like perl where you have to jump through hoops to get that paralellism back which you have right away in good old shell.

    How's that new Windows shell comparing? Monolytic or implicit thread/process creation?

    --
    Atari rules... ermm... ruled.
  119. Re:I wish the Itanic hadn't been such a horrible c by Anonymous Coward · · Score: 0

    Itanic 1 was a fine IA-64 chip, and IA-64 is a fine EPIC ISA.

    Itanic 1 was a weak IA-32 chip, and an expensive one. IA-32 is not a fine ISA, but it's pervasive.

    The thinking: users would recompile higher-level-language source code to IA-64 assembly (and then on to machine language), and rewrite their performance-critical IA-32 assembly to IA-64 by hand.

    The result: lots of IA-32 code continued to run unmodified because the users did not have the ability to recompile the hll source code, since it was not theirs. Lots of such source code was not portable, and the performance-critical assembly was especially difficult to reason about with respect to a port to IA-64. The expense of Itanic hurt it on two fronts: low adoption rates of IA-64 did not encourage proprietary software vendors to port their software that actually *did run* on Itanic 1 (since it handled IA-32 natively), and the computer buyers could get much better IA-32 cost-effectiveness with other chips, even from Intel.

    Itanic 1 should have been priced lower, and it should not have pretended to be a competitive IA-32 implementation.

    Modern Itanic is (relatively) cheaper, and does IA-32 in software using a system much like Apple's Rosetta.

  120. Re:Functional Programming Is a Red Herring by Anonymous Coward · · Score: 0

    And so on...did I just feed a troll?

    No... you enfatuated him.

  121. Please don't learn functional programming by Alexpkeaton1010 · · Score: 1

    Your inefficient OO programming keeps us FPGA developers employed. Move along please.

  122. Correct! by Anonymous Coward · · Score: 0

    Somebody give this man a prize!

  123. Re:Functional Programming Is a Red Herring by Anonymous Coward · · Score: 0

    WAY too late to the party here, but what the hell...

    you've forgotten how counter intuitive "X = X + 1" seemed at first

    I hate to admit it, but that's actually something I always liked from the B&D languages like Pascal. In those languages, "=" is an equality test (closer to what one would expect from grade school math), and ":=" is an assignment (usually pronounced "gets"). Thus, "X := X + 1" does not conflict with our analytical preconceptions.

    Of course, I also remember how many times I accidentally typed ";=" or ":+" instead of ":="--but that's a different issue.