Better HN
topnewbestaskshowjobs
Log inSign up

implicit

420 karma · joined Feb 20, 2009 (17y ago) · 99 submissions

Submissions

comment 10y ago · link · parent

I remember that. One of the crypto libraries was implemented by using unsafePerformIO to access a global handle to /dev/urandom rather than accepting another parameter.

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

Something I'm working on on the side is a way to run my sandbox in a Docker container inside a Linux desktop environment without any VM at all.

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

Sure. I've previously written up a short description of the approach here: http://andyfriesen.com/2015/06/17/testable-io-in-haskell.htm...

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

I write Haskell in production. One of the things we've built is a unit testing harness that denies application-level code any access to unrestricted IO. If a proper mock is not in place, type checking fails before the tests even begin to run.

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

> Anyway, therefore it follows that if we calcify and ossify data structures and types, we kill the progress, not to mention fun.

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

My experience is that typed functional programming is excellent for any application that can afford to run a garbage collector and needs to to be able to change continuously forever.

comment 10y ago · link · parent

I'm at IMVU. We're hiring! :) http://www.imvu.com/jobs/index/

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

This matches my experience.

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

How is "information flow control" different from a type system?

I've always considered the primary purpose of type systems to be restricting how data can flow through a program.

comment 11y ago · link · parent

Agreed.

More concerning is the bit where the author says that they have "1500 coders firefighting, just keeping that legacy monster alive."

I wonder if that has gotten any better since 2006.

comment 11y ago · link · parent

The problem is that developers do not know that they mustn't call datetime.now() and there will always be a developer who doesn't know this, either because people have a tough time knowing everything, or just because you're hiring new people.

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

You can, but in Haskell you can enlist the compiler's help to prove that everything is completely airtight.

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

Are you sure?

    > function isboxed() { return this instanceof Number; }
    > isboxed.call(5);
    true

comment 11y ago · link · parent

Right. I mean only to say that OCaml's superficial strangeness is regrettably offputting.

Talk of syntax is almost always history and religion, not science.

comment 11y ago · link · parent

I don't, unfortunately, nor do I have any source code I can share. :(

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/js_of_ocaml is presently my favourite AltJS stack.

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

This is very consistently my biggest problem with OCaml: it just doesn't follow conventions set in other ecosystems. I predict this is the sole reason it could never be "the next Java."

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

It's really valuable for mistakes to result in clear errors rather than confusing but "valid" programs.

Even worse:

    let [a, b, c, d] = [2];
a receives 2. b, c, and d receive undefined.

comment 11y ago · link · parent

Other languages have implemented this idea for decades now. It's a great feature.

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

Yesod provides a ton of functionality related to the larger problem of building a website with Haskell, but we're only using Haskell for JSON services.

All those extra bells and whistles are wasted on us. :)

comment 11y ago · link · parent

They are for now, but we've been whittling away at it.

We don't actually use any of Yesod's affordances except for its router. We're aiming to eventually split that off and run on bare Warp.

comment 11y ago · link · parent

> The testing frameworks out there are still fairly spartan from the developer experience standpoint.

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

I'm sure it depends on your programming style, but my experience is that you can almost always ignore laziness and focus on getting your work done.

comment 11y ago · link · parent

It's more about knowing your constraints ahead of time and working within them.

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

I worked with Chad to write BufferBuilder.

We conspired our use of C++ to exclude the C++ standard library. It's basically C with stricter pointer conversion rules.

comment 11y ago · link · parent

I use this technique to achieve bulletproof unit tests in Haskell HTTP services by providing two run functions: One that runs on IO and does all the real stuff, and another that twiddles some state and produces a pure result.

This nets us tests that are 100% reliable. The compiler rejects all code that can introduce external inputs.

comment 11y ago · link · parent

That's a shame!

"Gets the job done in just a few hundred lines of easily-explained code" is a terrific standard to meet.

"Magic abstract Haskell-fu" cannot improve such a program very much.

comment 11y ago · link · parent

Hack is also a substantially better language than PHP.

It, directly or indirectly, fixes a lot of horrible behaviour. PHP's absurd comparison operators, for instance, are safely usable once you drop them into a statically typed environment.

comment 11y ago · link · parent

Even as a pragma, a la "use strict"?

"use stricter"?

1234