11 ms·
This is great, but I'm still waiting for multicore support, and a mature GUI library.
by amelius 7y ago
This is great, but I'm still waiting for multicore support, and a mature GUI library.
- lifty 7y agoOCaml would have seen so much more adoption if it had a solid multicore story. It really is a shame, because it's a nice language.
- rwmj 7y agoUse multiple processes, and then your code works across multiple machines too (and better across NUMA machines). Threads are simply a bad idea.
- dna_polymerase 7y agoShared memory is still an issue though. To my knowledge there is no convenient way to share memory between processes in OCaml. That said, you are right, threads are horrible.
- lifty 7y agoCorrectly implemented concurrency/parallelism primitives are not a bad idea. I am thinking along the lines of Clojure/Erlang/Go. They make life more enjoyable.
- newen 7y agoWhat is it called when you live in an environment where X is not available and so you convince yourself that X is a bad idea?
- rwmj 7y agoI used shared memory concurrency all the time, you're simply wrong.
- pjmlp 7y agoModern security exploits and application crashes due to state corruption have proven that while threads were an enticing idea, they aren't something that we should keep around if we care about security and application stability. This applies to all programming languages, not only OCaml, hence why everyone is moving away into other concurrency models anyway.
- amelius 7y agoThere are many applications where these kind of security issues don't apply.
- pjmlp 7y agoSuch as? Every application should strive for proper quality, just like in other industries.
- amelius 7y agoFor example: embedded applications, or when I'm the only one running trusted code on my computer. Think also of scientific computing. If you insist on networked solutions: database servers. Also: "multicore + purely functional style" is just as clean as "multiprocess + purely functional style", but ... the latter is less efficient because of communication overhead.
- pjmlp 7y agoUnless you manage to do any kind of work without IO, there is always a security risk. And if that is irrelevant to you, there is still the application stability and memory consistency to ensure data is being handled in a memory consistent state. Fortran is a good example on how to do scientific computing without low level threads.
- amelius 7y agoYes threads should be used with extreme caution, that's why I advocate using a functional programming style. But you still want the performance of multicore. It's not one or the other (but with OCaml it unfortunately is).
- amelius 7y agoOne of the strengths of functional programming is using structurally shared immutable data structures. You can't use this approach efficiently if you don't share a heap with other processes. Converting everything to a shared byte array (or similar) mostly ruins the usefulness of the programming language, and also makes GC impossible.
- Hsbfufbrtfd 7y agoWouldn't functional programming also bend itself particularly well to concurrent programming?
- mseri 7y agoConcurrent programming in OCaml is fine though. Multicore is more about parallelism and the ability to use multiple cores without the need to rely on threads and multiple processes
- bjoli 7y agoLike Python?
- lostmsu 7y agoPython got adopted, IMHO, because of the hype around deep learning.
- new4thaccount 7y agoPython was already in the top 5 well before the whole AI craze and before pandas was out. Python has a huge amount of introductory learning material that assumes it is your first language, while most FP languages (Ex: Clojure, Haskell, F#, Scala, OCaml) really struggle in this area. I really like FP, but there is a bit of a steep plateau when learning. If you look at some of the questions people ask in the Python stack exchange, you get the impression that millions are learning it as the defacto first language (I was one of those nearly a decade ago). I try to find similar paths to FP and everything from the tooling to lack of thorough introductory material keeps killing it for me. Another issue is that from a pedagogy perspective all the "building blocks" in FP are different to what many people already know. If you're used to the imperative/OO paradigm you can move between languages by just learning the syntax to (lists, dictionaries, while and for loops, branching, array access, file IO, and classes). When learning FP you have to learn similar, but different concepts (pattern matching, monads, currying, discriminated unions...etc). The beginner books that do exist (ex: learn you a Haskell) are nice, but I've talked to many (myself included) that when they finish say "I still have no clue how to program in Haskell". To give another example, I spent two weeks reading a Python book on building text games and when I was finished I was like "OMG I can do stuff". That book covered how all the main data structures could be used with short and fun programs. It also included reading text files, string operations, pickling data, classes, modules..use of the included IDLE IDE. It was great.
- iLemming 7y ago> Python has a huge amount of introductory learning material that assumes it is your first language, while most FP languages (Ex: Clojure, Haskell, F#, Scala, OCaml) really struggle in this area I don't know how long ago have you tried Clojure, but it is a lot easier to start with than Haskell or Scala. There are now more than a dozen of books available (for the beginner and for the advanced levels). Clojure is much better than Python - it has extremely nice, consistent standard library; It has "true" REPL - with it you can evaluate almost any chunk of your code with no preliminary ritual, even much praised Jupyter doesn't feel as nice; Clojure not statically typed but it has Spec, which is totally awesome - the way how you can derive property based tests is almost mind-blowing; Clojure's stability is almost legendary; It makes concurrency simple; It makes dealing with dependencies less painful; It can seamlessly run on both: front-end and back-end, having live-updates in your browser and REPL connected to it feels like magic. Honestly, transforming data using Clojure is a pure joy.
- bsaul 7y agoI wonder how come people working in PL research aren’t more interested in concurrency. Typeclass, monads, etcs are great but they still haven’t reach the point were everyday people could expect to write proved safe program ( unless the code base is extremely small and you’re using special software such as Coq), and while they make programs more concise and expressives, i think concurrency remains the elephant in the room. Rust is the first PL i’ve heard in a long time that tries to actually do something in that area since erlang ( that opted for strict message passing and let it crash philosophy, but gave you the tool to deal with that approach). Is it because it’s too « down to earth » for PL purist, or is it simply because they don’t have the mathematical or logical tools to deal with the problem ?
- riffraff 7y agoOz and AliceML had a lot of work in concurrency, and AFAIR are both younger than Erlang. Also, maybe not very original but Go seems to have put concurrency up front as one of its selling points
- tsss 7y agoPony also offers some nice ideas about concurrent programming as well as Occam.
- ernst_klim 7y agoOCaml concurrency story is great, there are Lwt [1] and Async [2] for that. Multicore is slowly incoming as well, bits are landing in mainline. [1] https://ocsigen.org/lwt/4.1.0/manual/manual https://ocsigen.org/lwt/4.1.0/manual/manual [2] https://opensource.janestreet.com/async/ https://opensource.janestreet.com/async/
- amelius 7y agoThe problem is that engineering an efficient concurrent garbage collected runtime environment is hard. It may even be harder than writing the compiler itself, especially if you rely on llvm for the back end.
- fulafel 7y agoQuite a lot of things have been tried since Erlang (1986). Concurrency has been a fairly well funded sector of compiler and PL research to the point of starving other arguably more important areas. Wp has a list at https://en.m.wikipedia.org/wiki/List_of_concurrent_and_parallel_programming_languages https://en.m.wikipedia.org/wiki/List_of_concurrent_and_paral... Futhark is one of the more interesting recent parallel languages IMO since GPU languages were in such a lull for a while. Too bad everyone is stuck with emitting opencl or going vendor specific though.