Programming paradigms
도입됨
13:52
프로그래밍 패러다임
여기에 한 가지 과제가 있습니다: A 등급을 받은 모든 학생을 나열하십시오. 한 프로그래머는 루프를 작성합니다 — 첫 번째 레코드에서 시작하여, 등급을 확인하고, 이름을 목록에 추가하고, 이동…
영어 내레이션 · 영어와 중국어 자막 전환 가능
이 수업의 내용
| English | 의미 |
|---|---|
| loop/luːp/ | A structure that repeats a sequence of instructions. |
| array/əˈreɪ/ | An indexed collection of elements arranged in one or more dimensions. |
| filter/ˈfɪltə/ | A function that selects items from a collection using a given condition. |
| state/steɪt/ | The saved information needed to continue a program from its current point. |
| rule/ruːl/ | A logic-program statement deriving a conclusion when its conditions hold. |
| SQL/ˌes kjuː ˈel/ | Structured Query Language, used to define, query and manipulate data in relational databases. |
| index/ˈɪndeks/ | A position marker or lookup structure used to locate data within a collection or database. |
| cores/kɔːz/ | Independent processing units within a processor that can execute instructions. |
| paradigm/ˈpærədaɪm/ | 패러다임 |
| low-level/ləʊ ˈlevl/ | 저수준 |
| imperative/ɪmˈperətɪv/ | 명령형 |
| declarative/dɪˈklærətɪv/ | 선언형 |
| hardware/ˈhɑːdweə/ | The physical parts of a computer system that can be touched. |
| machine code/məˈʃiːn kəʊd/ | Instructions encoded in binary form that a processor can execute directly. |
| assembly language/əˈsemblɪ ˈlæŋɡwɪdʒ/ | A low-level programming language using symbolic names for machine instructions and their operands. |
| direct/daɪˈrekt/ | An addressing method where the instruction contains the memory address of the data. |
| registers/ˈredʒɪstəz/ | A small, fast storage location within a processor used to hold data, addresses or instructions temporarily. |
| memory addresses/ˈmeməri əˈdresɪz/ | Identifiers of locations in an addressable memory space, used to access stored instructions or data. |
| instructions/ɪnˈstrʌkʃnz/ | Commands that tell a computer what actions to perform. |
| memory/ˈmeməri/ | The part of a computer that holds data and programs currently in use. |
| processor/ˈprəʊsesə/ | The component that executes instructions and performs the operations of a computer or similar system. |
| device drivers/dɪˈvaɪs ˈdraɪvəz/ | Programs that allow an operating system to control hardware devices. |
| firmware/ˈfɜːmweə/ | Software stored in a device to control its hardware and basic operation. |
| embedded controllers | Computers built into larger devices to control their operation. |
| real-time system | A system that must respond to events within a required time. |
| immediate/ɪˈmiːdɪət/ | An addressing method where the data value is part of the instruction. |
| indirect/ɪndaɪˈrekt/ | An addressing method where the given address holds the address of the data. |
| indexed/ˈɪndekst/ | An addressing method that adds an index value to an address to find the data. |
| relative addressing/ˈrelətɪv əˈdresɪŋ/ | An addressing mode that adds an offset to the program counter. |
| operand/ˈɒpərænd/ | A value, register or memory location that an instruction operates on. |
| procedural/prəˈsiːdʒərəl/ | Describes programming that uses a sequence of commands to change program state. |
| sequence/ˈsiːkwəns/ | A set of things arranged in a particular order. |
| commands | Instructions that tell a computer or program to perform actions. |
| assignments | Statements that give values to variables in a program. |
| conditionals | Statements that choose which actions to perform based on a condition. |
| procedures | Named sets of instructions that perform tasks when called. |
| variables/ˈveərɪəblz/ | A quantity or named value that can change or take different values. |
| pseudocode/ˈsuːdəʊkəʊd/ | A language-independent description of an algorithm using structured, programming-like statements. |
| runtime | The software environment that manages and carries out a program while it runs. |
| Functional/ˈfʌŋkʃənl/ | Describes programming that builds results by combining functions. |
| pure functions/pjʊə ˈfʌŋkʃnz/ | 순수 함수 |
| side effects/saɪd ɪˈfekts/ | Observable effects beyond a routine's returned value, such as modifying an argument, changing shared state or writing output. |
| Logic/ˈlɒdʒɪk/ | Describes programming that uses facts and rules to answer questions. |
| facts/fækts/ | Statements treated as true within a logic program. |
| engine | Software that uses facts and rules to work out answers to queries. |
| inference/ˈɪnfərəns/ | The use of a trained model to make a prediction from new input. |
| query/ˈkwɪərɪ/ | A request to retrieve or manipulate information, especially data in a database. |
| rows | Horizontal lines in a table, each containing one record. |
| database/ˈdeɪtəbeɪs/ | An organised collection of data that can be accessed and managed. |
| memory locations | Places in memory where data is stored, each identified by an address. |
| data transformation | The process of changing data from one form into another. |
| parallel/ˈpærəlel/ | Describing operations that take place concurrently rather than one after another. |
| cached | Stored for a time so that it can be used again quickly. |
| global variable/ˈɡləʊbl ˈveərɪəbl/ | A variable declared outside a routine's local scope and accessible wherever the language's program or module scope rules permit. |
| bugs/bʌɡz/ | Mistakes in software that can make it work incorrectly. |
같은 프로그램을 네 가지 방식으로 작성함
- 영국에 거주하는 모든 고객을 요청하면 C 프로그래머는 배열을 순회하는 루프를 작성합니다. Haskell 프로그래머는 필터를 작성합니다. Prolog 프로그래머는 규칙을 정의하고 질문을 던집니다. SQL 사용자는
SELECT * FROM Customer WHERE Country = 'UK'를 작성합니다. - 첫 번째만 어떻게 하는지를 말합니다. 나머지는 원하는 결과를 말하고 '어떻게'를 기계에 맡겨, 작업을 재배열하거나 인덱스를 사용하거나 여덟 개의 코어로 실행할 수 있게 합니다.
- 일반적으로 어느 쪽이 더 나쁘거나 나은 것은 아닙니다. 다른 점은 언어가 당신에게서 어떤 결정을 빼앗느냐이며, 이것이 바로 패러다임의 의미입니다.
- 이 수업에서 다루는 패러다임은 커리큘럼에서 언급하는 저수준, 명령형 및 선언형입니다.

저수준 프로그래밍
- 저수준 프로그래밍은 하드웨어 근처에서 작동하며, 기계어 또는 어셈블리 언어로 레지스터, 메모리 주소 및 개별 명령어에 직접 접근합니다.
- 장점: 최대 제어권과 속도, 그리고 가능한 한 작은 코드 크기를 제공하여, 메모리가 키로바이트 수준일 때 중요합니다.
- 단점: 아키텍처 의존적이라 다른 프로세서를 위해 다시 작성해야 하며, 작성 속도가 느리고 유지보수가 어렵습니다.
- 하드웨어를 정확히 제어해야 하는 곳에서 사용됩니다: 장치 드라이버, 펌웨어, 임베디드 컨트롤러, 실시간 시스템의 가장 안쪽 루프 등.
- 어셈블리 언어 수업에서 즉시, 직접, 간접, 인덱싱 및 상대 주소를 연습하십시오. 해당worked trace는 동일한 피연산자가 서로 다른 결과를 낳는 이유를 보여줍니다.

Which are true of low-level programming? Select 모든 that apply.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Control is bought with effort: assembly is slow to write and hard to maintain, which is why it is confined to drivers and firmware.
명령형 프로그래밍
- 명령형 프로그래밍은 프로시저형이라고도 하며, 프로그램 상태를 변경하는 명령의 연속입니다: 할당, 조건부, 루프 및 프로시저 호출 등이 포함됩니다.
- 프로그래머가 어떻게 결과를 계산할지를 단계별로 명시합니다. 상태를 저장하는 변수들이 핵심입니다.
- Python, C, Java 및 가짜코드의 스타일이며, 거의 모든 사람이 처음 배우는 방식입니다.

명령이 하나씩 이어지며, 각각 저장된 값이 바뀌기 때문입니다

Imperative (procedural) programming is based on:
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Imperative code gives step-by-step commands (assignments, loops, calls) that change state.
선언형 프로그래밍
- 선언형 프로그래밍은 무엇을 계산할지를 말하지, 어떻게 할지를 말하지 않습니다. 런타임이 단계를 파악합니다.
- 함수형 프로그래밍은 순수 함수를 조합합니다. 순수 함수에는 부수 효과가 없으며, 동일한 입력은 항상 동일한 출력을 생성하고 함수 외부의anything가 변하지 않습니다. Haskell과 Lisp가 그 예입니다.
- 논리 프로그래밍은 사실과 규칙을 명시하고, 엔진이 추론을 통해 질문에 답합니다. Prolog가 그 예입니다.
- SQL은 거의 모두가 접한 선언형 언어입니다. 쿼리는 원하는 행을 지정하고 데이터베이스가 어떻게 찾을지 결정합니다.
Programming concept lab
Connect examples to the programming idea they show.
Declarative programming means you specify:
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Declarative code (functional, logic, SQL) states the goal; the runtime decides the steps.
A pure function (functional programming):
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Purity means no side effects and a deterministic result, which makes functional code easy to reason about.
Declarative paradigms (functional, logic, SQL) state WHAT to compute and let the runtime decide how, whereas imperative code spells out every step.
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
A SQL query says which rows you want, not how to scan the tables — the opposite of step-by-step imperative code.
A pure function always gives the same output for the same input and has no ____.
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
That is what lets it be tested in isolation, run in parallel safely and have its result cached.
worked example: 패러다임을 식별하기
FOR i ← 1 TO n : total ← total + A[i] : NEXT i— 명령형:total에 저장된 상태를 변경하는 명령어의 서열입니다.SELECT Name FROM Customer WHERE Country = 'UK'— 선언형: 어떤 행이 필요함을 명시할 뿐, 이를 검색하기 위한 구체적인 절차를 설명하지 않습니다.LDD 200 : ADD 201 : STO 202— 저수준: 메모리 위치를 직접 지칭하는 어셈블리 명령어입니다.parent(X, Y) :- father(X, Y).— 선언형, 구체적으로는 논리 프로그래밍: 엔진이 답을 추론하는 규칙입니다.- 패러다임을 이름으로 말하고, 이를 보여주는 코드의 특성을 설명하십시오.
Match each fragment to its paradigm.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Commands changing state, a statement of what is wanted, instructions addressing memory, and a rule for inference.
비교하기
| 패러다임 | 말함 | 강점 | 일반적인 용도 |
|---|---|---|---|
| 저수준 | 정확한 명령 | 제어, 속도, 크기 | 드라이버, 펌웨어 |
| 명령형 | 어떻게, 단계별로 | 직접적이고 친숙함 | 일반 프로그래밍 |
| 선언형 | 원하는 것 | 간결함, 런타임 최적화 | 쿼리, 규칙, 데이터 변환 |
- 현대 언어들은 혼합합니다. Python은 명령형이지만 함수형 특징을 가지고 있으며, SQL은 명령형으로 작성된 프로그램 내부에 위치합니다. 패러다임은 스타일이지 벽이 아닙니다.
Match each paradigm to its core idea.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Imperative says how step by step; OO models objects; functional uses pure functions; declarative states the goal.
What is the essential difference between imperative and declarative programming?
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Because the declarative version does not fix the how, the runtime may reorder the work, use an index or parallelise it.
worked example: 부수 효과의 중요성
- 순수 함수는 부수 효과가 없습니다. 하나의 장점을 설명하십시오.
- 동일한 입력은 항상 동일한 출력을 생성하고 외부 anything가 변하지 않으므로, 순수 함수는 격리되어 테스트될 수 있습니다: 초기화 없이 숨겨진 상태를 설정할 필요도 없습니다.
- 두 번의 호출이 서로 간섭할 수 없으므로 병렬로 안전하게 실행할 수 있으며, 결과를 캐시할 수도 있습니다.
- 대비: 전역 변수를 업데이트하는 명령형 routine은 이전에 실행된 내용에 따라 differently하게 동작하므로, 이러한 버그를 찾기 어렵게 만드는 원인이 됩니다.

놓칠 수 있는 점
- 명령형은 어떻게를 말하고, 선언형은 무엇을 말합니다. 이 대비가 여기서의 대부분의 질문에 대한 답입니다.
- 저수준 언어의 단점은 "오래된" 것이 아니라 아키텍처에 종속적이며 유지보수가 어렵다는 점입니다.
- 순수 함수는 부수 효과가 없고 동일한 입력에 동일한 출력을 제공합니다. 양쪽 부분이 모두 필요합니다.
- SQL은 선언형입니다. 시험에서 가장 자주 사용하는 예시이므로 이를 인지하십시오.
이해했습니다
- 패러다임은 코드를 구조화하는 스타일이며, 현대 언어들은 여러 개를 혼합합니다
- 저수준: 기계어 또는 어셈블리, 직접 하드웨어 접근, 최대 제어권과 속도, 하지만 아키텍처 의존적이고 유지보수가 어려움
- 명령형: 상태를 변경하는 명령어의 서열, 어떻게를 명시; Python, C 및 가짜코드의 스타일
- 선언형: 원하는 무엇을 명시하고 '어떻게'를 런타임에 맡김, 함수형 프로그래밍의 순수 함수, 논리 프로그래밍의 사실과 규칙, 그리고 SQL과 같이
어떤 문제가 있었나요? 사이트 팀만 이 내용을 볼 수 있습니다.