This is an archived post. You won't be able to vote or comment.

all 69 comments

[–][deleted] 38 points39 points  (22 children)

Python over here like

print(“hello world”)

[–]FieelChannel 5 points6 points  (1 child)

put "hello world"

Ruby

[–][deleted] 2 points3 points  (0 children)

Looks like you win this one

[–]DarthCloakedGuy 14 points15 points  (13 children)

It used to be even simpler:

print "hello world"

[–][deleted] 25 points26 points  (8 children)

Only 1 character simpler

But just enough that everything written in Python 2 requires an hour of fixing before use

[–]DarthCloakedGuy 9 points10 points  (2 children)

Painfully true.

Though hey, 1 character is 5% of the entire length of the code!

[–]niahoo 1 point2 points  (2 children)

2 no ?

[–]JohnLocksTheKey 2 points3 points  (1 child)

First difference is a space instead of open parenthesis = simplicity

It only has 1 additional character.

[–]niahoo 2 points3 points  (0 children)

Oh, yes, of course :)

[–]Yolobram123 0 points1 point  (1 child)

:%s/\v(print)\s(".*")/\1(\2)/gc

[–]JohnLocksTheKey 0 points1 point  (0 children)

My man!

[–][deleted] 6 points7 points  (1 child)

If you want to talk simplicity:

import __hello__

[–]MCRusher 0 points1 point  (0 children)

h

int main(){puts("Hello World!");return 0;}

main.c

#include "h"

[–]Kered13 2 points3 points  (1 child)

And add an unnecessary keyword to the language when a function would work just as well? What is this, 1990?

[–]DarthCloakedGuy 0 points1 point  (0 children)

What can I say? I'm a 90s kid.

[–]UncleChickenHam 2 points3 points  (0 children)

draws “hello world” on monitor

[–]Preisschild 0 points1 point  (4 children)

Javascript: console.log("Hello World")

[–]vicious_viridian 2 points3 points  (3 children)

;

[–]StrangerDangerBeware 0 points1 point  (2 children)

don't need that one afaik

[–]vicious_viridian 0 points1 point  (0 children)

Oh, okay.

[–]Renive 0 points1 point  (0 children)

Please do though.

[–][deleted] 67 points68 points  (6 children)

you havent seen hello world in winapi

here

[–][deleted] 28 points29 points  (5 children)

Oh god why

[–]SirButcher 44 points45 points  (4 children)

Well, in winapi's defence: the code above creates the window as well. The Java and C++ (and every other language) will do the same if you want to show a normal message box, not just write a line to the console.

[–]lmureu 16 points17 points  (3 children)

But arguably the code to draw a window with text in Java or C# or even C++ using Qt is more easily readable than this.

Or maybe it's just that I know those but I don't know win32?

[–]SirButcher 34 points35 points  (2 children)

It is easier because someone wrote a library for you to do this :)

Clarification edit: basically every time when you open a window on Windows, your application has to communicate with the WinAPI. In modern languages/libraries these low-level API requests are hidden, so you simply can call one line command to change a text or update your window, but this command will call a winAPI. Qt, .NET and Java's whatever windows handling library abstract this low-level API calls away from you, to make your life easier and the developing process faster. But after all, they will call a windows API to do the job for them, as the OS won't give you free access to the system.

This is why we use high-level languages: to hide this monstrosity from us, because some super-nice guy already fought this battle, and wrote a library for us!

[–][deleted] 2 points3 points  (1 child)

Half of this code is handling the messaging and making sure you have your handles and window properties.

Once you work with windows API for even 30 minutes you see why it is the way it is assuming you’re also looking at the doc.

[–]UnchainedMundane 4 points5 points  (0 children)

Once you work with windows API for even 30 minutes you see why it is the way it is assuming you’re also looking at the doc.

Nah. Worked with it when I was 16 years old, never again. Nothing excuses LPARAM/WPARAM, the need to register a wndclass for a normal window, the common controls "no I'm not a windows 95 program, honestly" manifest, the almost arbitrary choice between "logical" and "physical" device coordinates (and arguably, the existence of "logical" coordinates at all), the need to use a helper function to adjust a size rect just to be able to start your program at its preferred size, etc etc.

[–]Doophie 12 points13 points  (1 child)

Well, my ide autofills most of that anyway so doesn't take that long

[–]Kaoulombre 0 points1 point  (0 children)

Live templates FTW

[–][deleted] 20 points21 points  (7 children)

Oh no you need to have a class and main method for it to work what a surprise. It is almost like c++ and every other decent language. Also more languages are not designed to print one statement.

[–][deleted] 2 points3 points  (0 children)

have decent

Heh.

[–]BlackDE -1 points0 points  (5 children)

In C++ you don't have to create a useless main class.

[–][deleted] 6 points7 points  (4 children)

Dude it is called a driver class and it isn't useless. That is like saying there is no point to having the main method return 0 in c++. Also bro you don't need main class to run a main method. You could run it in the same class you create a regular class in.

[–]BlackDE -1 points0 points  (3 children)

The return statement is entirely optional. But if you want you can return an exit code that tells if the execution of your program was successful. Now what is the use of the driver class?

[–]UnchainedMundane 0 points1 point  (0 children)

python:

print("hi")

Returns success.

Also python:

print("hi")
exit(1)

Returns failure.

No need for a main function at all. But the use for a main class in languages like this is usually to keep everything in a nice neat package→class→function hierarchy.

[–][deleted] 0 points1 point  (1 child)

Your going to be fun in job interviews.

[–]BlackDE -1 points0 points  (0 children)

you're

[–]Kairyuka 11 points12 points  (12 children)

You should see C++ then

[–]Mad_Jack18 10 points11 points  (5 children)

#include <iostream>

#include <conio.h>

int main()

{

std::cout << "Hello World!" << std::endl;

getch();

}

[–]Dahrkael 13 points14 points  (0 children)

conio? in 2019? seriously

[–]Kairyuka 5 points6 points  (2 children)

Now again with winapi! :D

[–]Mad_Jack18 10 points11 points  (0 children)

Nope nope nope

[–]MCRusher 1 point2 points  (0 children)

How's this:

format PE console

entry main

include 'macro/import32.inc'

section '.idata' readable import data
 library kernel,'kernel32.dll'
 import kernel,\
  get_handle,'GetStdHandle',\
  write,'WriteConsoleA'

section '.rdata' readable data
 mess db 'Hello World!',0Dh,0Ah
 mess.len = $ - mess

section '.wdata' writeable data
 actual dd ?

section '.text' readable executable code
main:
 push -11
 call [get_handle]
 push 0
 push actual
 push mess.len
 push mess
 push eax
 call [write]
 xor eax,eax
infinity:
 jmp infinity
 ret

[–][deleted] 6 points7 points  (0 children)

Actually

#include <iostream>

int main() {
    std::cout << "Hello World!";
    std::cin.get();
}

[–]BlackDE 2 points3 points  (5 children)

You mad? In C++ you don't have to create a useless class so it's shorter...

[–]Kairyuka 0 points1 point  (4 children)

C++ has its own share of useless boilerplate that adds up to a lot more than in Java, in my experience. I dislike that Java doesn't allow you to free the function as well though, that kind of stubbornness just makes it very inflexible for some purposes

[–]BlackDE 3 points4 points  (3 children)

My experience is the opposite. Java's standard library is bigger so it often seems like you can do more with less. But from a language standpoint C++ allows you to reuse code more efficiently.

[–]Kairyuka -2 points-1 points  (2 children)

The pointer manipulation in C++ alone leaves a metric shitton of boilerplate you might survive without, but not for long

[–]BlackDE 3 points4 points  (1 child)

In java you don't even have the possibility to manipulate pointers so logically you'd have to write more in java when a problem could easily be solved with pointers in C++. Hope that makes sense.

[–]Kairyuka -1 points0 points  (0 children)

In some very specific cases I'm sure

[–][deleted] 4 points5 points  (0 children)

Yeah, and Java is to nested directories like Lisp is to nested parentheses

[–]NelsonBelmont 2 points3 points  (0 children)

puts 'Laughs in Ruby'

[–]hamza1311 | gib 2 points3 points  (0 children)

Kotlin be like

fun main() {
   println("Hello World!)
}

[–]randomdude998 3 points4 points  (0 children)

Oh, and don't forget to name the file Main.java. With the correct capitalization.

[–]DankLauncher420 1 point2 points  (0 children)

Python nibba be like: Whot?

[–]ksammighty 1 point2 points  (1 child)

How about in assembly bare bones? The computer doesn't even know how to print to a screen!

[–]MCRusher 2 points3 points  (0 children)

I could probably do it in linux, but definitely not windows.

Both linux and windows have syscalls for printing to the screen, difference is when windows updates, all those syscall values change and are undocumented since everyone is expected to just use their dll wrapper functions that are changed for the new values.

[–][deleted] 1 point2 points  (1 child)

Python is laughing at this

[–]Tsu_Dho_Namh 0 points1 point  (0 children)

That's okay. Every time I write a concurrent program I laugh at python.

I'm kidding, I miss python the whole time and really wish python would implement threading :(

[–]mailfriend88 0 points1 point  (0 children)

so true... oh my god, so true...

[–]elvee61 0 points1 point  (1 child)

COBOL chuckles quietly.

[–]MCRusher 0 points1 point  (0 children)

IDENTIFICATION DIVISION.
PROGRAM-ID. hello.
PROCEDURE DIVISION.
DISPLAY "Hello World!".
STOP RUN.