Scala 시작하기
Scala 환경을 살펴보고 개발 도구를 설정한 다음 JVM에서 첫 Scala 애플리케이션을 실행합니다.
Scala 시작하기은(는) CoddyKit의 무료 Scala for Backend Engineering & Functional Programming 강의입니다. 이것은 3개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Scala for Backend Engineering & Functional Programming 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Scala for Backend Engineering & Functional Programming 강의에는 총 3개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Welcome to Scala!
Welcome to Scala! It's a powerful programming language that combines both Object-Oriented (OO) and Functional Programming (FP) concepts. This makes it incredibly versatile.
Scala runs on the Java Virtual Machine (JVM), meaning it can interact seamlessly with Java code and leverage the vast Java ecosystem.
Why Choose Scala?
Scala offers several advantages:
- Concise Code: Often requires less boilerplate than Java.
- Powerful Features: Supports advanced functional programming patterns.
- Concurrency: Excellent for building robust, concurrent systems.
- Industry Use: Used by companies like Twitter, LinkedIn, and Netflix for scalable backend services.
The JVM: Scala's Engine
At its core, Scala code compiles to bytecode, which then runs on the Java Virtual Machine (JVM). This is the same runtime environment used by Java.
To run Scala, you'll need the Java Development Kit (JDK) installed on your machine. It includes the JVM and necessary tools.
Introducing SBT
For managing Scala projects, the standard tool is SBT (Scala Build Tool).
SBT handles everything from compiling your code and running tests to managing external libraries (dependencies) and packaging your application. It's your primary command-line interface for Scala projects.
Creating a New Project
Let's create our first Scala project using SBT. We'll use a g8 template, which is like a project boilerplate.
Open your terminal and run this command:
sbt new scala/scala-seed.g8 --name my-first-scala-appProject Structure Unpacked
After creating the project, you'll see a structure like this:
my-first-scala-app/-
build.sbt(SBT configuration) -
project/(SBT internal files) -
src/ -
main/ -
scala/(Your Scala source files go here!) -
Main.scala(Your first file) -
target/(Compiled code, etc.)
Your First Scala Code
Navigate into your new project directory: cd my-first-scala-app.
Now, let's write our classic "Hello, CoddyKit!" program in src/main/scala/Main.scala. Try running it!
object Main {
def main(args: Array[String]): Unit = {
println("Hello, CoddyKit!")
}
}Running Your Application
With the code saved, use SBT to compile and run your program. Make sure you are in your project's root directory (my-first-scala-app).
sbt runThe Scala REPL
Scala also has an interactive shell called the REPL (Read-Eval-Print Loop). It's great for quickly testing code snippets without creating a full project.
To start the REPL from your project, type sbt console. Then you can type Scala expressions directly:
scala> val message = "Hello from REPL"
message: String = Hello from REPL
scala> 1 + 2 * 3
res0: Int = 7Quick Check: Running Scala
You've written your first Scala program and know about SBT. Which command would you use to compile and execute a Scala application within an SBT project?
Recap & Next Steps
Great job! In this lesson, you've taken your first steps with Scala:
- You learned Scala runs on the JVM and requires the JDK.
- You discovered SBT as the essential build tool.
- You created a new project and understood its basic structure.
- You wrote and ran your very first Scala "Hello, CoddyKit!" program.
- You explored the interactive Scala REPL.
Next, we'll dive deeper into Scala's basic syntax and core data types!
자주 묻는 질문
“Scala 시작하기” 강의는 무료인가요?
네 — “Scala 시작하기” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Scala for Backend Engineering & Functional Programming 강의 전체를 잠금 해제할 수 있습니다. Scala for Backend Engineering & Functional Programming 강의에는 총 3개의 강의가 포함되어 있습니다.
“Scala 시작하기”에서 뭘 배우나요?
Scala 환경을 살펴보고 개발 도구를 설정한 다음 JVM에서 첫 Scala 애플리케이션을 실행합니다. 브라우저에서 직접 실행하는 실습 코드로 Scala for Backend Engineering & Functional Programming을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Scala for Backend Engineering & Functional Programming을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Scala for Backend Engineering & Functional Programming은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 3개 중 1번째 강의입니다.
“Scala 시작하기” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Scala for Backend Engineering & Functional Programming 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Scala for Backend Engineering & Functional Programming 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.