プログラミング言語アイコン & サンプルコード集

このページでは、当ブログで対応している様々なプログラミング言語のアイコンとシンプルなサンプルコードを紹介します。全て基本的な「Hello World」スタイルで、各言語の特徴を簡潔に表現しています。

フロントエンド言語

JavaScript

app.js
// Hello World in JavaScript
console.log("Hello, World!");

// 関数の例
function greet(name) {
return `Hello, ${name}!`;
}

greet("JavaScript");

TypeScript

types.ts
// Hello World in TypeScript
interface Greeting {
message: string;
language: string;
}

const greeting: Greeting = {
message: "Hello, World!",
language: "TypeScript"
};

console.log(greeting.message);

React (JSX)

HelloWorld.jsx
// Hello World in React
import React from 'react';

function HelloWorld() {
return (
<div>
<h1>Hello, React World!</h1>
<p>Welcome to React development!</p>
</div>
);
}

export default HelloWorld;

React (TSX)

App.tsx
// Hello World in React with TypeScript
import React from 'react';

interface Props {
name: string;
}

const HelloWorld: React.FC<Props> = ({ name }) => {
return (
<div>
<h1>Hello, {name}!</h1>
<p>TypeScript + React = ❤️</p>
</div>
);
};

export default HelloWorld;

マークアップ & スタイル

HTML

index.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello World</title>
</head>
<body>
<h1>Hello, HTML World!</h1>
<p>Welcome to web development!</p>
</body>
</html>

CSS

style.css
/* Hello World Styling */
body {
font-family: 'Arial', sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
text-align: center;
padding: 50px;
}

.hello-world {
font-size: 2rem;
margin: 20px 0;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

バックエンド言語

Python

main.py
# Hello World in Python
def hello_world():
"""Simple hello world function"""
message = "Hello, World!"
return message

# Main execution
if __name__ == "__main__":
print(hello_world())
print("Welcome to Python! 🐍")

Java

HelloWorld.java
// Hello World in Java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
System.out.println("Welcome to Java!");

// Create a greeting
String greeting = createGreeting("Java Developer");
System.out.println(greeting);
}

public static String createGreeting(String name) {
return "Hello, " + name + "!";
}
}

C

main.c
// Hello World in C
#include <stdio.h>
#include <stdlib.h>

int main() {
printf("Hello, World!\n");
printf("Welcome to C programming!\n");

// Simple calculation
int a = 10, b = 20;
printf("Sum: %d + %d = %d\n", a, b, a + b);

return 0;
}

C++

main.cpp
// Hello World in C++
#include <iostream>
#include <string>

class Greeter {
private:
std::string message;

public:
Greeter(const std::string& msg) : message(msg) {}

void greet() const {
std::cout << message << std::endl;
}
};

int main() {
Greeter hello("Hello, C++ World!");
hello.greet();

std::cout << "Welcome to modern C++!" << std::endl;
return 0;
}

Rust

main.rs
// Hello World in Rust
fn main() {
println!("Hello, World!");
println!("Welcome to Rust! 🦀");

// Simple function
let greeting = create_greeting("Rustacean");
println!("{}", greeting);
}

fn create_greeting(name: &str) -> String {
format!("Hello, {}! Safe and fast programming awaits!", name)
}

Go

main.go
// Hello World in Go
package main

import (
"fmt"
)

func main() {
fmt.Println("Hello, World!")
fmt.Println("Welcome to Go! 🐹")

// Simple function call
greeting := createGreeting("Gopher")
fmt.Println(greeting)
}

func createGreeting(name string) string {
return fmt.Sprintf("Hello, %s! Let's build something awesome!", name)
}

PHP

index.php
<?php
// Hello World in PHP

function createGreeting($name) {
return "Hello, " . $name . "!";
}

// Main execution
echo "Hello, World!\n";
echo "Welcome to PHP! 🐘\n";

$greeting = createGreeting("PHP Developer");
echo $greeting . "\n";

// Simple array example
$languages = ["PHP", "JavaScript", "Python"];
echo "Supported languages: " . implode(", ", $languages) . "\n";
?>

Node.js

server.js
// Hello World in Node.js
const fs = require('fs');
const path = require('path');

function greetUser(name) {
return `Hello, ${name}! Welcome to Node.js! 🟢`;
}

// Main execution
console.log("Hello, World!");
console.log(greetUser("Node Developer"));

// Simple file operation
const message = "Hello from Node.js!";
console.log(message);

Lua

hello.lua
-- Hello World in Lua
print("Hello, World!")
print("Welcome to Lua! 🌙")

-- Simple function
function createGreeting(name)
return "Hello, " .. name .. "! Lua is lightweight and powerful!"
end

-- Call the function
local greeting = createGreeting("Lua Developer")
print(greeting)

-- Simple table example
local languages = {"Lua", "JavaScript", "Python"}
print("Languages: " .. table.concat(languages, ", "))

スクリプト & シェル

Bash/Shell

hello.sh
#!/bin/bash
# Hello World in Bash

echo "Hello, World!"
echo "Welcome to Bash scripting! 🐚"

# Simple function
create_greeting() {
local name=$1
echo "Hello, $name! Let's automate everything!"
}

# Call the function
greeting=$(create_greeting "Shell Scripter")
echo "$greeting"

# Simple variable example
languages=("Bash" "Zsh" "Fish")
echo "Shell languages: ${languages[*]}"

データ & 設定

JSON

config.json
{
"message": "Hello, World!",
"language": "JSON",
"description": "JavaScript Object Notation",
"features": [
"Lightweight",
"Human readable",
"Language independent"
],
"example": {
"greeting": "Hello, JSON World!",
"emoji": "📄",
"isAwesome": true
}
}

YAML

config.yml
# Hello World in YAML
message: "Hello, World!"
language: "YAML"
description: "YAML Ain't Markup Language"

greeting:
text: "Hello, YAML World!"
emoji: "📝"
isAwesome: true

features:
- Human readable
- Configuration files
- Data serialization

examples:
simple: "Hello, YAML!"
complex:
nested:
value: "YAML supports deep nesting"

SQL

queries.sql
-- Hello World in SQL
SELECT 'Hello, World!' as greeting;

-- Create a simple table
CREATE TABLE greetings (
id INT PRIMARY KEY,
message VARCHAR(100),
language VARCHAR(50)
);

-- Insert data
INSERT INTO greetings VALUES
(1, 'Hello, SQL World!', 'SQL'),
(2, 'Welcome to databases!', 'SQL'),
(3, 'Data is powerful! 🗃️', 'SQL');

-- Query data
SELECT
message,
language,
'Database magic!' as note
FROM greetings
WHERE id <= 3;

ドキュメント

Markdown

README.md
# Hello World in Markdown

Welcome to **Markdown**! This is a *lightweight* markup language.

## Features

- Easy to write
- Easy to read
- Widely supported

## Code Example

Here's a simple code snippet:
console.log("Hello from Markdown!");

## Lists

### Programming Languages
1. JavaScript
2. Python
3. Rust
4. Go

### Why Markdown?
- Simple syntax
- Great for documentation
- Supported everywhere

> Markdown makes writing for the web fast and easy! 📝

まとめ

このサンプルコード集では、多様なプログラミング言語とその特徴を簡潔に紹介しました。各言語には独自の強みと用途があります:

  • JavaScript/TypeScript: Web開発の中核
  • Python: データサイエンスとAI
  • Rust: システムプログラミングと安全性
  • Go: クラウドとマイクロサービス
  • C/C++: システムレベルとパフォーマンス
  • Bash: 自動化とシステム管理

どの言語も「Hello World」から始まりますが、それぞれが異なる世界への扉を開いてくれます。あなたの次のプロジェクトではどの言語を選びますか? 🚀

言語名のみ指定の例

ファイル名を指定しない場合は、左上にアイコン + 言語名が表示されます:

JavaScript(言語のみ)

JavaScript
// シンプルな変数と出力
const message = "Hello, JavaScript!";
console.log(message);

Python(言語のみ)

Python
# リスト内包表記の例
numbers = [1, 2, 3, 4, 5]
squares = [x**2 for x in numbers]
print(squares)

CSS(言語のみ)

CSS
/* シンプルなボタンスタイル */
.button {
background-color: #3b82f6;
color: white;
padding: 0.5rem 1rem;
border-radius: 0.375rem;
border: none;
cursor: pointer;
}