Skip to content

Instantly share code, notes, and snippets.

@lagenorhynque
Last active December 10, 2025 08:11
Show Gist options
  • Select an option

  • Save lagenorhynque/f85b4963501cfaac9d9638ea67076633 to your computer and use it in GitHub Desktop.

Select an option

Save lagenorhynque/f85b4963501cfaac9d9638ea67076633 to your computer and use it in GitHub Desktop.
🐬の推し本紹介2025: 『コーディングを支える技術 ―⁠―成り立ちから学ぶプログラミング作法』
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
slides:
charset: utf-8
theme: night
highlight_theme: monokai-sublime
separator_vertical: ^\s*----\s*$
revealjs:
transition: convex
plugins:
- extra_css:
- https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css

🐬の推し本紹介2025

『コーディングを支える技術
―⁠―成り立ちから学ぶプログラミング作法』


x icon

  • 法学部出身のITエンジニア

  • イルカ🐬が好き

  • プログラミング、語学、法学、数学が好き


🐬が新人プログラマによく推薦する技術書

Technologies Underpinning Coding Seven Languages in Seven Weeks The Art of Readable Code The Productive Programmer

Technologies Underpinning Coding


🐬<「成り立ちから学ぶ」とは


2種類の比較の視点

  • 共時的(synchronique)/同時代的な「横」の比較

    • 英語 vs フランス語
    • 日本法 vs アメリカ法
  • 通時的(diachronique)/歴史的な「縦」の比較

    • 古代の日本語 vs 現代の日本語
    • 近世の法令 vs 現代の法令

synchronique vs diachronique: 言語学者フェルディナン・ド・ソシュールによる区別


例: 自然言語(英語)を通時的に探る

The Introduction to the History of English


人間が目的のために生み出したツールについて、

共時/通時的な比較から類似点や相違点を探り、

「なぜ」そのように設計されているのか学ぶことで、

効果的な活用/応用や発展の可能性が見えてくる。


この本の構成

  1. 言語を深く効率的に学ぶには

  2. プログラミング言語を俯瞰する

  3. 文法の誕生

  4. 処理の流れのコントロール

  5. 関数

  6. エラー処理


  1. 名前とスコープ

  2. コンテナと文字列

  3. 並行処理

  4. オブジェクトとクラス

  5. 継承によるコードの再利用


内容紹介: プログラムでの数式表現

書籍「第3章 文法の誕生」より


数学での数式

例えば、

1 + 2 × 3

中置記法(infix notation)と呼ばれる


これは通常、

1 + (2 × 3)

を意味する。


1. 現代の多くのプログラミング言語の場合

1 + 2 * 3

と書くと

1 + (2 * 3)

の意味で扱われる。

演算子 + よりも * のほうが優先順位が高い、というルール(文法)が言語処理系に組み込まれているため。


ツリー🎄形式で図示すると

abstract syntax tree

抽象構文木(abstract syntax tree, AST)と呼ばれ、
パーサー(parser, 構文解析器)によりコードから変換して得られる表現


2. FORTHという古い言語(1950年代〜)の場合

1 2 3 * +

後置記法(postfix notation), 逆ポーランド記法(reverse Polish notation)と呼ばれる

  • 演算子の優先順位のルールは不要

  • 括弧は不要
    (演算子ごとに受け付ける被演算子(operand)の個数が決まっていて曖昧さがないため)


FORTH on browserで数式を評価してみると

> 1 2 3 * + .  (数式。ここで . は結果を取り出す操作)
7              (評価結果)

スタック(stack)というデータ構造を用いて

calculation using stack

と計算することができる。

スタックマシン(stack machine)と呼ばれ、
現代のプログラミング言語の処理系でも使われることがある仕組み


3. LISPという(同じく)古い言語の場合

(+ 1 (* 2 3))

前置記法(prefix notation), ポーランド記法(Polish notation)と呼ばれる

  • 演算子の優先順位のルールは不要

  • 括弧は省略できない
    (演算子ごとに受け付ける被演算子の個数が不定なため)


LISP on browserで数式を評価してみると

> (+ 1 (* 2 3))  ; 数式
7                ; 評価結果

多くのプログラミング言語での関数呼び出しの記法

add(1, multiply(2, 3))

と同等であり、抽象構文木(AST)に素直に対応する。

abstract syntax tree

※ プログラムのコード表現と抽象構文木が近いため、
コードのプログラム的な変換(構文マクロ(syntactic macro))が容易に実現できる


これらの例では、文法を考える際に

  • ルールを設けず機械的に扱いやすくする

  • ルールを加えて人間に分かりやすくする

という設計判断の違いがあることが見えてくる。


Further Reading

#!/usr/bin/env bash
# pip install mkslides
open http://localhost:8000 \
&& mkslides serve *.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment