🚀 30 Dakikada MELP
Bu rehberde MELP programlama dilini sıfırdan öğrenecek, 7 adımda çalışan programlar yazacaksınız.
Adım 0: Kurulum (2 dk)
MELP binary'sini indirin ve PATH'e ekleyin:
# Linux x86-64
wget https://github.com/MELP-Lang/MELP/releases/latest/download/melp-linux-x64.tar.gz
tar xzf melp-linux-x64.tar.gz
export PATH="$PWD/melp/bin:$PATH"
export MELP_PATH="$PWD/melp"
# Test
melp_compiler --version
Bağımlılıklar: clang-22, libgmp-dev
Adım 1: Merhaba Dünya (3 dk)
İlk MELP programınız:
-- hello.mlp
numeric function main()
println("Merhaba MELP!")
return 0
end function
Derleme ve çalıştırma:
cp hello.mlp /tmp/.melp_compile_src
melp_compiler > hello.ll
clang-22 -O2 build/shim.o hello.ll -o hello -lm -lgmp
./hello
Merhaba MELP!
Adım 2: Değişkenler ve Döngüler (5 dk)
numeric function main()
numeric yas = 25
string isim = "Ali"
println(isim & " " & str(yas) & " yasinda")
-- 1'den 5'e say
numeric i = 1
loop i <= 5
println(str(i))
i = i + 1
end loop
-- Faktöriyel
println("5! = " & str(faktoriyel(5)))
return 0
end function
numeric function faktoriyel(numeric n)
if n <= 1 then return 1 end if
return n * faktoriyel(n - 1)
end function
Ali 25 yasinda
1
2
3
4
5
5! = 120
1
2
3
4
5
5! = 120
Adım 3: Dosya Okuma (5 dk)
numeric function main()
string icerik = mlp_fs_read_to_string("/etc/hostname")
println("Hostname: " & icerik)
return 0
end function
Hostname: pardus-81y4
💡
mlp_fs_read_to_string dosyayı okur, mlp_fs_write yazar.Adım 4: HTTP İsteği (5 dk)
numeric function main()
-- curl ile HTTP GET
string yanit = shell_exec("curl -s https://api.github.com/zen")
println("GitHub Zen: " & yanit)
return 0
end function
GitHub Zen: Avoid administrative distraction.
Adım 5: Struct + Enum (5 dk)
struct Point
numeric x
numeric y
end struct
enum Color
Red
Green
Blue
end enum
numeric function main()
Point p = Point(3; 4)
println("Point: (" & str(p.x) & ", " & str(p.y) & ")")
Color c = Color.Blue
println("Color enum: " & str(c))
return 0
end function
Point: (3, 4)
Color enum: 2
Color enum: 2
Adım 6: Web Sayfası (5 dk)
numeric function main()
string html = "<h1>MELP Web</h1><p>Merhaba dunya!</p>"
string yanit = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n" & html
string cmd = "echo '" & yanit & "' | nc -l -p 8888 -q 1 & sleep 1 && echo 'http://localhost:8888'"
numeric rc = shell_exec(cmd)
return 0
end function
http://localhost:8888
Sonraki Adımlar
- 📖 Showcase: Tüm özellikler — 10 demo dosyası
- 📋 MELP Dil Spesifikasyonu — Tam referans
- 🔧 IDE Eklentileri — VS Code, Electron
- 💬 Topluluk — GitHub Discussions, Discord
MELP — Sade. Scope-bazlı. Hızlı. 🚀