News for hackers. Stuff that matters.
Re:How (not) to write Factorial in Java by meadowsp on Thursday January 27, 2011 @11:03AM (#2148291)
Could you point me towards a comparison of an insane java library and the sane equivalent in a different language?
Re:How (not) to write Factorial in Java by steveklabnik on Thursday January 27, 2011 @11:21AM (#2148365)
Hello world in Swing: (from here: http://www.java2s.com/Code/Java/Swing-JFC/HelloWorldSwing.ht... )

    import javax.swing.JFrame; 
    import javax.swing.JLabel;

    public class HelloWorldSwing {
      public static void main(String[] args) {
        JFrame frame = new JFrame("HelloWorldSwing");
        final JLabel label = new JLabel("Hello World");
        frame.getContentPane().add(label);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
        frame.setVisible(true);
      }
    }
Hello world in Shoes:

    Shoes.app do
      para "Hello, world"
    end
Hello world for Hibernate: (from here: http://www.javaworld.com/javaworld/jw-10-2004/jw-1018-hibern...)

    package hello;
    public class Message {
       private Long id;
       private String text;
       private Message nextMessage;
       private Message() {}
       public Message(String text) {
          this.text = text;
       }
       public Long getId() {
          return id;
       }
       private void setId(Long id) {
          this.id = id;
       }
       public String getText() {
          return text;
       }
       public void setText(String text) {
          this.text = text;
       }
       public Message getNextMessage() {
          return nextMessage;
       }
       public void setNextMessage(Message nextMessage) {
          this.nextMessage = nextMessage;
       }
    }

    Session session = getSessionFactory().openSession();
    Transaction tx = session.beginTransaction();
    Message message = new Message("Hello World");
    session.save(message);
    tx.commit();
    session.close();
The equivalent in ActiveRecord:

    class Message < ActiveRecord::Base
    end

    message = Message.new(:text => "Hello, world")
    message.save
You have to set up your schema in both, so I've left that out.

These are just the first two that came to my head. I ditched Java so long ago that I'm sure a few hundred more have come up.