News for hackers. Stuff that matters.
Re:Haskell Problems for a New Decade by socialdemocrat on Friday January 24, 2020 @07:40AM (#22137563)
Despite the positive tone, what really struck me in this article was that they struggle with getting people to work on the compiler because it is too complex.

It just confirms my main criticism against advance statically typed languages: They are simply too complex.

It is why I have more faith in languages like Julia, because you can achieve a tremendous amounts of power, expressiveness and performance in a relatively simple language.

Dynamic typing gives you simplicity in the type system which is impossible to achieve with static type checking.

Long term this has profound implications. People can keep hacking on and expanding Julia because they can wrap their head around the language. You don't need to be Einstein to grok it.

I think you may also see Clojure overtake Scala for the same reason. The simplicity of Clojure may in the long run overtake Scala although Scala benefits a lot from similarity to Java at a superficial level.

Re:Haskell Problems for a New Decade by cinnamonheart on Friday January 24, 2020 @08:15AM (#22137846)
GHC was released in 1992 and has a large amount of language options it supports (over 100 now, I think) https://downloads.haskell.org/~ghc/latest/docs/html/users_gu...

I don't think the issue here is due to static typing, but due to the age and complexity of the language implementation. It's not trivial to figure out how all of those extensions interact with each other and your changes.

Re:Haskell Problems for a New Decade by kryptiskt on Friday January 24, 2020 @08:09AM (#22137805)
Compilers are wonderful to implement in a statically typed language with algebraic types and pattern matching, every pass can be a function transforming this intermediate language to that intermediate language until you emit the target code. The only thing that comes close in dynamically typed languages is the Nanopass framework used in Chez Scheme.

GHC development has a far lower bus factor now than when it just consisted of a handful of Simons. Compare to Clojure that has everything needing to go through one guy.

Julia is irrelevant, it is implemented in C++. All the real work is done in LLVM, which is a tremendously complex heap of C++, far more intimidating than GHC.

Re:Haskell Problems for a New Decade by socialdemocrat on Friday January 24, 2020 @08:12AM (#22137828)
Say Julia is all LLVM is like saying Haskell is all C code because that is what it outputs. That is simply a fantastically ignorant statement.

If LLVM was what mattered every dynamic language would have slapped it in the back. I am sorry but it just isn't that simple.

Re:Haskell Problems for a New Decade by kryptiskt on Friday January 24, 2020 @08:18AM (#22137867)
LLVM isn't all that matters, but Julia is built on 4 million lines of statically typed code, so maybe tone down your dynamic typing boosting a bit?
Re:Haskell Problems for a New Decade by socialdemocrat on Friday January 24, 2020 @08:36AM (#22138042)
How did you arrive at that number? Quite a lot of ways one could count that.

Anyway I have never claimed statically typed languages are irrelevant or not useful. My criticism is of advance statically typed languages.

I am quite okay with stuff like Go, C and maybe Ada and Swift. I am highly critical of C++. Far too complex language.

With Haskell my criticism is different. It seems like an elegant language you can learn a lot from. However I criticize the prevalent belief that Haskell is some sort of programming Nirvana. That somehow it is the ultimate language. I think Haskell is grossly overrated. It is too complex at a theoretical level for the average programmer.

When we also learn the implementation is complex.... well then I am not sure there is much hope for that language. Sure keep it in academia. People learn lots of useful stuff from it. But don't kid yourself into thinking world dominance is right around the corner.

Re:Haskell Problems for a New Decade by adrianN on Friday January 24, 2020 @07:44AM (#22137590)
Most compilers are very complex because generating performant code on modern hardware is hard. I don't think the complexity of the type system make much of a difference. Of course many new languages (like Julia) outsource a large part of the complexity to LLVM.
Re:Haskell Problems for a New Decade by socialdemocrat on Friday January 24, 2020 @08:01AM (#22137741)
I completely disagree. The experience with Julia points in a different direction.

Julia performance has has little to do with LLVM. If performance was that easy, you could just slap LLVM in the back of any dynamic language and poff by magic you have super performance.

Most dynamic languages that have reached decent performance have done so using trace-JIT compilers. These are complex and require a lot of man hours to make.

PyPy is a similar approach. It is hard problem to solve.

Yet Julia spending considerably less man hours than either project and with smaller and simpler code base has managed to run circles around these two projects in terms of performance.

Why? Because of smart language design. The pervasive multiple-dispatch design tailored towards JIT code generation has been key.

It allowed Julia to get great performance with a very simple method-JIT compiler. These are much easier to make than trace-JIT compilers.

But Julia is not alone. Go is another example of a language which kicks above its weight. It is a relatively simple implementation, yet has good performance and is enjoyable for most people to work with. Except those who really hate Go of course ;-)

My bottom line is: LANGUAGE DESIGN MATTERS!!! You you design a smart and simple language you can get away with simple implementations and still get good performance.

Sure LLVM is an important piece of the puzzle, but it serves no more important role than C does as the backend for Haskell IMHO.

Re:Haskell Problems for a New Decade by josch on Friday January 24, 2020 @08:51AM (#22138196)
"pervasive multiple-dispatch design tailored towards JIT code generation" sounds interesting. What is the relationship between the two?
Re:Haskell Problems for a New Decade by pansa on Friday January 24, 2020 @09:42AM (#22138656)
Julia is built around multiple dispatch - when making a call, the method to execute is chosen based on the run-time types of all of the arguments.

Once this choice has been made, Julia compiles the method, specialised for the exact types of the arguments.

So, the dispatch process and the JIT compiler are linked - both are reliant on type information every time a function is called.

This specialisation is the only way the Julia JIT uses runtime type information. Unlike JavaScript JITs, Julia does not track things like the types of local variables during execution (although it may do some static inference). Therefore type annotations for local variables can improve performance.

Re:Haskell Problems for a New Decade by StefanKarpinski on Friday January 24, 2020 @01:28PM (#22141044)
Mostly spot on, although it's very rare for local variables to require type annotation—type inference can easily figure it out for locals. Unless, of course, they are assigned from an untyped external source the compiler couldn't possibly know. You could, for example read something from a JSON source knowing that it should be an number, annotate it with `json["field"]::Float64` and then the compiler will emit code to check the type and throw an error unless the type is actually a Float64.
Re:Haskell Problems for a New Decade by pansa2 on Friday January 24, 2020 @06:23PM (#22143330)
Thanks for the reply - I wasn’t sure what Julia did in terms of type inference.

So, if not on local variables, where are explicit types necessary (other than function parameters)?

Re:Haskell Problems for a New Decade by ChrisRackauckas on Friday January 24, 2020 @06:45PM (#22143443)
You actually don't need explicit types in function parameters unless you're trying to control dispatching. Otherwise the compiler will auto-specialize on call. This blog post might be a better explanation on when it's necessary: https://www.stochasticlifestyle.com/type-dispatch-design-pos...
Re:Haskell Problems for a New Decade by socialdemocrat on Friday January 24, 2020 @12:37PM (#22140500)
pansa had a great answer so I will just add to that. Multiple dispatch is rare among programming languages and the few which do it only has it as an add-on.

I believe Julia is the only programming language where multiple dispatch is the way all function calls work. There are no exceptions. It is also the only language where it was used to aid a JIT compiler.

Once you dig into multiple dispatch and see how it affects everything from performance to Julia package design and how packages integrate with each other, you will just be blown away.

It is hard to convey how ingenious this solution is. Even the creators themselves have admitted they did not realize how clever this would end up being. They only realized after people started actively using Julia what a gold mine they had hit.

Re:Haskell Problems for a New Decade by the_af on Friday January 24, 2020 @08:39AM (#22138076)
> It just confirms my main criticism against advance statically typed languages: They are simply too complex.

But this is about the complexity of the compiler itself, not of general software written in Haskell. For any given language, most people use the language and don't hack the compiler. The compiler of any given language can be complex for plenty of reasons, many historical and unrelated to the programming language itself.

Re:Haskell Problems for a New Decade by noelwelsh on Friday January 24, 2020 @07:54AM (#22137677)
I don't think that the type systems are too complex. I think the issue is that approximately zero effort (perhaps even negative effort) has been put into the UX of the type system. We have tools for debugging run-time errors, such as debuggers and tracing. When you shift errors from run-time to compile-time, as type systems do, you need similar tools to debug and inspect type checking. Very little work has been done here.
Re:Haskell Problems for a New Decade by lonelappde on Saturday January 25, 2020 @08:14AM (#22146108)
Yes, this is missing from the article. There is some recent work (inspired by Elm raising the bar) with better UX for type errors. The technology tools exists but the labor is waiting to be done for every type in every program. Like documentation in general, it's the kind of work that requires a long slog across the code base, not inventing a new abstraction, so most Haskellers and most people don't bother to do it.
Re:Haskell Problems for a New Decade by socialdemocrat on Friday January 24, 2020 @08:14AM (#22137838)
That is why dynamic languages shine. Because types are objects like any other object you can use the same tools to deal with types as other code. It is one of the reasons why meta programming tends to be much harder to achieve in statically typed languages.
Re:Haskell Problems for a New Decade by noelwelsh on Friday January 24, 2020 @08:18AM (#22137865)
(What you call types are not what those who work in programming language theory call types. I disagree but this is an old and well worn argument and I'm not really interested in revisiting it.)
Re:Haskell Problems for a New Decade by socialdemocrat on Friday January 24, 2020 @08:28AM (#22137954)
There is your problem right there. These static type gurus live in an alternative universe in ivory towers far removed from where the rest of us simpleton programmers live.

Frankly I think it is an intellectual cargo cult. For all its sophistication these languages have not delivered that much. Look at language like Go, which these guys would laugh their butt off. Yet Go has produced usable software for a lot more people and made a lot more developers happy than Haskell ever could.

Coming years after Haskell Julia seems to be doing a lot more for science than Haskell has ever managed to achieve.

Re:Haskell Problems for a New Decade by noelwelsh on Friday January 24, 2020 @09:08AM (#22138349)
Well allow me to climb down from my ivory tower and offer the following in way of explanation:

Here is a reasonably good overview of safety (aka dynamic typing) vs types: https://papl.cs.brown.edu/2018/safety-soundness.html

Put another way, the standard programming language theory is that types are constraints that are uncovered (via type inference) and checked at compile-time. If type information is found at run-time these are known as tags. In Haskell, for example, you can declare a type like

   newtype SecretKey = Int
This creates a new type (SecretKey) that has a run-time representation that is just an Int. I.e. it has no additional information associated with it at run-time that you could use to distinguish it from an Int. At compile-time it is distinguished, however. You cannot use a SecretKey where an Int is expected and vice-versa. This could prevent you leaking secrets to other parts of your program, for example. This is one way you can reclaim performance in a statically typed language, vs dynamic types, without degenerating to passing around uninformative primitive types like Int (which introduces the possibility for errors).
Re:Haskell Problems for a New Decade by socialdemocrat on Friday January 24, 2020 @01:14PM (#22140923)
In my opinion you are actually reading this the wrong way. When I explain concepts such as boxing to people I will refer to type tags. But in that context I use the phrase to refer to how something is implemented.

How a type system is implemented is different from how it conceptually / semantically.

For instance in Julia types are conceptually objects you can pass around. However they will not always correspond to a type tag. Conceptually all objects in Julia have a type. However at runtime they may not. The JIT compiler could have gotten entirely rid of them.

When values are placed in a Julia array, individual elements will typically not have any type tags. However conceptually they still have a type.

To me type tags are just an implementation detail which both dynamic and static languages may use. However when you speak at a conceptual level you don't use that word. You don't say, "lets put this type tag into that object," you say "lets put that type into that object, bind to that variable or whatever."

The way I like to talk about static and dynamic languages is to say: In dynamic languages values have types, but not expressions / variables. In static languages expressions have types, not values.

That is of course a simplification, but IMHO simple and sensible way of making the distinction.

Re:Haskell Problems for a New Decade by socialdemocrat on Friday January 24, 2020 @02:12PM (#22141444)
> This creates a new type (SecretKey) that has a run-time representation that is just an Int. I.e. it has no additional information associated with it at run-time that you could use to distinguish it from an Int. At compile-time it is distinguished, however.

I can do exactly the same in Julia

   struct SecretKey
      value::Int
   end
After the JIT compiler is done, there is no difference between this and an `Int`. The type associated with the value only exists conceptually at runtime. A `SecretKey` value in Julia will in most methods look no different from an `Int`

> without degenerating to passing around uninformative primitive types like Int (which introduces the possibility for errors).

That would be the same in a strongly typed dynamic language. Except the error will of course be caught at runtime. But it is not like you can use the types in an illegal way.

Re:Haskell Problems for a New Decade by magicalhippo on Friday January 24, 2020 @07:02PM (#22143537)
Static typing makes the code self-documenting though. Just yesterday I was looking at this code I found, my very first time trying Node.js:

    stream.on('data', function(data) {
        processStreamData(data, (results) => {
            callback(results);
        });
    });
Ok, I get `data` from the stream, I guess it's some kind of array, but what can I do with it? What exactly is it's type? I need to extract Int32's from the stream and operate on those, how do I do that?

So, as you say, I was forced to trigger the code at runtime, by inserting some debugging code that logged the type to console.

So for a simpleminded guy like me, static typing helps me a lot because it makes it easier to reason about the code I'm reading.

Re:Haskell Problems for a New Decade by Random_ernest on Friday January 24, 2020 @07:55AM (#22137681)
> I think you may also see Clojure overtake Scala for the same reason. The simplicity of Clojure may in the long run overtake Scala although Scala benefits a lot from similarity to Java at a superficial level.

Correct me if I'm wrong, but didn't Scala overtake Clojure some years ago as the second most popular language on the JVM (second to Java ofc). From my point of view it rarely happens that these trends reverse.

Scala has the advantage that it allows OOP or Functional Programming, which Clojure does not.

But I do get your point about simplicity. I tried 3 times to learn functional programming by learning Haskell and it never clicked. Then I learned Clojure and who would have thought, functional programming is actually not as hard as Haskell makes it out to be.

Re:Haskell Problems for a New Decade by EdwardDiego on Friday January 24, 2020 @09:08AM (#22138348)
I work in a JVM shop and I don't see Clojure making much head way. Unlike say, Apache Spark, there's no killer app (datomic notwithstanding) that requires Clojure over Scala.

Scala also offer the advantage of static type checking, and a less alien syntax. Yeah, I know Clojure is just s-expressions, but all the brackets don't help its uptake.

Oh, and Clojure stack traces make Scala stack traces look positively brief and informative.

Re:Haskell Problems for a New Decade by lonelappde on Saturday January 25, 2020 @08:10AM (#22146092)
Scala's syntax for (generic) type declarations is super alien, and you can't avoid it because it's a big part of why you'd use Scala in the first place.
Re:Haskell Problems for a New Decade by socialdemocrat on Friday January 24, 2020 @08:19AM (#22137875)
I don't keep up with Scala and Clojure that much since I am not a JVM guy but I was always under the impression that Scala being older has ALWAYS had a lead on Clojure.

However the Scala hype seems to have died down years ago while you see more enthusiasm around Clojure.

> I tried 3 times to learn functional programming by learning Haskell and it never clicked.

LISP (Racket) and Julia helped me most with functional programming. For Haskell type of functional programming I think Swift actually helped me most.

But I find many of the same problems with Swift as with Haskell. Understanding type mistakes can be really hard. You struggle much longer with figuring out type problems than you would in a dynamic language.

I think advocates of these super statically typed languages completely overestimate the complexity the average human mind is capable of dealing with. Perhaps because the creators are super smart themselves ;-)

Re:Haskell Problems for a New Decade by Random_ernest on Friday January 24, 2020 @08:44AM (#22138111)
> I think advocates of these super statically typed languages completely overestimate the complexity the average human mind is capable of dealing with. Perhaps because the creators are super smart themselves ;-)

That is a really good point. From my personal pov languages that take to long to understand and take you >1 week to get productive are rarely useful since you won't be able to afford or train "normal" people to use it.

In my company we recently switched from Python + Numba to Python and Clojure. Since even though people never heard of functional programming or Clojure, they can get started on simple things within the first week.

Re:Haskell Problems for a New Decade by pjmlp on Friday January 24, 2020 @01:43PM (#22141187)
> Scala has the advantage that it allows OOP or Functional Programming, which Clojure does not.

Clojure certainly allows both, that is what protocols and multi-method dispatch are all about.

CLOS has Object in the name for a reason.

Re:Haskell Problems for a New Decade by hopia on Friday January 24, 2020 @09:53AM (#22138755)
Haskell's compiler is already big and fat, having a very wide range of features. I don't think Haskell's extensibility is a problem in terms of adoption at this point, the problems lie elsewhere.

Therefore, simplifying GHC development likely wouldn't attract any larger user base for the language.

> Dynamic typing gives you simplicity in the type system

Can you elaborate on this? Dynamically typed languages essentially have no type system (but yes even they do have types).

Re:Haskell Problems for a New Decade by socialdemocrat on Friday January 24, 2020 @03:08PM (#22141947)
> Therefore, simplifying GHC development likely wouldn't attract any larger user base for the language.

I can agree with that. What I meant was more that I see it as a sort of symptom of its complexity. A kind of complexity which causes problems elsewhere.

> Can you elaborate on this? Dynamically typed languages essentially have no type system (but yes even they do have types).

Of course they have a type system. You define types and the types of values determine what you can do with them. That is not different from static typing. It is just that the enforcement happens at runtime.

One example of complexity in static typing is what you get when you try to do any kind of meta programming such as templates or generics.

Perhaps the easiest way to illustrate the problem is to look at the terra language. http://terralang.org

In terra you see Lua serving the same job as the templating language in C++. Yet a typical templating language is very limiting compared to a full blown dynamic language.

With static typing you just very easily end up in a catch-22 situation: What are the types of the types of the types?

For instance in Julia I can write:

   A = Int
   B = Char
   c = 10
   bar(name::String) = println("Hello ", name) 
   foo(x::(c < 10 ? A : B)) = 2+x - 10
Which is kind of complete nonsense code, but it illustrates a few different things which I can trivially do in a dynamic language like Julia but which would be hard in a static language. Here I am storing types in the variables A and B. Then I define a function `foo` which has a specific implementation depending on the type of its single input argument `x`.

In `bar` I specify the type of `name` as String. However in `foo` the type of `x` is evaluated at runtime. When the function definition of `foo` get evaluated, only then do we decide what the type of `x` is.

Here an if statement is used to determine the type of `x`. However I have the availability of the full Julia language to make that decision. I can make multiple functions to do that.

Try something like that in a statically typed language and the type system will tie itself in knots. If you could even support this in a static language, the complexity of describing what I just did in a static language would make most software developers dizzy.

Re:Haskell Problems for a New Decade by hopia on Friday January 24, 2020 @07:48PM (#22143805)
> That is not different from static typing. It is just that the enforcement happens at runtime.

Isn't the inherent problem with dynamically typed languages exactly that they do not enforce types at compile time nor runtime? Like you try to call a method of an object that does not exist, and it crashes the runtime.

Moreover, I'm not sure I get your example. Wouldn't that be just a matter of a union type + parametric pattern matching in a statically typed functional language? You would just get exhaustiveness checks and type safety on top of that for free.

Re:Haskell Problems for a New Decade by tsss on Friday January 24, 2020 @08:36AM (#22138044)
You can get literally the same "simplicity" as a "dynamically typed" language through structural row-polymorphic types with type inference, i.e. static duck typing. Not to mention that the concepts of static and dynamic typing are orthogonal and there are languages that have both or neither. You have no clue what you're talking about.
Re:Haskell Problems for a New Decade by socialdemocrat on Friday January 24, 2020 @08:45AM (#22138123)
Before calling somebody clueless you have to understand the point they are actually making. I don't have the space to go into details in this comment. But you can read a more detailed explanation of what sort of simplicity I am talking about here:

https://medium.com/@Jernfrost/the-many-advantages-of-dynamic...

It is not just about the simplicity of implementation but also about the simplicity you can create in your whole development environment and process.

> You can get literally the same "simplicity" as a "dynamically typed" language through structural row-polymorphic types with type inference

If you believe that, then I am sure you can point me to a language that does exactly this and let me try learning it myself and make up my own mind whether it is simple or not.

Re:Haskell Problems for a New Decade by IceDane on Friday January 24, 2020 @10:07AM (#22138846)
That is an absolutely awful article. Example:

> The same problem as before repeats itself. Complexity grows to a point that we yet again need a real language to do the job. A script language which allows us to write some code that explains how e.g. our C++ values should show up in the debugger. Not to mention that debuggers for statically typed languages themselves tend to grow into complex behemoths with a dizzying array of functionality to deal with the complexities of statically typed languages.

This is just blatant nonsense and the author of the article clearly has no idea what a powerful static type system is capable of.

If you want to get a feel for what structural typing can give you, you don't need to look further than TypeScript. If you want proper row polymorphism, you can try PureScript.

Re:Haskell Problems for a New Decade by socialdemocrat on Friday January 24, 2020 @02:29PM (#22141608)
> This is just blatant nonsense and the author of the article clearly has no idea what a powerful static type system is capable of.

A complete non-sequitur. It does not refute the fact that most tools such as debuggers are customized with dynamic languages. The few times statically typed languages are used, it tends to be some kind of managed language where a lot of type info is retained at runtime.

> no idea what a powerful static type system is capable of.

If statically typed languages where so amazing and powerful then they would have been frequently used as extension mechanisms. They are not. Meta-programming also tends to be poorly developed in most statically typed language. The paradigm is just very limiting.

> If you want to get a feel for what structural typing can give you, you don't need to look further than TypeScript

I know structural typing from Go. If you think structural typing is a proper substitute for dynamic typing then you simply have not used a powerful dynamic language before. Or you have not learned how to use it properly.

With dynamic typing you can easily manipulate types as objects. Structural typing does not give you that. You latch on to a completely superficial similarity and think it is somehow similar in capability and scope.

The attitude you display is what makes a lot of the static typing fans kind of off putting. The smug superiority complex. I prefer dynamic languages but I recognize areas where static typing is preferable.

Re:Haskell Problems for a New Decade by tsss on Friday January 24, 2020 @03:29PM (#22142145)
> With dynamic typing you can easily manipulate types as objects

There are statically typed languages like Agda in which types themselves are "first-class objects" whose types are "kinds" whose types are "sorts" and so on. They form a hierarchy of Russel universes where functions can be defined at every level of the hierarchy. Typical ambiguity even allows to define implicitly universe-polymorphic functions that work on terms of every universe, i.e. you can write a function that can be applied to values _or_ types _or_ kinds just the same.

Re:Haskell Problems for a New Decade by darksaints on Friday January 24, 2020 @11:21AM (#22139583)
Scala is still growing, and it has been doing so (albeit slowly) from the very beginning. Clojure was very trendy for a while and grew really quickly, but it peaked around 2015 and is mostly dead now. The idea that clojure will supercede scala in the future is completely lost to reality.
Re:Haskell Problems for a New Decade by G4BB3R on Friday January 24, 2020 @08:23AM (#22137902)
Scala and Haskell are complex because it's creators wanted that way, not because they are typed FP. Take a look at Elm, it's very simple and clean syntax.
Re:Haskell Problems for a New Decade by eklavya on Friday January 24, 2020 @09:46AM (#22138701)
Yeah, it’s not like they created a much much more feature rich language and solved really hard problems.
Re:Haskell Problems for a New Decade by lonelappde on Saturday January 25, 2020 @08:05AM (#22146072)
> power, expressiveness and performance

Static languages are static because static provides opportunities for correctness, not on your list.