[카테고리:] Programming

  • Is Remix.js a framework or a library?

    A framework provides a complete structure and set of conventions to build an application.

    Remix.js is a Framework because:

    1. Routing and File-Based Structure

      • Uses a file-based routing system
      • Provides nested routes, layout routing, and error boundaries as core concepts.

      2. Data Handling

      • Has a build-in data loader system via loader() and action() functions, which lets you manage server-side rendering and from submissions declaratively.

      3. Full Stack Capabilities

      • Remix.js is full stack: it manages both frontend and backend logic (including fetching, mutations, and authentication).
      • Can be deployed on many backends: Express, Vercel, Cloudflare Workers, etc.

      4. Build-in Optimization

      • Provides intelligence resource preloading, streaming and caching out-of-the-box.

      5. Opinionated Project Structure

      • Remix.js dictates how your app should be structured (e.g., /routes, /app), which is a sign of a framework, not just a resuable library.

      Summary:

      • Remix.js is a framework – specifically a modern, full-stack, React-based web framework designed for performance and developer experence.
    1. 이제부터 에러는 무섭지 않다! AutoHotkey v2로 예외 다루기

      개발을 하다 보면 피할 수 없는 존재, 바로 ‘에러(Exception)’입니다. 하지만 에러가 난다고 두려워할 필요는 없습니다. AutoHotkey v2에서는 예외 처리가 간단하면서도 강력하게 개선되었습니다. 이번 글에서는 AutoHotkey v2의 예외 처리 방법을 명쾌하게 정리하여, 여러분의 자동화 스크립트가 더욱 견고해지도록 도와드리겠습니다.

      1. 간결하고 직관적인 try-catch 문법

      AutoHotkey v2에서는 try-catch 구조를 활용하여 손쉽게 예외를 처리할 수 있습니다.

      Bash
      try {
          FileRead("없는파일.txt")
      }
      catch as e {
          MsgBox("에러 발생: " e.Message " (" e.Line "번째 줄)")
      }
      Bash

      2. 에러의 모든 정보를 담고 있는 Exception 객체

      발생한 에러를 더욱 깊이 이해할 수 있는 Exception 객체의 유용한 속성을 살펴보세요.

      • e.Message: 에러 설명
      • e.What: 실패한 명령어
      • e.File: 에러 발생 파일
      • e.Line: 에러가 발생한 줄 번호
      Bash
      try {
          value := ObjGet("invalid.file")
      }
      catch as e {
          MsgBox("에러 메시지: " e.Message
                 "\n명령어: " e.What
                 "\n파일: " e.File
                 "\n줄 번호: " e.Line)
      }
      Bash

      3. 나만의 예외 직접 던지기

      커스텀 예외를 정의해 더욱 명확한 코드 작성이 가능합니다.

      Bash
      try {
          Throw Error("내가 정의한 커스텀 에러입니다!", -1, "상세한 추가 정보")
      }
      catch as e {
          MsgBox("예외 발생: " e.Message "\n추가 정보: " e.Extra)
      }
      Bash

      4. 놓치지 않고 실행하는 finally

      에러 발생 여부와 관계없이 꼭 수행해야 하는 작업을 finally에서 처리하세요.

      Bash
      try {
          result := 1 / 0
      }
      catch as e {
          MsgBox("예외: " e.Message)
      }
      finally {
          MsgBox("finally 블록은 항상 실행됩니다!")
      }
      Bash

      마무리하며

      예외 처리를 잘 활용하면 자동화 작업의 안정성이 크게 높아집니다. AutoHotkey v2의 예외 처리 방식을 마스터하여, 예측 불가능한 상황에도 당황하지 않고 멋지게 대응해 보세요!

    2. CMake Quick Guide (with docker compose)

      1. 개요

      CMake는 C/C++ 등 여러 프로그래밍 언어로 작성된 프로젝트의 빌드 자동화 도구입니다. GNU Make나 Ninja 같은 하위 빌드 시스템의 설정 파일을 생성하는 메타 빌드 시스템(Meta Build System) 이라고 할 수 있습니다.

      2. CMake의 핵심 개념

      2.1. CMakeLists.txt

      • CMake 프로젝트는 이 파일을 중심으로 구성됩니다.
      • 빌드 설정, 소스 코드 목록, 컴파일 옵션 등을 명시합니다.

      2.2. 빌드 디렉토리 분리 (Out-of-source build)

      • 소스 코드와 빌드 결과물을 분리하여 관리 가능
      • 예:
      Bash
      mkdir build
      cd build
      cmake ..
      make
      Bash

      2.3. 다양한 플랫폼 지원

      • Windows, macOS, Linux 등에서 동일한 CMakeLists.txt로 빌드 구성 가능
      • Visual Studio, Makefile, Ninja 등 다양한 빌드 시스템을 지원

      3. 주요 명령어

      명령어설명
      cmake .현재 디렉토리의 CMakeLists.txt를 바탕으로 빌드 설정 생성
      cmake ..상위 디렉토리의 CMakeLists.txt를 사용해 빌드 설정 생성
      make생성된 Makefile로 실제 빌드 수행
      cmake --build .플랫폼 독립적 빌드 명령

      4. 주요 기능

      • install, test, configure_file 등 다양한 프로젝트 관리 기능 내장
      • find_package로 외부 라이브러리 탐색
      • target_link_libraries로 라이브러리 연결
      • option, if 등을 활용한 조건부 설정

      5. 예시 프로젝트 구조

      Bash
      MyCMakeWithDockerCompose/
      ├── app/
         ├── CMakeLists.txt
         └── hello-world.cpp
      └── docker-compose.yml
      Bash

      app/CMakeLists.txt:

      CMake
      cmake_minimum_required(VERSION 3.10)
      
      set(CMAKE_C_COMPILER "/usr/bin/gcc")
      set(CMAKE_CXX_COMPILER "/usr/bin/g++")
      
      project(HelloWorld)
      
      add_executable(HelloWorld hello-world.cpp)
      CMake

      app/hello-world.cpp:

      C++
      #include <iostream>
      
      int main() {
          std::cout << "Hello, World!" << std::endl;
          return 0;
      }
      C++

      docker-compose.yml:

      YAML
      services:
        hello-cmake:
          image: ubuntu:18.04
          container_name: hello-cmake
          volumes:
            - type: bind
              source: ./app
              target: /app
          working_dir: /app
          command: >
            bash -c "
              apt update &&
              apt install -y cmake build-essential &&
              mkdir -p build &&
              cd build &&
              cmake .. &&
              make
            "
      YAML

      6. 예시 프로젝트 빌드

      Bash
      root@centricone:~/MyCMakeWithDockerCompose# docker compose up
      [+] Running 1/1
        Container hello-cmake  Created
      Attaching to hello-cmake
      hello-cmake  | 
      
      ...... 생략 ......
      
      hello-cmake  | [100%] Linking CXX executable HelloWorld
      hello-cmake  | [100%] Built target HelloWorld
      hello-cmake exited with code 0
      root@centricone:~/MyCMakeWithDockerCompose# ls -l app/build/
      total 40
      -rw-r--r-- 1 root root 12200 May 19 02:14 CMakeCache.txt     
      drwxr-xr-x 5 root root  4096 May 19 02:15 CMakeFiles
      -rw-r--r-- 1 root root  1460 May 19 02:14 cmake_install.cmake
      -rwxr-xr-x 1 root root  8928 May 19 02:14 HelloWorld
      -rw-r--r-- 1 root root  4839 May 19 02:15 Makefile
      root@centricone:~/MyCMakeWithDockerCompose/app# ./build/HelloWorld 
      Hello, World!
      root@centricone:~/MyCMakeWithDockerCompose#
      Bash

      1: 도커 컨테이너 실행

      12: 빌드내용 확인을 위해 디렉터리 조회

      17: 빌드된 HelloWorld 바이너리

      7. CMake의 장점

      • 다양한 옵션 제공: 테스트, 설치, 패키징 등 통합 관리
      • 유지보수 용이: 큰 프로젝트에서도 구성 관리가 쉬움
      • 크로스 플랫폼: 다양한 OS 및 빌드 도구에 대응
      • 모듈화: 서브 디렉토리 단위 구성 가능