News for hackers. Stuff that matters.
Re:Three Months of Go, from a Haskeller’s perspective (2016) by crimsonalucard on Sunday March 19, 2017 @12:38PM (#13908086)
Haskell is actually less expressive. It is a functional abstraction on top of what is essentially a procedural machine and with all abstractions placed on top of lower layers you can only lose functionality as you go up rather than gain. You could say assembly language is the most expressive language out there.

The great thing about Haskell and other functional programming languages is that the functional style forces the program to be created in a form that is modular and elegant. Programs become modular and composable and re-composable in the functional world because the programmer has No Choice but to build his programs in an elegant way. It's hard to explain this to a typical programmer who hasn't dived deep into functional programming but code reuse, modularity and elegance are significantly higher in functional programming languages than in procedural.

This elegance, beauty and forced organization comes at a high cost though. And the cost is thinking in a way that is outside the normal paradigm of what humans are use to. I know a lot of haskellers think that humans can be taught to think in both ways equally, I disagree with them and believe that it is far Easier for a human to think about an algorithm procedurally than it is for him to think about it functionally.

If you have several tasks to execute, what is your first thought on how to plan out those tasks? A task list (aka list of functions) or a series of composed tasks placed in a single sentence (aka expression)? The answer is obvious: humans think about the list first because procedural programming comes more naturally.

This I believe is the main reason why Haskell or lisps haven't taken over the programming world. Functional programming is just HARDER. It takes me 10 times longer to hack out a simple program in haskell than it does in python because haskell doesn't allow you to 'hack' together a program. In haskell the application has to be an elegant diamond or the thing won't even compile! Python allows me to hack something together quickly which is both a good and a bad thing because as we all know hacking together software is quick but easily leads to unmaintainable software.

Re:Three Months of Go, from a Haskeller’s perspective (2016) by platz on Sunday March 19, 2017 @01:11PM (#13908305)
> In haskell the application has to be an elegant diamond or the thing won't even compile!

Nonsense - You only have to make things as hard/elegant as you want them to be (and fore sure, some people do play that game for better/worse).

But, Haskell will happily allow you throw everything in to IO; you can side-step creating a perfect model and just hack together a list of imperative IO statements.

(unless you're referring to the difference between a dynlang and a static lang; that's a difference of another category altogether)

Re:Three Months of Go, from a Haskeller’s perspective (2016) by pekk on Sunday March 19, 2017 @03:22PM (#13909076)
If you are going to "throw everything in IO" then what advantage does Haskell have?
Re:Three Months of Go, from a Haskeller’s perspective (2016) by tel on Sunday March 19, 2017 @04:31PM (#13909442)
Even "just IO" in Haskell enjoys some very nice typing properties and is often easier to write and ensure proper operation than similar "just IO" programs in other languages.

It's actually super pleasant!

Re:Three Months of Go, from a Haskeller’s perspective (2016) by swift on Sunday March 19, 2017 @03:56PM (#13909273)
You can refactor it later, of course.

It's even possible to opt out of static type checking if you want.

GHCi also provides a REPL that makes exploratory programming easy.

Re:Three Months of Go, from a Haskeller’s perspective (2016) by platz on Sunday March 19, 2017 @03:44PM (#13909202)
yes, there is a difference between "'hack' together a program" and doing proper domain modeling.

However, neither should prevent the other. (i.e. "you can do X" should not be confused with "always do X"). Haskell allows you to choose.

Indeed, proper domain modeling is preferred.. but it's nice to have to ability to make that choice yourself based on your own constraints.

Additionally, Haskell makes it very easy/pleasant to refactor from the former to the latter. (On that note, imho the best models (in business) are arrived at iteratively rather than big-design-up-front)

Re:Three Months of Go, from a Haskeller’s perspective (2016) by rs86 on Monday March 20, 2017 @12:04AM (#13911592)
Lazyness, generic programming, algebraic datatypes, inferred typing
Re:Three Months of Go, from a Haskeller’s perspective (2016) by prance on Monday March 20, 2017 @04:17AM (#13912520)
> Haskell is actually less expressive. It is a functional abstraction on top of what is essentially a procedural machine and with all abstractions placed on top of lower layers you can only lose functionality as you go up rather than gain. You could say assembly language is the most expressive language out there.

That is not what is usually meant by "expressiveness" of a language. You seem to be talking about types of languages (as in the Chomsky hierarchy), by implying that there are problems you can solve in assembler but not in Haskell. That is not the case, as both are Turing-complete (Type-0).

In contrast, "expressiveness" usually refers to the "ease" (one may substitute conciseness in most cases) with which higher level concepts (abstractions) are expressible in the language, and here Haskell clearly wins against assembler, and many other popular languages.

Re:Three Months of Go, from a Haskeller’s perspective (2016) by crimsonalucard on Wednesday March 29, 2017 @09:59AM (#13986240)
The set of all possible assembly instructions is bigger than the set of all possible assembly instructions that haskell can compile to. Therefore haskell is less expressive than assembly language. That is what I mean by expressive.
Re:Three Months of Go, from a Haskeller’s perspective (2016) by prance on Friday March 31, 2017 @11:43AM (#14004928)
>The set of all possible assembly instructions is bigger than the set of all possible assembly instructions that haskell can compile to.

No it's not. The Haskell compiler is free to use whatever assembly instructions that it sees fit to compile the Haskell program.

Maybe you mean that effectively, the set of assembly programs (i.e. sequences of assembly instructions) which existing Haskell compilers happen to produce is limited. This is true. But it is also true that you can find an equivalent Haskell program for every possible assembly program, where equivalent means they exhibit the same behavior with respect to inputs and outputs. This is because both are Turing equivalent.

Now, it's also true that the way two equivalent programs get to their results may differ. For example, the assembly program might be faster. However, these are non-functional properties of the programs. And you were talking explicitly about functionality, so this point doesn't count towards your argument.

Re:Three Months of Go, from a Haskeller’s perspective (2016) by crimsonalucard on Friday March 31, 2017 @03:42PM (#14007409)
My mistake, I shouldn't have used the word "functionality" so I concede. And yes, I meant sets of assembly instructions, thanks for the correction.

But this is the basic idea I was trying to convey: that you lose "expressiveness" as you get higher and higher in levels of abstraction.

Re:Three Months of Go, from a Haskeller’s perspective (2016) by asdfasdf on Thursday April 06, 2017 @06:51AM (#14049427)
you are mistaking the meaning of expressiveness I'll provide a short example in assembler vs haskell expressive power. I'll use hello world as an example. This is considers an amd64 compatible processor, because I have to know the names of the registers.

```asm section .data str: db 'Hello world!', 0Ah str_len: equ $ - str

section .text global _start

_start: mov eax, 4 mov ebx, 1 mov ecx, str mov edx, str_len int 80h mov eax, 1 mov ebx, 0 int 80h ```

In Haskell I don't have to consider any processor.

```hs main = putStr "Hello World" ```

expressiveness is about how much code you need for a certain behavior. It's not about how many (possible fucked up) source files my compiler accepts.

Re:Three Months of Go, from a Haskeller’s perspective (2016) by jaegerpicker on Monday March 20, 2017 @12:19PM (#13915378)
I don't believe this is true for Haskell but I'm not a great Haskell dev. I do know Ocaml (mostly F# actually but it's super close) and this isn't at all true for OCaml which has a ton in common with Haskell. In OCaml I make lists of functions as pipe based expressions, where each step in the pipeline is a function. It's incredibly easy to reason about and matches the lists of functions view of development extraordinarily well. I know Elm (a simplified version of Haskell) supports pipe based programming also. Functional languages haven't taken over because OO and Java are still the primary way of teaching beginners to code. Very few beginners start with functional programming.
Re:Three Months of Go, from a Haskeller’s perspective (2016) by crimsonalucard on Monday March 20, 2017 @04:40PM (#13917472)
function composition sort of emulates a list of procedures but it's not really the same thing. There's restrictions on function composition that aren't intuitive.

A typical task list has tons of side effects, which is not the case with your "pipe lines."

Re:Three Months of Go, from a Haskeller’s perspective (2016) by ngrilly on Sunday March 19, 2017 @04:10PM (#13909334)
I don't understand the downvote. The main argument looks valid:

> If you have several tasks to execute, what is your first thought on how to plan out those tasks? A task list (aka list of functions) or a series of composed tasks placed in a single sentence (aka expression)? The answer is obvious: humans think about the list first because procedural programming comes more naturally. This I believe is the main reason why Haskell or lisps haven't taken over the programming world.

Re:Three Months of Go, from a Haskeller’s perspective (2016) by willtim on Sunday March 19, 2017 @06:03PM (#13909941)
It's overly simplistic. For example, Haskell's do notation allows asynchronous programming in a linear "task list" (to use your phrase). Yet most popular imperative programming languages do not; one must instead use callbacks.

As to whether programming with expressions is fundamentally harder, I'm not so sure. Since Fortran, most languages have supported arithmetic expressions over primitive numeric types, since they are certainly not easier with an imperative approach (MOV, MOV, ADD, PUSH). Haskell allows one to easily take this further using arbitrary objects and algebras, for example, expressions with drawing primitives, parsing grammars, financial contracts etc. With a small amount of syntactic sugar, you can even make expressions that look exactly like imperative programming (Haskell's do notation).

Re:Three Months of Go, from a Haskeller’s perspective (2016) by willtim on Monday March 20, 2017 @01:57AM (#13912066)
Forgot to mention that I didn't downvote either, despite disagreeing with much of the post.
Re:Three Months of Go, from a Haskeller’s perspective (2016) by platz on Sunday March 19, 2017 @04:26PM (#13909421)
I'm not the downvoter, but I still don't understand the assertion why Haskell doesn't allow the "task list".

There is nothing preventing using these "task lists" (e.g. lists/steps/procedures) in Haskell. In fact, "do notation", a core language feature every beginner learns, features it.

Re:Three Months of Go, from a Haskeller’s perspective (2016) by crimsonalucard on Sunday March 19, 2017 @07:16PM (#13910386)
You are right, but no beginner truly understands do notation. It's just magic to them. Do notation is an abstraction on top of monads which is an incredibly hard to understand abstraction on top of functional programming.

Functional programming in essence does not allow procedures, but with special incredibly complex abstractions you can simulate procedures. If you program using said abstractions I would argue that it makes functional programming even Harder to understand.

Re:Three Months of Go, from a Haskeller’s perspective (2016) by mathw on Monday March 20, 2017 @03:21AM (#13912372)
I never found monads particularly difficult.

I still don't understand what the problem is with them.

It's just a box with some "stuff" in, a function that makes a new box with a thing inside, and a function that takes a box and a value and gives you a new box with some different stuff inside.

The hardest part for me was accepting that I can't look inside the box and don't actually need to.

I do get that there are a lot of people who'll look at monads and want to know why the heck they should bother when any "decent" or "reasonable" language just lets all their functions crap all over the filesystem whenever they like.

Re:Three Months of Go, from a Haskeller’s perspective (2016) by platz on Sunday March 19, 2017 @07:35PM (#13910508)
Look, I'm not saying Haskell is easy to learn, it's one of the steepest learning curves I know of in programming.

But I don't think do notation is what trips up beginners (not sure if this discussion is about beginners per se). It is explained by simple mechanical plug-and-chug transformations that I think beginners understand, but am willing to hear if there is evidence otherwise.. I just think it's the other things that will eventually trip them up (I was only responding to specific claims made earlier). Also, on the point of resting on abstractions being a problem, I don't find compelling, because I'm also sure that Python beginners don't understand what "class MyStuff(object):" is really doing, but if the abstraction isn't leaky try don't need to know right away, and they can delve later.

Re:Three Months of Go, from a Haskeller’s perspective (2016) by ScottBurson on Sunday March 19, 2017 @04:46PM (#13909532)
I didn't downvote either, but the first paragraph seems to me definitely wrong. The rest of the post makes an argument that I don't necessarily agree with, but I think is interesting and deserving of discussion.