News for hackers. Stuff that matters.
Re:F* – An ML-like functional programming language aimed at ... by ainar-g on Monday October 30, 2017 @02:14AM (#15583372)
Why didn't refinement types find their way into mainstream languages yet? It seems like it would have a tremendous impact on how programs are written and tested.
Re:F* – An ML-like functional programming language aimed at ... by johncolanduoni on Monday October 30, 2017 @04:03AM (#15583619)
I find it even more frustrating that some mainstream languages accept all the complexity of dependent typing while restricting the benefits by hiding it deep within an ad-hoc construction (C++ and Scala are both guilty of this).
Re:F* – An ML-like functional programming language aimed at ... by hellohn123 on Monday October 30, 2017 @07:00AM (#15584166)
Genuinely curious; can you elaborate which benefits the C++ implementation is missing out on?
Re:F* – An ML-like functional programming language aimed at ... by Peaker on Monday October 30, 2017 @09:49AM (#15584946)
C++ and Scala don't really have dependent typing, but rather a single feature that is typical of dependent typing. That is: type-level values of any type.
Re:F* – An ML-like functional programming language aimed at ... by johncolanduoni on Wednesday November 01, 2017 @08:41PM (#15606873)
Both Scala and C++ have a set of type-system features that when combined allow you create functions whose return type can depend on the value of the passed argument. For a good step by step of how to do this in Scala see here[1], and a (unfortunately less in depth) C++ example is here[2].

[1]: http://gigiigig.github.io/tlp-step-by-step/dependent-types.h...

[2]: https://www.reddit.com/r/cpp/comments/2tilfw/dependent_typin...

Re:F* – An ML-like functional programming language aimed at ... by Peaker on Sunday November 05, 2017 @04:18AM (#15628776)
I am not familiar enough with Scala, but the C++ example certainly does not seem like dependent types.

Which function in there do you consider to have a return type that depends on the value of the input?

Re:F* – An ML-like functional programming language aimed at ... by taejo on Monday October 30, 2017 @02:01PM (#15587341)
Doesn't C++ only have type-level integers (as template parameters)? Are you referring to something else?
Re:F* – An ML-like functional programming language aimed at ... by Peaker on Monday October 30, 2017 @10:15PM (#15590669)
I haven't used C++ in years. That may be true.

In that case, it may be even more puzzling to claim that C++ has dependent types.

Re:F* – An ML-like functional programming language aimed at ... by tom_mellior on Monday October 30, 2017 @05:52AM (#15583922)
Statically checking refinements still only works so-so, that is, what do you do when the SMT solver times out? Writing manual proofs (or proof fragments) is great for special-purpose languages used by highly trained people, but it's not quite ready for the mainstream yet.

Checking refinements at run time is considered "too expensive" by many people.

Re:F* – An ML-like functional programming language aimed at ... by saosebastiao on Monday October 30, 2017 @12:47PM (#15586553)
I use the Refined library for scala and it works incredibly well (a few bumps here or there, and some occasional boilerplate for library interop). On my app server, it basically becomes my validation layer for all request data, after which I only worry about object ownership/authorization.

The big win with refined types is from compiler level support though. With relatively simple checking occurring mostly at IO boundaries, you can eliminate or make obsolete massive portions of testing, type checking, manual optimization, etc., and enable massive amounts of automated optimization. In other words, the "too expensive" refinement checking at runtime becomes a net performance and engineering benefit over the whole product lifecycle.

Re:F* – An ML-like functional programming language aimed at ... by floatboth on Monday October 30, 2017 @01:20PM (#15586913)
Runtime refinements are actually useful for places where you'd have checks anyway. E.g. in Haskell, this library http://nikita-volkov.github.io/refined/ — can be integrated with JSON: https://github.com/myfreeweb/magicbane/blob/7c417504590fc40e... — and you get input validation specified right in the types of your data structures.
Re:F* – An ML-like functional programming language aimed at ... by pjmlp on Monday October 30, 2017 @02:23AM (#15583399)
Because major organizations only want replaceable developers, as cogs in the enterprise machine.

Better quality of software is irrelevant unless they get fined, like it happens on medicine or aeronautics industry.

Re:F* – An ML-like functional programming language aimed at ... by ainar-g on Monday October 30, 2017 @02:34AM (#15583429)
If anything, I would say refinement types make developers more replaceable. If Developer-1 documents all assumptions in the code using refinements, then, when they are replaced with Developer-2, the new developer can be productive more quickly.
Re:F* – An ML-like functional programming language aimed at ... by pjmlp on Monday October 30, 2017 @03:18AM (#15583521)
I agree with you, but most managers don't.

They only care about cost centers, Excel reports and who delivers at lower cost per seat.

Re:F* – An ML-like functional programming language aimed at ... by mcguire on Monday October 30, 2017 @10:06AM (#15585064)
To an extent. My feeling is that developers themselves, in general, don't want to learn anything more complicated than they can pick up from a three-month bootcamp and certainly don't want to take on the responsibility for their errors.
Re:F* – An ML-like functional programming language aimed at ... by kakarot on Monday October 30, 2017 @03:52AM (#15583597)
Those "major organizations", with the exception of Google and Apple, aren't spearheading language design.

Their point of view has no impact on the evolution of language paradigms, and if you told them they could save money on QA and increase the reliability of their product for virtually no overhead with new paradigms, I don't see why many people would reject the idea.

Re:F* – An ML-like functional programming language aimed at ... by pjmlp on Monday October 30, 2017 @04:24AM (#15583667)
Google, as in Go?

"Type system tyranny", page 8 - https://talks.golang.org/2009/go_talk-20091030.pdf

"Programmers working at Google are early in their careers and are most familiar with procedural languages, particularly from the C family. The need to get programmers productive quickly in a new language means that the language cannot be too radical."

https://talks.golang.org/2012/splash.article

Re:F* – An ML-like functional programming language aimed at ... by fauigerzigerk on Monday October 30, 2017 @06:42AM (#15584088)
This is a convenient explanation and you will find a lot of evidence for it, but I think it's superficial.

The real question is, why can they afford to take this approach without being outperformed by companies that use better languages and better developers?

For those of us who enjoy exploring more powerful/innovative languages, there is a convenient explanation and a not so convenient explanation.

The convenient one is that the success of these "Blub companies" is largely determined by factors unrelated to software development.

The inconvenient one is that all these interesting and powerful language features do not significantly improve software development outcomes.

I think it is remarkable that some of the companies that are on the Blub side when it comes to software development are among the most cutting edge, research oriented companies in other regards, such as AI.

Also, companies like Google can not only choose among the best candidates, they also have a lot of influence on what people learn before they even apply for a job there. So I simply don't buy the familiarity excuse, at least not for the entire workforce.

I also don't buy the large existing codebase excuse as that would apply equally to new Blub languages and new PL research based languages.

There is simply very little faith in any positive impact of PL research innovations on software development outcomes. And this lack of faith cannot be explained away by claiming that all those lacking faith are simply incompetent.

The likes of Google and Microsoft can and do hire competent PL researchers, just as they hire competent AI researchers. And they do have a massive incentive to improve software development quality and productivity.

I think the truth is that PL researchers simply haven't made the case for the effectiveness of their work.

In part because it's extremely difficult to make that case empirically. All the empirical studies I have seen suffer from huge and mostly unfixable counfounders.

But I think another reason is that PL researchers seem to largely ignore cognitive science and sociology. I haven't seen much discussion about the impact of particular PL features on developers' state of mind in any realistic context.

Nor have I seen much debate about programming languages as group communication tools or about the different roles in which people interact with code as part of a software development process. All of that is apparently considered out of scope.

And that, I think, is the reason why it is so easy for many practitioners to dismiss PL research out of hand. Even where PL research is being picked up decades later it appears more fashion driven than evidence based.

Re:F* – An ML-like functional programming language aimed at ... by pjmlp on Monday October 30, 2017 @06:58AM (#15584150)
If we look at blub engineering regarding mankind's history, impressive pieces of work were build by recurring to thousand of workers each doing his/her little thing across several years, even generations.

Yet, most likely we would use heavy construction building machines nowadays.

Niklaus Wirth admits on one of his papers that he expected developers would pick Oberon by caring about tools for quality in software engineered, but he was wrong about it.

Hoare has a similar remark on his Turing award speech.

So from my point of view it is a mix of sociology, fashion driven development and office politics.

Re:F* – An ML-like functional programming language aimed at ... by davidgrenier on Monday October 30, 2017 @07:55AM (#15584349)
I may misunderstand your statement, you seem to be saying Google and Apple ARE spearheading language design?

If so, you must be very confused with what they are doing with Go and Swift and Dart if you still consider that a thing.

Re:F* – An ML-like functional programming language aimed at ... by kakarot on Monday October 30, 2017 @03:13PM (#15587987)
I should have expanded a bit more. They are spearheading the design of a language or a few languages, and thus have skin in the game. I didn't mean to imply that they are spearheading language design in general.
Re:F* – An ML-like functional programming language aimed at ... by badsectoracula on Monday October 30, 2017 @03:48AM (#15583591)
Doesn't Ada have something like this?
Re:F* – An ML-like functional programming language aimed at ... by tom_mellior on Monday October 30, 2017 @08:37AM (#15584522)
AFAIK Ada's "refinement types" are essentially ranged integer types, i.e., you can define

    type Int is range 0 .. 100;
and it will be impossible to store any number outside that range in a variable of this type. But you can't define more general properties than this.
Re:F* – An ML-like functional programming language aimed at ... by badsectoracula on Tuesday October 31, 2017 @06:59AM (#15592265)
Pascal also has this, but i remember some Ada-related post from a few months ago here that had code along the lines of (imaginary syntax, i don't remember the exact code):

    type Int is range 0 .. 100 check(v)
      if (v = 10) or (v = 50) then error;
    end;
That would allow all values of v between 0 and 100, except 10 and 50. Note that everything after (and including) "check" is something i came up (and is more Pascal-ish), not what i am talking about. I also remember that this could be used with objects so that you could have something like (this one is Object Pascal-ish, i do not know Ada):

    type Foo = object
      Enabled : Boolean; Magnitude : 0..1000;
      check 
        if (Enabled and (Magnitude=0)) or
           (not Enabled and (Magnitude > 0)) then error;
      end;
      procedure Bar;
    end;
The code in check would be called whenever the object changes externally, so "Bar" can change Enabled and Magnitude with the check being invoked only at the exit of Bar to ensure object consistency and not whenever Bar does the assignment (so it can do a Enabled:=False; Magnitude:=0; and not fail at the first assignment), but assigning those values directly from outside the object would trigger it (so having a var f: Foo; and then writing f.Enabled:=True; would trigger the error).

Or at least that is what i remember understanding.

Maybe i remember some other Pascal-styled language, but the only other such language i know of is Oberon and that goes against the "put everything imaginable, plus extra more" mentality of Ada seems to have :-P.

Re:F* – An ML-like functional programming language aimed at ... by touisteur on Thursday November 02, 2017 @02:04AM (#15608184)
You might be thinking of type predicates, added in Ada2012 : http://sworthodoxy.blogspot.fr/2015/08/ada-2012-type-invaria... some of them statically provable in Spark : http://www.spark-2014.org/entries/detail/spark-2014-rational... (if interested, there's a link down there with a 'rationale' pdf).
Re:F* – An ML-like functional programming language aimed at ... by mcguire on Monday October 30, 2017 @10:02AM (#15585043)
In general Ada, those are only checked at runtime, IIRC.
Re:F* – An ML-like functional programming language aimed at ... by junke on Monday October 30, 2017 @11:10AM (#15585516)
Types are checked by names, even you have the same underlying range of values. But some checks can only be done at runtime.
Re:F* – An ML-like functional programming language aimed at ... by pjmlp on Monday October 30, 2017 @04:26AM (#15583672)
Kind of, you can achieve something similar with SPARK.