News for hackers. Stuff that matters.
Re:The Future of Standard ML (2013) [pdf] by eatonphil on Thursday July 14, 2016 @01:47PM (#12095879)
Cutting to the chase: use Haskell or Scala or F# if you need to do some scripting or build a web application that requires lots of different tasks (being a web server, rendering templates, connecting to a database, etc.). Haskell and Scala have great libraries and polymorphism that allows you to express things succinctly. Dunno much about F# except .NET.

Use OCaml if you want easily native binaries, predictable performance and need very little in the way of well-documented, high-quality third-party libraries.

Use Standard ML if you want to learn OCaml/Haskell/F#/Scala. Why? Ultimately it comes down to usability. First off, operators (not named functions) are to programming languages as icon-only buttons are to web pages; they are completely unusable. The only reason Standard ML avoided the plague of the operators is because it's a simpler language that was used less. Second, since it's a simpler language, you get a much cleaner introduction to things like monads and modules. It makes it very simple to jump into more complex languages like Haskell or OCaml or Scala.

I work on Ponyo [0] because I want to allow people (myself) to program at a high-level in Standard ML. Furthermore, I want to promote quality and usability. Basically, every function's type is annotated and we avoid abusing operators. The current state is such that you can parse CLI args, parse/marshal JSON, serve web pages, make http requests, browse file trees, and many other ideas in the works. But the most important part about Ponyo is that it is a large, (hopefully) well-documented project that others can study to learn Standard ML (and Haskell and Scala and OCaml and F#) better.

Scala, Haskell, F#, OCaml have their place and do their jobs well. If you don't know their place or just want to get exposure to the history behind these modern languages, I recommend giving Standard ML a shot. You can get started by reading the /r/sml wiki [1] or joining #sml on Freenode.

[0] https://github.com/eatonphil/ponyo

[1] https://www.reddit.com/r/sml/wiki/index

Re:The Future of Standard ML (2013) [pdf] by virtualwhys on Thursday July 14, 2016 @02:26PM (#12096178)
Coming from Scala I'd like to see successor ML become a reality. Whether it's 1ML, Ponyo, Ur (without the /Web), or another ML derivative that's not OCaml (petty, but the crufty syntax makes Scala seem elegant in this regard) isn't all that important.

As it stands every year Rossberg publishes a paper on latest 1ML enhancements; Harper does the same wrt to PLT, and by proxy SML. Meanwhile, nothing's really happening AFAICT in terms of the ML torch really being taken up and carried forward (beyond OCaml and Haskell).

Perhaps a charitable donation from an SV unicorn founder or two, corporate backing of some form, or academic backing similar to EPFL for Scala could really get the ball rolling.

Moving forward we've got OCaml and upcoming modular implicits; Haskell and the new module system, Backpack; and Scala's transition to Dotty -- basically a lot to look forward to, but would love to see SML in the mix, such a beautiful language...

Re:The Future of Standard ML (2013) [pdf] by owyn on Thursday July 14, 2016 @06:48PM (#12097776)
What about Facebook's Reason? It's an alternate syntax for OCaml that hooks into the existing OCaml compiler toolchain.

https://facebook.github.io/reason/

Looks like they've used it to build all kinds of stuff (including the Hack/PHP compiler).

Re:The Future of Standard ML (2013) [pdf] by cwyers on Thursday July 14, 2016 @03:20PM (#12096510)
I find it interesting that you list all of the ML derivatives except the popular one.
Re:The Future of Standard ML (2013) [pdf] by andrzejsz on Thursday July 14, 2016 @05:33PM (#12097330)
Maybe its not that popular but I would mention ATS programming language http://www.ats-lang.org
Re:The Future of Standard ML (2013) [pdf] by jfb on Thursday July 14, 2016 @07:38PM (#12098031)
Don't be silly; nobody uses Windows.
Re:The Future of Standard ML (2013) [pdf] by hroman on Thursday July 14, 2016 @03:34PM (#12096604)
Poly/ML?
Re:The Future of Standard ML (2013) [pdf] by cwyers on Thursday July 14, 2016 @03:39PM (#12096633)
No.

I mean, I know Tiobe isn't great, but the only ML-derivative I see on the top 50 is F#. ML and OCaml crack the top 100.

Re:The Future of Standard ML (2013) [pdf] by groovy2shoes on Thursday July 14, 2016 @03:57PM (#12096753)
F# is an OCaml derivative. I'd reckon that OP's feelings about F# would be rather similar to their feelings about OCaml.
Re:The Future of Standard ML (2013) [pdf] by cwyers on Thursday July 14, 2016 @04:12PM (#12096834)
The only objection to OCaml is "the crufty syntax," which I think F# has taken steps to improve upon.
Re:The Future of Standard ML (2013) [pdf] by sixbrx on Thursday July 14, 2016 @04:30PM (#12096942)
But F# didn't bring along the beautiful module system from the MLs, nor does it have type classes. Polymorphism there is basically just the OO + generics variety found in C#. That can rub some people (like me) the wrong way.
Re:The Future of Standard ML (2013) [pdf] by ZenoArrow on Friday July 15, 2016 @02:49AM (#12099312)
F# does have type classes, they're just called interfaces.

https://msdn.microsoft.com/en-us/visualfsharpdocs/conceptual...

Re:The Future of Standard ML (2013) [pdf] by lkitching on Friday July 15, 2016 @05:30AM (#12099769)
Type classes are quite different from interfaces. How would you encode the Eq typeclass in F#? .Net has the IEqualityComparer<T> interface but you need to manually pass that around (unlike Eq instances) and you also lose the global uniqueness property.
Re:The Future of Standard ML (2013) [pdf] by ZenoArrow on Friday July 15, 2016 @06:18AM (#12099912)
You don't have to rely on the built in interfaces provided by .NET, you can create your own. Just like in Haskell in F# you can use pattern matching against types to define which of the equality operators to use.

Also, I'm not sure what you mean by "manually pass that around". When you define a class in Haskell that inherits from a typeclass you reference that typeclass in the header of the new class. You follow the same approach in F# with interfaces.

Re:The Future of Standard ML (2013) [pdf] by lkitching on Friday July 15, 2016 @07:02AM (#12100096)
By 'pass around', I mean pass around instances, not definitions. You could define your own Eq interface in F#

  type IEq<'a> =
    abstract member eq: 'a -> 'a -> bool
but you then need to explicitly pass instances of this interface around into every method that requires it e.g.

  let allEq (s: 'a seq) (eq: IEq<'a>) = ...
whereas the haskell version would receive the Eq instance for the input type implicitly.

Typeclass instances are globally unique for each type, which cannot be enforced with the interface solution. If you have an ordered map type, you can be sure the Ord instance used for insertion is the same that is used for retrieval. With the interface approach, clients cannot know which instance to use since there could be multiple implementations. The Haskell approach has its own problems, such as the proliferation of newtype wrappers to manage the dispatch mechanism.

Interfaces also hide the representation of one of their arguments (the receiver) whereas typeclasses are just a dictionary of functions.

Re:The Future of Standard ML (2013) [pdf] by ZenoArrow on Friday July 15, 2016 @10:09AM (#12101023)
I'm not sure I understand all of what you've said, as I'm not familiar with Haskell, but there are at least some Haskell programmers have recognised the similarities between type classes and interfaces. Do you disagree with any of the following?

https://wiki.haskell.org/OOP_vs_type_classes#Type_classes_ar...

"Type classes are like interfaces/abstract classes, not classes itself

There is no inheritance and data fields (so type classes are more like interfaces than classes)....

For those more familiar with Java/C# rather than C++, type classes resemble interfaces more than the classes. In fact, the generics in those languages capture the notion of parametric polymorphism (but Haskell is a language that takes parametric polymorphism quite seriously, so you can expect a fair amount of type gymnastics when dealing with Haskell), so more precisely, type classes are like generic interfaces.

Why interface, and not class? Mostly because type classes do not implement the methods themselves, they just guarantee that the actual types that instantiate the type class will implement specific methods. So the types are like classes in Java/C#.

One added twist: type classes can decide to provide default implementation of some methods (using other methods). You would say, then they are sort of like abstract classes. Right. But at the same time, you cannot extend (inherit) multiple abstract classes, can you?

So a type class is sort of like a contract: "any type that instantiates this type class will have the following functions defined on them..." but with the added advantage that you have type parameters built-in, so:

  class Eq a where
    (==) :: a -> a -> Bool
    (/=) :: a -> a -> Bool
    -- let's just implement one function in terms of the other
    x /= y = not (x == y)
is, in a Java-like language:

  interface Eq<A> {

    boolean equal(A that);
    boolean notEqual(A that) { 
       // default, can be overriden
       return !equal(that); 
    } 
  }
And the "instance TypeClass ParticularInstance where ..." definition means "ParticularInstance implements TypeClass { ... }", now, multiple parameter type classes, of course, cannot be interpreted this way."
Re:The Future of Standard ML (2013) [pdf] by groovy2shoes on Thursday July 14, 2016 @04:57PM (#12097120)
They explicitly said "an ML derivative that's not OCaml". It's not a big leap from that statement to "neither OCaml nor a Caml derivative" given the similarities between the languages. I'm really not at all surprised that if they want to discount OCaml as a successor ML, they'd want to discount F# as well, given the close relationship between the two. Like @hroman, I too was rather puzzled by your initial statement.
Re:The Future of Standard ML (2013) [pdf] by agentgt on Thursday July 14, 2016 @06:07PM (#12097554)
I'm sort of sick of hearing that OCaml has crappy or crufty syntax. I like OCaml's syntax. There is just a sea of useless algol brackets in so many languages. I was sort of sad that Rust fell victim to the damn bracket. At times I don't even think Scala is that much more succinct than modern Java 8 (ala bracket indentation fun).

I remember years ago (15 years.. jesus I'm old) discovering OCaml and I couldn't believe how terse the language was for producing native code. If anything I don't like about OCaml syntax is that it actually has an enormous amount of syntactic sugar.

Re:The Future of Standard ML (2013) [pdf] by qbrass on Thursday July 14, 2016 @11:14PM (#12098747)
Was OCaml was your first ML language? It seems that most of the people who find OCaml crufty used Standard ML before OCaml.
Re:The Future of Standard ML (2013) [pdf] by agentgt on Friday July 15, 2016 @09:47AM (#12100873)
Guilty as charged.. I did learn OCaml first and from that official green HTML documentation which still appears to be green after 16 years :).

My complaint with OCaml was OCamlp and the tedium of creating modules and functors. While AdHoc poly (aka type classes) is not as flexible it is IMO easier to understand, generally less verbose and slightly more elegant than OCaml modules. I'm glad they added first class modules as I recall wanting something like that a long time ago.

Re:The Future of Standard ML (2013) [pdf] by eatonphil on Friday July 15, 2016 @07:25AM (#12100202)
For what it's worth, I think OCaml's syntax is one of its weakest points (not to mention syntax extensions...) and I have been writing OCaml 3 years longer than I've been writing Standard ML.
Re:The Future of Standard ML (2013) [pdf] by agentgt on Friday July 15, 2016 @09:39AM (#12100831)
Well yes I agree if you compare OCaml to Standard ML its syntax is not as good and I do prefer Standard ML over it. However I prefer OCaml over Java, Javascript, Scala (and the bazillion other brace block languages that are the same), and yes even Haskell.
Re:The Future of Standard ML (2013) [pdf] by jonsterling on Thursday July 14, 2016 @05:53PM (#12097481)
F# doesn't even have modules. Not really in the SML spirit—it's like if you combined Classic/LCF ML from the 1970s with C#.
Re:The Future of Standard ML (2013) [pdf] by ZenoArrow on Friday July 15, 2016 @02:44AM (#12099296)
In the context of ML, what are modules and why are they useful?
Re:The Future of Standard ML (2013) [pdf] by groovy2shoes on Thursday July 14, 2016 @03:56PM (#12096747)
Poly/ML isn't an SML derivative, per se. It's an implementation of Standard ML (and a damn fine one at that).
Re:The Future of Standard ML (2013) [pdf] by Peaker on Thursday July 14, 2016 @03:16PM (#12096489)
Many icons are well known and work well.

The back, forward, reload buttons are more usable as icons than text.

When not overused, operators are similarly more usable than verbose English names.

Re:The Future of Standard ML (2013) [pdf] by dukerutledge on Thursday July 14, 2016 @05:42PM (#12097390)
Totally agree. There was a great example on /r/haskell the other day.

https://www.reddit.com/r/haskell/comments/4sdkch/haskel_newb...

Operators are certainly overused in Haskell, but sometimes they make something so much more readable.

Re:The Future of Standard ML (2013) [pdf] by marktangotango on Thursday July 14, 2016 @02:42PM (#12096298)
Holy cow, poly/ml looks outstanding, threads, sockets, signals, a ffi, a lot of things I've been missing in SML all these years. Is there support for unicode in the string library? How's the generated code performance wise? I will definitely keep an eye on this project.
Re:The Future of Standard ML (2013) [pdf] by groovy2shoes on Thursday July 14, 2016 @03:59PM (#12096770)
Poly/ML produces excellent code. It's probably the second most performant SML implementation after MLton.
Re:The Future of Standard ML (2013) [pdf] by Narishma on Friday July 15, 2016 @02:01AM (#12099197)
Does it produce native executables that are easy to distribute?
Re:The Future of Standard ML (2013) [pdf] by groovy2shoes on Friday July 15, 2016 @06:56AM (#12100069)
On platforms for which it can produce native code, yes. The compiler will produce typical object files which can then be linked with the usual linker. For other platforms it uses a byte compiler.
Re:The Future of Standard ML (2013) [pdf] by isomorph on Thursday July 14, 2016 @02:07PM (#12096024)
Interesting, thanks. Worth noting that every Cambridge compsci undergrad has to learn SML. I ended up moving onto OCaml and Scala.
Re:The Future of Standard ML (2013) [pdf] by s3nnyy on Thursday July 14, 2016 @02:19PM (#12096118)
Same as compsci students at TU Munich, if Prof. Rybalchenko does the intro to functional programming course.

I really enjoyed it and found it much better suited for students than other languages, especially with the book by Gert Smolka.

Re:The Future of Standard ML (2013) [pdf] by blatant on Thursday July 14, 2016 @02:58PM (#12096383)
Do you have a link to "that book?"
Re:The Future of Standard ML (2013) [pdf] by s3nnyy on Friday July 15, 2016 @02:45AM (#12099298)
Re:The Future of Standard ML (2013) [pdf] by jxy on Thursday July 14, 2016 @03:43PM (#12096666)

  > operators (not named functions) are to programming
  > languages as icon-only buttons are to web pages;
  > they are completely unusable.
I see ( ) ; . you are using already. Latin letters are gibberish to people who don't use it.
Re:The Future of Standard ML (2013) [pdf] by rvense on Thursday July 14, 2016 @03:57PM (#12096761)
I wrote some Scala just today:

  val list = a +: l :+ b
And I knew I had to put in a comment because that stuff always makes my eyes cross over when I come back to it.
Re:The Future of Standard ML (2013) [pdf] by talideon on Thursday July 14, 2016 @08:34PM (#12098250)
Don't know Scala, but I'd assume that `+:` is prepend to list and `:+` is append to list.
Re:The Future of Standard ML (2013) [pdf] by rvense on Thursday July 14, 2016 @08:43PM (#12098278)
You'd be correct.

But they're just method calls, both defined on the class of l. It is a little weird.

Re:The Future of Standard ML (2013) [pdf] by jfb on Thursday July 14, 2016 @08:55PM (#12098326)
I can see the argument for terseness in source, particularly in domains where the terseness in code reflects well-understood shorthand in the actual problem space. But stuff like that makes me itch, to be honest.
Re:The Future of Standard ML (2013) [pdf] by rvense on Thursday July 14, 2016 @09:24PM (#12098419)
The alternative would be something like

  l.prepend(a).append(b)
Horrible. Ghastly. Can't see anybody tolerating a language that looked like that.. /s
Re:The Future of Standard ML (2013) [pdf] by yawaramin on Thursday July 14, 2016 @10:19PM (#12098590)
It gets even worse. Because Scala has infix syntax for method calls, you can do

    l prepend a append b
Re:The Future of Standard ML (2013) [pdf] by jfb on Thursday July 14, 2016 @09:45PM (#12098483)
What? Mutating a list? DISGUSTING!
Re:The Future of Standard ML (2013) [pdf] by speedkills on Thursday July 14, 2016 @10:33PM (#12098633)
It's not mutating, its returning a new list with elements prepended and appended.
Re:The Future of Standard ML (2013) [pdf] by snoman on Friday July 15, 2016 @02:12AM (#12099222)
Don't know Scala but why wouldn't it be

a.append(l).append(b)

?

Re:The Future of Standard ML (2013) [pdf] by rvense on Friday July 15, 2016 @06:00AM (#12099860)
That would only work if a was itself a list..
Re:The Future of Standard ML (2013) [pdf] by jxy on Thursday July 14, 2016 @06:50PM (#12097782)

  もっと練習  ⍝ Practice more  NB. ⍝ is a symbol for comment.
  /* NB. is for comment, too. */
  // Anything inside /* */ is comment, too.
  #  // starts a comment, too.
Re:The Future of Standard ML (2013) [pdf] by pmontra on Thursday July 14, 2016 @05:25PM (#12097283)
I don't know Scala and I have no idea of what +: :+ means, which at first is not a good sign (think about onboarding.) Then I remembered that many mainstream languages have the

    a ? b : c
construct which maybe was equally puzzling when it was introduced by CPL in 1963.
Re:The Future of Standard ML (2013) [pdf] by rvense on Thursday July 14, 2016 @08:42PM (#12098275)
They're operators that cons an element on to a list. They're both defined on the List class, but differ in associativity because they start/end in a colon.

"a +: l" calls the +: method on l with a as its argument and returns a list with a added to the start, "l :+ b" calls the :+ method on l with b as its argument and returns a list with b added to the end. "a +: l :+ b" (parsed as "(a +: l) :+ b") therefore returns a copy of l with a added to the start and b added to the end.

This is user definable, you can make operators whichever way you like (and start them with : if you want them to be right associative).

It's very flexible and you do sort of get used to libraries using it, but I'm not entirely sure that getting used to something always means it's good.

(TBH though, I use the ternary operator constantly and think nothing of it.)

Re:The Future of Standard ML (2013) [pdf] by billrobertson42 on Thursday July 14, 2016 @06:55PM (#12097807)
Scala can be extended by users with stuff like that.
Re:The Future of Standard ML (2013) [pdf] by pekk on Thursday July 14, 2016 @08:33PM (#12098245)
The fact that C-style ternary is hard to pick up doesn't really excuse this kind of thing in new languages.
Re:The Future of Standard ML (2013) [pdf] by coolsunglasses on Thursday July 14, 2016 @04:35PM (#12096967)
Learning SML isn't going to help as much with Haskell as you might think. The others, yes.
Re:The Future of Standard ML (2013) [pdf] by eatonphil on Thursday July 14, 2016 @05:29PM (#12097310)
I have ~4 years experience writing OCaml, and ~1 year experience writing Standard ML. I also once did contracting for a Play app in Scala for 3 months. A month ago, I started looking into Haskell for the first time for another side project and was immediately able to pick it up due to how similar it is to OCaml and Standard ML. In particular, the type syntax and function declarations are similar; understanding monads in SML/OCaml helps understand... everything in Haskell; and understanding of modules/functors/signatures transfers indirectly to type classes as well. (Here is a paper going into even more detail [0].) It felt like Haskell has some of the syntactic sugar I always wished Standard ML had as I learned its limitations.

[0] http://www.cse.unsw.edu.au/~chak/papers/modules-classes.pdf

Re:The Future of Standard ML (2013) [pdf] by qbrass on Friday July 15, 2016 @12:26AM (#12098931)
If you already know SML or OCaml, you'll pick up Haskell easier, but if you don't know them and want to learn Haskell, you're not taking a shortcut by learning SML or OCaml first.
Re:The Future of Standard ML (2013) [pdf] by eatonphil on Friday July 15, 2016 @07:35AM (#12100251)
Although I happened to learn OCaml first, I am actually arguing that learning SML is a better way to learn the concepts behind tremendously more complex and less user-friendly languages like OCaml and Haskell. I don't know if I'd say it's a shortcut, but it's pretty natural to learn by studying a simpler (perhaps historic) topic before studying a more modern and complex one.
Re:The Future of Standard ML (2013) [pdf] by dtornabene on Friday July 15, 2016 @01:38AM (#12099143)
Its whatever works for every person, but I'll throw in my own experiences and say, that by taking a detour into Ocaml I was actually greatly aided in understanding Haskell. And that having spent a great deal of time with a number of Lisps. I had grabbed a copy of RWH, dug into it, been a little defeated at first, took a studious detour through RWOcaml and have returned to Haskell with a clearer view. Again, to each their own, my own experience was actually the opposite of your statement.