ときどきの雑記帖 RE* (新南口)
dark nebula
ノート
つい最近、別件で行った文房具店で見かけたノート。 ノート類はいろいろ探したり試したりしているのだけど、 今のところ決定版はなし(でもそれなりに満足している)。
リングの薄さを追求した新発想のリングノート「ソフィーチェノート」を発売します。 - 株式会社リヒトラブ
リングで綴じているノートなので360度(?)開くのも簡単で、 バッグなどに入れるときにもリングが邪魔にならない感じでいい感じ。 「バラせる」のは一度だけだけどそれはまあ。
お試しでサイズ違いを3冊ほど買ってみた。
しかし今回初めて見かけた気がするんだけど、 発売開始は一年近く前なんだよなあ。 なんで気がつかなかった?
用語@中国語
- プログラミング用語の中国語の漢字表記がカッコ良すぎるし初心者に優しいからもっとみんなに知ってほしい #Swift - Qiita
- [B! プログラミング] プログラミング用語の中国語の漢字表記がカッコ良すぎるし初心者に優しいからもっとみんなに知ってほしい - Qiita
- シニフィアンとシニフィエ - Wikipedia
レーザービームプリンターの中国語表記を初めて見たときはびっくりしたなあ(遠い目)
ちなみに「激光打印机」と書きます😄 >LBP
意味を訳したのと、音を当てはめたのと両方あるのがちょっと面倒だよね (まあカタカナ表記も音訳だろうし同じようなものか)
梨(南水)
年明けに行ったスーパーマーケットで 梨があるのを見つけてびっくり(本日2回目)。
ちょっと手が出なかった😓
30 Years of Ruby
RubyConfTH 2023 - Keynote: 30 Years of Ruby by Yukihiro “Matz” Matsumoto - YouTube
「Prolog」の話はどの辺に出てくるんだろう
牡蠣小屋
小田原に牡蠣小屋が出張オープン-「宮城県の牡蠣」1盛り660円に | マイナビニュース
以前千葉の方でやっていたのと同じところ(団体)かな。 小田原は気合い入れないといけない距離だ😓
Niklaus Wirth
世間一般的には「Pascalの人」というイメージが強いのだろうけど、 自分としてはPascalよりもModula-2が好き、というか印象に残っているなあ。 「未来を見た」のよModula-2に。当時(遠い目)。
Oberonは正直「よくわからなかった」けど、 あれがひとつの到達点だったんですかねえ…
- Pascal (programming language) - Wikipedia
- Modula - Wikipedia
- Modula-2 - Wikipedia
- Lilith (computer) - Wikipedia
- Oberon (programming language) - Wikipedia
We lost a titan of programming languages, programming methodology, software engineering and hardware design. Niklaus Wirth passed away on the first of January. We mourn a pioneer, colleague, mentor and friend.
— Bertrand Meyer (@Bertrand_Meyer) January 3, 2024
- Niklaus Wirth, laureate of the Turing Award and creator of the Pascal programming language, has passed away : r/programming
- Niklaus Wirth has died | Hacker News
- Niklaus Wirth, Inventor of Pascal, Dies At 89 - Slashdot
- RIP: Pascal Creator Niklaus Wirth | Hacker News
- Computer science pioneer Niklaus Wirth passes away : r/programming
- RIP: Software design pioneer Niklaus Wirth • The Register
- Niklaus Wirth, laureate of the Turing Award and creator of the Pascal programming language, has passed away : r/programming
- 【訃報】プログラミング言語「Pascal」の開発者ニクラウス・ヴィルト氏が89歳で死去、ソフトウェア設計のパイオニアとして複数のプログラミング言語を考案し1984年にチューリング賞を受賞 - GIGAZINE
- [B! 訃報] 【訃報】プログラミング言語「Pascal」の開発者ニクラウス・ヴィルト氏が89歳で死去
なんでModula-2じゃなくてModulaなんだ>GIGAZINE
ところでWirth先生といえばこの論文、今はPaywallの向こうに行っちゃったんだろうか…
- Niklaus Wirth’s “Good Ideas, Through the Looking Glass” is an interesting read o… | Hacker News
- [PDF] Good ideas, through the looking glass [computing history] | Semantic Scholar
- Wirth - Good Ideas, Through the Looking Glass 2005 (extract) · GitHub
新刊近刊
Resourceful Code Reuse by Dmitry Zinoviev @aqsaqal
— PragmaticProgrammers (@pragprog) January 4, 2024
Reusing well-written, well-debugged, and well-tested code improves productivity, code quality, and software configurability and relieves pressure on software developers.https://t.co/rBVrYsYEom pic.twitter.com/JhbQynPUdU
気になってこの本のページ Resourceful Code Reuse: Write → Compile → Link → Run by Dmitry Zinoviev を見てみたけど
Pages: 64
Published: April 2021
ほぼ3年前の本だった。 ページ数も少な目だけど 何度か同じような本をPragProgで見たような記憶がある。
ストレンジコード
ストレンジコード(仮) Ronald T. Kneusel(著/文) - 秀和システム | 版元ドットコム
ひょっとして? と思ったらやはり Strange Code | No Starch Press の翻訳本のようだ。
Amazonで著者について調べると 他にも結構書いている人だった。 「この本もこの人だったのか」 というのもあったり。
Amazon.co.jp: Ronald T. Kneusel: books, biography, latest update
cout and operator«
俺C++のHello Worldで
— 山田ハヤオ (@Hayao0819) January 3, 2024
・coutは何者
・<<ってどういう意味
・なんで関数じゃなくてシフト演算子のオーバーロードなんだ
ということに囚われてしまいC++挫折した思い出がある https://t.co/jsZlUvLUZk
演算子オーバーロードってのは理解できたんだけど、それを使ってる理由とストリームがなんとかみたいな話は結局理解できないままだった
— 山田ハヤオ (@Hayao0819) January 3, 2024
私もいまだに「なんで関数じゃなくてシフト演算子のオーバーロード」なのか分かんないんですが、これってどういう理由なんでしょう?可変長引数が嫌だったとか? https://t.co/Fd3UipxDCk
— ikk (@ikk30179331) January 4, 2024
そういった疑問を持つのは不思議ではないと思うし、 気持ちはわからんでもないけど、 なぜそうしたかはすぽすっぽセンセイ() は書いていたはず (なので調べてほしかった😄 けど、「古文書」にあたれというのも無理筋か)
で、いろいろコメントされている (このポストの引用 / X) けどその辺りに言及したものが見当たらないので以下略。
そう言えばtnozakiさんが以前
Cの場合はどんなに理不尽と思える仕様があっても、それには必ず何らかの歴史的理由があるということだ。
のようなことを言っていた(書いていた)なあ。などと (元サイトがなくなっているので自分のところからの引用でスマン) 思い出しながら、 手元には初期のC++本なんかはもうないし(処分してしまった) そもそも物理本をめくって探すのも面倒(ry ということでテキトーなキーワード (もちろん英文) で検索したらそれらしいのが見つかった のでいくつか紹介(という名目の転載)。
c++ - Why are bitwise shifts (« and ») used for cout and cin? - Stack Overflow
According to §8.3.1 of The Design and Evolution of C++:
The idea of providing an output operator rather than a named output function was suggested by Doug McIlroy by analogy with the I/O redirection operators in the UNIX shell (>, », |, etc.)
[…]
Several operators were considered for input and output operations: the assignment operator was a candidate for both input and output, but it binds the wrong way. That is cout=a=b would be interpreted as cout=(a=b), and most people seemed to prefer the input operator to be different from the output operator. The operators < and > were tried, but the meanings “less than” and “greater than” were so firmly implanted in people’s minds that the new I/O statements were for all practical purposes unreadable (this does not appear to be the case for « and »). Apart from that, ‘<’ is just above ‘,’ on most keyboards, and people were writing expressions like this:
cout < x , y, z;
It is not easy to give good error messages for this.
From “The C++ Programming language”. Stroustrup’s(language authors) words:
Overloading the operator « to mean “put to” gives a better notation and lets the programmer output a sequence of objects in a single statement.
But why «? It is not possible to invent a new lexical token. The assignment operator was a candidate for both input and output, but most people seemed to prefer to use different operators for input and output. Furthermore, = binds the wrong way; that is, cout=a=b means cout=(a=b) rather than (cout=a)=b . I tried the operators < and >, but the mean “less than” and “greater than” were so firmly implanted in people’s minds that the new I/O statements were for all practical purposes unreadable.
ひとつめの
According to §8.3.1 of The Design and Evolution of C++:
は Design and Evolution of C++, The | Stroustrup, Bjarne | Language で、その翻訳本はこれ C++の設計と進化 | Bjarne Stroustrup, ビョーン ストラウストラップ, επιστημη, επιστημη, 岩谷 宏
ふたつめの
From “The C++ Programming language”. Stroustrup’s(language authors) words:
は第4版まであるんだけど、新しい方には載っていない気がするなあ(未確認)
- プログラミング言語C++ (アジソン ウエスレイ・トッパン情報科学シリーズ) | B. ストラウストラップ, 信男, 斎藤
- プログラミング言語C++ (アジソン ウェスレイ・トッパン情報科学シリーズ) | ビョーン ストラウストラップ, Stroustrup,Bjarne
- プログラミング言語C++ 第3版 (アスキーアジソンウェスレイシリーズ) | Bjarne Stroustrup, 高弘, 長尾
- プログラミング言語C++ 第4版 | ビャーネ・ストラウストラップ, Bjarne Stroustrup, 柴田 望洋
四つの版で全部訳者(陣)が違ってたのか。 今まで気が付かなかった。
あとは C++(プラスプラス)入門―次世代C言語によるプログラミングの実際 (FINE SOFTシリーズ) | 足立 高徳 あたりにもなにか関連情報があるかもしれない(ので任せた)
そのほかそれっぽいものを
The reason they picked operator« is that it looks like arrows pointing to the left, which makes sense because the thing on the right is written/outputted to the thing on the left.
The key decisions was to separate formatting from buffering, and to use the type-safe expression syntax (relying on operators « and »). I made these decisions after discussions with my colleague Doug McIlroy at AT&T Bell Labs. I chose « and » after experiments showed alternatives, such as < and >, comma, and = not to work well. - Stroustrup
We can think of many reasons why « and » were eventually chosen:
a. As Peter87 pointed out, looks like arrows pointing to the left
b. Also, as pointed pout, symmetric with respect to input and output « and »
c. Not very commonly used as a built-in; with stm < i ’less than’ may be what comes to mind immediately.
d. Left-associative; so we can write stm « i « j ;
e. Has reasonably low precedence; so we can write stm « i + j ;
‘printf’ vs. ‘cout’ in C++ - Stack Overflow
From the C++ FAQ:
[15.1] Why should I use
instead of the traditional ? Increase type safety, reduce errors, allow extensibility, and provide inheritability.
5.3.1 The Stream I/O Library
C’s printf family of functions is an effective and often convenient I/O mechanism. It is not, however, type safe or extensible to user−defined types (classes). Consequently, I started looking for a type safe, terse, extensible, and efficient alternative to the printf family.
7.3 What Was The Biggest Mistake?
- Input/output via
and
, C++ FAQ - Stroustrup: FAQ
- せんせいが “びゃーね・すぽっすぽっ” と呼ばれる理由 - keshimogus dagbog
- C++のiostreamの«を導入したのはストラウストラップ - Arantium Maestum
string.format
関連して、printfのような書式指定を使った文字列化の関数って Javaのアレが最初なんですかねと思いながらいくつか調べた。 Javaのprintlnも最初からしばらく(だいぶ?)は「アレ」でしたよねえ。 そういった事情もあるので、C++の「あれ」を今の視点であれこれ あげつらうのは「後出し孔明(事後諸葛亮)」じゃないのかねえ と思わなくもない。
What’s the difference between String.format() and str.formatted() in Java? - Stack Overflow
public static String format(String format, Object... args)
It’s introduced in Java SE 5 [since 2004].
public String formatted(Object... args)
It’s introduced in Java SE 15 (JDK 15) [since 2020].
String Format versus String Interpolation in .NET | by Moritz Kross | Medium
String.Format method and the newer string interpolation feature introduced in C# 6.0.
Python | formatメソッドを使った文字列の書式設定
Python 2.6 から文字列型に format メソッドが追加され、書式化演算子 % を使用するよりもより高機能な書式設定が行えるようになりました。
stream
あと、cout にどうやってformatかませるのか知りたい。
— そうは、い観世音菩薩@GPT (@iruka3) January 4, 2024
一旦std::format()って書くのはなしで。
これは
この辺の話ですかね。
このように、C++でも、printfファミリでできることが iostreamのマニピュレータを利用することで実現できます。 使いにくいと思われるかもしれませんが、慣れるまでの辛抱です。
そうかなあ😓
iomanipの「カラクリ」は理解できた気にならなかったな(笑)
初めて見たときはまだC++にテンプレートが入ってなくて、 プリプロセッサーを駆使した代物だった(はず) というのも大きいと思うけど。
いや、テンプレート駆使したものもわからんか😓
C++
ABI
せっかくなのでしばらく出し損ねていたものも
人類はC ABIの上に文明を築いているのでC ABIとして提供されたものは何からでも使えるけど、C++ ABIはそうはなってないのでC++で実装したものをCで実装したものようには使えないというのは何から使うかにほぼよらない事実(´・ω・`)
— てらモス🌻 (@termoshtt) August 26, 2023
Rust と C言語の相性は抜群であるにもかかわらず、C++との相性は案外悪いなと感じています。
— Ryuji Fuchikami (@Ryuz88) August 26, 2023
bindgen とかいろいろあるにはありますが、やはりC++のクラスライブラリ的なものをRustから使うのは少し面倒ですね。
なんでC++ってあんなに他の言語から呼び出しづらいんや。結局C APIを見せるグルーコードを生成して互換性のあるバージョンのC++コンパイラでコンパイルするぐらいしかないやんか。まあC++どうしてもなんか古いライブラリのリンク失敗するんやが。
— Hideyuki Tanaka (@tanakh) August 26, 2023
thisの絡みで色々面倒があったんだよねえ… ほかの言語から使いにくいのもその辺に理由(のひとつ)があるんじゃないかなあ。 しかしBeOSってABIがC++を考慮したものとかC++で書きやすいとか 聞いたことがあるような記憶があるんだけど 実際のところどうだったんだろう
拡張子
.cpp にするか .cc にするか .c++ にするか .cxx にするか .C にするかの基準はファイル作ってる時の指先の気分としか……ごめんなさい嘘です .cpp にしたことしかありません (既存プロジェクトが別のルールだったときを除く)。
— yoh2 (@yoh2_sdj) July 13, 2023
なんでこんなに異なる流派があるんだよ。
— yoh2 (@yoh2_sdj) July 13, 2023
たしか最初は.C(大文字)か.c++だったんだけど、 どちらもMS-DOSでは使えないので .cxxや.cppが使われるようになった。 みたいな流れだったかと。 .cppが主流になったのはやっぱりMSが採用したからってのが大きい?
.ccは…?
FORTRAN Compiler on IBM 704
ゆるゆると
A = 0, B = NBAR?
R01000 CLA LAMBDA,A ADD INTO GAMMA COUNTERS 4F14220
PAX 0,B 4F14221 Place Address part in B
CLA BETA,B 4F14222
ADD BETAD1 (-3)*2**18+(-3) 4F14223 BETAD1 OCT 77775077775 (-3(*2**18+(-3)
STD BETA,B 4F14224 store dec part
STA BETA,B 4F14225 store addr part
TXI R01700,A,-3 4F14226 inc counter
R01700 TXH R01000,A,0 -3L IN XA AT END 4F14227 dec part = 3LBAR
ここ、BETAD1を加算している理由(目的)がわからん…
CLS ALPHA-4,4 4F13573
STO LAMBDA,1 4F13574
L23130 SLW ALPHA,C STO -N IN ALPHA+A 4F13893
CLS L(0) 4F13894
STO LAMBDA+3,A STO -0 IN LAMBDA+3(L+1) 4F13895
LA2000 CLS ALPHA-1,C 4F13897
STO LAMBDA,A STO C(ALPHA+A-1) IN LAMBDA+3L 4F13898
L43130 SLW ALPHA,C STO -(N+2) IN ALPHA+A 4F13901
CLS L(0) 4F13902
STO LAMBDA+9,A STO -0 IN LAMBDA+3(L+3) 4F13903
L33130 SLW ALPHA,C STO -(N+1) IN ALPHA+A 4F13944
CLS L(0) 4F13945
STO LAMBDA+6,A 4F13946
この辺を読むと、前回引用した記述にもあるように LAMBDAにおかれるデータの オフセット0、3、6、9… のところにはALPHAと関係が強そう
前回のものとは別のドキュメントから
http://archive.computerhistory.org/resources/text/Fortran/102649787.05.01.acc.pdf p.44
11.(LAMBDA Table). This table, and the BETA Table which follows, limit the size of arithmetic expressions on the right-hand side of arithmetic formulas and as the arguments of IF statements. In any one expression let n=number of literal appearances of variables and constants, except those in subscripts; b=number of open parentheses, except those introducing subscripts; p=number of appearances of + or -, except in subscripts or as unitary operators. (The + in A*(+B) is a unitary operator.); t=number of appearances of * or /, except in subscripts; e=number of appearances of **; f=number of literal appearances of function names; and a=number of arguments of functions. (For SINF(SINF(X) ), a=2.) Then λ, which equals n+4b+4a-3f+3p+2t+e+3, must not exceed 400.
- (BETA Table). With the same definitions, β=λ+1-n-f must not exceed 300
JavaScript、いっちょんわからん…
— 専門性・売上・原稿 (@golden_lucky) January 4, 2024