News for hackers. Stuff that matters.
Re:Erlang: What the Cool Kids Are Doing by davidw on Tuesday January 15, 2008 @11:29AM (#98717)
I thought the cool kids had already moved on to Scala...
Re:Erlang: What the Cool Kids Are Doing by bilbo0s on Tuesday January 15, 2008 @12:34PM (#98747)
That's the interesting thing isn't it. With the Scala platform around people have very little incentive to go in and make the improvements to Erlang that would help it to become more mainstream. Particularly on the web.

For instance, what follows is the code to the Scala address book example:

object addressbook {

  case class Person(name: String, age: Int)

  /** An AddressBook takes a variable number of arguments
   *  which are accessed as a Sequence
   */
  class AddressBook(a: Person*) {
    private val people: List[Person] = a.toList

    /** Serialize to XHTML. Scala supports XML literals
     *  which may contain Scala expressions between braces, 
     *  which are replaced by their evaluation
     */
    def toXHTML =
      <table cellpadding="2" cellspacing="0">
        <tr>
          <th>Last Name</th>
          <th>First Name</th>
        </tr>
        { for (val p <- people) yield
            <tr>
              <td> { p.name } </td>
              <td> { p.age.toString() } </td>
            </tr> 
        }
      </table>;
  }

  /** We introduce CSS using raw strings (between triple
   *  quotes). Raw strings may contain newlines and special 
   *  characters (like \) are not interpreted.
   */
  val header =
    <head>
      <title>
        { "My Address Book" }
      </title>
      <style type="text/css"> {
     """table { border-right: 1px solid #cccccc; }
        th { background-color: #cccccc; }
        td { border-left: 1px solid #acacac; }
        td { border-bottom: 1px solid #acacac;"""}
      </style>
    </head>;

  val people = new AddressBook(
    Person("Tom", 20),
    Person("Bob", 22),
    Person("James", 19));

  val page =
    <html>
      { header }
      <body>
       { people.toXHTML }
      </body>
    </html>;

  def main(args: Array[String]) {
    println(page)
  }
}

This is so much less scary to people than the Erlang equivalent. EQUALLY complicated, just less scary! So if there are kids out there looking at implementing something new really fast, they will be drawn to Scala.

Remember PERL, it was lightning fast . . . and really scary. Java was less scary. PHP was friendlier still. And, I suspect, the frameworks built using Scala will be downright promiscuous.

It's too bad, I'm an old fart, 36, but I like Erlang.

Maybe the kids will let their religion get the best of them. They are really anti-Java, and Scala is built on Java.

Of course, they love JRuby.

Quel dommage.

Re:Erlang: What the Cool Kids Are Doing by rontr on Tuesday January 15, 2008 @12:42PM (#98750)
The cool kids won't move on to Scala for a number of reasons, the primary of which is that Scala's actors are not as powerful as Erlang processes.

See Virding's First Rule of Programming (http://www.nabble.com/Erlang-concurrency-to14747956.html):

"Any sufficiently complicated concurrent program in another language contains an ad hoc informally-specified bug-ridden slow implementation of half of Erlang."

Re:Erlang: What the Cool Kids Are Doing by davidw on Tuesday January 15, 2008 @04:08PM (#98841)
> Scala's actors are not as powerful as Erlang processes.

How so? I know Erlang reasonably well, but haven't messed with Scala at all.

Re:Erlang: What the Cool Kids Are Doing by nootopian on Tuesday January 15, 2008 @12:30PM (#98745)
"You cannot change the state of a variable once it has been set" http://www.onlamp.com/pub/a/onlamp/2007/09/13/introduction-t...

Im not a cool kid.

Re:Erlang: What the Cool Kids Are Doing by dpapathanasiou on Tuesday January 15, 2008 @02:13PM (#98785)
It's not a question of cool or not; it just seems you haven't been exposed to functional programming yet.

Here's an introduction if you've got an imperative/OO background: http://www.defmacro.org/ramblings/fp.html

Re:Erlang: What the Cool Kids Are Doing by Tichy on Tuesday January 15, 2008 @06:18PM (#98943)
I thought LISP is functional, and it lets you change variables. So I don't think that is specific to functional programming.
Re:Erlang: What the Cool Kids Are Doing by paulgb on Tuesday January 15, 2008 @07:21PM (#98976)
Lisp is not purely functional (few languages are). Purely functional languages do not let you modify variables.

Edit: Also, programmers in non-pure functional languages will often still minimize their use of mutation (changing variables) for a number of reasons.

Re:Erlang: What the Cool Kids Are Doing by Tichy on Wednesday January 16, 2008 @08:02AM (#99192)
In any case, when evaluating Erlang, I found the immutable variables to be rather unpractical. I can see why they might help to avoid errors with multi threading, but I don't see a reason to be excited about it? At the end of the day, it is another limitation of the language. With Java, that is what people complain about, the constraints, why wish for it in other languages?

If you think that immutable variables reduce programming errors, you are free to just not change your variables anyway, I guess. No language constraint required.

Re:Erlang: What the Cool Kids Are Doing by dpapathanasiou on Wednesday January 16, 2008 @07:03AM (#99182)
As paulgb said, Lisp is not purely functional, unlike Erlang or Haskell.

And actually, you could ignore functional programming and write code in an imperative style in Lisp (though it's not recommended, since you'd be missing out on the benefits of using Lisp).

Take a look at "Imperative Outside In" (chapter 3, section 2) in "On Lisp" (http://lib.store.yahoo.net/lib/paulgraham/onlisp.pdf) for an example.

Re:Erlang: What the Cool Kids Are Doing by Xichekolas on Tuesday January 15, 2008 @01:56PM (#98781)
It sounds weird at first to have variables that don't really vary, but it works out quite nicely.
Re:Erlang: What the Cool Kids Are Doing by jward on Wednesday January 16, 2008 @02:14AM (#99124)
It's sad. After coding in Haskell and Erlang I moved back to Python for a project and my code was just littered with extra variables. I had become so used to the functional way that varying variables just seemed so wrong and foreign.