It has been my experience that it is difficult to get a bug passed the Hindley-Milner type system. Amusingly, this typo (passed instead of past) is an example of the challenge facing language and tool developers. We can make a checking system isomorphic to a spell-checking system, but then we need a grammar-checking system to ensure that even if a word is correctly spelled, it forms a legal sentence. Once we have tha…
Advanced programming languages
41–50 of 82 posts
Re: Advanced programming languages
#42It has been my experience that it is difficult to get a bug passed the Hindley-Milner type system. Amusingly, this typo (passed instead of past) is an example of the challenge facing language and tool developers. We can make a checking system isomorphic to a spell-checking system, but then we need a grammar-checking system to ensure that even if a word is correctly spelled, it forms a legal sentence. Once we have tha…
Even with perfect grammar, spelling, and logic checks, you're still going to lose sometimes: I mistyped a single letter in an email and offended a coworker for life. He was on the road; I was in the office. I argued persuasively about a difference in design, ending with "When you get it, we can talk some more". I had intended to say "When you get in, we can talk some more". http://news.ycombinator.com/item?id=1375231
Ugh. Have you considered...
I had some 'splainin to do!
Re: Advanced programming languages
#43Earlier quoted context omitted.
No. All that work predates both, in some cases by several years. In fact, a good friend of mine is working to put scala bindings over all the clojure data structures so they can be used transparently in scala. They're that good.
Your friend might be wasting a lot of effort (apart from his personal learning experience), as Phil Bagwell is working on Scala's collection library.
Wrapping the PersistentMaps took like less than 200 lines of code: http://github.com/codahale/yoink
Re: Advanced programming languages
#44Earlier quoted context omitted.
> Another issue with Scala is that the interface with Java, particularly using collections, is awkward; [...] Really? For me one of Scala's best attributes, by far, is the ability to use its implicit conversions to make awkward Java APIs smooth like butter. > One problem is that, based on the JVM, type erasure is a big "broken window" that seriously damages the Scala type system. I'm not sure I understand or agree. U…
Using implicits is really nice to clean up the interface to some Java APIs (especially for APIs making heavy usage of anonymous inner objects) but I experienced more ugly boilerplate than I would like when having to use Java collection classes from Scala, too. To be more specific, when I want to transform a collection given by a Java library in a functional manner, I usually ended up with one or two localized import…
Re: Advanced programming languages
#45I smiled when I read this: Haskell's type system literally allows the compiler to infer the correct code to run based on its type context It literally has overloading! Imagine that!
Re: Advanced programming languages
#46I'm curious where all the data is about "expressiveness" being so important. I'm yet to meet the person who can churn out functional solutions quicker than imperative... but I hope this is my naivete and not just the CS bandwagon effect.
http://www.norvig.com/java-lisp.html
Not clear how much is due to the functional nature of Common Lisp, but does show a clear difference between programming languages in expressiveness and productivity.
Re: Advanced programming languages
#47Some thoughts. The people I know who do work in machine learning (Jon Kleinberg, Thorsten Joachims, and their students) work in straight-up C, not Haskell, as the author suggests. Most of the dominant methods used today, such as the SVM, boosting, and the dynamic programming methods used in genomics are (i) numerical more than symbolic and (ii) involve moving a LOT of data around, so you want control of your data str…
Is their work in applying ML theory, or creating more of it? ML almost always involves large datasets in practical use, but when you're trying to come up with a new method for ensuring correctness in some edge-case, you would be testing it with hypothetical extreme inputs, not feeding it mounds of data that won't trigger the problem. Haskell works well to model computer science research problems—that is, research into CS, not using CS to research other domains. Once your model has "solidified", you should by all means optimize it in C before running it on real-world data.
Re: Advanced programming languages
#48Earlier quoted context omitted.
> Another issue with Scala is that the interface with Java, particularly using collections, is awkward; [...] Really? For me one of Scala's best attributes, by far, is the ability to use its implicit conversions to make awkward Java APIs smooth like butter. > One problem is that, based on the JVM, type erasure is a big "broken window" that seriously damages the Scala type system. I'm not sure I understand or agree. U…
Using implicits is really nice to clean up the interface to some Java APIs (especially for APIs making heavy usage of anonymous inner objects) but I experienced more ugly boilerplate than I would like when having to use Java collection classes from Scala, too. To be more specific, when I want to transform a collection given by a Java library in a functional manner, I usually ended up with one or two localized import…
I think the other poster was right about this being more of a library issue than a language issue. In my experience it was rare to do more than wrap Java collections to or from an Iterable[]; that could be done easily without having to bring full mutable collections into the namespace.
Also, it might be part of the cost of working with "enterprise" Java, but it was actually really rare for me to work with a vanilla Java collection rather than some library's implementation of its own damn 'typesafe' iterator, like this: http://xerces.apache.org/xerces-j/apiDocs/org/w3c/dom/NodeLi.... It was super-nice to toss together my own wrappers of some library or another's semi-standard iteration API and have a ton of functionality come along via the magic of mixins; and get it all automatically applied for the cost of a single import statement via implicits.
> match { case x: List[Foo] => ... case x: List[Bar] => ... }
I suppose such a thing is made impossible via erasure, it's true. I haven't encountered a need for it -- maybe because the problem there is erasure + dynamic/runtime typing, rather than erasure on its own. Also it's something that's coming for Scala, it sounds like. (I haven't paid as much attention as I should to its ongoing development..)
> Why do you have the preference for Scala?
Part of it's just the intuitive feel: When I code in Scala, I'm writing in Scala -- it might be a fairly huge language, but it is its own thing. Coding in F# feels like bouncing back and forth between C# and O'Caml, depending on how functional you're feeling at the moment -- here's a C#-ish clause; there's an O'caml-esque one.
As an example, I don't believe you can use both inheritance and discriminated unions in F#. In Scala you can and it's actually quite useful.
Another example is that in F# you can omit type declarations on function arguments until you start using OO, then they become mandatory and infect your code. On the one hand the extra inference is nice but on the other it really drives home that you are coding in two languages, not one.
Besides that intuitive part, I think that Scala's module/class-level type system, although complicated, helps tremendously for writing big, complex, programs. Traits/mixins, flexibility in type constraints, and allowing types as members of other types add up to a really powerful ability to modularize without sacrificing. At least for me, a lot of my older O'Caml projects made fairly heavy use of functors. F# didn't bother to try to support the idea and only supports plain-vanilla C# interfaces. Scala embraced them, extended it, and made them much better.
Re: Advanced programming languages
#49I smiled when I read this: Haskell's type system literally allows the compiler to infer the correct code to run based on its type context It literally has overloading! Imagine that!
To give a concrete example: The printf function in Haskell takes on the responsibilities of both the traditional printf (printing to the screen) and sprintf (generating a formatted string). Haskell knows which it's supposed to do based on whether the return value is used in an IO context or as a string.
Re: Advanced programming languages
#50Earlier quoted context omitted.
Using implicits is really nice to clean up the interface to some Java APIs (especially for APIs making heavy usage of anonymous inner objects) but I experienced more ugly boilerplate than I would like when having to use Java collection classes from Scala, too. To be more specific, when I want to transform a collection given by a Java library in a functional manner, I usually ended up with one or two localized import…
Out of curiosity, what do you mean by "fixing typing"? (I'm genuinely curious. I don't know Scala and F# well enough to really understand.)
F# has basically two type systems -- the O'Caml/ML one, and C#'s. As a plus, you get full type inference so long as you stick with ML discriminated unions or records; as a minus, you lose the ability to apply concepts from OO without converting them to classes -- in which case you lose the ability to apply some handy ML-isms.
Scala tries to pull off a fairly deep unification of OO with functional types; for example making discriminated unions into case classes; or blending OO ideas of objects and classes with ML ideas about modules (including functors) into a single concept. It's far more ambitious in this regard than F#, but not necessarily an unqualified success either.