Hacker News new | past | comments | ask | show | jobs | submit login

>In practical terms what happens is that your clients need to have a real good mental model of what will block and what won't.

I don't understand. Who are "clients" in this context? You need to know what calls will block and what calls won't regardless of style (event vs thread) unless you are using OS threads or processes.

>Threading sucks.

Why?

>Which ones do you think are good?

The one that comes with ghc.




I think perhaps the communications problem here is a difference in context.

I'm coming from a C/C++ background. I get some Haskell but you'll have to explain specifics to me (I'm certainly willing to change my mind!).

Are you using a framework, or developing one? Who gets to choose the concurrency strategy?

As a framework provider, if you provide LWPs to ppl (like provide open and read and all that stuff for them) so they can write sequential code as if it were sequential, but it's actually nonblock, what happens in C/C++ is that when they need to integrate third-party stuff, life gets really complicated. Clients are the clients of the API I'm talking about, which is a hypothetical "lightweight thread" based API where everything just works as per original post.

>>Threading sucks. >Why?

Well, in an ideal model of computation we wouldn't need to synchronise things. This is the great attraction of likesay a node-based model where we run our stuff as synchronous events. Once you accept threading you need to care about who does what to which at what time. Also you need to figure out e.g. how your dependencies are thread-safe and under what conditions. You might have berkeley db where contexts are not generally thread-safe but handles can be if you set the right flags, for example.

>>Which ones do you think are good? >The one that comes with ghc.

That's cool :) I should probably learn more about it. The really cynical part of my mind is going "please tell me about this magical solution to integrating different event loops and concurrency models" and the less cynical part is open to your suggestions.


>Are you using a framework, or developing one?

No.

>Who gets to choose the concurrency strategy?

The person writing code?

>Clients are the clients of the API I'm talking about, which is a hypothetical "lightweight thread" based API where everything just works as per original post.

In that context, I am the client. Here's how it works:

    forkIO myFunction
That's it. Very simple, scales to millions of "threads", and if compiled with -threaded, those millions of "threads" are spread over a set of OS threads so I also get parallelism.

>The really cynical part of my mind is going "please tell me about this magical solution to integrating different event loops and concurrency models" and the less cynical part is open to your suggestions.

The key is just in the "demanding better from languages" part. You don't have to worry about a dozen incompatible green thread libraries if it is built into the language.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: