Name: Anonymous 2012-07-08 10:47
>Functional programming
>Better syntax
>Better frameworks
>Better threading and concurrency
>Better garbage collection
>Better Hello World:
Scala:
Java:
>Better syntax
>Better frameworks
>Better threading and concurrency
>Better garbage collection
>Better Hello World:
Scala:
println("Hello, world!")Java:
package helloworld.beans;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.ejb.Remote;
import javax.ejb.Stateless;
@Remote
public interface HelloWorldRemote
{
public String helloWorld();
}
@Stateless
public class HelloWorldBean implements HelloWorldRemote
{
@Override
public String helloWorld()
{
return "Hello, world!";
}
}
public class Main
{
public static void main(String[] args)
{
System.out.println("Starting...");
System.out.println("Establishing connection to the bean...");
HelloWorldBean hwBean;
try {
InitialContext initialContext = new InitialContext();
hwBean= (HelloWorldBean) initialContext.lookup("java:global/HelloWorldBean");
System.out.println(hwBean.helloWorld());
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
System.exit(-1);
}
}
}