What language even is that? It allows multiline function parameters without backslashes, so itās not Python, but it uses print, meaning it isnāt JavaScript, and pretty much everything else requires a semicolon.
It's python indeed. (Could also be GDscript) I am not breaking the string, but simply splitting the line. if this was an ini, it would look very natural to you.
Semicolons in Java are used to end a line. The reason youāre probably confused about the semicolon thing is that semicolons donāt end bodies of code. When creating a Java class, you give the Java class modifier (public here), specify youāre making a class, then the class name (HelloWorld), upon class creation, you need a class body, which is made by the swirly brackets ({}), any code thats written in these brackets are part of the class, but in Java syntax, bodies are never ended with a semicolon. Thatās why the print line statement ends with a semicolon colon (mandatory), but the class body itself and the function body donāt end with a semicolon. Basically, semicolons only end lines of code, not bodies of code (same for if statements and stuff)
Edit: Sorry, mb, I thought you were talking about the commenter who wrote the Java class HelloWorld, and not the above commenter who wrote print(āhello worldā). Then yes, to answer your question, it is python. Whoops! Misunderstood!
This. No compilation needed as for e.g. the Ruby example. These work as well in just one line: clj -M -e '(print "Hello World")' perl -E 'say "Hello World"' ... the latter even on out-of-the-box macOS or Linux.
It's not just a style thing, string concatenation is much less performant, since it creates more object (e.g. "I'm " + name + "the builder" = "I'm Bob" + "the builder" = "I'm Bob the builder"), where f strings generate only the final string. "".join is also another way to concatenate strings performantly. Generally you should avoid direct string concatenation in any interpreted language
It's not white space dependent, so as long as you put a ; between statements, everything can be written on a single line. Include statements require their own line, but ultimately they're just injecting code from the other files. You can therefore, in theory, just process all the files in a c program into a single file and process the common directives out, making a giant ball of c code that can be written in one line.
newlines (and a lot of whitespace) are pretty much irrelevant in C (the only things that need their own lines are directives like #includes).
#include <stdio.h>
int main() {
printf("Hello world");
return 0;
}
is identical to
#include <stdio.h>
int main(){printf("Hello world");return 0;}
so with the caveat that you don't count preprocessor directives as part of the program (though you should), every program in C can be a 1-liner so long as the line is long enough.
Well I think it's because you don't actually need to add a new line. It's exclusively to make the code easier to read. I've seen people who didn't want others reading their code, so they intentionally removed the line breaks, and the code was simple a massive paragraph.
Most languages, C very much included, ignore stuff like spaces and newlines, those are only there for human readability. If you remove all of these from any C program, it will still behave just like before, except any human trying to read it will want to strangle you.
On top of that, C has an extensive ability to merge actual lines into one, only using a single semicolon at the end. Like:
Java is actually pretty intuitive, it's just really ugly there because it's such a short program and all in one line, so like 70% of that is the stuff to start putting down commands.
Come to think of it, years ago I did some native Android programming, so that was Java. It was ok. I fumbled my way through it, but never got confident with it. I only did a few small projects.
I'm at the point in my career where I need to learn a new language, and Java/Android was my first choice, up until I started playing with Python. I think Python is the route I'm going to go down.
Depends on your definition of code. Wouldn't make sense to only classify binary as code if the switches convert it to a flow of electricity, but I'm sure we all agree that electricity isn't a language
I mean... in some languages it is! Even in C it's technically one line of code, the rest is just boilerplate. Sometimes this one line could be... cout (i'm still can't get over how fcd up it is)Ā
185
u/TalesGameStudio Mar 14 '26
93
u/C04511234 Mar 15 '26
120
u/qwertty164 Mar 14 '26
It can be depending on the language. Though that might not be the most useful way to do it.
36
u/XIII-TheBlackCat Mar 15 '26 •
These days though.
16
u/Henry_Fleischer Mar 14 '26
puts "Hello World"It's one line in Ruby
12
u/xcski_paul Mar 15 '26
In Java, first you have to instantiate an AbstractHelloFactoryImpl in order to generate a Hello class.
24
u/GhostVlvin Mar 14 '26
Only one line in java
5
u/dizzywig2000 Mar 15 '26
10 PRINT āHELLO, WORLD!ā
5
u/Glad_Share_7533 Mar 15 '26
8
u/MinecraftPlayer799 Mar 15 '26
It is. That joke makes no sense.
4
u/DapperCow15 Mar 15 '26
This would make sense in the assembly sub, but not here.
3
u/[deleted] Mar 14 '26
Msgbox("Hello World") ez
3
u/Living_The_Dream75 Mar 15 '26
System.out.println(āHello World!ā); One line of code
3
u/GloblSentence_totoro Mar 15 '26
Console.WriteLine("Hello World!");
cout << "Hello World!";
3
u/KaleidoscopeSalt3972 Mar 15 '26
Everything is translated to machine code.... So nothing is one line of code
2
u/ByteBandit007 Mar 15 '26
Now he wants to learn DSA
2
u/PolyPenguinDev Mar 15 '26
it is one line what are you talking about
public class Main{public static void main(String[] args {System.out.println(āHello, worldā);}}
2
u/EvnClaire Mar 14 '26
println!("Hello world!")
2
u/Zukas_Lurker Mar 15 '26
hello_worl("print")
1
u/Spiritual_Detail7624 Mar 15 '26
Depends if you count macros expanded or not.
1
u/Jacked_Nerd_musafir Mar 15 '26
Python š
1
u/Convoke_ Mar 15 '26
I dont remember the name og the language, but there is one where an empty file prints hello world
1
u/linuswanberg Mar 15 '26
1cent
1
u/nitnelav153 Mar 15 '26
1
u/rayanlasaussice Mar 15 '26
Actually 492 files and 34262 lignes rn
1
u/admiral_nivak Mar 15 '26
10 PRINT āHello World!ā
1
u/JackyYT083 Mar 15 '26
print(āHello, world!ā)
1
u/Furry_Eskimo Mar 15 '26
-but,, but it is?
Python/Ruby: print("Hello, World!")
JavaScript: console.log("Hello, World!");
C++: std::cout << "Hello, World!";
C#: Console.WriteLine("Hello, World!");
Java: System.out.println("Hello, World!");
HTML: <h1>Hello, World!</h1>
Lua: print("Hello, World!")
1
u/[deleted] Mar 15 '26
Say it with me java devs publicš staticš void šmainš stringš argsš system šout šprintlnšhello world
1
u/classicblox Mar 15 '26
Print = ("Hello World")
That actually should do the job in python.
1
u/epilektoi Mar 15 '26
machine code
1
u/AdMurky5620 Mar 15 '26
System.out.println(āHello World!ā);
1
u/kusti4202 Mar 16 '26
now take a look at the bytecode it generates
1
u/thisisnotchicken Mar 16 '26
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
1
u/PrestigiousAd3576 Mar 16 '26
Brainfuck. It's one line.
1
u/Lemenus Mar 16 '26
I mean... in some languages it is! Even in C it's technically one line of code, the rest is just boilerplate. Sometimes this one line could be... cout (i'm still can't get over how fcd up it is)Ā
1
u/Maximum-Rub-8913 Mar 17 '26
python 101 for you
1
u/Maximum-Rub-8913 Mar 17 '26
In python this takes 1 line of code. In C this takes 100 lines of code. In firmware it takes 483289 resistors and 3334345 transistors
1
u/iEngrMoeen Mar 17 '26
cout<<"same old boring message"
1
u/Intelligent_Comb_338 Mar 17 '26
On bash:
echo "hello world" // printf "hello world\n"
On python:
print("hello world")
On C: printf("hello world\n");
(I know these "programs" are incomplete) But in bash only are 2 lines (on python too)
!/bin/bash
echo "hello world"
Or
echo "hello world"
sh hello.sh
1
u/WriedGuy Mar 17 '26
alert print puts console
1
u/Otherwise-Cup-6030 Mar 17 '26
Everything can be one line of code if you are brave enough
1
u/colandline Mar 17 '26
In reality, he mad cuz he forgot to save, and had to type it again.
1
u/Comprehensive_Gas147 Mar 18 '26
BEGIN
10 PRINT 'HELLO WORLD'
END
1
u/corvak Mar 19 '26
Depending on how your language uses white space lots of things can be āone line of codeā
1
u/thecratedigger_25 Mar 21 '26
Console.WriteLine("Hello World");
You can basically get away with this in C#. Don't know about Java, though.
1
u/linuswanberg Mar 26 '26
1cent