1. Kompailreo-reul al-aboja
Keompyuteoneun saram-ui eoneoreul ihaehaji mothamnida. Keompyuteoneun peurogeuraeming eoneo jochado ihaehaji mothamnida. Keompyuteoga ihaehaneun geon danjiman meosin kodeu-ro sseuyeo jin peurogeuraem—0wa 1lo i뤄jin kodeu—ppun-imnida. Banmyeon saram-eun dan-eo, idea, geurigo dang-yeonhi 0wa 1man-euro gadeukhan peurogeuraem jeonche-reul jageumjageum sseuneun geosi himdeupnida.
00100100eun 10jinsu
36 tto-neun munja
$reul uimi합니다
Geuraeseo Kotlin gateun peurogeuraeming eoneoga tteonaseumnida. Ireohan eoneodeul-eun iljong-ui “beonyeokgi” yeokhal-eul 합니다: ije peurogeuraemeoneun peuroseseo-ege gilyeojin myeongnyeong yeol-eul sseuneun geos-i anira, jagi-ga ihaehaneun eoneo-ro “Igeohae, jeogeoh-ae” gateun myeongnyeong-eul jeog-eul su itseumnida.
Hajiman han 가지 munjega itseumnida. Keompyuteoneun yeojeonhi Kotlin-eul ihaehaji mothamnida! Danjiman kodeu pail-eul deonjyeo jumyeon, eokkae-reul 으쓱하고 amugeotdo haji anh-eul geosimnida. Ireul wihan geosi baro kompailreo-imnida.
Kompailreo-ran?
Kompailreoneun kodeu-reul kompailhaneun teukbyeolhan peurogeuraem-imnida: Kotlin kodeu-reul keompyuteoga ihaehaneun kodeu-ro beonyeok합니다. Kotlinro sseuyeo jin texteu-reul gajigo, hae석하고, oryu-reul geomsa-hago, 가상 meosin JVMeul wihan biteu kodeu-ro bakkupnida.
flowchart TD
A[📝 Kotlin code] --> B[Compiler]
B --> C{Are there errors?}
C -->|Yes ❌| H[Error message. Go back to code]
H --> A
C -->|No ✅| I[⚙️ Bytecode generation]
I --> J[JVM bytecode]
J --> K[JVM virtual machine]
K --> L[Program execution]
style A fill:#7B68EE,color:#fff
style B fill:#FF8C00,color:#fff
style J fill:#20B2AA,color:#fff
style K fill:#3CB371,color:#fff
style L fill:#3CB371,color:#fff
style H fill:#DC143C,color:#fff
Kompailreo-reul kkang-kanghan seonsaengnim-euro saenggaghalsu itseumnida. Geu seonsaengnim-eun:
- munjangeul jageumjageum geomsa-hago (sil-su haji anh-assna?),
- gyuchig-eul jikigeumyeo (ye: olbareun byeonsu ireum, gwalho, tipeu…),
- geurigo nan hu-e ya keompyuteowa “myeonjeop”hal su itge haejumnida!
Kompailreo-ga eopseossdamyeon, peurogeuraem jagseongeun Morse code-ro “War and Peace”reul sseuneun geotcheoreom 느껴졌을 geosimnida.
Kompailreo-neun deo ttokttokhada
Jigeum Kotlin kompailreo-neun deo ttokttokhaejyeoseo—danjiman beonyeokman 하는 게 아니라 kodeu-reul 최적화hago, oryu-reul alryeojugo, eotteohge sseumyeon deo joheulji kkaji jo-eonhagi-do 합니다. Geu oe-edo aju manhseumnida.
JVMwi-eseo dongjakhaneun Kotlin (jeung, ilbanjeog consol app / backend on JVM) eun bo통 ireohge jinhaengdoemnida:
- cheot beonjjae dan-gye-eseo Kotlin kodeu-neun teukbyeolhan jung-gan hyeongtae-in JVM bytecodero byeonhwan-doemnida.
- geurigo silhaeng sigan-e JVM(virtual machine) i ge bytecode-reul CPU-ui jin짜 meosin myeongnyeong-euro beonyeok하며 (meosin-e ttaraseo 다르게 최적화halsu itsseumnida).
- Kotlin eoneo peurogeuraem
-
Kotlin compiler
- teukbyeolhan kodeu(de: bytecode)ro guseongdoen peurogeuraem
-
Java VM
- meosin kodeuro guseongdoen peurogeuraem
Man약 dangsin-ui CPU-ga deo manh-eun meosin myeongnyeong set-eul jiwonhaneun “joheun” CPU라면, i beonyeok/choejeokhwa gwajeong-eseo JVM-i OSwa CPU-ui gangjeom-eul sal린 meosin kodeu-reul saengseonghalsu itsseumnida. Geuraeseo JVM eoneo( Kotlin 포 함 )ro sseuyeo jin peurogeuraem-i eotteon task-eseoneun aju 빠를 su도 itseumnida.
JVM man-i 아니다
Cheoeum-e Kotlin-eun gibonjeog-euro JVMeul wihan eoneo(jeung “Javacheoreom, hajiman deo pyeonlihage”)ro mandeul-eojeotseumnida. Geuraeseo orae dong-an gibon sinario-neun ireon geos-ieotseumnida: Kotlin code → JVM bytecode → execution on JVM.
Hajiman najung-e Kotlin-eun dareun “compilation mode”(dareun silhaeng sinario)do gajige doeeotseumnida:
- Kotlin/JVM — gajang jeontongjeog-in hyeongtae: console, server, Android(bubunjeog), modu JVM segye.
- Kotlin/JS — browser tto-neun Node.jsreul wihan JavaScript-ro compilation.
- Kotlin/Native — native meosin kodeu-ro compilation (ye: iOS, macOS, Windows, Linux).
- Kotlin Multiplatform — ilbu kodeu-neun gongtong, ilbu-neun platform uijon-jeog-in gujo-ro, han peurojekteu-reul yeoreo target-eul wihan 빌드가 가능하게 하는 접근.
Haendulleun gateumnida: compilero-ga Kotlin code-reul gajigo, target platform-i “ihae”hal su itneun hyeongtae—JVM, browser(JS), tto-neun native OS—ro bakkupnida.
2. Compilation si jar주 mannaneun oryu
Jigeum-eun kodeu 속도나 최적화ga gajang jungyohan geon anijiman, jungyohan geon kompailreo-ga dangsin-ui peurogeuraem-e seo bug(oryu)-reul geomsa-handa-neun 점입니다. Kompailreo-neun kodeu-ui 타당성-eul geomsa-hago, jageun silsuboda-do oryu-reul chat-eumyeon 다음 단계로 neomeogaji 못하게 합니다.
Oryu 예시:
Munja열 man dam-eul su itneun byeonsu-e sulja(reul) dae입haryeo 합니다.
val userName: String = 42 // Oops! You can’t do that.
Kompailreo-neun ngayong-eul bogo band드시 tipeu ga 맞지 않는다-neun oryu-reul naepnida(ye): Type mismatch: inferred type is Int but String was expected.
Dareun 예si-neun println myeongnyeong-e seo typing mistake-reul nae-neun geos입니다:
printline("Hello!") // Error in function name
Kompailreo-neun da-eum-gwa gateun sik-euro 말할 geosimnida: “Geureon ham-su-neun eopse니 munbeob-eul hwaginhae!” (ye: Unresolved reference: printline).
Oryu-reul eotteohge 읽을까?
Dae부분-ui compilero-neun oryu-ga eodi-seo nanjeung-inji code-eseo wichi-reul alryeojugo, ttaeron su-jeong 방안-eul 제안하기도 합니다. Oryu-reul duryeowohaji maseyo: oryu han geon han geon-i “gaed-u”reul wihan han georeum-i고, nae면-ui “boss”reul kkaeneun 과정입니다.
3. Comments
Jageum, sangsanghaeboseyo: dangsin-eun bok잡한 peurogeuraem-eul sseumnida. Modu jal dongjakhago, dangsin-eun 천재입니다! Hajiman han dal hu geu kodeu-reul yeoreobomyeon... amugeotdo ihaeha ji 못합니다. Yeogi-neun code du jul, jeogi-neun isanghan byeonsu hana. 머릿속엔 dan 하나: “Igeon bunmyeong nuga sseotji, na-neun aniya!” Ireul sal려jun geosi baro comment-imnida.
Commentsneun gyogwaseo yeobaek-e sseuneun memo, tto-neun 냉장고-e butyeodun 메모(“Beer. Don’t drink. For tomorrow morning!”)cheoreom입니다. Compiler-neun comments-reul 무시하지만, saram-eun 반대로 comments-reul bogo ihae합니다. Comments-neun code-ui 의도-reul seolmyeonghago, jungyohan 포인트-reul 표시하며, code-reul 지우지 않고도 ilg시적으로 “끄는” 데도 도움-i doemnida.
Important: compiler-neun dangsin-ui comments-reul ilgi anseumnida. comments-neun jeonbu 무시됩니다!
Single-line comments
Kotlin(geurigo Java)eseoneun comments-ga 두 가지: single-line gwa multi-line입니다. Single-line comment-neun double slash //ro sijakhago, 줄 끝까지 이어집니다. // 뒤-ui modeun geon comment로 ganju-doemyeo, kompailreo-e 의해 jeonbu 무시됩니다.
Example:
println("Hello, world!") // This prints a greeting to the screen
Yeogi-seo // This prints a greeting to the screen ga 바로 comment입니다. Code-reul bogo “Wae i 줄-i piryohaji?” ga halla면, ireon sik-euro 적으세요!
Another example:
val x = 42 // The programmer’s age value
Single-line comment-neun dok립된 줄에도 쓸 수 있습니다:
// Initialize a variable with the user name
val userName = "Vasya"
Sikeuha-ge-do scenario-ui 대사처럼, comment-ga “왜/무엇을” seolmyeonghae jumnida.
Multi-line comments
Man약 sseoya 할 게 manh-aseo 길게 적어야 한다면? Jinjja 긴 이야기라면? Geureol ttaeneun multi-line comment-reul 씁니다. /*로 sijakhago */로 kkeutnapsnida. I 기호 사이-ui modeun 내용-eun 여러 줄이어도 kompailreo-ga 무시합니다.
Example:
/*
Here we print the user name to the screen.
If the name is missing, we print "Guest".
*/
println("Please enter your name:")
Or like this:
var age = 18 /* Initial age value
for a new user */
Warning: multi-line comments 안에 multi-line comments를 중첩할 수는 없습니다. Compiler보다 “더 똑똑한 척”하려고 해도 안 통합니다.
Illustration:
| Type | Syntax | Example |
|---|---|---|
| Single-line | |
|
| Multi-line | |
|
4. Real-life examples
“Disabling” a line of code:
Gakkeum dangsin-eun eotteon code bun-reul ilg시적으로 silhaenghaji 않게 하고 싶-eul 때가 있습니다. I ttae comments-ga 딱입니다:
// println("Text that is temporarily not needed")
줄은 남아 있지만, compiler-neun geu 줄-eul “보지” 못합니다.
TODO and FIXME notes
Programmerdo saram입니다. Gakkeum “아직 덜 했다”geona “여기 bug 있다”reul 자기 자신-e게 알림haryeo hae야 합니다. Geureol ttae bo통 ireon geol sseumnida:
// TODO: add a check for empty input
// FIXME: this function calculates the sum incorrectly
Manh-eun editorwa IDE는 ireohan dan-eo-reul 따로 highlight하기도 합니다!
Programmers joke
// I am not responsible for this code. I was forced to write it against my will.
// Dear future me! Please forgive me for this code.
// If I see this again, I’ll have to start bringing a weapon to work.
// If this condition is ever met, please notify me at phone xxx-xxx-xxx for a reward.
// Dear programmer:
//
// When you finish "optimizing" this subroutine
// and realize what a huge mistake it was,
// please increment the counter below as a warning
// for the next guy:
//
// hours_wasted_here = 42
// When I started writing this, only God and I knew what I was doing.
// Now only God knows.
// Sometimes I think the compiler ignores all my comments.
// I dedicate all my code, all my work, to my wife Darlene,
// who will have to support me, our three children, and the dog,
// when this goes to production.
Yes, comments can be very funny—because they’re written by real people.
GO TO FULL VERSION