News for hackers. Stuff that matters.
Re:OCaml for the Masses (2011) by weberc2 on Monday November 26, 2018 @09:13AM (#18533446)
I agree with the points in your post and I also want a mainstream typed FP (something with a clear happy path so I don’t need to guess about what prelude or string types or standard library or etc to use). The biggest impediment I see is that these language communities are more concerned about the abstract mathematical properties of the language and things like tooling get neglected.

I would love to see a typed FP equivalent to Go—everything is super simple/small learning curve (I should be able to meaningfully contribute to a project after a day or so), the standard library is decent, package management just works, no guessing about what test lib to use, everything compiles to a single static binary by default (dead simple deployments), no-fuss documentation generation, great concurrency/parallelism story, straightforward profiling and optimizations (e.g., if my program is slow because I’m allocating too much in the hot path I can trivially preallocate), etc. These are the things that matter for real world projects—mathematically elegant type systems really are just gravy, which is why Go has been able to be so successful in spite of its flat-footed type system.^1

^1: if you go over to r/programming, no one can figure this out because everyone believes you can’t ship Software in a language without monads or generics, so Go’s popularity must be due to Google marketing.

Re:OCaml for the Masses (2011) by akavel on Monday November 26, 2018 @09:25AM (#18533528)
Personally, I see Elm as an interesting development in such a direction, i.e. humane FP language, with the author relentlessly striving for simplicity and ease of use kin my opinion, successfully). That said, it's currently limited to a web dev./"frontend" domain (JS replacement).
Re:OCaml for the Masses (2011) by vram22 on Monday November 26, 2018 @01:23PM (#18535552)
>Personally, I see Elm as an interesting development in such a direction, i.e. humane FP language, with the author relentlessly striving for simplicity

Red is another language that is or was striving for simplicity (or resisting the complexity that seems to be the norm in tech nowadays). In fact that was supposed to be one of its main goals. I felt sad when they went down the ICO route for funding, though.

Not sure how FP-ish Red is, though. Rebol, which Red is based on, is supposed to be homoiconic. I like Rebol and Red.

The size of the Rebol and Red interpeters (and Red is a compiler too) and the size of the Red EXEs are quite small, which is another plus. Much smaller than some other languages.

Re:OCaml for the Masses (2011) by vram22 on Monday November 26, 2018 @03:24PM (#18536474)
>or resisting the complexity

I should say, sometimes seemingly unnecessary complexity.

Re:OCaml for the Masses (2011) by _hardwaregeek on Monday November 26, 2018 @02:12PM (#18535956)
I'd say Rust is the closest thing. Cargo is fantastic, super ergonomic and with an excellent package ecosystem. Rust doesn't have the pretense of purity or immutability, but honestly, you can very easily write pure functional Rust (and it'll save you a lot of pain with lifetimes). Performance is excellent, of course.
Re:OCaml for the Masses (2011) by weberc2 on Monday November 26, 2018 @03:03PM (#18536319)
I agree that Rust is the exception--it has a fantastic tooling story, but it's actually the _language_ that holds it back for the sorts of applications I tend to write. The performance and even correctness benefits it affords me over Go are just too small for the cognitive burden it imposes (and yes much of the gap closes with time--I've been kicking the tires on and off for 5 years now--but every year the returns diminish and it's looking like the gap will remain significant). Hopefully I'll be proven wrong in the next few years.
Re:OCaml for the Masses (2011) by Ar-Curunir on Monday November 26, 2018 @06:55PM (#18537938)
Would you mind elaborating on the cognitive burden you find Rust imposes?

I find that after roughly two years of writing Rust, I can architect and re-architect big projects fairly clearly, and the type system gives me strong reassurances that refactors haven't screwed things up.

Not to mention the advantage of even simple things like enums, which most languages (including Go) tend to lack.

Re:OCaml for the Masses (2011) by weberc2 on Tuesday November 27, 2018 @01:10PM (#18544890)
> Would you mind elaborating on the cognitive burden you find Rust imposes?

Millions of little decisions with respect to which lifetimes to use, which types to use, which type of pointer to use, whether to pass by ref or by copy, and so on.

> I find that after roughly two years of writing Rust, I can architect and re-architect big projects fairly clearly, and the type system gives me strong reassurances that refactors haven't screwed things up.

> Not to mention the advantage of even simple things like enums, which most languages (including Go) tend to lack.

I don't doubt it. I think these are really cool properties of Rust. They just don't pay for the cognitive burden, since the applications I write aren't critical systems (I can afford _some_ unsafety, but I can't afford to slow my development process).

To put it differently, if I write in Go, I can quickly ship a feature with a high degree of confidence that it's overwhelmingly correct, and the few errors that do slip into production can be quickly fixed because I can iterate so quickly. If I write in Go, I will eventually ship a feature with a very high degree of confidence that it's overwhelmingly correct, but even if I find zero bugs in production, the time spent shipping the first iteration in Rust is much larger than the time it would spend me to ship _and_ iterate on bugfixes in Go. I'm sure the extent to which this is true shrinks as I get more experience with Rust, but there's a law of diminishing returns at play, and no indication that the gap will ever vanish entirely.

Re:OCaml for the Masses (2011) by Ar-Curunir on Wednesday November 28, 2018 @08:16PM (#18557325)
What kind of code have you been writing? For most Rust code that I write and read, I find almost no lifetime annotations are needed.
Re:OCaml for the Masses (2011) by christophilus on Monday November 26, 2018 @07:32PM (#18538193)
I'd be curious to hear about your edit -> recompile -> run experience with Rust. My typical dev process is edit -> auto-recompile in the background -> refresh the browser / whatever I need to do to see how my edits affected the thing I'm working on. Rust's compilation speed seems like a non-starter for me.
Re:OCaml for the Masses (2011) by Ar-Curunir on Monday November 26, 2018 @11:42PM (#18539438)
Depending on the project I'm working on, I do need a server class machine for running benchmarks, but that might not be the case for most projects (I work with heavy cryptographic things, so tests sometimes take a while to run).

However, for compilation errors, feedback is instant, because cargo check (which runs everything except codegen) is almost instantaneous. I've also set up neovim to give run it on every save (via a plugin), so I don't have to leave my editor for this. I know that VS Code and IntelliJ also do this.

Re:OCaml for the Masses (2011) by pjmlp on Tuesday November 27, 2018 @02:22AM (#18540239)
Try to write GUI applications without sprikling the code with RC<RefCell<>> everywhere, due to callbacks and access to widget fields.
Re:OCaml for the Masses (2011) by lolive on Monday November 26, 2018 @07:30PM (#18538182)
I have heard about Rust. But I wonder if you can do something that a OO programmer (like me :) would call "string subclasses" so you do not manipulate a generic type called string, but a meaningful subclass such as "FirstName" or "LastName", or "TownName".
Re:OCaml for the Masses (2011) by steveklabnik on Monday November 26, 2018 @07:41PM (#18538248)
You wouldn’t do it as a “subclass”, as Rust doesn’t have classes or inheritance.

You’d use the “new type pattern”, which is like a named 1-tuple:

  struct FirstName(String);
Re:OCaml for the Masses (2011) by lolive on Tuesday November 27, 2018 @09:07AM (#18542337)
is this type interchangeable with String?
Re:OCaml for the Masses (2011) by vram22 on Tuesday November 27, 2018 @05:32PM (#18547476)
I'm not the person you asked, but I don't think domain-specific user-defined types (whether defined as subclasses or subranges (see Pascal) of existing language types, or another method as Steve said), are supposed to be automatically interchangeable or equivalent to the existing type they are derived from (without a cast or conversion of some kind), otherwise it would defeat the purpose, which is better type or range checking.
Re:OCaml for the Masses (2011) by steveklabnik on Tuesday November 27, 2018 @09:35AM (#18542555)
Not exactly. That is, you can't pass it directly to a function that takes a String, but if we made the inner string public, we could extract it with two characters. If we don't want to make it public, we can write an accessor as well, etc.
Re:OCaml for the Masses (2011) by lolive on Tuesday November 27, 2018 @11:12AM (#18543541)
As far as i understand, Rust is strongly typed, has generics and no type erasure. I also suppose String is some kind of a primitive type. Could it be possible to make it parametrizable, so we can manipulate a String<FirstName> as a String, but the compiler will never confound it with (for example) String<LastName>.
Re:OCaml for the Masses (2011) by steveklabnik on Tuesday November 27, 2018 @11:55AM (#18543995)
String is a library type, not a primitive type.

You could write your own string parameterized in this way, but it would be incompatible with the standard library String and so you’d need the same conversion steps.

Re:OCaml for the Masses (2011) by lolive on Monday December 03, 2018 @06:34AM (#18587979)
What would happen if the Rust core team decided to parametrize String? Would it work with legacy code? (that creates something like String<?> and consume String<?>).
Re:OCaml for the Masses (2011) by steveklabnik on Monday December 03, 2018 @08:15AM (#18588495)
It cannot be done in a backwards compatible way with today’s language features.
Re:OCaml for the Masses (2011) by cix_pkez on Monday November 26, 2018 @05:19PM (#18537364)
Love Rust, but there's room for garbage collection over borrowchecking if we're talking about replacing scripting languages. It would be hard for a decent statically-typed FP language to be slower than Ruby, for example.
Re:OCaml for the Masses (2011) by twic on Monday November 26, 2018 @02:55PM (#18536256)
Rust is lovely - but you definitely do have to guess about what string types to use!
Re:OCaml for the Masses (2011) by mseri on Monday November 26, 2018 @03:16PM (#18536425)
I think that’s more of a problem (or at least used to be one) in Haskell. In Rust it mostly boils down to how much speed or ergonomics you want
Re:OCaml for the Masses (2011) by rwmj on Monday November 26, 2018 @10:01AM (#18533754)
This isn't really true for OCaml. I daily compile large OCaml programs which are linked to C programs, we run valgrind on them, they are fully integrated with GCC and autotools and so on, ship in tarballs to end users who can run ‘./configure && make’ etc. In case that all sounds very Unix-specific, I have also in the past cross-compiled OCaml programs on Linux and Windows and Mac OS X at the same time.
Re:OCaml for the Masses (2011) by weberc2 on Monday November 26, 2018 @10:58AM (#18534202)
I wouldn't consider a home-grown autotools/gcc/valgrind setup to be "simple", especially when it comes to dependency management (assuming you care that dependencies don't conflict and that your code links against the right version of the dependency and deterministic/reproducible builds and so on). If you can afford the personnel to manage all of that, then that's great, but for those of us who can't, it's nice to be able to run `go build` or `go test` with zero configuration.
Re:OCaml for the Masses (2011) by rwmj on Monday November 26, 2018 @12:30PM (#18535052)
Why would you think OCaml can't do that as well? opam lets you build from source with "zero configuration". We don't use it because we have invested heavily in autotools and want to integrate with many other programming languages, but the option is there.
Re:OCaml for the Masses (2011) by weberc2 on Monday November 26, 2018 @01:15PM (#18535496)
I'm a little hazy on the particulars because I never got terribly deep into OCaml and haven't tried it in a while, but IIRC, OPAM is a package manager (and according to https://opam.ocaml.org/doc/Packaging.html, it requires a configuration file). The most popular build system for OCaml is JBuild (or whatever it got renamed to) which also requires a configuration file (formatted as S-expressions to make things more confusing for newcomers) and I think that usually bottoms out in a Makefile to boot (or maybe it's the other way around, and OPAM packages usually call into Make which calls into JBuild?).

In any case, it's a far cry from `go build`.

Re:OCaml for the Masses (2011) by christophilus on Monday November 26, 2018 @10:48AM (#18534113)
Man, I agree 100%. I wonder if it would be possible to get this by compiling an Elm/SML-like language to Go?

[Edit: I'd add a few things to your feature list: really fast, OCaml-speed compilation, along with a utop-like REPL]

Re:OCaml for the Masses (2011) by weberc2 on Monday November 26, 2018 @11:11AM (#18534307)
+1 regarding your additions to my list! With respect to compiling an SML-like language to Go (I've thought about this a lot), it would probably get you a long way, but the performance would suffer because FP langs allocate like crazy and Go's GC is not optimized for lots of fine-grained allocations. And there would still be a long tail of things that didn't work quite right: stack traces would need to be modified to map to lines in your source program (instead of the emitted Go code), documentation generation and linking would need to be patched, dependency fetching would need to understand and distinguish between packages in $MYLANG and Go packages (so it invokes the $MYLANG->Go compiler appropriately), and so on. That said, it would certainly be a great proof of concept!
Re:OCaml for the Masses (2011) by vram22 on Monday November 26, 2018 @01:56PM (#18535825)
>Go's GC is not optimized for lots of fine-grained allocations

Why is it not? Hadn't heard of this point before. Is it because of catering to the most common use cases, which are not fine-grained, maybe?

Re:OCaml for the Masses (2011) by weberc2 on Monday November 26, 2018 @03:11PM (#18536386)
Go has value types and they're used pervasively. Where an OCaml or Python or Haskell list is O(n) allocations, a Go slice is 1 allocation (values are laid out side-by-side in memory). This allows Go to have a simple, concurrent GC with pause times on the order of 1us (compared to 10-100ms, as is common for compacting generational collectors) as well as great (CPU) cache properties (things are more likely to be collocated in memory, so you're more likely to have cache hits).
Re:OCaml for the Masses (2011) by vram22 on Monday November 26, 2018 @03:35PM (#18536561)
Got it, thanks. The Go team has been working on improving Go's performance, over time, I've read. One other such example I read about is that for compilation, where package A depends on B and B depends on C, the metadata for C is stored in the header of B, so when A is being compiled, it only needs to read B, not C - and there are other related optimizations on the compilation front, IIRC. I thought that was a good optimization.

I wish the EXE/binary sizes of Go programs were smaller, though I know they've done some work on that too. Coming from a C background originally, I was a bit surprised when I first saw that the size of a simple hello-world-style Go binary was ~1 MB (some years ago). Equivalent Free Pascal and D binaries are a lot smaller, IIRC, from what I tested at the time (~100 KB or less). Heck, the Red interpreter / compiler (and the Rebol interpreter before it) fit in ~1 MB. Don't mean to denigrate the efforts of the Go team at all (even apart from the fact that as a long-time Unix guy, Rob Pike, Ken Thompson, et al are among the people I look up to); I know language translation technology is a hard field, plus the scope of Go may be much more than that of Rebol / Red; just speaking from the POV of a user, hoping for smaller binary sizes.

Re:OCaml for the Masses (2011) by weberc2 on Monday November 26, 2018 @03:51PM (#18536690)
> Got it, thanks. The Go team has been working on improving Go's performance, over time, I've read. One other such example I read about is that for compilation, where package A depends on B and B depends on C, the metadata for C is stored in the header of B, so when A is being compiled, it only needs to read B, not C - and there are other related optimizations on the compilation front, IIRC. I thought that was a good optimization.

AFAICT that's a compiler optimization, not a runtime optimization. But yes, generally the Go team is working to improve performance.

> I wish the EXE/binary sizes of Go programs were smaller, though I know they've done some work on that too. Coming from a C background originally, I was a bit surprised when I first saw that the size of a simple hello-world-style Go binary was ~1 MB (some years ago). Equivalent Free Pascal and D binaries are a lot smaller, IIRC, from what I tested at the time (~100 KB or less). Heck, the Red interpreter / compiler (and the Rebol interpreter before it) fit in ~1 MB. Don't mean to denigrate the efforts of the Go team at all (even apart from the fact that as a long-time Unix guy, Rob Pike, Ken Thompson, et al are among the people I look up to); I know language translation technology is a hard field, plus the scope of Go may be much more than that of Rebol / Red; just speaking from the POV of a user, hoping for smaller binary sizes.

Go binaries contain _everything_, while C programs (usually) statically link against libc (glibc is on the order of 10mb by itself). Go's runtime is also quite a lot more complex than C's--it comes with a scheduler, a reflection system, and a garbage collector. These are one-time costs--the binary for a program 10 times the size of hello world is pretty much the same size as the hello world binary. If you really want, you can dynamically link a Go program, but I can't imagine a scenario where this is practical.

Re:OCaml for the Masses (2011) by vram22 on Tuesday November 27, 2018 @06:50AM (#18541519)
>AFAICT that's a compiler optimization, not a runtime optimization. But yes, generally the Go team is working to improve performance.

Right, it is a compile time one.

>Go binaries contain _everything_, while C programs (usually) statically link against libc (glibc is on the order of 10mb by itself).

Did you mean "dynamically" (for C) [1]? Also, I'm not too sure if Go links all dependencies statically by default, if that is what you implied above. IIRC I read somewhere recently that some things are linked statically, and some dynamically - I need to check that.

[1] I need to check it for C too, because things have changed since I last used C a lot.

>Go's runtime is also quite a lot more complex than C's--it comes with a scheduler, a reflection system, and a garbage collector. These are one-time costs--the binary for a program 10 times the size of hello world is pretty much the same size as the hello world binary.

Agreed on the points about the other stuff Go has that C does not, like a GC, reflection, etc. And that those are one-time costs. But they are still costs, and if you create lots of small binaries, that cost adds up. Disk space is cheap nowadays, but depending on the use case and your environment (e.g. small or embedded system, cost constraints if shipping many copies of a h/w + s/w product or appliance, etc., that cost might be significant. Whereas with some of those other languages that I mentioned above, those costs can be quite a bit less, times the number of copies of binary or appliance that you ship. That's all that I meant. That's not to say that we should not use Go, though, of course. As always, the overall picture and all factors need to be taken into account, e.g. the benefits of Go's language features vs. some of those others, team knowledge of the various language contenders, even availability of needed libraries, time to market, etc. etc.

Re:OCaml for the Masses (2011) by weberc2 on Tuesday November 27, 2018 @10:59AM (#18543382)
> Did you mean "dynamically" (for C) [1]?

Yeah, I did. Good catch.

> Also, I'm not too sure if Go links all dependencies statically by default, if that is what you implied above. IIRC I read somewhere recently that some things are linked statically, and some dynamically - I need to check that.

By default, Go does dynamically link to some things--it will prefer to use the system DNS resolver if one is available, for example. But you can disable this by setting `CGO_ENABLED=0` at compile time. If you do this, a Go program needs nothing more than a linux kernel (no system libraries or even libc) and whatever other files it requires (certificates, for SSL for example).

> I need to check it for C too, because things have changed since I last used C a lot.

I'm sure you can make statically-linked C programs which are smaller. For example, the musl libc implementation is quite small and designed for static linkage. But lots of libraries break (often in bizarre and hard-to-debug ways) if they don't link against glibc specifically, so it's not a panacea.

> But they are still costs, and if you create lots of small binaries, that cost adds up. Disk space is cheap nowadays, but depending on the use case and your environment (e.g. small or embedded system, cost constraints if shipping many copies of a h/w + s/w product or appliance, etc., that cost might be significant.

Agreed, but again, Go does allow for dynamic linkage in those cases so you can conserve disk space. There's no doubt that if you're golfing, C allows for smaller binaries than Go, but Go can meet 99.9% of real-world requirements when it comes to size (if you're at the extreme end of what Go can support, you've probably already ruled out Go for other reasons).

There are still many reasons to pick other languages besides Go--if you're working on a hard real-time system, if you're working with a team of people who all prefer a different language, if you're working in a domain (iOS app dev, for example) for which there are no good Go libraries, if you're willing to trade all else for extreme performance or extreme correctness, etc. But Go is actually a pretty good little language for most things that aren't at those extremes.

Re:OCaml for the Masses (2011) by vram22 on Tuesday November 27, 2018 @12:27PM (#18544387)
>By default, Go does dynamically link to some things--it will prefer to use the system DNS resolver if one is available, for example. But you can disable this by setting `CGO_ENABLED=0` at compile time. If you do this, a Go program needs nothing more than a linux kernel (no system libraries or even libc) and whatever other files it requires (certificates, for SSL for example).

Ah, sounds similar to what it says in the osso.nl link I posted below. Good to know.

>I'm sure you can make statically-linked C programs which are smaller. For example, the musl libc implementation is quite small and designed for static linkage. But lots of libraries break (often in bizarre and hard-to-debug ways) if they don't link against glibc specifically, so it's not a panacea.

Didn't know this, interesting. But actually, I didn't mean making statically-linked C programs smaller by using leaner libraries like musl. I just meant that for equivalent code, the resulting C binary (even when using the default libc) was smaller by a lot than the Go binary. And so were the Free Pascal and D binaries smaller than the Go binary, but they were both slightly larger than the C binary. But it was only an anecdotal observation based on writing a few small programs in C, Go, Free Pascal, and D, and comparing the resulting binary sizes. Not a thorough scientific study.

>Agreed, but again, Go does allow for dynamic linkage in those cases so you can conserve disk space.

Got it.

>>There's no doubt that if you're golfing, C allows for smaller binaries than Go, but Go can meet 99.9% of real-world requirements when it comes to size (if you're at the extreme end of what Go can support, you've probably already ruled out Go for other reasons).

It wasn't about golfing, it was about equivalent code in the two languages, and the relative sizes of the resulting binaries. But good last point (about 'other reasons').

>There are still many reasons to pick other languages besides Go--if you're working on a hard real-time system, if you're working with a team of people who all prefer a different language, if you're working in a domain (iOS app dev, for example) for which there are no good Go libraries, if you're willing to trade all else for extreme performance or extreme correctness, etc. But Go is actually a pretty good little language for most things that aren't at those extremes.

Agreed. In that sense it is somewhat like Python, which is sometimes described as "the second-best language for almost any domain", an interesting description that I read only somewhat recently. I wouldn't necessarily fully agree with that description, it is probably the best language or at least equally the best (with some other language) for certain areas. Similarly, there are probably areas where Go is, if not the best language, one of the best, for certain kinds of tasks, such as the command-line utilities, web and network server applications that it is often used for.

Re:OCaml for the Masses (2011) by vram22 on Tuesday November 27, 2018 @07:17AM (#18541678)
I googled briefly about dynamic vs. static linking of Go binaries, didn't find much useful info; will try more again later and post again here if I find anything. Will also do some experiments with compiling and linking and see if that gives the needed info.

Update: Found this page which seems to make sense:

https://www.osso.nl/blog/golang-statically-linked/

Re:OCaml for the Masses (2011) by pjmlp on Tuesday November 27, 2018 @02:29AM (#18540261)
Haskell can do value types allocations, not everything is a list.
Re:OCaml for the Masses (2011) by weberc2 on Tuesday November 27, 2018 @11:04AM (#18543438)
Unless 90% of Haskell allocations are value types on the stack, this is irrelevant pedantry.
Re:OCaml for the Masses (2011) by pjmlp on Tuesday November 27, 2018 @11:24AM (#18543656)
Do not optimize what isn't proven by an optimizer.

The features are there, 90% of the cases it doesn't matter for the typical use cases.

When it does matter, they are in reach to any savy Haskell developer.

Re:OCaml for the Masses (2011) by McWobbleston on Monday November 26, 2018 @05:26PM (#18537417)
F# touches on most of these points doesn't it?
Re:OCaml for the Masses (2011) by weberc2 on Monday November 26, 2018 @06:20PM (#18537748)
Last time I tried using it, it was unclear what build system to use and I had a hard time finding the "happy path" (what test library to use, how to set up my project file to include a test target, etc). It also seems to have this weird FP/OOP dichotomy where some things are methods on a class and others aren't and that affects how you call things and so on. I didn't get far enough to really be able to articulate my problem, but it seems quite complex (albeit much of the complexity probably exists to support interop with other .Net things). I think most of this could be addressed with documentation "How to do X in F#" (I'm sure someone has a writeup somewhere, but I couldn't find any such document around the time I tried it).
Re:OCaml for the Masses (2011) by McWobbleston on Tuesday November 27, 2018 @12:50AM (#18539793)
F# for fun and profit is an excellent resource
Re:OCaml for the Masses (2011) by weberc2 on Tuesday November 27, 2018 @10:40AM (#18543148)
Yeah, I remember trolling through those and I found them really useful and accessible; unfortunately I don't remember the details about why they didn't help me get over the hump (I'm sure if I stuck with it long enough I could have; I just have limited free time).
Re:OCaml for the Masses (2011) by vram22 on Wednesday November 28, 2018 @01:05PM (#18553936)
Seconded. It helped me clear up some FP concepts.
Re:OCaml for the Masses (2011) by rs86 on Monday November 26, 2018 @09:01PM (#18538683)
FP and OOP are orthogonal... You can have purely functional objects
Re:OCaml for the Masses (2011) by phyrex on Tuesday November 27, 2018 @03:18PM (#18546271)
I fail to see how this would work. An object is a combination of state and methods acting on the state, and purely functional meaning no state.
Re:OCaml for the Masses (2011) by gtycomb on Monday November 26, 2018 @09:57AM (#18533734)
> The biggest impediment I see is that these language communities are more concerned about the abstract mathematical properties of the language and things like tooling get neglected

Is it really so. I am only asking. A mathematical model allows deeper insight on structure (backed by hundreds of years of prior mathematical thought), and we then sugar it appropriately for users. Just like civil engineers who learn Strength of Materials etc mathematically before they design the bridges we drive over daily.

Tooling is one of my gripes also. There was a time decades ago when I couldn't go beyond compiling the simple hello world example. This has gotten much better after many years. Same with Haskell. Is this due to difficulties in getting the necessary financial support.

Re:OCaml for the Masses (2011) by weberc2 on Monday November 26, 2018 @10:42AM (#18534063)
I don’t know for sure, but I’ve never had a project fail for lack of monads or functional purity, but they’ve often failed because I couldn’t figure out the tooling quickly enough or there was some critical library missing or the documentation was shit or etc. And the economics of bridges and web apps aren’t comparable (I can’t redeploy a bridge in an hour and no one dies if one of my routes 500s when the user passes unexpected input).
Re:OCaml for the Masses (2011) by gtycomb on Monday November 26, 2018 @10:57AM (#18534195)
I feel the pain as I read your line. One great disaster in my career early on was my going into Haskell, and also Prolog, after frustration with Java (remember Java Beans etc?) in an enterprise project. Whereas Perl5 (this was in the biotech/genomics industry) and later Python did the real work. Still I cannot forget the impressive functional power while coding Ocaml.
Re:OCaml for the Masses (2011) by tikhonj on Monday November 26, 2018 @08:19PM (#18538481)
Projects fail because of bad code quality and architecture all the time. Monads and functional purity are simple tools that help tame and manage these issues.

I've seen a number of projects (often in JavaScript or Python) fail because of poor effect management—but if you don't have much experience with functional programming, you'd see it as yet another project failing because of bad development practices or lack of discipline.

With experience, it became pretty clear that what we needed were not iron-willed, self-disciplined developers but just better tools, of which effect management (ie monads) and functional programming are some of the most powerful.

Re:OCaml for the Masses (2011) by weberc2 on Tuesday November 27, 2018 @10:47AM (#18543223)
This seems like a reasonable hypothesis, but I don't perceive a clear signal that indicates that projects which use monads or pure FP are more successful than their counterparts. I think your hypothesis actually jives with mine and with my observation from the previous sentence--that monads and functional purity could help, but if the language neglects things like documentation, high quality libraries, and tooling to productionise and operationalize your code, then it's a non-starter.
Re:OCaml for the Masses (2011) by bunderbunder on Monday November 26, 2018 @10:20AM (#18533882)
At least in the case of Haskell, it is explicitly so. Haskell is a language that is meant to support programming language research, and you can see that manifest itself all up and down the design of its toolchain. It's a woefully under-appreciated factor in Haskell's famous learning curve.

OCaml less so, but the Jane Street monoculture means that, if it's not itchy for a trading firm, it's not gotta get scratched. Trading's an odd industry, tech-wise. There are aspects of the OCaml ecosystem that eliminate any of my own desire to use the language that I would have seen as neutral or even strongly positive when I worked at a trading firm. (At least during working hours.)

So, yeah, I do think that one of the big things that's missing from typed FP right now is a strong language that has similar semantics to an ML or (preferably) Haskell, but with a much more pragmatic focus. F# is really nice if .NET is an option for you, but I'd sure like to see something that is statically compiled and can produce C-friendly binaries, so that it can play nice with a wider variety of pre-existing codebases.

Re:OCaml for the Masses (2011) by pjmlp on Monday November 26, 2018 @10:30AM (#18533973)
In what concerns F#, there is Mono AOT, IL2CPP, eventually CoreRT and .NET Native might support F# native compilation as well.
Re:OCaml for the Masses (2011) by weberc2 on Monday November 26, 2018 @12:17PM (#18534913)
Out of curiosity, how do these compare to `go build`? I'm jaded by years of C and C++ which of course can statically link, but doing so in practice is tedious and error prone and still often not possible (e.g., many popular libraries can't be statically linked or it's infeasible to do so).
Re:OCaml for the Masses (2011) by pjmlp on Monday November 26, 2018 @12:44PM (#18535209)
Well, Xamarin applications for iOS use Mono AOT and Unity gameplay code gets compiled to native code for deployment on game consoles and iOS, optionally on Android.

As for compilation time, Go compilers use very basic optimizations as such they tend to compile faster, but hardly impressive for those that ever used TP, C++ Builder, Delphi, Modula-2 and similar languages.

Re:OCaml for the Masses (2011) by vram22 on Monday November 26, 2018 @02:02PM (#18535865)
Some Borland language tools' compilation speeds were insane. I remember them claiming 100s of KLOC per second compilation speed for their BCC++ and Delphi. Anecdotal experience bears it out. Even TP used to compile real fast. I read somewhere that early TP versions were written in tuned assembly.
Re:OCaml for the Masses (2011) by weberc2 on Monday November 26, 2018 @01:18PM (#18535526)
Sorry, I read your comment before my coffee and misread "native compilation" as "static compilation", so I'm conflating two distinct things.
Re:OCaml for the Masses (2011) by int_19h on Monday November 26, 2018 @03:33PM (#18536547)
> There are aspects of the OCaml ecosystem that eliminate any of my own desire to use the language that I would have seen as neutral or even strongly positive when I worked at a trading firm.

Can you give some examples? Really curious.

Re:OCaml for the Masses (2011) by bunderbunder on Monday November 26, 2018 @04:52PM (#18537162)
No support for multi-core parallelism. Strings are sequences of 8-bit characters, so crappy Unicode support. Weak support for non-Unix OSes.
Re:OCaml for the Masses (2011) by int_19h on Tuesday November 27, 2018 @12:58AM (#18539825)
I'm curious as to why you'd consider them advantages in that specific line of work. I can see lack of threads as an advantage in that it doesn't let you write multithreaded code with shared state, and forces into some kind of multiprocessing with message passing. But why would you prefer strings as 8-bit-clean, or weak support for non-Unix?
Re:OCaml for the Masses (2011) by bunderbunder on Tuesday November 27, 2018 @12:04PM (#18544103)
Multithreading is the stronger positive.

I'm guessing 8-bit strings is a minor positive, on the basis that you really don't need to deal with non-ASCII text in that kind of setting, and there's probably some performance benefit to not supporting it. Even if you stick to characters from 7-bit ASCII in your own data, if the strings are technically UTF-8 or UTF-16, then the fact that it's a variable-length encoding means that more string operations will involve costly branch instructions. And if UTF-32, your strings will be 4x as big as they need to be.

Not working on non-Unix is neutral. There's no benefit to it, but nothing was going to be running on Windows, anyway, so there'd have been no harm in it, either.

Re:OCaml for the Masses (2011) by mirekrusin on Monday November 26, 2018 @10:13AM (#18533825)
Crystal is very close to your list.
Re:OCaml for the Masses (2011) by christophilus on Monday November 26, 2018 @10:57AM (#18534182)
Crystal is interesting-- I've followed it at a distance-- but from what I understand, it's not really functional. Persistent data structures aren't a first-class citizen, and it seems to prefer blocks to lambdas. Also, (unrelated to the functional thing), the compiler isn't super fast. I think a really fast edit -> save -> compile -> reload time is one of the defining features of OCaml and Go.
Re:OCaml for the Masses (2011) by kbp on Monday November 26, 2018 @08:05PM (#18538397)
> it seems to prefer blocks to lambdas

What does this mean?

Re:OCaml for the Masses (2011) by christophilus on Tuesday November 27, 2018 @07:52AM (#18541895)
Crystal prefers these constructs [0] `foo.map {|x| x + 1}` where the stuff between the squiggles is called a "block". I come from Ruby, so maybe Crystal got this one right, but Ruby blocks, at least, are a more limited, less general-purpose approach to lambdas (by which I mean anonymous, first-class functions + closures) [1].

[0] https://crystal-lang.org/docs/syntax_and_semantics/blocks_an...

[1] https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...

Re:OCaml for the Masses (2011) by mirekrusin on Tuesday December 04, 2018 @06:03AM (#18598284)
Crystal has lambdas w/closures (called Proc) with `->{ 1 }` syntax [0]. Because of ruby-like syntax where `foo` is a call if `foo` is a function you need to do `foo.call` on those lambdas explicitly - so you can distinguish between passing them around as values `foo` and calling them `foo.call` or `foo.call(arg1, arg2, ...)`.

I've played with it a bit, haven't seen problems with compile times, they were actually pretty good.

The nice thing about Crystal is that it is extremely easy to use, terse code, easy macros, fast executables, algebraic types, good packaging story - in general very good ergonomy.

I hope it'll pick up one day.

[0] https://crystal-lang.org/docs/syntax_and_semantics/literals/...