14

Scala has been called complex with its rich feature set by many of my colleagues and some even blamed all those new features of it. While most programmers are aware of the OO-features, and at least the decent ones also know about functional programming, there is one feature in particular in Scala for which I am not aware of its historical origins.

Given that a major mantra of our profession is to not reinvent the wheel, I am rather confident, that Scala does not have any actual unheard-of-before features, but I stand to be corrected on this one if necessary.

To get to the actual question, while I am aware of the origins of most of Scala's features I have never seen something like its implicit declarations before. Are there other (older!) languages out there which also provide this feature?

Does it make sense to distinguish the different cases of implicits (as they may originate from different sources), namely implict conversions and implicit parameters?

2
  • Maybe a duplicate?: stackoverflow.com/questions/3069432/…
    – gerferra
    Commented May 31, 2012 at 20:45
  • @gerferra Not an exact duplicate, and there isn't a notion of a cross site duplicate. If you want, you can compose an answer referencing the SO question and it's answers and their references, that's perfectly acceptable.
    – yannis
    Commented Jun 1, 2012 at 0:03

3 Answers 3

9

I disagree with Brian's answer on that other question.

As far as I know, there's no implicit concept on any other language. The change history for Scala implies that implicits were a generalization of view bounds, and a view bound is, itself, a generalization of automatic type conversion, which is very common indeed.

Implicits then enabled type classes, but I'd be very surprised if that was the original intent.

Edit

The release notes for Scala 2.0 (2006) say:

Views in Scala 1.0 have been replaced by the more general concept of implicit parameters

That doesn't mean, of course, that implicit parameters were introduced with the goal of replacing views.

However, Odersky clearly likes it when once concept can replace multiple ones. In that sense, it may well be the case that Odersky wanted type classes, but did not want to introduce a mechanism to handle that exclusively, and, therefore, came up with something else that let him remove one concept (Views) and replace it with a more generic concept that handles both views and type classes.

In case anyone is interested, Poor Man's Type Classes, referred to by Brian back at Stack Overflow, is dated 2006 as well. Clearly, Odersky was aware of the link between implicits and type classes when he introduced them.

Yet, I stand by my claim. :-)

3
  • What about the response by Norman Ramsey? stackoverflow.com/a/3071461/63489. It refers to a previous implementation of implicit conversions in Haskell
    – gerferra
    Commented Jun 1, 2012 at 13:17
  • @gerferra Sounds reasonable -- note that Odersky is referred to in that paper. The mechanism is different, but it might well have the ball rolling. Odersky's referred paper discusses type classes, and implicits were introduced in 2006, the date of the "Poor Man's Type Classes" presentation cited by Brian -- clearly, there's a link. Still, release notes for Scala 2.0 (2006) say "Views in Scala 1.0 have been replaced by the more general concept of implicit parameters". From what I know of Odersky, one mechanism that solves multiple problems would have great attraction to him. Commented Jun 1, 2012 at 15:56
  • fair enough :-)
    – gerferra
    Commented Jun 2, 2012 at 15:34
4

Implicit in scala means two different things

  1. Implicit Parameters. These appeared in Haskell, and maybe other languages first. Supporting evidence: This paper from 2000 and GHC 5.04.1 documentation (Sept-2002, before there was a Scala)
  2. Implicit conversions. I don't know the first language to have these, but they were in C# 1.0 (using the implict keyword) which pre-dates the first version of Scala by about a year.
1
  • +1, I didn't know implicit conversions are available in C#. Thanks for the pointer.
    – Frank
    Commented Jun 3, 2012 at 9:59
3

I asked a similar question on Stack Overflow. The most voted answer and others suggest that the origins are in Haskell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.