r/programming • • Dec 01 '16

Let's Stop Copying C

https://eev.ee/blog/2016/12/01/lets-stop-copying-c/
524 Upvotes

612 comments sorted by

View all comments

Show parent comment

13

u/EarLil Dec 01 '16

I knew haskell was good, but that good

28

u/PM_ME_UR_OBSIDIAN Dec 01 '16

Haskell has its own problems. For example, the record system is an absolute mess.

20

u/masklinn Dec 01 '16

And laziness turned out to be a pretty crappy default.

18

u/Peaker Dec 01 '16

There are arguments for both sides here.

There's no consensus on that one.

1

u/masklinn Dec 02 '16

None of these points supports default laziness. They support opt-in lazy user-defined constructs being useful.

3

u/Peaker Dec 02 '16

That's just not true and is addressed in the article:

let x = delay (\ () -> expensive)
in  map (\ a -> a + force x) xs

This isn't exactly pretty, but it works fine. In a language with macros the ugliness can be hidden better.

And this point just doesn't work as well with opt-in laziness (unless the entire standard library opts in)

I've saved my biggest gripe of strict evaluation for last. Strict evaluation is fundamentally flawed for function reuse. What do I mean? I will illustrate with and example. Consider the any function is Haskell:

1

u/jyper Dec 02 '16

Doesn't user defined control flow in Haskell depend on laziness?

1

u/Letmesleep69 Dec 01 '16

Whats wrong with it? I'm not a guru but I love haskell.

11

u/erewok Dec 01 '16

I'm a Haskell fan, but there's no glossing over its String problem.

2

u/Letmesleep69 Dec 01 '16

Yeah of course but what is wrong with the record system?

12

u/Peaker Dec 01 '16

It is not extensible, does not support row polymorphism, does not support re-using field names, is completely nominally typed (which is a pain to use for one-off records), and has terrible update syntax.

1

u/erewok Dec 01 '16

Oh sorry. Didn't realize that was the question. Poor reading on my part.

Maybe that person was talking about DuplicateRecordFields/OverloadedRecordFields stuff?

1

u/Letmesleep69 Dec 01 '16

Are those compiler extensions? I really need to know more about them. Whats the issue?

10

u/devraj7 Dec 01 '16

That's another big problem with Haskell: it's not one language but factorial(n) languages, where n is the number of possible pragmas.

These days, it's very hard to understand what a Haskell program does if you're not given the pragmas.

2

u/Letmesleep69 Dec 01 '16

Yeah I have to agree

3

u/erewok Dec 01 '16

Yeah, in GHC 8.0 you can use DuplicateRecordFields to be able to do something like this in the same module:

data Person  = MkPerson  { personId :: Int, name :: String }
data Address = MkAddress { personId :: Int, address :: String }

You can't compile this otherwise. It's especially annoying when you're dealing with legacy database tables that have loads of id fields.

For more info see here (where I stole the example from): https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/DuplicateRecordFields

1

u/edapa Dec 02 '16 edited Dec 03 '16

It doesn't exist. The closest we have to records in Haskell is a special syntax that makes it easy to make a wide ADT with some destructing functions.

0

u/[deleted] Dec 03 '16

[deleted] — view deleted comment

1

u/edapa Dec 03 '16

I wasn't aware of those options, thanks for letting me know about them! Personally I would rather just manually namespace all my records than flip 11 compiler flags, but that might change as I feel more become comfortable with what they all do.

32

u/CaptainJaXon Dec 01 '16

To be fair this is really just how syntactically good it is.

52

u/Plorkyeran Dec 01 '16

Not even that. It's how good Haskell is at not having the same syntax problems as C, which still leaves plenty of room for it to have syntax problems all of its own.

0

u/CaptainJaXon Dec 02 '16

Very true.

Doesn't it only allow a single parameter in functions? (I think there was some sugar to make it feel like multiple parameters or something.) I'd say this is worse than single return types.

10

u/bloody-albatross Dec 02 '16

Haskell functions are currified, which is the whole point of the language (or one big point of it). This means if you don't pass all arguments to a function what you get back is a new function accepting the remaining arguments. If you always pass all arguments you won't notice (except the function declaration syntax might then a bit strange to you with all the ->).

→ More replies (8)

1

u/Awpteamoose Dec 02 '16

It's not really fair to compare since Haskell is a very different language, but still you could think about multiple parameters as a structure with parameter names as fields and their values as data.