Programming is a highly sought-after skill in today’s digital world. Whether you’re looking to start a new career or simply expand your existing skillset, learning to code is an excellent way to open up new opportunities. One of the simplest, yet most impactful, programs you can write as a beginner is “Hello World”. This program serves as an introduction to the basic syntax and structure of a programming language.

Advertisement

In this comprehensive guide, we will show you how to print “Hello World” in 20 of the most popular programming languages. This will provide you with a foundational understanding of how different programming languages approach the task of printing a simple message on the screen. So, get ready to dive into the world of coding and let’s get started!

Printing 'Hello World' in 20 Programming Languages

  1. Python

    Python uses the print() method to print a string on the console. The string must be enclosed under double quotes.

    
    print("Hello World")
    
    
  2. Java

    In Java, the System.out.println() method is used to print content on the output console. This method prints the string and moves the cursor to a new line.

    
    public class HelloWorld {
        public static void main(String[] args) {
            System.out.println("Hello World");
        }
    }
    
    
  3. C Programming

    In the C programming language, the printf() function is used to print values on the output console.

    
    #include
    
    int main() {
        printf("Hello World");
        return 0;
    }
    
    
  4. C++ Programming

    C++ uses std::cout along with the stream insertion operator << for output operations. std::endl is used to insert a new line.

    
    #include
    
    int main() {
        std::cout 
    
  5. Ruby

    Ruby uses the puts method to output text with a newline at the end.

    
    puts "Hello World"
    
    
  6. PHP

    PHP uses the echo statement to output one or more strings.

    
    <?php
        echo "Hello World";
    ?>
    
    
  7. JavaScript

    JavaScript uses console.log() to print messages to the web console.

    
    console.log("Hello World");
    
    
  8. Swift

    Swift uses the print() function to write the textual representation of the given items to the standard output.

    
    print("Hello World")
    
    
  9. Go Programming

    Go uses the fmt.Println() function from the fmt package to print lines.

    
    package main
    
    import "fmt"
    
    func main() {
        fmt.Println("Hello World")
    }
    
    
  10. Kotlin

    Kotlin uses the println() function for printing a line to the standard output.

    
    fun main(args: Array) {
        println("Hello World")
    }
    
    
  11. R Programming

    R uses the cat() function to concatenate and print.

    
    cat("Hello World")
    
    
  12. Perl Programming

    Perl uses the print function to output text. The newline character \n is used to move to the next line.

    
    print "Hello World\n";
    
    
  13. Scala

    Scala uses the println() method, similar to Java, for printing lines.

    
    object HelloWorld {
        def main(args: Array[String]) {
            println("Hello World")
        }
    }
    
    
  14. Objective-C

    Objective-C uses NSLog() for logging, which is similar to printf() but adds some extra information like timestamp and log level.

    
    #import 
    
    int main (int argc, const char * argv[]) {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        NSLog (@"Hello World");
        [pool drain];
        return 0;
    }
    
    
  15. Shell Scripting

    Shell scripting uses the echo command to output text to the terminal.

    
    echo "Hello World"
    
    
  16. Assembly (x86) Programming

    Assembly language for x86 processors uses a combination of system calls to write text to the console and to exit a program.

    
    section .data
        msg db 'Hello World',0
    
    section .text
        global _start
    
    _start:
        ; write(1, msg, 12)
        mov eax, 4
        mov ebx, 1
        mov ecx, msg
        mov edx, 12
        int 0x80
    
        ; exit(0)
        mov eax, 1
        xor ebx, ebx
        int 0x80
    
    
  17. SQL Statement

    In SQL, you can use the SELECT statement to output a string.

    
    SELECT 'Hello World';
    
    
  18. Rust Programming

    Rust uses the println!() macro for printing to the console.

    
    fn main() {
        println!("Hello World");
    }
    
    
  19. TypeScript

    TypeScript, being a superset of JavaScript, uses console.log() for printing messages to the console.

    
    console.log("Hello World");
    
    
  20. Lua Programming

    Lua uses the print() function to send text to the standard output.

    
    print("Hello World")
    
    

Conclusion

In conclusion, "Hello World" is a simple yet powerful program that helps beginners understand the basic syntax and structure of a new programming language. By printing "Hello World" in 20 popular programming languages, we hope to provide a comprehensive guide to help those new to the program understand how the syntax and structure of a program can vary between languages. Whether you are just starting out or looking to expand your skills, this guide serves as a valuable resource to help you get started. Regardless of the language you choose, the most important aspect is to keep practicing and building on your skills. Happy coding!

Share.
Leave A Reply


Exit mobile version