Better HN
topnewbestaskshowjobs
Log inSign up

grumpyprole

4,485 karma · joined Jun 30, 2015 (11y ago) · 2,043 submissions

Submissions

comment 9y ago · link · parent

Great summary. I'd like to add the nix package manager to your list. It allows non-destructive updates, rollbacks, parallel installs of different app/library versions, development environments and much more.

comment 9y ago · link · parent

Sleep and hibernate have never broken for me on various ThinkPads, what hardware and distro are you using?

These days tlp gives power management on Linux a good set of defaults. Powertop tweaking should not be necessary as long as you use a distro that supports tlp.

comment 9y ago · link · parent

This is an impressive list of new features! Well done to all involved!

comment 9y ago · link · parent

Actually most of us do not have a choice, OOP languages, tools and frameworks are usually forced upon us. At least OOP languages are finally adopting functional features, but if one really wants to favour immutability and composition (modern OOP advice), one needs a functional-first language.

comment 9y ago · link · parent

Contrary to popular belief, OOP doesn't really encapsulate state, it just hides it. Encapsulated state should mean state that does not contribute to the global state space of the system. The danger of OOP is that one ends up with a combinatorial explosion of possible states your system may be in. This may be desired in some situations (e.g. simulations) but does not make a good general approach. Note that functional languages are also capable of building stateful systems this way, for example Erlang actors or composing finate-state automata.

comment 9y ago · link · parent

Well in this instance Functional programming languages allow one to easily embrace the relational paradigm and avoid all the complexity from an ORM.

Note that it has never been "proved" that OOP is more productive than anything else either.

comment 9y ago · link · parent

Ah overloaded field access, that explains the type signature. I implemented a very similar extensible record/variant system for a product definition language at Barclays. I hope we see a lot more structural typing in industry going forward, it is an especially good fit for typing queries.

comment 9y ago · link · parent

Are you able to comment on your implementation of row types?

You give the following type for a field selector:

> :t .foo

(a.foo::b) => (a) -> b

These give constraints with arbitrary types embedded in them. Most examples in the literature using qualified types, suggest something like the following type:

(r lacks foo) => { foo :: b | r } -> b

Where r is of kind row. The lacks constraint here is a very simple constraint and it is clear that this function takes a record, the disadvantage is that predicate lists can get very large. The old Haskell TREX extension built into Hugs worked this way.

It would be great to learn some background behind your choice. Thanks.

comment 9y ago · link · parent

I have programmed some Q professionally. It provides a lot of syntactic sugar, does not support operator precedence and there is a culture of avoiding whitespace. These can make it hard to read sometimes.

comment 9y ago · link · parent

What exactly do you mean by "build quality"? An aluminium case? Sure it gives a premium feel, but it's also heavy, dents and attenuates radio, so not really an obvious choice before Apple popularised it. Recently Apple have also standardised on glued-in batteries, which is not really representative of a premium "build quality" IMHO. Their trackpads have been very good, but I've always preferred the ThinkPad nipple.

> the screen, and the keyboard were superior to anything money could buy

You are showing your bias here. Thinkpad keyboards have always been more highly regarded than Apples. And not everyone wants a glossy glass-covered panel, even if it's a good one (i.e. not the MacBook Air).

comment 9y ago · link · parent

They look readable to me, certainly much more so than K or Q.

comment 9y ago · link · parent

This looks like a typed take on KDB/Q, something that is long overdue! The key to making this work is structural typing of rows (row polymorphism / extensible records). I'd be interested to see more details on how they tackled this.

comment 9y ago · link · parent

You are offering a one-sided argument with regard to strict versus lazy!

Lazy evaluation can make space usage difficult to reason about, but time complexity should be unchanged.

Lazy evaluation, by default, is also a huge benefit to Haskell. Strict evaluation is often a huge impediment to function reuse.

comment 9y ago · link · parent

Both Erlang anr Elixir, while safer than C/C++, are still far from ideal for any critical system, since they lack any kind of static typing.

comment 9y ago · link · parent

Thanks for the references. It looks like "gradual typing" is about trying to retrofit types to dynamic languages. That is certainly harder than starting with a statically-typed system and adding dynamic types (my preference). The latter clearly works, as evidenced by e.g. C# and Dart 2.

> With this restriction, you cannot assign an accurate static type to a function with a dynamically typed implementation, which means that you can't use dynamically typed libraries from inside statically typed code.

It depends what you mean by an accurate type. A accurate type for adapting your example would be to expose Variant -> Variant as Int -> Maybe Int, thus capturing the partiality. I concede that Int -> Maybe Int cannot be used in a function that expects Int -> Int, but that is how it should be! An untyped language cannot provide me with a function of Int -> Int.

comment 9y ago · link · parent

I did not mention GHC's Dynamic type. I mentioned GHC's deferred-type errors as an alternative technique to "gradual typing". I believe there were plans to implement a polymorphic version of Dynamic, but it obviously wasn't a high priority. Note that GHC does not require any special type-system extensions to support Dynamic.

comment 9y ago · link · parent

> Dart's choice of an unsound type system doesn't actually matter for those gradual typing problems we were talking about. I think you are getting too caught up in that point.

I was trying to show that "gradual typing" should be possible in any reasonable static type system, without resorting to unsoundness. I do concede that there is probably a definition of the term "gradual typing" out there that I am not strictly adhering to.

> Suppose I write down a dynamically typed implementation of the identity function and pass it to some typed code that expects an int->int function. When we pass the function to the typed side we will call fromVariant on it but the best we can do at first is check if the value we have is a function (and not an integer, etc).

If the best we can do is tag it as a function, then fromVariant would unpack it to a function with type Variant -> Variant, which represents all dynamically-typed functions. When we call this function, we indeed would need need to assert the outputs.

> One way to solve this problem is for fromVariant to return a wrapped version of the dynamic function that checks if the returned value is of the expected type

Agreed. Although the danger of this is that you have a bomb waiting to go off inside some unsuspecting piece of typed code. The alternative to to acknowledge that it is a partial function in the type, e.g. the Variant -> Variant function becomes Int -> Maybe Int, or similar. The point is that we are solving these problems using conventional static typing. You haven't yet convinced me that this doesn't work.

> You will either need to do a runtime check when the dynamic code writes to the array (which slows down the dynamic code) or you need to add runtime checks when the static code reads from the array (which makes it slower than it would be in a fully static language).

It sounds like you are concerned with performance and efficiency, that may indeed be an issue, but it's orthogonal to the type system. My own position is that if one wants performance, then don't write untyped code!

> If you are interested I can send you links to a couple of gradual typing papers. As munificent said, there is currently lots of ongoing research about this and we all wish it were as simple as you were suggesting it would be

Thanks for the offer, I am definitely interested. I suspect that the outstanding issues are around usability and efficiency. I stand by my original point that "gradual typing" should be possible in any sufficiently expressive static type system.

comment 9y ago · link · parent

I respectfully disagree. The "right membrane" around any untyped value is a Variant type. A static type system would then stop you making any assumptions without unpacking and asserting its type. If we don't want variants and just want to defer type errors until runtime, then this is possible too (GHC Haskell can do this).

comment 9y ago · link · parent

I assume that my downvoters do not believe this can be done in a conventional static type system. So I will try to explain further.

> The problem munificent was talking about is that for more complex types you cannot write that type checking predicate you want, which would check if a value belongs to the given type and return a variant-free version of the object.

The complexity of the type should not matter to a sound type system. Assume a "fromVariant" function that unpacks the variant, it has a type: forall a. Variant -> Maybe a. Maybe is either Nothing or Just a, depending on whether the variant does indeed contain what you expect it to contain.

> if you have a reference to an array of integers in the typed part of the code you need to protect against untyped parts of the code inserting non-integers inside the array.

This "protection" is exactly what static type systems do. "Untyped code" in the context of using a static type system, is code that works with variants. So we need to pack the array of integers into a variant, where they will be suitably tagged by the runtime. The "untyped code" is free to write whatever it wants into a variant, so we must unpack it with runtime checks. The static type system forces us to unpack and assert its contents, before we can assign a specific type to it.

> The only solution is to insert typechecks in the reads and/or writes to the array

I am not sure what you mean here. When the array is packed into a variant then it can indeed be modified into anything by "untyped" code. But it should always be tagged correctly, which is the responsibility of the runtime. It will need to be re-asserted when unpacked into a specific type.

> A similar problem happens with functions

Functions should be values like any other, so my points apply to them too.

The point I have been trying to make, is that a conventional static type system will already allow for "gradual typing". I cannot see a need to use an unsound type system in order to achieve this goal.

comment 9y ago · link · parent

I still do not understand why this cannot be done via a Variant type. Also it doesn't explain why Dart 2 has a similar feature.

comment 9y ago · link · parent

Of course variants would need to tag their payload, but this is what all dynamic languages need to do anyway. My point was that such dynamic behaviour can be done without resorting to an unsound "optional type system".

comment 9y ago · link · parent

> To keep the guarantees you expect inside your typed code, you have to figure out how to handle untyped data that flows into it.

This would be solved in a conventional static type system by forcing the user to eliminate the variant, and forcing the user to deal with the case that it has an unexpected value.

So I cannot see why even C# dynamic is necessary, except to perhaps save some thinking, but this isn't a good thing IMHO.

comment 9y ago · link · parent

In Haskell (and I believe Scala), one can use pragma hints to specify to the compiler when to specialise, if performance becomes a problem. So I don't see this as an argument against parametric polymorphism.

comment 9y ago · link · parent

As a far as I can tell, an "optional type system" is just an unsound type system with a marketing name. Any decent static type system would allow one to progressively increase the level of typing, the weakest form being using a Variant type to hold all other types. The advantage here is that any invariants/proofs that are captured in the system are not compromised by unsoundness.

comment 9y ago · link · parent

C++ is not "strongly typed" when compared to almost any other statically-typed language, e.g. Ada, OCaml, Haskell or Rust. This is a big part of why it is so insecure.

comment 9y ago · link · parent

Yes it reads like satire. MirageOS, having been written in OCaml, would have a better claim to being written with security in mind.

comment 9y ago · link · parent

Haskell is used for critical projects in production at Standard Chartered, Barclays and Facebook. There are also numerous startups. For both parallelism and concurrency, Haskell has a particularly good story. There's now even an O'Reilly book: "Parallel and Concurrent Programming in Haskell"

http://chimera.labs.oreilly.com/books/1230000000929/index.ht...

comment 9y ago · link · parent

I'm aware of TBB, but IMHO C++ is not the future of parallel and concurrent programming, or at least not the future I am hoping for.

comment 9y ago · link · parent

Linux support

comment 9y ago · link · parent

I use shortcuts for these, which I guess is what you must be doing.
1
545556
69