News for hackers. Stuff that matters.
Re:Javax.cache: The new Java Caching Standard by fleitz on Monday October 17, 2011 @01:08PM (#3121358)
My fav language is F# (preferred over OCaml because of VS and the #light syntax), but for webdev I usually use ruby/RoR because of the functionality available through gems. Making facebook/twitter integration work on ASP.NET MVC was more work than it should be last time I tried, and I hate all the hoops you have to jump through to make jQuery / json work with ASP.NET. Mostly I like F# because of the pipe and composition operators, inferred typing, records, active patterns, and a very succinct way of defining classes.

Pipe Operator:

  Seq.init 100 (fun x -> x*2)
  |> Seq.reduce (+)
Creates a sequence of numbers from 1 to 100 multiplies them by two and then adds together.

Composition operator:

  let add x y = x+y
  let mul x y = x*y
  let addFiveMultiplyBy20 = add 5 >> mul 20
  
Define a class

  type User(firstName,lastName,email) =
    property x.Name.get = x.firstName + x.lastName
I'm a little rusty on the class syntax so it might be off. Btw, the class that that would create would be fully generic with a requirement that the class of firstName and lastName have the (+) operator defined. So you could use the code:

  let user1 = new User("Foo","Bar","[email protected]")
  let user2 = new User(42,24,new EmailAddress("[email protected]"))
As well you could do this:

  let (+) (x:string) (y:int) = x + y.ToString();
  let (+) (x:int) (y:string) = x.ToString() + y;
  let user3 = new User(42,"Bar","[email protected]");

There are no comments on this comment yet.