Joe Duffy spends a lot of time thinking about the future of concurrent programming and parallelism. In his role as Lead Developer in the Parallel
Computing Platform team, Joe is the creator of
PLINQ and a key contributor to many of the managed (.NET)
concurrency incubations happening in and around his broader team. He's also an author (check out his latest book,
Concurrent Programming
on Windows)
You've met Joe many times
before on C9 and the concurrency topic
should be quite familiar to you by now (There's a lot of very innovative thinking going on in the parallel computing platform team (
and
it's not just about the managed world, as you know)).
We've spent a lot time discussing library-based approaches to enabling parallelism in a readily understanable, predictable, safe and scalable way for .NET programmers. We've also spent time on language level approaches to the problem (new constructs in C# that
make it easier to compose in a semi-functional way (lamdas, LINQ, etc) or purely in a hybrid-functional way in
F# or with experimental DSLs like
Maestro).
Erik Meijer, Expert to Expert host, programming language designer and one of the high priests of the lamda calculus spends a great deal of time thinking about
the problem of software's capability to scale effectively (as efficiently, safely, and as composable as possible) in the Many-Core age. So, we add Joe + Erik and we get many excellent, insightful questions and answers. Of course the notion of side-effects
plays a big role here and we even debate the merits of Haskell in the real world. This is a great conversation. It goes deep, but not so far into the rabbit hole that you won't be able to find your way back.

Enjoy!
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
Niiiiiiiiiiiiiiiiiiiice! Thanks guys.
Joe has a point: Haskell only looks complicated. Probably if the language would look more like C/C++, C# or JAVA people would probably use it more and not get scared simply by checking it out. The stuff often is only named in a way that people get scared.
I have already had a similar experience with trying to explain Lambda Expressions in C#. They are not that complicated to get but people are scared when you tell them the term "Lambda Expression(s)". It's as if the name activates a blocking system in the brain.
--midwatch edit (17:24)--
now this is why i love channel 9.. right here. cutting edge stuff. stuff you're not even sure you can talk about yet. thats what i love about channel9
--midwatch edit2 (40:40)--
erics talks about how the dlr is alot about talking to legacy. i dont think thats entirely true.. diffrent problems requre diffrent things of the language and one thing the dlr really enables imo is to have a wider choice of approaches to those problems
I really enjoyed this particular conversation because it really surfaced the vision behind Expert to Expert!
Thank you Erik and Joe! We will meet again.
C
imo even the most perfect system is useless if no one uses it [because its too hard or whatever]
purity is great but what i like about duffy and that whole team is that they are still pragmatic, they want people to have use for their stuff, not just create something thats perfectly pure beautiful but not useable in a practical sense
maybe we wont be able to create completly linear scaling programs with out errors while using side affects, but i think we'll always have errors in our programs, no matter how pure they are
however, there is no right awnser to this cunandrum imo, just diffrent oppinions
purity adds a bunch of constrains on programs (thats the whole point) to make absolutly double sure that they are "correct" but people are able to create things that work even without these constraints
you mention small companies. well its in those companies that .net really gives an advantage because its such a boost in productivity. if microsfot was to make the entire runtime and bcl pure, those companies would have to look elsewhare for that productivity boost
i dont think c# should become haskel because we already have haskell, if we want to use haskell, use haskell
you talk about the "coming decades". yes that is probobly true that in 50 years time we'll open a vs2008 project and sigh loudly but im abolutly sure that we would do that even if we switch to haskell right now
great, great interview as always.. i dont want to take a break at all

we cant just ignore the people.. that is unfortunate
it touches on alot of things ive been burning cycles in my puny brain on..
the pull between more static and more dynamic, both are beeing called "the solution" but they pull in so diffrent directions and c# is in the middle..
i think what anders said at pdc and other times is so very true. there is no one correct model. sometimes we need to be dynamic, sometimes we want o be really static.. there just isnt a single solution, a single model. so should we accept this and try making using diffrent models easier or should we make it more difficult
i know you dont agree sylvan but i think its better to get 80%-90% there and get high adoption that to get 100% and make 99% of programmers relearn 99% of what they know
banans must be one of the more paralell fruits btw..
C
its time, not marketing that stopping joe programmer from learning from learning something radically diffrent.. marketing may help convince people to spend that time, but in a lot of cases its just not possible.. if the boss man tells you that he wants the serverapp back up you cannot tell him/her that you gotta go relearn a large portion of your programming skills first
yes i know thats an extreme example but time is always an issue in industrial programming
if c# becomes more complicated
than haskell for newbies, arent the newbies free to use haskell?
Adding things to c# will make it more complex, this is true. but when its "too" complex is a subjective thing. when c# does become "too" complex for someone, that person will move to another language (hopefully still .net)
My point is that you already do have a language that is pure from the start, haskell, so why not use that if thats what you prefer.. perhaps the best thing would be to have a haskell compiler for the clr (with its own pure bcl). also, theres f#, its a lot more pure than c# and its beeing added as first class language, isnt that sort of what your calling out for?
the lines of programming is pretty blurry, sometimes you need some purity and sometimes you really need to be dynamic, c#4, as a true general purpose language (i dont agree with eric that haskell is GP, not in practice anyway), tries to find a middle road. its not optimal for dynamic programming and its not optimal for pure functional programming, if you want more dynamic/more pure, use a diffrent language
i dont think there can be one language that pleases everyone and trying to force people to do this or that just doesnt work. they have to come willingliy.. i think exposing people to functual constructs through c#4 will entice them to try purer languages like f# or haskell where its applicable and that cant be bad right?
I'm still bullish on message passing in the long term for a number of reasons. I find the Erlang world view (if not the details of the language) very appealing. And I systems like Singularity make me even more optimistic about it. I look at IOCP and see the same sort of thing going on.
It might be interesting for a future video to "go deep" on how synchronization primitives work (right down to the opcodes). I'd like to know if we'll ever get to the point where hardware designers can no longer maintain cache coherency system wide.
It might also be interesting to look into how Second Life's new Mono based script engine handles massive parallelism. You could also touch on Erlang style processes and the way the CCR can leverage iterators.
I need a coffee.
Don't you think we have a big enough problem without that rearing its head
I'm glad you enjoyed the discussion.
I'm reading over all of your comments, and I see many great points being made.
One that I'd like to deposit for your consideration. Haskell is an ideal language _in certain contexts_. For some people, those contexts are important enough to learn an entirely new language. Highly parallel programs may be one such context, where the safety moving wholesale to Haskell brings is worth the cost of switching. Even if that were true, _most_ .NET developers are not currently salivating for parallelism. In 5 years? Maybe. But not today. So as a broad blanket statement, it is safe to say that the perceived cost of switching to Haskell is far higher than the perceived benefit for the bulk of the development community. This is why an incemental, move-select-parts-of-your-program-over-to-the-safe-world-piecemeal, strategy is so attractive.
In addition to that, I mentioned in the video that Haskell is not a panacea. It has many interesting ideas, but some that I consider to be debatable for the .NET community at large. Algebraic data types mixed with structural pattern matching -- with type classes for polymorphism -- are useful for a certain class of programming, but telling a whole community of object-oriented developers to switch overnight will not only result in religious clashes, but is probably just plain wrong anyway. There is a plethora of shared knowledge (e.g., in patterns -- see GoF), collateral (books, articles, training), and frameworks that Windows developers rely on each day, which are strongly tied to the C++-family of languages. Moreover, I don't believe vanilla Haskell (98) has solved _all_ of the problems associated with composition of separate agents that are performing I/O. The "one top-level I/O loop" style of programming doesn't scale beyond one coarse-grained agent. For that, something more like Occam or Erlang is neeeded, and this is crucial to address in order to enable composition of fine-grain with coarse-grain concurrency.
Food for thought, I hope.
Best Regards,
---joe
In any case, we probably agree on one thing: in the long-term, a new language is needed. We're just debating execution strategies to get there. I firmly believe we need a stepping stone from here to there, but that "there" is still a very important place to end up.
---joe
C
haskell might be great for paralellism but like joe said, its not great for everything. c# is really good for a very wide amout of stuff and i think that means more to most general purpose programmers that excelence in a perticular area
the world is massibly paralell after all.

As far as new language goes.. well.. yeah a better language is always great, but i think its easy to over state the importance of languages and understate the importance of philosophies and understanding of what one is doing.. alot of these problems really transcends computing in my view
what i mean is that its prefectly possible to create perfectly pure-no-side-effects applications in any language, its the philosophy thats the core. no language will allways produce perfectly scalabe programs. we must not forget that we, the humans, are the ones who wants to express something and the language is just a means (all be it, an important one) to do that
Wasn't .NET a revolution? it seems to have done well, I don't think you need expect developers to give up their investment in .net code, just as .NET was harnessed and interoped with their native 'investments' (plus I bet companys would actually WANT to 'port' their code up for the advances it gives).
oh and get nullability right.. etc
But really, why not? it won't sell?
I wasn't suggesting nothing is done or people do nothing. After all fully parallel applications have been possible for a long time (I have even written some). The problem is not 'can it be done' but 'how do we make it easier'. Your original point was that it would be better to teach people something new rather than (say) relying on C# to provide the necessary concurrency. Sure it would be good to teach programmers a new paradigm that really helps solve the concurrency issues -- I am just sure we have much idea as to what it is.
its not great for anything where the static type of something you need to talk to isnt known.
beeing completly pure also restricts what kind of optimizations you can make. all those guarantees about isolation just does not come for free.
basicaly every arguments that is used against the static:ness of c# is even more applicable to haskell
you can use c#/.net to write
web apps,
ria apps,
desktop apps,
xbox games,
mobile apps and
embedded apps
all without having to write your own runtime and without using obscure 3rd party libraries. is that true for haskell?
its interesting that you ask me to "compare the amount of work required to get it running" because that doesnt seem to be a requirement for you.. just how much work would it be to create a graphically rich, multi touch application in haskell? id image you'd have to re-invent a whole bunch of things already present in c#/.net
"C# can't easily be compiled" not sure what you're talking about.. the c# compiler is included in the framework but surely you must know that
"Can you generate x86 assembly on the fly into a buffer and then jump into it and start executing in C#?" well, c# is jitted so no. but you can generate IL with AssemblyBuilder/Reflection.Emit. however i dont see that as a very general purpose or command thing to do
"Can you use C# to write hardware?" yes? pinvoke/CreateFile?
"How about reactive animation?" from what i understand, that pretty much what depedency properties do
im not saying it doesnt matter what language we use. im saying that language is not the most important thing, the understanding of the concept is. you seem to think that if we all used haskell, everything would just work, and thats not true.
no language will let you escape the need to understand the problem and if you do understand the problem you truly can implement it in almost any language (even assembler). its just a matter of preference what language you actually use.
the debate between static/dynamic has been going on for what? 40-50 years? knowing that i dont understand how anyone can think there is a simple solution that will just work in any situation.. thats just religion..
the cold hard fact is that haskell is a minority langunage. if it was sooo great, sooo easy to learn, soo general purpose, soo free from problems, it would be more widely used. its not, so it isnt. blaming marketing is pretty lame because haskell has been around for ~20 years, and still hasnt become mainstream. thats not just a marketing problem..
im not married to c#. it has problems and can be made better. its not great for everything.
the fact that you cant admit that about haskell just makes you look silly, and worse than that, you're hindering the progress of haskell by not admitting its flaws..
I think the question here (like we discussed in this interview) is:
Does Microsoft create a new general purpose language and runtime that specifically addresses the concurreny problem while providing engineers with high level abstractions that make programming parallel systems easy, effective, safe and scalable?
Haskell is not the panacea as Joe and even Erik have said (and so has Simon Peyton Jones).
In the end, general purpose programmers who have evolved in this imperative, sequential world must learn to think differently, first and foremost. Getting your minds around completely foreign concepts is a great approach to this. I think it's time for a series of conversations and tutorials on Channel 9 based on the theme of Expand Your Mind. First up: Functional Thinking. Stay tuned.
C
I mean, would it make sense to write entire applications in a DSL like Maestro? Of course not. You would build the parts of the system that are not parallelizable (they don't need to be.....) in the tool you are comfortable with (C#) and use other tools (like Maestro, for example, or F#) to solve specific problems (like breaking a complex data computation into pieces and running them in parallel).
I love this type of discourse and I do not claim that my opinions are any more than my opinions (and they can change based on conversational data).
Keep on posting,
C
I didn't say "Haskell is not general purpose." There is a difference between asking a question and stating a position.
I think you're right about a language that supports EDSLs. That's something we talked about in conversation with Anders at JAOO 2008.
C
This is a hard problem that requires changes in several layers of the software stack, including thinking. Someday, perhaps we'll have a new language, let's call it Nirvana (remember that SPJ brief interview? Note where "Nirvana" lives on the Useful vs Safe (where safe-ness is measured in how side-effectual the language is -> unsafe = very side-effectual, safe = not side effectual...) graph), that can be all things to all scenarios (probably by virtue of its native support for EDSLs and it's highly generic runtime). Who knows.
C
gui :: IO ()
gui = do
f <- frame [ text := "Event Handling" ]
st <- staticText f [ text := "You haven\'t clicked the button yet." ]
b <- button f [ text := "Click me!"
, on command := set st [ text := "You have clicked the button!" ]
]
set f [ layout := column 25 [ widget st, widget b ] ]
Ooo my...I don't see myself ever being comfortable mentally with that and being able to write (or read) my windows apps that way. Not saying it will never happen, but I just don't feel it (and I am pretty open minded). Moreover, would Intellisense be able to work with this?
I am interested to hear more thoughts on linear types and more thoughts on types that could have attributes to dictate concurrency behaviors and useage rights (i.e. read only, read/write, reads for these callers, etc.) with compiler enforcement.
I have to watch this show again. Good show guys.
A random related side: My 4-way 2.66GHz HP is noticiably slower then my 2-way 3GHz HP in the Vista look and feel category. I know there is many factors. But more cores is not really helping the user UI experience more then faster cores in my experience (from the clock on the wall). This is because the "user" things are bound by the UI loop (including the shell). So we can not forget about the "fast" path while reasearching many-core solutions. Hardware and software vendors still need to push each core and not think adding cores is the ultimate solution to the problem.
There is also an issue which you pointed out. All these 3rd party libriaries with limited or no support that come and go. That was same reason I finally left my beloved Perl. It turns into a treasure hunt all the time looking for and downloading libraries and extentions and patches and version mismatches, etc. That part could be fixed if MS made it a .net language however. I say, use what you like to write in. The syntax question however is OT to the larger issue of the right Model for concurrency. I think the truth lies somewhere between Erlang, CCR, Linq, and Agents (not Agent Smith) as I think Joe was leading to.
BTW. Anyone *here actually write a non-trivial Windows application written in Haskell and have a URL to sample? Would be interested in looking at it. How about Eric?
" If all .net languages eventually compile down to CIL, then why not just focus on analysing the CIL code for parallel optimisations and then literally restructure the code on that common level? (rather than finding a common model for all high level paradigms) "
This is why the functional programming model is so appealing from a parallelization point of view: the higher level meaning is not lost, but in plain site and reliably computable (surprise-free, with controlled(controllable) side effects). Determining how to split up code to run in parallel, for example, is explicitly expressed in the higher level thinking (expressed in code), therefore it can be accurately interpreted and recomposed in the compilation process.
C
diffrent tools are good for diffrent things, c# id good at alot of thing while say, haskell is really great for parallelization
another point you make that ive also tried to put forth is that the functional thinking is the real gold and that it can be applied across alsmost all languages, purely functional or not
all im saying is that c# and .net is more general purpose given whats available today. and really, thats all that counts. if may be possible to write xbox games in haskell but as you say, it (along with alot of other things) its not supported. and if its not supported at least to some extent, it might as well be impossible im most buisness scenarios.

we differ in what we mean by general purpose. the examples you give, compileing to native and writing hardware are general purpose in a very formal way, but they are very specific applications and not sovething that you do very often as a regular programmer. what i mean is, given all programers, very few do what you describe.. you see, most programmers dont care if its the "language" or if its "api". if its possible with an api, its possible with the language. i know thats not formally correct, but thats the way people reason..
in that regard, haskell is less general purpose as it has a smaller api. it does have the potential to be more general purpose, but in practice it isnt.
you are right though. i dont know much about haskell. im sorry if you feel ive been putting word in your mouth, that was not my intent.
one thing you dont seem to realize however is that just because someone cant (or has the time) to prove to you that something is difficult, that doesnt mean it isnt difficult. no i dont care enough about winning a discussion at a forum to create a whole app proving some point about c# or haskell. but that doesnt mean that i or stacy or charels are lieing when we say we feel something is unintuative.
thats how we feel, theres nothing you can do about that
also, where are these awsome 3dshooters and webapps written in haskell? love to see some links
Specifically, I don't like the " <- ". I don't like loosing the "dot". I don't like lack of explicit statement terminator.
But this is all subjective. Some people love the Mona Lisa, other people see a dude with a wig on.
If an executing conceptual framework inside the brain is not able to understand certain incoming information, then it shouldn't block.
The message is simply ignored, asynchronously or sequentially (it doesn't really matter; not in terms of understanding a foreign concept), as expected; the reaction is involuntary, initially. Therefore, the ability for blocking to occur is there, but not highly probable(this is a human brain, after all).
As the language is learned so to is the understanding it realizes, sure. But nothing stops you from investigating a foreign concept directly, bypassing the requirement of mastering any of its associated higher level and formalized expressive abstractions (languages). In fact, this should be the default learning pattern: understand the concepts first (or concurrently, if you can), then language-level expression becomes an exercise in mastering language-specific patterns and syntax. In this sense, a programming language is really just a thin wrapper around a core conceptual framework.
It's rather hard to interpret or express that which you don't understand.
Hypothesis: You can think functionally and formally express side effects in a composable manner without programming in a functional language.
The expression of parallel intentions, for example, can be achieved in an imperative way, implicitly: the functional-ness is abstracted away by the tooling, e.g., Parallel Extensions for .NET, LINQ, Lamdas, TPL, CCR and the runtime (CLR) or in a functional way, explicitly (F#, Haskell, etc). In the latter case there is no indirection overhead, but if you've mastered an imperative toolset, then you should still be able to exploit functional concepts successfully in both a composable and side effectual way in the langauge you already "speak" fluently.
This is exactly what Anders, Joe, et al are thinking with respect to C# evolution and the various parallel .NET libraries in production and incubation.
I think Erik and I are going to pay a visit to Anders soon. Indeed, we'll dig into the thinking behind this thinking as part of a future episode of Expert to Expert. Sound good?
Keep on posting,
C
sounds great charels


as ive said before (though in a far less eloquent manner than you) i truly belive that the concepts, the thinking, is where its at.
learning language x is in a sense a byproduct of learning the concepts behind x imo.. in a way the language is a means to express the concepts.
you can in some cases learn the language without grasping the concepts, but that makes you a lousy programmer
looking forward to that anders video and more conceptual goodness
Even though there are religious wars about syntax, I guess most people would adapt pretty easily to another syntax if they really were convinced there was a substantial benefit in using another language.
If our brains didn't adapt easily to weird syntaxes, we wouldn't have seen all those C-inspired syntaxes and Perl would have remained a sick fantasy inside only one man's brain.
I’m not entirely convinced that the metadata relating to the high level thinking/interpretation is even required to solve this kind of problem? (i.e. mapping serial/sequential code to an equivalent and more parallelized version). In some packages such as Simulink (Mathworks) and BlockBuilder for Simulink (Maplesoft) the model of the algorithm/application is analysed and algebraically simplified into a form that is far more efficient, but equivalent. As, at the low level, the entire application can ultimately be described as a system of equations, why would this abstract principle even require metadata to reform the solution? Only the basic procedural/functional subsets/partitions need be maintained.
In your example of a string of characters, even this can be considered a single value as is commonly used in databases and cryptography (see gmp mp bignum library applications for references). So on the base, all of this can simply be considered one large algebraic problem? Or do you disagree?
Remove this comment
Remove this thread
close