News for hackers. Stuff that matters.
Re: Haskell is our first choice for building production soft... by jcelerier on Monday January 11, 2021 @06:21AM (#25727482)
> the types are really low level (missing basic things like tuples) and lack of type inference

how far ago was this in the past ? C++ had tuples and type inference for ten+ years officially now - gcc 4.4 had it in 2009

Re: Haskell is our first choice for building production soft... by thesz on Monday January 11, 2021 @11:09AM (#25730800)
C++ cannot have non-local type inference due to, you know, object-oriented part of it.

This means that you cannot say something like this:

  auto sepulka;
  auto bubuka = zagizuka(sepulka);
Because if zagizuka's parameter is a structure or a class, you have a selection of parents. On a contrary, you have a selection of descendants of the result type of zagizuka() for bubuka, each having their own copy or assignment constructor.

[1] http://lucacardelli.name/Talks/2007-08-02%20An%20Accidental%...

[2] https://en.wikipedia.org/wiki/Intuitionistic_type_theory#Mar...

[1] shows how hard it is to make right type system with inheritance. I believe these slides mention 25 years of collaborative effort. Compare that to [2] where it took 8 years to design intuitionistic type theory (1971-1979) by mostly single person.

Re: Haskell is our first choice for building production soft... by gpderetta on Monday January 11, 2021 @12:47PM (#25732683)
C++ doesn't have type inference at all which I understand requires constraint solving.

It has a much simpler type deduction system where the type of an object is deduced from its initializing expression, i.e. deduction always flows in one direction.

It is nowhere as powerful, but it does cover a lot of use cases.

One advantage (in addition to the ease of implementation) is that, except for circular definitions, there are no undecidable cases and it is not necessary to restrict the type system to prevent them.

Re: Haskell is our first choice for building production soft... by andrekandre on Monday January 11, 2021 @04:20PM (#25737249)
not that im advocating it per se, but couldnt you deduct the tyope based on what `zagizuga()` does with `sepulka`?

for example

  def sepulka(zagizuga)
    zagizuga.doSomething()
    zagizuga.doSomethingElse()
would infer the type of zagizuga as some object that implements two methods `doSomething()` and `doSomethingElse()`... i think that should be doable (and possibly extremely slow) right?

maybe i missed something...

Re: Haskell is our first choice for building production soft... by thesz on Tuesday January 12, 2021 @10:42AM (#25748299)
Yes, it is doable, but what if there several memory-layout incompatible classes which implement both methods?

E.g, A implements virtual doSomething() and B and C inherit from A, add some different fields and both implement doSomethingElse() which they should overload for their inheritance from class Z.

Re: Haskell is our first choice for building production soft... by andrekandre on Tuesday January 12, 2021 @12:27PM (#25750091)
good question, i guess it depends on the language... multiple inheritance without namespacing would either result in either method getting chosen randomly, or a build error...

for example, in swift you cant even inherit from two protocols that have default implementations... and i think in c++ you also cant call the method without specifying namespace...

so, i suppose, if you wanted to go all the way, you could even do namespace inference

  def sepulka(zagizuga)
    zagizuga::Something.doSomething()
    zagisuga.doSomethingElse()
so zagizuga is infered to be some type that inherits from `Something` namespace and expects that namespace to defined `doSomething()` function, in addition to providing `doSomethingElse()`

though that seems getting a bit fragile irl maybe...

Re: Haskell is our first choice for building production soft... by mjburgess on Monday January 11, 2021 @06:27AM (#25727526)
There's also the culture around the language to fold in.

A culture of writing code assuming inference and structural typing is quite different than it merely being available.

Re: Haskell is our first choice for building production soft... by FpUser on Monday January 11, 2021 @07:44AM (#25728154)
I have zero problems using type inference, tuples, etc in my code. Other developers I deal with and who do use C++ have no problems using those "novel" concepts either. So I am completely at loss about what type of culture you are talking about here. It looks like grasping at a straw type of argument to me.
Re: Haskell is our first choice for building production soft... by mjburgess on Monday January 11, 2021 @08:32AM (#25728622)
I'm talking about all libraries and books written since it's development up until the early 10s; and of all those teams, libraries, and code which are legacy.

Haskell has never had a decades-long history of 'compiler-oriented programming', ie., excessive declarations, and so on.

The idea that C++ has a haskellish culture is patently absurd, even if the vanguard regard itself as presenting tending toward that direction.

Re: Haskell is our first choice for building production soft... by FpUser on Monday January 11, 2021 @12:12PM (#25731987)
I am in no way implying that "C++ has a haskellish culture". Neither I would consider it of any advantage. All I said is that modern C++ programmers have no problems using the concepts. There is plenty of those that are used in gobbles of libraries as well. Sure old libraries do not have it but so what?
Re: Haskell is our first choice for building production soft... by sfg on Monday January 11, 2021 @07:34AM (#25728058)
So, OCaml or something?

Or has Haskell added structural typing?

Re: Haskell is our first choice for building production soft... by mjburgess on Monday January 11, 2021 @09:07AM (#25728983)
Haskell is structurally typed...
Re: Haskell is our first choice for building production soft... by tome on Monday January 11, 2021 @09:13AM (#25729044)
Hmm, what do you mean? Haskell is generally considered nominally typed (or rather types introduced by its newtype and data declarations are ...). "Structural typing" typically refers to things like polymorphic row types and polymorphic variants.
Re: Haskell is our first choice for building production soft... by mjburgess on Monday January 11, 2021 @10:53AM (#25730557)
Sure, my mistake. I meant something looser.

Only that the types can be analysed structurally (ie., pattern matched).

In C++, etc. there's a "radical nominalism" in which the type was very opaque, ie., encapsualated.

Re: Haskell is our first choice for building production soft... by gpderetta on Monday January 11, 2021 @12:53PM (#25732792)
It is complicated. Templates do allow some form of structural typing and the new-in-C++17 structured bindings do allow for decomposing and inspecting types (although this being C++ it is kind of awkward). Structured bindings are expected to evolve into full pattern matching in the future.