İlk main İşleviniz
En basit Zig programının yapısı.
İlk main İşleviniz, CoddyKit'te ücretsiz bir Zig Academy dersidir. Bu, 4 dersinin 2. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Zig Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Zig Academy kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Where Programs Begin
Every Zig executable starts at a function named main. The compiler looks for it and runs it first when your program launches. 🚀
Import the Standard Library
Most programs begin by pulling in tools. You bind the standard library to a name using @import, a built-in that loads a module.
const std = @import("std");Built-ins Start with @
Names beginning with @, like @import, are compiler built-ins. They are part of the language itself, not normal library functions.
Declaring main
You define main with the fn keyword. The simplest version takes no arguments and returns void, meaning it hands back no value.
pub fn main() void {
// your code runs here
}Why pub Matters
The pub keyword makes main visible outside its file so the runtime can call it. Without pub, the program cannot find an entry point.
void Means No Return
The void return type says main produces nothing. Many real programs instead return an error union so they can report failures.
The Function Body
Code inside the curly braces is the body. Statements there run top to bottom, exactly in the order you write them.
Add a First Statement
Inside main you can call functions. Here a single print statement greets the world from the standard library.
pub fn main() void {
std.debug.print("Hi from Zig!\n", .{});
}Statements End with Semicolons
Each statement finishes with a semicolon. Zig is precise about this, which keeps the boundaries between statements crystal clear.
Comments for Humans
Lines starting with two slashes are comments. Zig ignores them entirely, so use them to explain intent to future readers.
// This is a comment, ignored by the compiler
const answer = 42;The Whole First Program
Putting it together gives a complete, minimal Zig program: one import and one main function that prints a line.
const std = @import("std");
pub fn main() void {
std.debug.print("Hello!\n", .{});
}Quick Check
Look at a minimal Zig program. Which keyword exposes main so the program can actually start?
Recap
A Zig program starts at main: import std, declare pub fn main() void, and fill the body with statements that run in order. 🎯
Sıkça Sorulan Sorular
“İlk main İşleviniz” dersi ücretsiz mi?
Evet — “İlk main İşleviniz” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Zig Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Zig Academy kursu toplamda 4 dersten oluşur.
“İlk main İşleviniz” dersinde ne öğreneceğim?
En basit Zig programının yapısı. Zig Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Zig Academy öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Zig Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 2. dersidir.
“İlk main İşleviniz” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Zig Academy dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Zig Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Zig'i Her Platforma Kurma
- İlk main İşleviniz
- std.debug.print ile Yazdırma
- Tek Adımda Derleyip Çalıştırma