실행 환경: macOS IDE: VSCode + CodeRunner
C
hello_c.c
#include <stdio.h>
int main(void)
{
puts("안녕하세요, C입니다!");
return 0;
}
실행 명령어
gcc hello_c.c -o hello_c && ./hello_c
C++
hello_cpp.cpp
#include <iostream>
int main() {
std::cout << "안녕하세요, C++입니다!" << std::endl;
return 0;
}
실행 명령어
g++ hello_cpp.cpp -o hello_cpp && ./hello_cpp
C#
hello_csharp.cs
using System;
namespace GreetingApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("안녕하세요, C#입니다!");
}
}
}
실행 명령어
brew install scriptcs
scriptcs -script hello_csharp.cs
Go
hello_go.go
package main
import "fmt"
func main() {
fmt.Println("안녕하세요, Go입니다!")
}
실행 명령어
go run helloworld.go
JavaScript
hello_javascript.js
const message = "안녕하세요, JavaScript입니다!";
console.log(message);
실행 명령어
brew install node
node hello_javascript.js
Kotlin
hello_kotlin.kt
package com.example
fun greet() {
println("안녕하세요, Kotlin입니다!")
}
fun main() {
greet()
}
실행 명령어
brew install kotlin
kotlinc hello_kotlin.kt -include-runtime -d hello_kotlin.jar && java -jar hello_kotlin.jar
Lua
hello_lua.lua
local greeting = "안녕하세요, Lua입니다!"
print(greeting)
실행 명령어
lua hello_lua.lua
Perl
hello_perl.pl
#!/usr/bin/perl
my $greeting = "안녕하세요, Perl입니다!\n";
print $greeting;
실행 명령어
perl hello_perl.pl
PHP
hello_php.php
<?php
$message = "안녕하세요, PHP입니다!";
echo $message;
?>
실행 명령어
brew install php
php hello_php.php
Python3
hello_python3.py
def main():
message = "안녕하세요, Python3입니다!"
print(message)
if __name__ == "__main__":
main()
실행 명령어
python3 helloworld.py
Ruby
hello_ruby.rb
#!/usr/bin/env ruby
class Greeter
def self.hello
puts "안녕하세요, Ruby입니다!"
end
end
Greeter.hello
실행 명령어
ruby helloworld.rb
Rust
hello_rust.rs
fn main() {
let message = "안녕하세요, Rust입니다!";
println!("{}", message);
}
실행 명령어
rustc hello_rust.rs && ./hello_rust
Shell
hello_shell.sh
#!/bin/bash
MESSAGE="안녕하세요, Shell입니다!"
echo "$MESSAGE"
실행 명령어
sh hello_shell.sh
Swift
hello_swift.swift
import Foundation
struct Greeter {
static func greet() -> String {
return "안녕하세요, Swift입니다!"
}
}
print(Greeter.greet())
실행 명령어
swift hello_swift.swift
TypeScript
hello_typescript.ts
function greet(): void {
console.log("안녕하세요, TypeScript입니다!");
}
greet();
실행 명령어
npm install -g typescript
npm install -g ts-node
ts-node hello_typescript.ts
Java
HelloJava.java
public class HelloJava {
public static void main(String[] args) {
String message = "안녕하세요, Java입니다!";
System.out.println(message);
}
}
실행 명령어
javac HelloJava.java && java HelloJava