ときどきの雑記帖 2012

最新ページへのリンク
目次ページへのリンク

一つ前へ 2012年6月(中旬)
一つ後へ 2012年7月(上旬)

ホームへ

2012年06月30日

■_

「チューリングを読む」
この本は原著が出たときから一部で話題になっていた (はず。それでわざわざ原著買ったので)のですが、コンピューター開発最初期の人物ということで この方に関する本の翻訳も(ry 確か本人が晩年に書いた伝記だかなんだかがあったと思うんですが。 コンラート・ツーゼ - Wikipedia Helmut Schreyer - Wikipedia, the free encyclopedia Zuse Z1 - Wikipedia Z2 (computer) - Wikipedia, the free encyclopedia Zuse Z3 - Wikipedia Zuse Z4 - Wikipedia プランカルキュール - Wikipedia

PFDS読書会 第8回 (Purely Functional Data Structures) #readpfds - Togetter 二回目から出てないなあ ○| ̄|_

■_ 比較

まあ翻訳されるでしょ。ということで軽く。 すでにみずしまさんを初めとしてツッコミを入れてる人も何人かいらっしゃるようで。

Java 8 vs Scala: a Feature Comparison

Java 8 vs Scala: a Feature Comparison

Introduction

With the release of JDK 8 planned for 2013, Oracle has a pretty fixed idea of what will be included.
Speaking at QCon London earlier this year, Simon Ritter outlined the new features that will be part
of JDK 8, which include modularity (Project Jigsaw), JRockit/Hotspot convergence, annotations on
types, and Project Lambda.

(略)

Conclusion

Java 8 is going to provide a variety of new language features, with the potential to fundamentally
change the way we write applications. Especially the functional programming constructs, such as
lambda expressions, can be considered a paradigm shift. This shift provides great new possibilities
for more concise, compact and easy to understand code.

In addition, lambda expressions are key to enabling parallel processing.

As explained in this article all these features are already available in Scala. Developers who want
to try them out can explore early builds of Java 8 on most platforms. Alternatively, we recommend
taking a look at Scala as a way of preparing for the paradigm shifts to come.

かなり Java よりすねw

■_

■_

上半期終了

2012年06月29日

■_

でまあ来週からまたイカサマータイムなわけですよ (ことしは「サマータイム」とは言ってないですけどね)

■_ Why learn C?

Head First シリーズに、Head First C ってのがあります Head First C - O'Reilly Media んで、このような記事が↓

記事中にリンクのあるビデオを観るのがよろしいかと。

Why learn C? - O'Reilly Radar

Why learn C?

David Griffiths on C's consistent popularity and what the language can do for you.

by Brian Sawyer

Though C has been around for decades, it's still consistently ranked at the top of any list of
programming languages used and studied today. I recently spoke with David Griffiths (@dogriffiths),
coauthor of "Head First C," about the reasons for C's continued (even increased)
popularity and what his book offers in such an established market.

Highlights from our conversation include:

    Why is C still popular? It's ubiquitous, closer to the hardware, and used to create other
    languages and operating systems. [Discussed at the 0:32 mark]

    なぜ C はまだ popular なのか?
    それはどこにでもあり、ハードウェアに密着していて、言語やOSの実装に使われているからです。

    What kinds of software is C used for these days? System programming (in pure C) or specialized
    areas when working with languages that are extensions of C or closely related (e.g., knowing C
    makes Objective-C programming for iOS apps more efficient and C++ games programming more
    intuitive). [Discussed at the 3:18 mark]

    今日、C はどのような種類のソフトウェアに使われているか?
    システムプログラミングや C で拡張する言語をつかうようなとき。

    If you learn C, what will it do for you? Knowing C gets you closer to the hardware, to better
    understand how things work on the system level. [Discussed at the 4:55 mark]

    C を学んだとして、それはどういう意味を持つのか?
    ハードウェアにより近づくことができ、システムレベルでの動作をよりよく理解できるようになる

    Why write Head First C? Kernighan and Richie's The C Programming Language is one of most popular,
    if not the most popular, programming books, and it defined the ANSI standard. That book is still
    the standard, but through the language hasn't changed, the audience has, and many learners are
    coming to the language from a different perspective and set of knowledge. [Discussed at the 6:03 mark]

    なぜ Head First C を書いたのか?
    K&R は良い本であるけれども、C を学ぼうとしている人が変化しているから。

    How does Head First C make the language more accessible to this new audience? For example, it
    teaches how memory works in a more profound way (a concept systems programmers will likely
    already know, though new programmers in specialized fields might not). [Discussed at the 8:12 mark]

    Describe the labs in Head First C. The book includes three hands-on missions for the learner,
    presenting the project without completed source code. In the first project, the learner uses
    Arduino lab to program a flower with sensors to tell you when it needs to be watered. In the
    second lab, a computer vision system (OpenCV) is used to capture images in a web cam to check
    for faces, motion, etc. And finally, the learner creates Asteroids game clone, pulling together
    many different concepts from the book. [Discussed at the 11:13 mark]

    Arduino is making C popular among the Maker community. As a constrained platform, Arduino is a
    natural environment for C. C makes the most of the machine's performance, particularly with
    real-time processing of input/output. And because it's such a small language, you can become
    competent in basic keywords rather quickly, making small Arduino projects a gratifying
    introduction to programming. [Discussed at the 13:54 mark]

    Why should colleges continue to teach C? It's an important, foundational language that requires
    you to understand the full stack of the technology. If you learn C, you'll understand computers
    at a much more profound level than if you don't. [Discussed at the 15:31 mark]

    なぜ大学では C を教え続けるべきなのか?
    C は、full stack of the technology を理解するのに重要な言語であり、foundational な言語であるから。


© 2012, O'Reilly Media, Inc.

reddit での反響 → That's it - watching this, I'm certain I want to learn C : programming

この本日本語訳されるかな。されないような気がする。

というか Zed のアレを

■_

2012年06月28日

■_

ベイスターズの藤田選手とイーグルスの内村選手のトレードがあったわけですが。 何を目的としたのかわからないのはいつものこととして、 内村選手はイーグルスのバッティングコーチと折り合いが悪いとかいう記事が。 まあそれを鵜呑みにしてしまうのはアレですが、 あのコーチはなあ(ry

■_ BD-BOX

ううむ。出るか。

【棺担ぎのクロ。】きゆづきさとこ 40【GA】

965 名無しんぼ@お腹いっぱい [sage] 2012/06/28(木) 18:33:12.76 ID:AEVDUL680 Be:
    ナミコさんとトモカネのやりとりはおもしろい
    来月休載は残念だけど、再来月は表紙&巻頭カラーに単行本があるから楽しみ

    アニメGAのBD-BOXが出るみたいだけど、最近休載多いのは単行本作業の他に
    それ用のイラストとか描いてるからかな

966 名無しんぼ@お腹いっぱい [sage] 2012/06/28(木) 18:59:30.08 ID:R2Et3YMqi Be:
    そんなにたくさんかかせるものかい? 

967 名無しんぼ@お腹いっぱい [sage] 2012/06/28(木) 19:07:42.79 ID:pdOaOJVF0 Be:
    >>966
    BDの初回特典に書き下ろしのオマケが結構つくっぽい 

972 名無しんぼ@お腹いっぱい [sage] 2012/06/28(木) 20:08:00.17 ID:KtngQ6oA0 Be:
    GA 芸術科アートデザインクラス Blu-ray BOX(仮)
    http://www.amazon.co.jp/dp/B008F66BPY/ 

Amazon.co.jp: GA 芸術科アートデザインクラス Blu-ray BOX(仮): DVD 発売予定日は2012年11月21日です。

■_ 素数夜曲

お前は俺か > 597

21日の終業後に行ったんだよねー。 八重洲ブックセンターに着いたのは18時前後だったかなあ。

Lisp Scheme Part34 

596 デフォルトの名無しさん [sage] 2012/06/20(水) 18:23:04.50 ID: Be:
    素数夜曲って発売は今日なのかな?26日なのかな?
    ブログ系は今日だし、Amazon他ネットショップ系は26日だ…どっちなんだろう? 

597 デフォルトの名無しさん [sage] 2012/06/25(月) 14:47:00.54 ID: Be:
    >>596
    取次の日付と、書店店頭の日付の違いらしい。
    八重洲ブックセンターは19日に一冊入荷していたとか。
    21日午後に行ったら、その朝開店直後に買われてしまっていて入手できなかった。 

598 デフォルトの名無しさん [sage] 2012/06/25(月) 14:52:14.69 ID: Be:
    書名のオヤジギャグが原因で回収されたのかもしれない 

599 デフォルトの名無しさん [sage] 2012/06/25(月) 15:39:57.79 ID: Be:
    amazonで頼んでいるけど、発送された形跡がないんだよなあ 

600 デフォルトの名無しさん [sage] 2012/06/25(月) 18:44:22.51 ID: Be:
    秋葉原の書泉に何冊かおいてあった。 

601 デフォルトの名無しさん [sage] 2012/06/27(水) 00:10:13.80 ID: Be:
    買った人いないの 

602 デフォルトの名無しさん [sage] 2012/06/27(水) 12:51:07.73 ID: Be:
    いないよ 

603 デフォルトの名無しさん [sage] 2012/06/27(水) 17:53:24.46 ID: Be:
    そうか、居なかったんだ 

604 デフォルトの名無しさん [sage] 2012/06/27(水) 23:38:54.27 ID: Be:
    いるよ 

605 デフォルトの名無しさん [sage] 2012/06/28(木) 11:35:38.88 ID: Be:
    吉田武「素数夜曲: 女王陛下のLISP」は、整数論とScheme入門として最高\(^O^)/ 「虚数の情緒」の感想も
    http://iiyu.asablo.jp/blog/2012/06/20/6486231 

606 デフォルトの名無しさん [sage] 2012/06/28(木) 13:11:15.28 ID: Be:
    こういう人が気に入りそうな本だということはわかった 

607 デフォルトの名無しさん [sage] 2012/06/28(木) 16:56:25.60 ID: Be:
    いつもの中村正三郎氏じゃないか 

608 デフォルトの名無しさん [sage] 2012/06/28(木) 20:00:35.97 ID: Be:
    SICPの準備に読むのに良い本なのか。 

609 デフォルトの名無しさん [sage] 2012/06/28(木) 20:06:28.15 ID: Be:
    まだ5章の途中だが、変なラブコメがない数学ガールって感じかな。

    後半はラムダ算法やら継続やら楽しみなものがいっぱいだ。 

読んだ人(自分もだけど)感想やらよろしく。

■_

Write Less Code

Write Less Code
Posted: Tuesday, 26 June, 2012

One of the fundamental truths of software development is that you have to write code, but oneof the
biggest fallacies is the idea that writing code is your job. When I first started out as a software
developer, I fell into that trap, writing code is a powerful thing, its empowering, you feel like
you are productive and you are accomplishing things. However, what I have learned over the years is
the real truth of the matter. The truth that the job of a software developer is to write as little
code as possible.

ソフトウェア開発における fundamental な真実のひとつはコードを書かなければならないということですが、
最大の fallacies (迷信?) のひとつがコードを書くことが自分の仕事であるというものです。
ソフトウェア開発者としての第一歩を踏み出したとき、わたしはこのわなに嵌りました。

しかし、何年もかけてわたしは本当に重要なものを学びました。
ソフトウェア開発者の真の仕事とは可能な限り小さなコードを書くというものです。


Now, don't get me wrong, we should not be getting ourselves into code golf situations where we are
compacting code and saving keystrokes to the point where the code you produce is no longer
understandable. When you think about it though the fact that most of your time will be maintaining
the terrible code you wrote, writing less code and not creating more work for yourself will start
to look like an exceptionally good idea.

しかし誤解しないでいただきたいのですが、コードゴルフを推奨しているのではありません。

もしあなたが、自分の書いた terrible なコードの保守に自分の時間の大半を浪費していると感じているのなら
書くコードを減らし、自分に対する余計な仕事を作らないことは
とても良い考えに写るでしょう。

Why?
以下略

Copyright 2009-2012 Mike Grouchy

■_ C++ 11

C にしろ C++ にしろそれらの後継を目論む言語にしろ言いたいことはあるんだけど(省略されました)

The Biggest Changes in C++11 (and Why You Should Care)

The Biggest Changes in C++11 (and Why You Should Care)
Posted by Danny Kalev on Mon, Jun 20, 2011 @ 06:03 AM

(略)

In this article I explain the biggest changes in the language, and why they are such a big deal. As
you'll see, threading libraries are not the only change. The new standard builds on the decades of
expertise and makes C++ even more relevant. As Rogers Cadenhead points out, “That's pretty amazing
for something as old as disco, Pet Rocks, and Olympic swimmers with chest hair.”

First, let's look at some of the prominent C++11 core-language features.
まず、C++11 の core言語の機能から見ていきましょう

Lambda Expressions
ラムダ式

A lambda expression lets you define functions locally, at the place of the call, thereby
eliminating much of the tedium and security risks that function objects incur. A lambda expression
has the form:

ラムダ式は関数オブジェクトの抱えるセキュリティリスクと長々とした記述を取り除き、
関数を呼び出されるその場所で局所的に定義することを可能とします。
ラムダ式は以下のような形式です

  [capture](parameters)->return-type {body}

(略)

C++11 still lacks a few useful libraries such as an XML API, sockets, GUI, reflection — and yes, a
proper automated garbage collector. However, it does offer plenty of new features that will make C++
more secure, efficient (yes, even more efficient than it has been thus far! See Google's benchmark
tests), and easier to learn and use.

C++11 にはまだ、XML API やソケット、GUI、リフレクションといったものの便利なライブラリの
いくつかが欠けています。そうそう、適切な自動ガーベジコレクターもですね。とはいえ
C++11 で追加された機能の数々は C++ をより secureに、より効率的に、より学びやすく、
より使いやすくするでしょう。


If the changes in C++11 seem overwhelming, don't be alarmed. Take the time to digest these changes
gradually. At the end of this process you will probably agree with Stroustrup: C++11 does feel like
a new language — a much better one.
© 2012 SmartBear Software. All rights reserved.

■_

2012年06月27日

■_

そういやここしばらく Julia の話題を見ていないような。 The Julia Language

■_ しまった

melancholic afternoon

    シフト量に負の数指定して良かったでしたっけ?

みんなつっこんでそうですけど, exponent <= 0のときの1 << -exponentなので問題ないのでは. 

○| ̄|_

■_

■_

だいぶ伸びたなあ Why don't C++ programmers like Go as much as former users of dynamic languages? : programming

■_

Both true and false: a Zen moment with C | Hacker News Both true and false: a Zen moment with C | mark shroyer, dot com

2012年06月26日

■_

多摩川線の、7月からの夏期臨時ダイヤというのは某社対応シフトなんだろか。 でも池上線もか 鉄道・バス情報|東急電鉄 |東急線のお知らせ|東急電鉄

■_ 11

C の方の。

C11: A New C Standard Aiming at Safer Programming

C11: A New C Standard Aiming at Safer Programming

Posted by Danny Kalev on Mon, Jun 25, 2012 @ 10:00 AM

Thirteen years after the ratification of the C99 standard, a new C standard is now available.
Danny Kalev, a former member of the C++ standards committee, shares an overview of the
goodies that C11 has to offer including multithreading support, safer standard libraries, and
better compliance with other industry standards.

C

C11 is the informal name for ISO/IEC 9899:2011, the current standard for the C language that
was ratified by ISO in December 2011. C11 standardizes many features that have already been
available in common contemporary implementations, and defines a memory model that better suits
multithreading. Put differently, C11 is a better C.

    See also: The Biggest Changes in C++11 (and Why You Should Care)

Problems with the C99 Standard
C99 に関する問題点

C99, the previous C standard, brought about many new features including:
(C11 のひとつ前の) 標準であった C99 は多くの新機能を取り込んでいました

    Variable length arrays
    Designated initializers
    Type-generic math library
    New datatypes: long long, _Complex, _Bool
    restrict pointers
    Intermingled declarations of variables
    Inline functions
    One-line comments that begin with //

Alas, it hasn't been a huge success. Finding C99-compliant implementations is a challenge
even today.

残念ながらこれは大成功ということにはなりませんでした。
C99 compliant な実装というものは今現在でさえ challenge なものなのです。


Where did C99 go awry? Some of its mandatory features proved difficult to implement in some
platforms. Other C99 features were considered questionable or experimental, to such an extent
that certain vendors even advised C programmers to replace C with C++.

C99 はどこへ行ってしまったのでしょうか?
いくつかの mandatory featruees (必須機能) は一部のプラットフォームでは実装困難なものでした。
そのほかの C99 機能は questionable なものだとか experimental なもとのみなされてしまって
いくつかのベンダーが C プログラマーに C から C++ への置き換えを勧めるような代物でした。


Politics also played a role in the lukewarm reception of C99. It's no secret that the 
cooperation between the C and C++ standards committees in the late 1990s was lacking, 
to say the least. The good news is that today, the cooperation between the two 
committees is much better, and that the design mistakes of C99 were avoided in C11.

政治 (politics)もまた、C99 の lukewarm reception  において役割を果たしました。
1990年代終わり頃の C 標準委員会と C++ 標準委員会との間の cooperation の欠如は
広く知られているところです(超訳)。
これら二つの委員会の間の cooperation が格段に良くなったこと、
C11 において取り除かれた C99 でのdesign mistakes は良い知らせです。


A New Standard, a New Hope?
新しい標準、新たなる希望?

C's security has always been a matter of concern. Insecure features – such as string 
manipulation functions that don't check bounds and file I/O functions that don't 
validate their arguments – have been a fertile source of malicious code attacks.

C のセキュリティは常に一大関心事でありました。
文字列操作関数が境界チェックをしないとかファイル入出力関数がその引数の
validate をしないといったような insecure な機能の数々は
malicious code attack の fertile source (大きな源泉とか?) となっていたのです。

C11 tackles these issues with a new set of safer standard functions that aim to 
replace the traditional unsafe functions (although the latter are still available in 
C11). Additionally, C11 includes Unicode support, compliance with IEC 60559 
floating-point arithmetic and IEC 60559 complex arithmetic, memory alignment 
facilities, anonymous structs and unions, the _Noreturn function specifier, and most 
importantly – multithreading support. Yes, I said the m-word!

C11 ではこれらの問題に対し、安全でない伝統的関数をより安全な標準関数でもって置き換える
ことで対処を試みています(旧来の関数も利用可能ではあります)。
加えて、C11 では Unicode のサポートや IEC 60559 に沿った浮動小数点数演算、
IEC 60559 の複素数演算、メモリーのアラインメントの faclitilies、無名構造体および無名共用体、
_Noreturn specifier、そして最も重要なものであるマルチスレッドのサポートが取り込まれました。
Yes, I said the m-word!

Let's look at some of these features and others more closely.
ではそういった機能を見ていくことにしましょう。

(略)

New fopen() Interface

fopen(), a widely-used file I/O functions, gets a facelift in C11. It now supports a new
exclusive create-and-open mode ("...x"). The new mode behaves like O_CREAT|O_EXCL
in POSIX and is commonly used for lock files. The "...x" family of modes includes
the following options:

広く使われている入出力関数である fopen() は C11 で手直しがされ、
新たに exclusive create-and-open mode ("...x") をサポートするようになりました。
この新しいモードは POSIX における O_CREATE|O_EXCL のように動作するもので、
一般的にはロックファイルに使われます。
モード の "...x" ファミリーには以下のオプションがあります

    wx create text file for writing with exclusive access.
    wbx create binary file for writing with exclusive access.
    w+x create text file for update with exclusive access.
    w+bx or wb+x create binary file for update with exclusive access.

Opening a file with any of the exclusive modes above fails if the file already exists or
cannot be created. Otherwise, the file is created with exclusive (non-shared) access.
Additionally, a safer version of fopen() called fopen_s() is also available.

これらの排他モード (exclusive modes) のいずれかを使ってファイルのオープンを試みた場合、
対象となるファイルがすでに存在していたり作ることができなかったときにはオープンに失敗します。
失敗しなければ、排他 (非共有) アクセスでファイルが作成されます。
さらに、fopen_s という fopen() のより安全にしたものも利用できるようになっています。


In Conclusion
結論

C11 attempts to fix what was broken in C99. It makes some of the mandatory features of C99
(variable length arrays, complex types and more) optional, and introduces new features that
were already available in various implementations. Not less important, C11 designers worked
closely with the C++ standards committee to ensure that the two languages should remain
compatible as much as possible. Chances are good that unlike its predecessor, C11 will
receive a warm reception. As a bonus, software written in C11 will be more robust against
security loopholes and malware attacks.

C11 は C99 において broken であったものを fix しようと試みています。
可変長配列や複素数型のような、C99 の mandatory features (実装が困難であったり面倒な機能)
の一部を optional とし、様々な実装においてすでに利用が可能であった新しい機能を取り込んでいます。
重要性はやや劣りますが、C11 の designer たちは C と C++ という二つの言語が
可能な限り互換性を保つべきだということを ensure (保証) するために
C++ 標準委員会と密に共同作業をしました。
Chances are good that unlike its predecessor, C11 will receive a warm reception.
As a bonus,
C11 で書かれたソフトウェアは security loopholes やマルウェアの攻撃に対して
一層 robust なものとなるでしょう。


© 2012 SmartBear Software. All rights reserved.

C11: A New C Standard. Former member of the C++ standards committee shares an overview of the changes. : programming

■_

2012年06月25日

■_

■_ 書評のようなナニカ

リーダブルコード ―より良いコードを書くためのシンプルで実践的なテクニック (Theory in practice)

新刊『リーダブルコード』が6/23に発売されますが、すでに誤植がありました。 - capsctrldays(2012-06-16) というのはさておき。

まずタイトル。 原著は「The Art of Readable Code」 The Art of ~ というタイトルの本はわりとたくさんあるし、 オライリーからも何冊か出ています。 これをどのように日本語にするのかというのは結構悩ましいと思うのですが 本書では「リーダブルコード」ときました。 オライリーの本で良く見る「アートオブ~」よりは良いと思います (The Art of Prolog → Prolog の技芸 みたいのが良いかも知れませんが この本で「技芸」というのはどうかという気も)

同様の内容の本でまず思い浮かぶのが「プログラム書法」なのですが、 いかんせん書かれた時期が古く、(今でも有効なものが少なくないとはいえ) 気軽にオススメできるものとは言い難いものがあります。また、訳者まえがきにもあるように ( Amazon.comには「Nothing New(別に普通じゃん)」とのレビューもある)、 読んで目から鱗が落ちるといったものはあまり(ほとんど?)ないのではないでしょうか。 しかしだからといって価値がないということはなく、読みやすい形できちんとまとめられた ことはとても良いことだと思います。 以下内容についてつらつらと。 原著者に対して言うべきことも混じってますが悪しからず。

p12 で PHP の explode のネーミングについて色々書かれているんですが、 確かに名前だけ見ると split との違いがわからないというのはそうでしょうね。 とはいうものの、どういう名前が良かったのよというと… という気はするのですよね。 あー Perl の chop と chomp みたいな感じ?

  2.2  tmp や retval などの汎用的な名前を避ける
ここはぜひとも 「flag」も挙げていただきたく :)

3章扉絵は、翻訳ってタイヘンだよねえと思わせるものでした :)

3.4。 first/last と begin/end の使い分けにはそんな意味が!

p35 「リンクトリスト」とあるんですが、 「リンクリスト」でないのがいい感じです。 まあちと収まりが悪いかなってのも同時にあるんですけども。

  5章 コメントすべきことを知る
  5.1 コメントするべきでは「ない」こと
  p56 コメントするべきでは「ない」ことを知る
p69 コメントすべきでは「ない」こと

「すべき」か「するべき」か統一した方が良い気がします。

定数にコメントをつける
  NUM_THRADS = 8 #値は「>= 2 * num_procssors」で十分

コメント部分の、特にカッコの中が文章として違和感があります。 原著の英語コメントだと素直に読めるんですけど

7.3 三項演算子
原著では conditional operator となっているのになんで 「三項演算子」にしたんだろうかという疑問があるのですが それはまあおいといて

  return exponent >= 0 ? mantissa * (1 << exponent) : mantissa / (1 << -exponent);

  if (exponent > 0) {
      return mantissa * (1 << exponent);
  } else {
      return mantissa / (1 << -exponent);
  }
  

シフト量に負の数指定して良かったでしたっけ? (追記) exponent 自体が負の数になっているので、シフト量自体は正の数になってます。 ということでコードに問題は無し。

Java演算子メモ(Hishidama's Java Operator/Expression Memo)
シフト演算子 
 
シフト演算子は、整数型に対してのみ使える(浮動小数floatやdoubleでは使えない)。 
 
Javaでは整数の符号の有無を型では管理しない(常に符号有りとして扱われる)。 
(C言語やC++では「int」に「signed int」と「unsigned int」がある) 
その違いが現れるのはビット右シフト演算なので、右シフト演算子には符号有り用の「>>」と符号無し用の「>>>」が存在する。[2003-07-06] 
「>>」ではシフト前の符号が保存されるが、「>>>」では保存されず、最上位ビットに0が入る。 (2の補数表現においては最上位ビットが符号を意味する) 
例えば-2(0xfffffffe)に対して「-2 >> 1」は「-1(0xffffffff)」になるが、「-2 >>> 1」は「0x7fffffff」になる。 
 
ただしbyteやshortに対する「>>>」は注意を要する。→数値の昇格 
 
 
シフト演算子の右オペランドは正の数しか扱えない。というか、負の数を指定して逆方向のシフトになったりはしない。 
なぜなら、右オペランドに対し、左オペランドがintの場合は「& 0x1f」、longの場合は「& 0x3f」してから
計算されるため。intは32bit、longは64bitなので、その範囲を超えるシフトは無意味、という判断なのだろうか。
(64ビット以上シフトすれば、結果は常に0(負数の符号付き右シフトなら-1)だから) 
 
つまり、「int a」に対する「a << -1」は、「a << (-1 & 0x1f)」なので「a << 31」と同じ。

p90 の 「do/while ループは、whileループで聞きなおせることが多い」ということで 例に出されている書き換え前後のコード、 今ひとつよろしくないのではと。 ループの条件式のどこが変わってるんだろうかとちょっと悩み、 違いを把握したところでそれはないんじゃないかなあと感じました。

p94 鍵となる考え 「変更するときにはコードを新鮮な目で見る」 「一歩下がって全体を見る」 というのは実にいいですね。

8.7 式を簡潔にするもう1つの創造的な方法 C++ で、プリプロセッサーマクロを使って「簡潔」にしているんですが マクロなしで同じことをするには? 言語によってはいろいろと使えるものもあるでしょうけれども。

p113 9.1 変数を削除する の 中間結果を削除する にあるコード片なのですが

var remove_one = function (array, value_to_remove) {
    for (var i = 0; i < array.length; i += 1) {

ここでページの終端に来て、次ページの頭に

        if (array[i] === value_to_remove) {
             array.splice(i, 1);
             return;
        }
    }
};

と続くのはどうにかならなかったのかなあと。 奇数ページから偶数ページへと変わるところなので ページをめくらないと続きが見られないのですよね。 原著は電子書籍で買ったので、原著がどういう風になっているのかは 確かめられませんでした。

9.5 「去るものは日々に疎し」(いい意味で) の原文との対比

  p130 「無関係の下位問題」

  第11章
  p144
  図


  12.2 ライブラリを知る
  の小題の原文との対比

  12.3
  の書き換え作業

  p165
  脚注

p169 に 「でも、アクセスが必ず同時に行われていることに気づいたので、」 というくだりがあるんですけど、 その前後を読んでみてもこの「同時」ってどういうことかがよくわからなかったので 原著の同じ部分をみてみると However, we noticed that the repeated accesses were always in a row. となっているんですよね。 キャッシングしようとしたアクセスの履歴が

read Object A
read Object A
read Object A
read Object B
read Object B
read Object C
read Object D
read Object D

だというのを考えると、同じ行 (row) を複数回繰り返しアクセスして 次の行へ移っているので単純なキャッシングでも効果が結構あったということですよね。 「同時」はちょっと違うんじゃないかなあ。

この辺で力尽きたw

 
  13.3
  コードを小さく保つ
  YAGNI でも・・・?

  ライブラリの再利用はなぜいいことなのか
 「出荷用」→ shippable

  UNIXツールの活用

  14章、15章

  高品質のコードを書くための書籍

要書き足し

■_

2012年06月24日

■_

色々書きたいことはあるのですが、 書いてもしようがないよなというのも本音だったりします。 というわけで先週の分はああなりました。

■_ 「リーダブルコード」

訳者の角さん(と arton さん)を通じオライリージャパン様より 「リーダブルコード」をいただいたのでレビューというか感想というか書評を書こうと思い (そういうヤクソクなものと認識しておりますので)付箋貼り貼り読んだのですが、 すみません今まとめなおしているところで、 今日には間に合いませんでした ○| ̄|_

あまり細かいところをつつくのは止めようと思いつつもいつの間にかこうなった↑(笑)

「チューリングを読む」の方もなんかしら書いておきたいのだよね。

■_

気がつくのが遅くて、後半しか観られなかった。 NHK オンデマンドで観られる NHK ハーバード白熱教室 6月16日、23日(土)[Eテレ]午後2時~午後3時 [マイケル・サンデル 5千人の白熱教室]を放送します。

■_

ruby-core でこういう投稿を見るとは(悪いこととは思いません) [ruby-core:45785] How can I contribute?

2012年06月23日

■_

「チューリングを読む」読了。

2012年06月22日

■_

ようやくげっと。

■_

本の虫: 僅かな挙動の変化も重大な影響を与える話 We will try to stop fixing bugs in PHP | Hacker News On behalf of PHP I would like to apologize. After carefully reviewing this bug report with our board of directors on 4chan... We will try to stop fixing bugs in PHP. : programming 確かに大いに盛り上がってるんだけど、このバグレポートのやり取り2年半ほど前のもののような。

PHP :: Bug #50696 :: number_format when passed a 0 as first function argument, returns null

Bug #50696 	number_format when passed a 0 as first function argument, returns null
Submitted: 	2010-01-08 19:13 UTC 	Modified: 	2012-06-22 06:26 UTC 	
Votes:	118
Avg. Score:	2.6 ± 1.8
Reproduced:	29 of 67 (43.3%)
Same Version:	27 (93.1%)
Same OS:	20 (69.0%)
From: 	endosquid at endosquid dot com 	Assigned: 	
Status: 	Wont fix 	Package: 	Math related
PHP Version: 	5.3.1 	OS: 	Linux 32 bit
Private report: 	No 	CVE-ID: 	
View Add Comment Developer Edit
Have you experienced this issue?
yes no don't know
Rate the importance of this bug to you:
high low

 [2010-01-08 19:13 UTC] endosquid at endosquid dot com

Description:
------------
php -r 2>/dev/null 'print number_format("",0) . "\n";'
on our old PHP 5.1.6 Solaris 8 box (that we are transitioning off of) returns 0.

Now, we're testing our code, and we run into this behavior change:
php -r 2>/dev/null 'print number_format("",0) . "\n";'
on our new RHEL5 with 5.3.1 from the REMI repository returns NULL. Is this the default behavior
expected? If so, why did this change happen? If not, where did we go wrong?

Reproduce code:
---------------
php -r 2>/dev/null 'print number_format("",0) . "\n";'

Expected result:
----------------
We expect to see 0 returned, not NULL.

Actual result:
--------------
NULL is returned.

(略)

 [2010-01-08 23:20 UTC] rasmus@php.net

Wow, a classic case of how not to treat unpaid volunteers who provide 
critical pieces of your money-making infrastructure.

 [2010-01-08 23:22 UTC] endosquid at endosquid dot com

Just look in the mirror, pal.

You need classes on how to listen to others.

 [2010-01-08 23:47 UTC] bjori@php.net

Sir.

This issue was recently brought to my attention.
On behalf of PHP I would like to apologize. I see that now that you have been treated unfairly.

After carefully reviewing this bug report with our board of directors on 4chan, we have come to
the conclusion that your "rusty C skills" should be enough to fix the issue.

I would therefore like to remind you that rasmus@php.net is http://en.wikipedia.org/wiki/Rasmus_lerdorf

Again, I sincerely apologize. We will try to stop fixing bugs in PHP.

 [2011-08-23 01:41 UTC] jacob at jacobweber dot com

Fun thread! Anyway, I was wondering if anyone has a complete list of the functions 
that changed as a result of this zend_parse_parameters() fix. I don't see anything 
specific in the upgrade instructions:
  http://www.php.net/manual/en/migration53.incompatible.php

Also, will number_format((float) $x) behave under PHP 5.3.x exactly the same way 
that number_format($x) behaved under PHP 5.2.x? Are there any subtle differences?

Thanks.

 [2012-06-22 04:20 UTC] contact at joezimjs dot com

I agree with Endosquid. What you did isn't a "bug fix". Whether or not it complies with
your zend_parse_parameters() nonsense is not the point. A function should only return values that
make sense for that function to return. number_format is supposed to return a string of a number
in a specific format. NULL is neither a string nor a number.

However, the documentation does dictate that number_format's first parameter is supposed to be a
float, and it is the programmer's job to supply correct parameters to the functions they use. If
you supply a string when there should be a number, you're doing it wrong.

Sooo, you both fail at your jobs. :D

(略) 
PHP Copyright © 2001-2012 The PHP Group
All rights reserved. 	Last updated: Fri Jun 22 14:10:08 2012 UTC

燃料投下した人が居たと。

2012年06月21日

■_

↑が

arton さんの口利き(使い方間違ってないよな?(^^;) でワタクシ奴にも。 ありがとうございます。 あともうちょっとで「チューリングを読む」を読み終えられるので その後すぐにでも読んで何かしら書きます。

■_

一冊だけ見本という形で入ってたらしい (終業後に急いで行ってみたらすでになくて、店員さんに訊いたのよ ○| ̄|_)

2012年06月20日

■_

2012年06月19日

■_


一つ前へ 2012年6月(中旬)
一つ後へ 2012年7月(上旬)

ホームへ


リンクはご自由にどうぞ

メールの宛先はこちらkbk AT kt DOT rim DOT or DOT jp