420 karma · joined Feb 20, 2009 (17y ago) · 99 submissions
comment 10y ago · link · parent
For what it's worth, this bug was an outlier. The pitfalls of unsafePerformIO are relatively well-known.
For contrast, there a bug in PHP's opcode cache that causes memory corruption in our setup. The best we've managed to do to deal with that by patching PHP to bump the refcount of some object to a billion. The failure condition is sufficiently obscure that it took us multiple man-months to figure that much out.
comment 10y ago · link · parent
If I can get this working, my source code will just be a bind mount that's accessable on both sides of the barrier.
The last major hitch I need to sort out is that our MySQL configuration is massively slower when run inside a Docker container. I haven't figured out why yet.
comment 10y ago · link · parent
The general high-level approach is that your business logic functions run in some monad, constrained by the set of capabilities it requires. Each capability is represented as a typeclass.
Your type signatures say that your business actions work in every monad that supports those capabilities, so the type checker rejects any code that tries to use "unblessed" side effects.
comment 10y ago · link · parent
All tests are thus 100% reliable and parallelizable.
This capability of isolating and controlling side effects makes Haskell very uniquely well-suited to applications that need to withstand a lot of maintenance by a lot of people for a very long time.
comment 10y ago · link · parent
I don't think it's fun to ship bugs to customers.
I think it's much more fun to have a pervasive, mandatory proof engine that shows that I don't create these bugs in my software. (since it's mandatory, I can also help my teammates use my code correctly even though they don't understand how it works!)
I make better progress when I'm not creating preventable bugs. My customers have more fun too.
> This is blown out of reasonable proportion by static type advocates. In a dynamic system, type is de facto a few bits of value in an object. So the above situation is just another value that is wrong.
It's wrong in a way that's totally preventable ahead of time. I'd rather take the proof engine and never suffer this class of bug. It certainly doesn't catch every bug, but I'll take what I can get.
comment 10y ago · link · parent
I intended to react to the comment "But when I try to dip my toe back into the Haskell community, a wave of despair washes over me. There's just too much. Haskell is changing too fast."
I think this is true. There are too many ways to do everything in Haskell and they're changing too often. If you don't get very specific guidance, you're going to be totally paralyzed with indecision. I have good evidence that you can do very well by confining the solution space.
comment 10y ago · link · parent
At the company I work at, we use Haskell for HTTP services. The software stack we've grown is extremely opinionated about how to do things. We provide just one way to do things like report errors, run queries, do work asynchronously, and so forth.
We get people up and running with about the same amount of effort as we spend getting people going on our PHP, and I think a big part of the reason why is because we're able to constrain the education effort to the slice of Haskell that we want them to read and write.
For instance, we accept the fact that we have new teammates who haven't yet truly understood what "do" blocks are all about. These people are nevertheless able to write perfectly serviceable, production-ready code. They've learned that they can chain imperative actions together in a particular way, and that's enough for awhile. Deep understanding comes later.
comment 11y ago · link · parent
Wouldn't it be nice if you could just obstruct such patterns within the first millisecond of their first interaction with the compiler?
comment 11y ago · link · parent
This property continues to hold, even as the application and the tests are modified by developers who do not even fully know what sort of effects they should otherwise be concerned with.
For instance, most programming platforms give you pretty ready access to a pseudo-random number generator. This is great until some well-intentioned new hire checks in code someplace that uses it to instrument something 1 out of 1000 runs.
We can't have this problem in Haskell and we don't have to spend any ongoing code review hours on it. It's gone.
comment 11y ago · link · parent
The only advice I can offer is that the documentation actually is correct and pretty complete, but there's nevertheless something about its organization that makes it difficult to find what you're after.
In particular, start by reading this page carefully: http://ocsigen.org/js_of_ocaml/2.5/manual/library
It explains everything at a high level.
comment 11y ago · link · parent
OCaml syntax is super idiosyncratic and doesn't resemble anything, but, once you retrain your eyes, the underlying semantics are terrific.
js_of_ocaml imposes very minimal code overhead (6k-ish). Sourcemaps work great, and OCaml values are mapped into JS in a very straightforward way. You can read them in a JS debugger.
Ocsigen's lwt library is also the best "callback hell" solution I've found.
comment 11y ago · link · parent
It's worth noting, however, that I've had very, very few problems with the semantic properties of the language. I think the slog is worth it for that reason.
comment 11y ago · link · parent
The main thing that bothers me is that the default behaviour is too permissive.
let a = [1,2,3,4,5];
let [b] = a; // ok. b receives 1
The equivalent Python will fail because there are "too many values to unpack."comment 11y ago · link · parent
At IMVU, we built up a bit of scaffolding along these lines: https://gist.github.com/andyfriesen/43d886ce60927c69b3d1
The basic premise is that all our business actions can either be run "for real" through Yesod, or within a State-based framework that's part of our standard testing scaffold.
The end result is that it's trivial to write tests that arrange for the database, clock, sockets, and so forth to be in precisely the state we want them to be for the test, and to sense everything afterward.
Running these tests as pure State actions has additional benefits:
Since State operates by making successive state copies for each "mutation", test fixtures are easily effected by performing some actions and saving the produced state. Individual tests can start from this state as many times as desired. The state is immutable, so test interference is impossible.
Additionally, tests run without access to IO. This means that the compiler rejects any test which could forseeably intermittently fail.
comment 11y ago · link · parent
If you're doing audio mixing, for instance, you probably have a thread that has to respond with samples within 1ms. Missing the window means catastrophic audio glitches. (it sounds terrible)
It's a mistake to write this in Ruby and expect the profiler to tell you something you don't already know.
comment 11y ago · link · parent
This nets us tests that are 100% reliable. The compiler rejects all code that can introduce external inputs.