Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Hello, world

Name: Anonymous 2014-01-07 4:03

I was amused at some of the archetypal "Hello Worlds" for various Java frameworks. For reference, I'll include an assembly version first:


; This program displays "Hello, World!" in a windows messagebox and then quits.
;
; Written by Stewart Moss - May 2006
;
; Assemble using TASM 5.0 and TLINK32
;
; The output EXE is standard 4096 bytes long.
; It is possible to produce really small windows PE exe files, but that
; is outside of the scope of this demo.

.486p
.model flat,STDCALL
include win32.inc

extrn MessageBoxA:PROC
extrn ExitProcess:PROC

.data

HelloWorld db "Hello, world!",0
msgTitle db "Hello world program",0

.code
Start:
push MB_ICONQUESTION + MB_APPLMODAL + MB_OK
push offset msgTitle
push offset HelloWorld
push 0
call MessageBoxA

push 0
call ExitProcess
ends
end Start


Now, Java's Swing framework:


import javax.swing.JFrame; //Importing class JFrame
import javax.swing.JLabel; //Importing class JLabel
public class HelloWorld {
public static void main(String[] args) {
JFrame frame = new JFrame(); //Creating frame
frame.setTitle("Hi!"); //Setting title frame
frame.add(new JLabel("Hello, world!"));//Adding text to frame
frame.pack(); //Setting size to smallest
frame.setLocationRelativeTo(null); //Centering frame
frame.setVisible(true); //Showing frame
}
}


And my favorite, the very poorly-named tinystruct 2.0:


package tinystruct.examples;

import org.tinystruct.AbstractApplication;
import org.tinystruct.Application;
import org.tinystruct.ApplicationException;
import org.tinystruct.system.ApplicationManager;

public class hello extends AbstractApplication {

@Override
public void init() {
// TODO Auto-generated method stub
this.setAction("say", "say");
}

@Override
public String version() {
// TODO Auto-generated method stub
return null;
}

public String say(String words){
System.out.println(words);
return "<h1>"+words+"</h1>";
}

/**
* @param args
* @throws ApplicationException
*/
public static void main(String[] args) throws ApplicationException {
// TODO Auto-generated method stub
// Praise to the Lord!
ApplicationManager.install(new hello());

// to print 'Hello World'
ApplicationManager.call("say/Hello World", null); // Hello World

// or...
Application app=ApplicationManager.get( hello.class.getName());
app.invoke("say", new Object[]{"<h1>Hello, World!</h1>"}); // <h1>Hello, World!</h1>
app.invoke("say", new Object[]{"<h2>Bye!</h2>"}); // <h2>Bye!</h2>

// or...
// http://localhost:8080/?q=say/Hello World
// https://github.com/m0ver/tinystruct2.0
}

}


So there you have it: Java is so bloated that it can actually take more lines of code to do something than it would in x86 assembly. I guess eventually in theory it would pay off, but why the fuck does anyone use this language? I feel like it's some kind of joke.

Name: >>1 2014-01-07 16:32

>>8
You mean this thread? The /g/ thread is 404'd now, but I didn't post it there.

>>7
That's kind of my point. If a framework is so bloated that you can't implement Hello, World without (something like) 26 lines of code, then other seemingly trivial tasks will probably encounter unnecessary stupidity. I mean, look at the empty overrides that MUST be put in there for no particular reason. A large percentage of classes will just have empty overrides sitting there. That kind of idiocy just makes me sick. YAGNI, to quote myself from five years ago.

The other thing is that Java itself is not actually that bad. It's the frameworks and the culture of making a new class for every fucking line of code that makes it unusable. There's a real intellectual and maintenance cost to burying a few lines of real functionality in three pages of cruft.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List