Concurrency, compilers, functional programming and advanced CS concepts!
1. What is a "semaphore" in concurrent programming?
💡 A semaphore is a signaling mechanism with a counter controlling how many threads can access a resource simultaneously.
2. What is "currying" in functional programming?
💡 Currying transforms f(a,b,c) into f(a)(b)(c) — each call returns a new function taking the next argument.
3. What is "software entropy"?
💡 Software entropy describes how code becomes increasingly disordered and difficult to maintain over time without deliberate refactoring.
4. What is a "race condition" in concurrent programming?
💡 A race condition occurs when two or more threads access shared data concurrently and the outcome depends on the order of execution.
5. What is "register allocation" in compiler design?
💡 Register allocation assigns frequently-used variables to CPU registers (fast) rather than main memory (slow) during compilation.
6. What is "garbage collection" in programming?
💡 Garbage collection automatically frees memory occupied by objects that are no longer referenced by the program.
7. What is "tail recursion"?
💡 Tail recursion places the recursive call as the last operation, allowing compilers to reuse the stack frame and prevent overflow.
8. What is "functional programming"?
💡 Functional programming treats functions as first-class citizens and avoids mutable state and side effects.
9. What is "just-in-time (JIT) compilation"?
💡 JIT compilation compiles frequently-executed code paths to native machine code at runtime, combining benefits of compilation and interpretation.
10. What is "lazy evaluation"?
💡 Lazy evaluation delays computation until the result is needed, improving performance by avoiding unnecessary calculations.
11. What is the difference between a process and a thread?
💡 A process is an independent program with its own memory. Threads are lightweight units within a process sharing the same memory.
12. What is "ABI" in computer science?
💡 ABI (Application Binary Interface) defines low-level conventions for binary code interaction: calling conventions, data layouts, system calls.
13. What is "lexical scoping" in programming languages?
💡 Lexical (static) scoping means a variable's scope is determined by its position in the source code, not where it is called.
14. What is "monadic" programming?
💡 Monads are a design pattern in functional programming for composing operations that involve side effects (IO, state, exceptions) in a clean way.
15. What is "type inference" in programming languages?
💡 Type inference allows a compiler to automatically determine the type of a variable without explicit annotation (e.g., var in Kotlin).
16. What is "polymorphic dispatch" in OOP?
💡 Polymorphic dispatch selects the appropriate method implementation at runtime based on the actual (dynamic) type of the object.
17. What is "continuation-passing style" (CPS)?
💡 CPS passes the rest of the computation as a function (continuation). Asynchronous callback-based code follows CPS principles.
18. What is a "pure function" in functional programming?
💡 A pure function always produces the same output given the same input and has no observable side effects.
19. What does "immutability" mean in programming?
💡 Immutable objects cannot be modified after creation. A new object must be created to represent any change.
20. What is a "deadlock" in concurrent programming?
💡 Deadlock occurs when two or more threads each hold a resource the other needs, causing all to wait forever.