ときどきの雑記帖'

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

一つ前へ 2013年2月(下旬)
一つ後へ 2013年3月(中旬)

ホームへ

2013年03月10日

■_

なんと言う寒暖の差。

ちと身辺が慌ただしくなっとります。

■_ なぜ歴史を学ぶのか

Hacker News ではときにこういう話題で盛り上がることが Why Study History? | Hacker News

Why Study History? - American Historical Association

Why Study History?

By Peter N. Stearns

People live in the present. They plan for and worry about the future. History, however, is the
study of the past. Given all the demands that press in from living in the present and anticipating
what is yet to come, why bother with what has been? Given all the desirable and available branches
of knowledge, why insist—as most American educational programs do—on a good bit of history? And why
urge many students to study even more history than they are required to?

Any subject of study needs justification: its advocates must explain why it is worth attention. Most
widely accepted subjects—and history is certainly one of them—attract some people who simply like
the information and modes of thought involved. But audiences less spontaneously drawn to the subject
and more doubtful about why to bother need to know what the purpose is.

(略)

History should be studied because it is essential to individuals and to society, and because it
harbors beauty. There are many ways to discuss the real functions of the subject—as there are many
different historical talents and many different paths to historical meaning. All definitions of
history's utility, however, rely on two fundamental facts.

History Helps Us Understand People and Societies

(略)

© 2006 American Historical Association
 

■_ Lua

Lua: Good, bad, and ugly parts | Hacker News

Lua: Good, bad, and ugly parts - ZeroBrane

Good

    Small: 20000 lines of C code that can be built into a 182K executable interpreter (under Linux).
    小さい
    Portable: builds on any platform with an ANSI C compiler. You can see it running on almost
              anything from microcontrollers and Lego Minstorms NXT, to mobile platforms, to game
              consoles, to a browser (translated to JavaScript).
    移植性がある
    Embedded and extensible language that provides a straightforward interface to/from C/C++.

    Sufficiently fast: performs well comparing to other languages and has a JIT compiler that
              noticeably improves performance on many tasks; those who may still be not satisfied
              with the performance, can implement critical parts in C and, given the ease of
              integration with C, still benefit from other good aspects.
              [Updated 3/9/2013] replaced shootout results that are no longer available with benchmarksgame.
    十分高速
    Well documented: reference manual, book, wiki, 6-page short reference and more.
    ドキュメントが豊富
    Friendly and enthusiastic community. Between the excellent documentation, the wiki, the mailing
              list, and StackOverflow, I didn't have any issues finding answers to my questions.
    Clean and simple syntax suitable for beginners and accessible to non-programmers. Lua has borrowed
              most of its control syntax from Modula, the descendent of Pascal, which was widely used
              in education as an introductory language. I still remember using early versions of
              Philippe Kahn's fast and elegant Turbo Pascal IDE.
    洗練されていて単純な構文
    (略)


Different

    Tables and strings are indexed from 1 rather than 0.

    Assigning nil as a value removes the element from a table. This is consistent with returning nil
    for non-existing element, so it makes no difference whether the element does not exist or exists
    with a value of nil. a = {b = nil} produces an empty table.

    No integers as a separate numeric type; the number type represent real numbers.

    No classes; object-orientation is implemented using tables and functions; inheritance is
    implemented using the metatable mechanism.

(略)

Bad

    Limited error handling support (using pcall and xpcall), although some may argue that it is
         sufficient and just needs some syntactic sugar and more feature support (like deterministic
         finalizers). The combination of pcall and error is quite powerful, especially given that
         error can return anything (for example, a table) rather than just a string, but having
         catch ... finally constructs may be cleaner and simpler to read in many cases.
    限定されているエラーハンドリングのサポート

    Global scoping by default (this has been partially addressed in Lua 5.2, which has no globals).
         There is a strict module that requires all global variables to be initialized. I have not
         had many issues caused by uninitialized globals, but still put this one into the "bad"
         category as I once made a mistake of calling a variable "next" and not localizing
         it, which caused an issue with an iterator in a completely different module as it overwrote
         the next function used with iterators.

    No Unicode support (at the very least you don't get string.len and pattern matching functions to
         recognize Unicode characters); there is a binding to ICU library that implements full Unicode
         support. See also this message and follow-ups for a good summary of what is already supported
         and what modifications may be required for string.* functions.
    Unicode をサポートしていない

(略)


Ugly

    Number of elements in a table is not easy to get and the result depends on how you do this (or
    what you mean by "length"). This is probably not surprising, given how powerful tables
    are in Lua and the fact that they support flexible indexing (by numbers and any other Lua type
    except nil). Tables in Lua have two parts: an "array/vector" part (generated with
    t = {1, 2, 3}) and a "hash" part (generated with t = {a = "foo", ["b"] = 2});
    the two can be flexibly combined. #table returns the length of the shortest "array/vector"
    part (without any gaps) and table.maxn(t) returns the longest "array/vector" part (this
    function is removed in Lua 5.2). The "hash" part doesn't have a defined length. Both
    parts can be iterated over using the pairs method, which allows you to count the number of elements
    in them. However, print(#{1, 2, nil, 3}) prints 4 and not 2 as one may expect, whereas
    print(#{1, 2, nil, 3, nil}) prints 2. I'm sure there is a good reasonable explanation for this,
    but for now it is in the "ugly" bucket.
    [Updated 11/17/2012] As FireFly noted in the comments, in Lua 5.2 the length operator is only
    defined for tables that don't have holes in them.

    return statement can't be used if it's not the last statement in a block; in other words, function
    foo() print(1); return; print(2) end will trigger an error 'end' expected... or unexpected symbol
    near <whatever statement you have after 'return'> (depending on whether you have semicolon
    after return or not). Not that anyone would want use this for anything other than debugging, but I
    got bitten by it couple of times. I would have put this in the "different" category, but
    I find it inconsistent that I can't use return, but can use do return end in exactly the same place.
    [Updated 5/19/2012] This also applies to break statement, although in Lua 5.2 break is no longer
    required to be the last statement in a block.

    Only one value is returned from a function if it's not the last one in a list; for example:

      function f123() return 1, 2, 3 end
      function f456() return 4, 5, 6 end
      print(f123(), f456()) -- prints 1, 4, 5, 6
      print(f456(), f123()) -- prints 4, 1, 2, 3

    The related behavior of return is also affected by this rule: return f456() returns three values,
    but return (f456()) returns only one value (note the extra pair of parentheses). This matches the
    overall simplicity of the language and is well documented, but I still find it to be a bit ugly
    (although ugliness as beauty is in the eye of the beholder).


Posted by Paul Kulchenko on Sunday, March 25, 2012 at 5:22 PM

All rights reserved © 2004-12 Paul Kulchenko

■_ chomp

確かに今の目で見ると、なんでこの仕様? と思うようなのは幾つもあるかもしれない。 awk もだけど :)

Perlについての質問箱 57箱目

936 デフォルトの名無しさん [sage] 2013/03/09(土) 00:31:11.39 ID: Be:
    ファイルの中身を配列に入れて改行を落とす時に
    @a = <$in>;
    chomp @a;

    みたいにするけど、これを1行で書けないだろうか 

940 デフォルトの名無しさん [sage] 2013/03/09(土) 02:06:55.71 ID: Be:
    chomp(@a = <$in>); で行けるみたいだけど。 

942 デフォルトの名無しさん [sage] 2013/03/09(土) 09:53:15.50 ID: Be:
    >>940が正解だな
    でも、なんで上手く行くのかの機序が説明できない

    代入文が何を値として持つのかよく知らない上に、
    スカラーで評価されてるのかリストで評価されてるのかも見て判らない 

944 デフォルトの名無しさん [sage] 2013/03/09(土) 10:16:31.79 ID: Be:
    代入文が返す値は代入後の値
    ふつうにリストで評価されてる 

945 デフォルトの名無しさん [sage] 2013/03/09(土) 10:49:59.02 ID: Be:
    >>942
    代入演算子の左辺は配列変数だから、式がリストコンテキストで評価される。
    右辺のダイヤモンド(山括弧)演算子もリストコンテキストで評価される。
    chompの引数がリストだから、chompもリストコンテキストで処理される。 

946 デフォルトの名無しさん [sage] 2013/03/09(土) 12:51:49.15 ID: Be:
    chomp がリストも扱える、ということ自体があまり知られてないんだよな

    代入結果を引数にするのはいいんだけど、
    それが値渡しなのか参照渡しなのかがはっきり見えない
    実際にはみんな参照渡しで、代入結果というよりは、
    最後に代入した変数そのものを渡していると見た方が分かり易い 

947 デフォルトの名無しさん [sage] 2013/03/09(土) 14:01:05.84 ID: Be:
    × ということ自体があまり知られてない
    ○ わたくしは馬鹿で無知なので全く知らない 

949 デフォルトの名無しさん [sage] 2013/03/09(土) 14:06:37.91 ID: Be:
    Perlはchompのような
    副作用をもたらす命令が多すぎ。

    関数型言語の逆を言ってるな。 

952 デフォルトの名無しさん [sage] 2013/03/09(土) 14:17:15.10 ID: Be:
    Perlって戻り値がスカラなのかリストなのか
    状況によって変わるから怖いんだよな。 

953 デフォルトの名無しさん [sage] 2013/03/09(土) 14:17:21.09 ID: Be:
    普通に考えると、リストを受け取って、改行を外したリストを返す仕様にするよな
    でもchompの戻り値はスカラー
    改行を外したバージョンと元のバージョンと両方使うことは無いだろうという思想の元、
    引数の方をいじる設計になっている

    @a = chomp <$in>;
    みたいに書ければいちばん素直なのに 

954 デフォルトの名無しさん [sage] 2013/03/09(土) 14:20:13.94 ID: Be:
    while(<>){
      chomp;
      ~~~
    }

    とかが想定した使い方なんじゃねーの
    なら、戻り値は無いほうがいい
    引数をいじったほうがイイ 

955 デフォルトの名無しさん [sage] 2013/03/09(土) 14:24:27.94 ID: Be:
    $_ だけを相手にするならそうだけど、
    ずっと $_ を持ってるのはいろいろ危険だから、
    while (my $line = <>) {
      chomp $line;

    }
    みたいになっていく訳で
    なら、
    while (<>) {
      my $line = chomp;

    }
    と書いても手間は同じ 

956 デフォルトの名無しさん [sage] 2013/03/09(土) 14:32:03.84 ID: Be:
    >>955
    むしろ$line一個書かないで済むから
    この場合は下のほうが楽になるな 

957 デフォルトの名無しさん [sage] 2013/03/09(土) 14:40:27.60 ID: Be:
    元々を考えろ。chompの派生元は、chopだぞ?
    my $v = 'ABC' ;
    my $tail = chop $v ;
    $tail は 'C'、$v は、 'AB'

    派生したchompの挙動を変更して、切った後の変数を返すようにしたら
    chopとの挙動が違いすぎる(それだったら0,1の現行の方がいい)。

    chomp単体で(しかもwhile(<>){chomp}だけに関して)
    考えると955のラインが良いとは思うけど、
    ハッシュ時は?リスト時は?
    my %hash2 = chomp %hash ;
    とかすんの? 

959 デフォルトの名無しさん [sage] 2013/03/09(土) 14:58:43.53 ID: Be:
    メモリが潤沢な今なら、
    my %hash2 = chomp %hash ;
    もありかと思うけど

    昔の設計では有り得ん罠 

■_

この本みたいな感じで是非 世界の駄っ作機
世界の駄っ作機

■_

2013年03月09日

■_

「担保」
「~を担保する」にはまあなんとか慣れてきたような気もするんですが (とはいえ違和感はあるし、自分で使おうとは思わんのですが)、 先日某社社内で 「○○をすることは××の担保になるのか?」 というのを聞いたときはどうしたものかと思いました。はい。 担保 - Wikipedia たんぽ【担保】の意味 - 国語辞書 - goo辞書 インターネットを利用して「担保する」を解く  野浪正隆

ホークウッド
3巻発売とタイミングを合わせて1巻も重版されたらしくようやく読めるように (買って積んでいた2巻を探すのにちと)。 んで、13xx年だのノルマンディーだのエドワード王太子だのというのがでてくるので、 あの辺りの話かなあと思ったらそうだった。で、主人公(傭兵隊長)の名前でぐぐってみたら そのものずばりな人が。 ジョン・ホークウッド - Wikipedia 第46話 傭兵隊長ホークウッド: 仄聞百話 ホークウッド トミイ大塚:360度の方針転換 ということでこういうのが好きな人にはオススメな気がします。
ホークウッド (MFコミックス フラッパーシリーズ) ホークウッド 2 (MFコミックス フラッパーシリーズ) ホークウッド 3 (フラッパーコミックス)
ぐはっ。3巻いいところで終わってる。次は今年の夏か ○| ̄|_

よつばと!
よつばと! 12 (電撃コミックス)
よつばと! 12 (電撃コミックス) 結構色んな人買ってるんですねえ(あまり他人のこた言えないような気もする)。 そしてこいつも。何年目だろうw よつばとひめくり2013 ([カレンダー])
よつばとひめくり2013 ([カレンダー])

よつばと!の表紙(の題材)は一巻のが一番好きなんだけど、 絵の感じが今とはちょっと違うかな? 2003年夏の発売かあ。うへえ。
よつばと! (1) (電撃コミックス)

「よつばと!」12巻は本日、ブックカバーやしおり特典も | ホビー | マイナビニュース 有隣堂で買ったんだけど、結構色んなところでやってるのねえ>特典カバー

■_ 「革命家」の仕事術

結構前に読み終わっていたのだけど。 目次はこちらで→ 「革命家」の仕事術 - 有限会社 海と月社 んでまあ元は十年ほど前に出ていた本の再販(タイトルは違う)らしく、感想もいろいろ書かれていて いまさらワタクシが付け加えることもないんですが (といいつつうだうだ書いているのはナゼかというと…) 『「革命家」の仕事術』 ガイ・カワサキ: Roko's Favorite Things 「革命家」の仕事術 活かす読書 【エバンジェリスト流?】『「革命家」の仕事術』ガイ・カワサキ:マインドマップ的読書感想文 書籍 「革命家」の仕事術/ガイ・カワサキ(著)|freeml

「デスマグネット」とか「高潔の士」とか「自分は『結果』で、他者は『意図』で評価する」 のようにいろいろ「使える」言葉(表現)が出てくるので、そういうのが好きな人なら 必読の一冊ではないでしょうか

ところで一点に気になったのが、23ページのこの部分。 新幹線の設計者はイドラに縛られなかった。だから列車に対する考え方は大きく変わった。 全車両に電動のエンジンがつき、線路はたとえ山を削ることになってもまっすぐ敷かれた。 その結果、ルール破りの新幹線は大阪・東京間を六二時間から三時間一〇分へと大幅短縮したのだった。 新幹線になる前の「62時間」ってどこから出てきた数字なんだろうか? 【グラフ】東京-大阪間の鉄道所要時間の推移~「リニアまだかな」付録その1 - 閑話も休題 - Yahoo!ブログ 1889 20時間5分 (新橋-神戸) 1958 特急 こだま 6時間40分 1960 特急 つばめ・はと 6時間30分 ううむ。 ところで章ごとに「革命家のための読み物」としてその章の内容に関連した 参考図書が数冊あげられているのですが(未訳のものも結構ありそう)、 誰かまとめてくれると嬉しい。

■_ 四つの理由

なぜ developer は secure programming ガイドを読まないのか

4 reasons why developers don't read secure programming guides | SD Elements Blog - Application Security

4 reasons why developers don't read secure programming guides

Rohit Sethi
by Rohit Sethi on January 21, 2013

At Security Compass, we had the experience of building secure programming guideline documents for
a number of clients. Unfortunately, we found that in many cases the documents became shelfware and
were rarely read by developers. If you're a security Subject Matter Expert (SME) who has built a
secure programming guide, there's a good chance you've experienced similar results. There are 4
main reasons why:

    Time pressure: Developers under time pressure to deliver a feature, iteration or release rarely
    have time to sift through a 40+ page document looking for best practice guidance. Moreover, even
    if one developer takes the time to read through the guide there’s still the challenge of
    disseminating knowledge to other members of the team.
    時間に追われている開発者には数十ページのドキュメントなんて読み込んでいる余裕はない

    Seniority: Senior developers can often feel they already have sufficient expertise in security,
    often ascribing security problems to more junior developers. It's natural for them to feel
    skeptical that any general best-practice guidance can really benefit their application,
    particularly if they have been through penetration tests and/or code reviews in the past.
    上級 developer は自分がすでに security に熟達していると思い込みがち


    Static content: A single document can grow quickly out of date with advances to attacks as well
    as defensive technologies. Developers need actionable information relevant to today's threats.
    一つにまとめられたドキュメントというのは容易に陳腐化してしまう

    Context switch: Studies show that developers lose productivity every time they shift context out
    of their development tools. Asking developers to switch between their regular tools and a static
    document means lost productivity, which in turn reduces the likelihood they'll read it.
    学習というのはコンテキストスイッチのために一見生産性を失わせるように見えてしまう


These are the reasons why we believe that tailored software security requirements are the right
approach to taking a proactive stance towards application security.


© 2013 SD Elements. All Rights Reserved.

■_

え、ビッグエンディアンのがいいんじゃね? と思ったけど、リトルエンディアンにもメリットあるなあ。どうなんだろう。

むかーし、師匠に 「ハードウェアに詳しい人はリトルエンディアンの方を好む人が多い」 とかなんとかいわれた記憶があるな。

■_ TDD

なんかまた某所で盛り上がったのから。 Test Driven Traps, part 1 | Java Code Geeks Test Driven Traps, part 2 | Java Code Geeks The Differences Between Test-First Programming and Test-Driven Development | Java Code Geeks The Pragmatics of TDD | 8th Light Test trivial code

■_

2013年03月08日

■_

世界の艦船 2013年 04月号 [雑誌]
世界の艦船 2013年 04月号 [雑誌]
世界の艦船の最新号で知ったのですが、ミッドウェイで今は博物館になってるんですね。 サンディエゴかあ。 ミッドウェイ博物館 USS Midway Aircraft Carrier | San Diego Museum | San Diego Tours サンディエゴタウン - [海軍航空博物館 - The USS Midway]

WILLCOM で iPhone4S ってあれ。 「ソフトバンクモバイルと契約」とかあるんですけど、 どゆこと?

■_ eureka definition

なんとなくメモ

関数型言語Part5

971 デフォルトの名無しさん [sage] 2013/03/07(木) 00:25:40.81 ID: Be:
    関数型プログラミングの本読んでたら"eureka definition"と何度か出てるんだけどどういう意味か分かる人います?

    ぐぐってもよく分からないし、辞書引いてもピンと来ない。用語?
    それともただの英単語として使われてる? 

972 デフォルトの名無しさん [sage] 2013/03/07(木) 18:55:14.01 ID: Be:
    エウレカ!って叫んでしまうほど見事な定義ってことなのかな。
    コロンブスの卵的な。 

973 デフォルトの名無しさん [sage] 2013/03/07(木) 19:07:30.16 ID: Be:
    簡約系で導出して新規に付加された簡約ルール定義のことを、
    eureka definitionって言うけれど、どういう系統の話で出てきたのかな? 

974 デフォルトの名無しさん [sage] 2013/03/08(金) 10:02:03.36 ID: Be:
    まあRentonは関係無いな 

975 971 [sage] 2013/03/08(金) 13:07:17.46 ID: Be:
    ちょっと間を置いて分からなかった箇所を再読してみたんですが、>>972氏のような「これだ!」的な意味かなと思えてきました。
    例として、リストを逆順にする関数を再帰で記述したい

    →まずfoldを使って記述
    →帰納法的な手順で、(n+1)個の要素がある場合をn個の場合+αの形に変形
    →再帰的記述のできあがり、これがEureka definitionだ!

    と言った文脈で使われてました。レントンとか月光号とかは関係ないです。 

976 デフォルトの名無しさん [sage] 2013/03/08(金) 13:46:41.16 ID: Be:
    やはりプログラム変換の話ですね。
    じゃあ書いた人は>>973のようなことを念頭に置いていると思います。
    技術用語として覚えたほうがいいです。
    もちろん972の人が書いた意味からこういう名前が付けられてます。

    例えばかなり古い文献ですが↓です。
    http://www.diku.dk/OLD/undervisning/2005e/224/papers/Burstall-1977-TransSystem.pdf
    A Transformation System for Developing Recursive Programs
    RM BURSTALL, J DARLINGTON

    こういう変換フェーズのことを"eureka step"と呼んでます。
    この変換は一般的ルールからは自明でない発見的なものなのです。
    上の文献ではっきりそう定義してます。
    プログラム変換屋では完全に定着している用語です。
    最近は論理プログラミングや制約プログラミングが多いですが。 

977 971 [sage] 2013/03/08(金) 15:54:02.49 ID: Be:
    丁寧な紹介ありがとうございます。PDFは後ほど読んでみます。 

978 デフォルトの名無しさん [sage] 2013/03/08(金) 19:23:11.51 ID: Be:
    Bird-Meertens Formalismの前身みたいな内容やな 

979 デフォルトの名無しさん [sage] 2013/03/08(金) 19:45:05.41 ID: Be:
    そうそう。
    Birdさんはeurekaって用語使ってなかったと思うけど。 

■_

七つの内訳がちょっと面白かった。 Epic codefest: 7 programming languages in 7 days | Application Development - InfoWorld

Epic codefest: 7 programming languages in 7 days | Application Development - InfoWorld

Epic codefest: 7 programming languages in 7 days

We challenged our developers to learn Clojure, Scala, JavaScript, Ruby, Java, Kotlin, and Go in a day.
Here's how easy it is to make the switch

By Andrew C. Oliver | InfoWorld
.
Epic codefest: 7 programming languages in 7 days

Much of today's buzz is about alternative programming languages, and the pitch often emphasizes
"increased developer productivity" (IMHO, a sham on multideveloper projects). As long as
the language has garbage collection, strings, real types, and so on, it shouldn't matter. This
means nearly anything at a higher level than C or its mangled Neanderthal cousin C++ should reap
the same productivity out of your developers.

That said, a shiny new hammer will always be tempting to those who get infatuated with their tools.
But to pitch a switch to another programming language, you need to prove to your boss that the
transition costs aren't ridiculously high. Here I would agree with the proselytizers for change. It
doesn't take much to train good developers to learn a new language -- so I decided to prove it.

■_

■_

2013年03月07日

■_

いなばさん、かくたにさんより wishlistからのお届け物が。 ありがとうございます(感涙にむせんでいる(花粉症かもしれない))。

■_

Woz が韓国の高校生からのメールに書いた返事とか。 YY — Letter from Steve Wozniak to a high school student in Korea

最後の辺り。

YY — Letter from Steve Wozniak to a high school student in Korea

    Sent: 2012-07-01 Sun 08:43:10

    Subject: Re: Hello. Steven Wozniak! I‘m one of the korean high school students:-

(略)

If you are not technical, you have many opportunities in your future just knowing how people do
things. Do listen to elders. They are mentors who have been in this world working with other humans
doing the important things that make life work a lot longer than you students. The world needs all
kinds of human effort to work and to progress. It doesn’t need for everyone to be a computer
programmer, for example. We need mathematicians, scientists, archaeologists, writers, and every
capacity of job for things to work.

Look at companies that you might someday work for. The hot products suggest some of these companies.
But pay attention to how good the companies are to employees. Do they respect the employees? Do they
allow them a large amount of decision making at the bottom of the org chart? Are responsibilities
moved down rather than coming as orders from above. Is there room for growth and advancement in a
particular company? Does the company consider employees as family? Will they take care of you if at
some point your job is not working out? Will they find a better role for you? It‘s a bad thought
that companies easily fire employees and leave them with no income to support a family and home.



© 2013 YY

訳つけようかなあとも思ったのだけど、つけない方が良いと判断した。

■_

■_

新しいPCの設定めんどー

2013年03月06日

■_

歴史群像

■_ Why C++ Is Not "Back"

500近くまで伸びているんですが Why C++ Is Not "Back" : programming

元記事は三か月ほど前に書かれたものだし、そのときも割と盛り上がってるんですよね。 何でまた今になって Why C++ Is Not "Back" | Hacker News Perspective: “Why C++ Is Not ‘Back’” | Sutter’s Mill

Why C++ Is Not “Back” | Making the Complex Simple

Why C++ Is Not “Back”

I love C++.

C++ taught me how to really write code.

Back in the day I would study the intricacies of the language, Standard Template 
Library, and all the nuances of memory management and pointer arithmetic.

Those were some seriously good times.  I remember reading Scott Meyers Effective C++ 
book series over and over again.  Each time I would learn something new or grasp more 
of how to use C++.

I'm saying all this just to let you know that I don't hate C++.  I love C++.

There are plenty of excellent developers I know today that still use C++ and teach 
others how to use it and there is nothing at all wrong with that.

So what is the problem then?

(略)

Here is a list of actual interview questions that I used to ask C++ developers interviewing for a
job I was hiring for.
求職してきた C++ developer に聞くこと


    How many ways are there to initialize a primitive data type in C++ and what are they?
      C++ において primitive data type を初期化する方法はどのくらいあって、それはどういうものか?
    Why should you declare a destructor as virtual?
      なぜデストラクターは virtual として宣言した方が良いのか?
    What does it mean that C++ supports overloading?
      C++ が overloading をサポートしていることにはどんな意味があるか?
    What are examples of overloading in C++?
      C++ における overloading の例を
    What is name mangling in C++ and why is it used?
      C++ における name mangling とはどういったもので、なぜ使われているのか?
    What is an abstract base class?
      abstract base class とはなにか?
    What is RTTI?
      RTTI とはなにか?
    How can you access a variable that is “hidden” by another variable of the same name?
      同名の別の変数によって「隠されている」変数にアクセスするにはどうすればよいか?
    What is a namespace and how is it used.
      namespace とはどういったもので、どのように使われているか
    What are the differences between a class and a struct in C++, and how does this compare to C?
      C++ における class と struct の違い、またCと比較してどうか?
    What are templates? How are they used?
      テンプレートとは何か? どのように使われているか?
    What is a copy constructor and when is it used, especially in comparison to the equal operator.
      コピーコンストラクターとはどういったもので、いつ使われるのか。特に代入演算子と比較してどうか
    What is the difference between a “shallow” and a “deep” copy?
      「浅いコピー」と「深いコピー」との違いとは?
    What is the const operator and how is it used?
      const 演算子とは何か? またどのように使われるものか?
    What are the differences between passing by reference, passing by value, and passing by pointer in C++?
      C++ において、参照渡し、値渡し、ポインター渡しの違いとはどういったものか?
    When is it and when is it not a good idea to return a value by reference in C++?
      C++ において参照を返すことが良い場合、悪い場合なのはどういったときか?
    What is the difference between a variable created on the stack and one created on the heap?
      スタック上に構築された変数とヒープ上に構築された変数との違いとは?
    How do you free memory allocated dynamically for an array? What are the implications of just using delete?
      配列のために動的にフリーメモリーを割り当てるにはどのようにするか?
      implications of just using delete とは?
    What is multiple inheritance? When should it be used?
      多重継承とは何か? それを使うのはどういったときか?
    What is a pure virtual function?
      純粋仮想関数 (pure virtual function) とは何か?
    What does the keyword mutable do?
      mutable キーワードが行っていることは?
    What does the keyword volatile do?
      volatile キーワードが行っていることは?
    What is the STL?
      STL とはなにか?
    What is a Vector?
      Vector とはなにか?
    What is contained in the <algorithms> header?
      <algorithms> ヘッダーに含まれているものは?
    What is the difference between #include <iostream.h> and #include <iostream>?
      #include <iostream.h> と #include <iostream> との違いとは?
    What's the difference between “++i” and “i++”?
      「++i」と「i++」の違いとは?
    What is short circuit evaluation? How can it be used? Why can is be dangerous?
      短絡評価とは何か? それはどのように使えるのか? なぜ危険なのか?
    What is the ‘,' operator?
      ',' 演算子とは?
    What is the only ternary operator? How is it used?
      唯一の三項演算子とは何か? それはどのように使われるのか?
    What is the use of a const member function and how can it be used?
      const メンバー関数の使用とはどういうことあるか、またどのように使えるのか?
    How is try/catch used in C++?
      C++ では try/catch はどのように使われているか?
    Why should you never throw an exception in a destructor?
      なぜデストラクターで例外を送出すべきでないのか?
    What is the explicit keyword?
      explicit キーワードとは何か
    What is the proper way to perform a cast in C++?
      C++ において適切にキャストを行う方法は?
    What does inline do?
      inline が行うこととは?

■_

Twitter / gotanda6: エレベーターのドアがあいたら猫がいた。 http://t.c ... Twitter / gotanda6: そして一緒に乗った ... Twitter / gotanda6: しばししゃべって、ここで別れた http://t.co/fI ...

■_ Why Haskell Is Worth Learning

この話題も定期的に繰り返されますね Why Haskell Is Worth Learning | Hacker News

Why Haskell Is Worth Learning

Why Haskell Is Worth Learning
By Job Vranish | Published: March 5, 2013

When I recommend learning Haskell to the uninitiated, I often get asked: “Why Haskell?” “Is it
a practical language?” and “Is it something I can actually use?” My answer is definitely yes.

Haskell isn't my primary language at work (I mostly write C code for embedded systems), I've still
found it incredibly useful. And even if I never used Haskell at work, I would still consider learning
it as time well spent. So, why Haskell?

1. Haskell Plays Well with C

(略)

2. Haskell Changes the Way You Think

(略)

3. Haskell's Steep Learning Curve Is a Good Thing

The most common complaint people have when learning Haskell is the steep learning curve. And they're
right, it does have a steep learning curve. It's like learning programing all over again. It takes
a bit to unlearn the patterns you instinctively want to use. No mutation! Static Typing! OMG they're
passing the value returned from that function as one of its arguments! WTF is going on!?

The hard part about learning Haskell is not the complex things, it's the simple things. Like Monads;
Monads are ridiculously simple. They're just a datatype with an instance implementation of two very
simple functions. Most implementations are just one or two lines! It's the comprehending the
implications, usefulness, and power of these very simple things that takes so much work. Profound
things take time to learn. This is ok. It means you're learning something that's worth learning.

    “Do you want to be locked into tricycles because they're easy to learn?” - Douglas Englebart
Copyright © Atomic Object LLC. — Grand Rapids +1 616 776 6020 — Detroit +1 313 444 6010 — Contact Us

学習曲線の傾きが大きいのが良いってのは初めて見たようなきがする。

■_

■_

2013年03月05日

■_

mortdeus/legacy-cc · GitHub を隙間時間に読んでたりするんですがなかなか面白い。 このコードからコンパイラーの実行ファイルを作るにはどうするのが早いんだろう (このコードをコンパイルできるCコンパイラーは現時点ではないはず(たぶん))。 むかーしのCコンパイラーといえば alohakunもなんか書いてたような。 この辺? KMC Staff Blog:素朴な C (pre K&R C) のお話

ラジオ放送を直接 SD/USB に録音できる FM/AM/短波ラジオ「TR-460」 - インターネットコム こういう、CDの再生機能はなくてSDカードから再生できるようなラジオが欲しいのだけど こいつでもまだ大きい(重い)んだよなあ おおよそのサイズは、幅260×高さ145×奥行き70mm、重さは約980g。

■_ hello, world

次のJavaコードを実行するとその出力が “hello world”に

java - Why does this code print "hello world"? - Stack Overflow

I came across this piece of code, and found it rather interesting. The following print statement
would print "Hello, World". Could anyone explain this?

  System.out.println(randomString(-229985452) + " " + randomString(-147909649));

And randomString() looks like this

  public static String randomString(int i)
  {
      Random ran = new Random(i);
      StringBuilder sb = new StringBuilder();
      for (int n = 0; ; n++)
      {
          int k = ran.nextInt(27);
          if (k == 0)
              break;

          sb.append((char)('`' + k));
      }

      return sb.toString();
  }

種明かし

java - Why does this code print "hello world"? - Stack Overflow

The other answers explain why, but here is how:

new Random(-229985452).nextInt(27)

The first 6 numbers that the above random generates are:

8
5
12
12
15
0

and the first 6 numbers that new Random(-147909649).nextInt(27) generates are:

23
15
18
12
4
0

Then just add those numbers to the integer representation of the character ` (which is 96):

8  + 96 = 104 --> h
5  + 96 = 101 --> e
12 + 96 = 108 --> l
12 + 96 = 108 --> l
15 + 96 = 111 --> o

23 + 96 = 119 --> w
15 + 96 = 111 --> o
18 + 96 = 114 --> r
12 + 96 = 108 --> l
4  + 96 = 100 --> d

Why does this code print “hello world”? : programming

■_ D is for Digital

納得>翻訳本タイトル 『ディジタル作法 カーニハン先生の「情報」教室』発売中!(+邦題の裏話) - オーム社開発部

『ディジタル作法 カーニハン先生の「情報」教室』発売中!(+邦題の裏話) - オーム社開発部

最後に、邦題について少し。 本書の原題は "D is for Digital" といいますが、 訳者の久野先生と
オーム社開発部とで相談して『ディジタル作法』というタイトルを選択したのは、 カーニハン先生の既刊を知っ
ている人にそれとすぐ分かるタイトルで、 なおかつ知らない人(本書の直接の対象読者のほとんど)にも書名
だけで中身を感じてもらいたい、 という思いからです。 (写真左手前の『ソフトウェア作法(さくほう)』の
訳者である木村先生は久野先生の恩師でもあり、 「作法(さほう・さくほう)」についての話は本書の訳者序文
でも少しだけ触れられています。)

あとでカーニハン先生に原題について直接聞いたところによると、これはスペルを説明するときの常套句で、
そのむかしお子さんに読んであげた絵本のフレーズを思い出して本書のタイトルをつけられたとのことでした。
部内の企画会議では、 原題のままがいいとか、 ブラッドベリの "R is for Rocket" の邦題にちな
んだものがいいとか(カーニハン先生自身はそのつもりはなかったとのことですが)、 原題のサブタイトルの
和訳(『立派な大人が知っておくべきコンピュータの基礎』みたいな)はどうかとか、 もっと「カーニハン」
押しのほうがとか(これはサブタイトルに生かされました)、 いろんな意見が出たのですが、 なるべくたく
さんの人に本書の価値が伝わるタイトルということで『ディジタル作法』を選びました。 

S is for Space の立場は… ウは宇宙船のウ【新版】 (創元SF文庫) スは宇宙(スペース)のス (創元SF文庫)

■_

■_

stackoverflow が意外に役に立っている? Api Documentation

2013年03月04日

■_

武蔵小杉の駅周辺の変わりっぷりがですね

■_

10日でおぼえるC#入門教室 (10日でおぼえるシリーズ)

ということで読後の感想。 翔泳社『10日でおぼえるシリーズ』 このシリーズ結構出ているんですね(C や Java のように版を重ねているものもある)。 シリーズの他のものがどのような内容なのかはよく知らないのですが、 arton さんのこの本の内容を10日で最後まで行くというのはかなりキツイペースを 要求されそうな気がします。 たとえば、企業の新人さんに対する講習を考えると、 二週間で正味が10日。勤務時間が一日8時間としてもまあ6時間くらいがいいところ? でどのくらいのことができるのか。 それでいて↓ですし

10日でおぼえるC#入門教室

CHAPTER01 開発環境の準備と操作ガイド

LESSON01 Visual Studioをインストールしよう
LESSON02 プロジェクトを作ろう
LESSON03 プログラムを実行しよう

CHAPTER02 対話型プログラムでC#の基本をマスターしよう

LESSON04 現在時刻を表示しよう
LESSON05 カウンターを作ろう
LESSON06 足し算をしよう
LESSON07 例外を捕まえよう
LESSON08 いろいろな計算しよう

CHAPTER03 電卓プログラムでオブジェクト指向とラムダ式をマスターしよう

LESSON09 クラスを作ろう
LESSON10 継承を使おう
LESSON11 ラムダ式を使って計算しよう
LESSON12 プッシュボタン式電卓を作ろう

CHAPTER04 情報収集プログラムでデータの取得と分類をマスターしよう

LESSON13 HTMLソースを表示しよう
LESSON14 HTMLからリンクを抽出しよう
LESSON15 データの管理方法をマスターしよう
LESSON16 コレクションからデータを抽出しよう

CHAPTER05 テキストエディターでファイルの読み書きをマスターしよう

LESSON17 テキストを保存しよう
LESSON18 テキストを読み込もう
LESSON19 複数の文字コードに対応しよう
LESSON20 安全にファイルを保存しよう

CHAPTER06 射的ゲームでオブジェクトの継承をマスターしよう

LESSON21 Formの上にオブジェクトを描画しよう
LESSON22 いろいろな的を作ろう
LESSON23 弾を飛ばそう
LESSON24 当たり判定を実装しよう

CHAPTER07 サウンドプレイヤーでデータの利用と同期を学ぼう

LESSON25 Waveファイルの内容を調べよう
LESSON26 逆再生Waveファイルを作ろう
LESSON27 非同期再生をしよう
LESSON28 音声合成をしよう

 
CHAPTER08 ソースコード閲覧プログラムで制御構造を学ぼう

LESSON29 ソースファイルのコメントと文字列を色づけしよう
LESSON30 行番号を表示しよう
LESSON31 状態をオブジェクトに変えよう
LESSON32 ソースコードをコンパイルしよう

 
CHAPTER09 リモコンプログラムで単体テストを利用した本格的なプログラミングを学ぼう

LESSON33 Webサーバを内臓したプログラムを作ろう
LESSON34 サーバ機能を切り離そう
LESSON35 HTML表示用リモコンを作ろう
LESSON36 ジュークボックスを作ろう

CHAPTER10 パラパラマンガでWindowsストアアプリのプログラミングを学ぼう

LESSON37 アプリケーションの枠組みを作ろう
LESSON38 お絵かきアプリケーションを作ろう
LESSON39 サスペンドから復帰できるようにしよう
LESSON40 パラパラマンガを完成させよう

いや、目次だけではよくわからんか。 まあとにかく、chapterごとにプログラムは丸きり変わるし新しいことがどんどん入ってくるしで、 独学でやるなら倍かそれ以上は見た方が良いんじゃないかという気はします (社会人で、帰宅してからの時間を考えるともうちょいか?)。

引き合いに出して申し訳ないんですが、たとえば同じシリーズのCのものを見ると、

10日でおぼえるC言語入門教室 第3版

CHAPTER 01 C言語基本
LESSON 01 C言語のプログラミング環境を整えよう
LESSON 02 簡単なプログラミングを作って動かそう
LESSON 03 九九表示プログラムを作ろう
LESSON 04 コマンドプロンプトの操作に慣れよう

CHAPTER 02 データ型と入出力
LESSON 05 データ型を学ぼう
LESSON 06 データを変換してみよう
LESSON 07 データと出力してみよう
LESSON 08 データを入力してみよう

CHAPTER 03 演算子
LESSON 09 算術演算子を使ってみよう
LESSON 10 比較演算子を使ってみよう
LESSON 11 論理演算しを使ってみよう
LESSON 12 ビット演算子を使ってみよう

CHAPTER 04 プログラムの制御
LESSON 13 ifを使ってコイントスゲームを作ろう
LESSON 14 switchを使ってパスを判定しよう
LESSON 15 forを使って2つの累乗を計算しよう
LESSON 16 whileを使って数当てゲームを作ろう

CHAPTER 05 配列と構造体
LESSON 17 配列を理解しよう
LESSON 18 文字列と配列について学ぼう
LESSON 19 二次元配列を理解しよう
LESSON 20 構造体を理解しよう
LESSON 21 構造体配列を使ってデータを管理しよう

CHAPTER 06 ポインタ
LESSON 22 ポインタを理解しよう
LESSON 23 配列とポインタの関係を理解しよう
LESSON 24 ポインタで文字列を扱ってみよう

CHAPTER 07 関数の基本
LESSON 25 関数を理解しよう
LESSON 26 オリジナル関数を作ってみよう
LESSON 27 引数の渡し方を学ぼう
LESSON 28 プログラムに引数を渡そう
LESSON 29 変数の有効範囲を理解しよう

CHAPTER 08 標準ライブラリ関数
LESSON 30 文字や数値を扱う関数を使ってみよう
LESSON 31 文字列を扱う関数を使ってみよう
LESSON 32 日付や時間を扱う関数を使ってみよう
LESSON 33 メモリを扱う関数を使ってみよう

CHAPTER 09 ファイル入出力
LESSON 34 ファイルからデータを入力しよう
LESSON 35 ファイルにデータを出力しよう
LESSON 36 バイナリファイルの扱いを学ぼう
LESSON 37 ファイル情報関数を使ってみよう

CHAPTER 10 マクロと記憶クラス
LESSON 38 マクロを使ってみよう
LESSON 39 ファイル分割について学ぼう
LESSON 40 記憶クラスと修飾子を理解しよう

特に前半部分なんかはデータ型だの制御構造だのかなりこまごました部分をやってます (伝統的な?進め方というか)。 もちろん、本によって目標とするところは違うでしょうから、 これはこれでいいのかもしれません (が、前の版のAmazonでのレビューを見ると評判はよろしくないですね)。 arton さんの本は「中級レベルまで一気に駆け上がること」を目標と「はじめに」にありますし それだけのものが詰まっていると思います。

読んでいてなるほどなあと感心したのは、 「LINQ」、「ラムダ式」のようなコード書きに直接関わるものばかりでなく、 「リファクタリング」や「テスト駆動開発」のような周辺技術的なものにもふれていて、 それらをかなり自然に行わせるように仕向けていたことです。 それはVisual Studioの機能に負うところが大きいのですが、 折角「ただで」使えるものなのだし活用しない手はないですよね。 覚えて損するものでなし。

細かいところを見ると、 変数の宣言は基本的に var キーワードを使った型推論を活用したものになっていて、 int やら double のような型名はあまり使われていません。 なぜそうするかの説明もきちんとされていますし良いことだと思います。

これはこの種の本についてほぼ共通して言えることだと思うのですが、 あるコードを丸ごと載せる → 変更点を載せる × n 回 のように進めるときの変更されたコードの記述方法をもう少しわかりやすくできないかなあ という感じはありました。 確かに行番号もありますしどこが変わった部分なのかというのはわかるんですが、 日頃 diff -u な差分を見慣れてたりするので あっちのページこっちのページを行き来して どう変わったかを確認するのはしんどいなあと。 いやまあこれはそうとうひねくれた意見です。はい (「入門者」には diff の出力はわけわからんフォーマットでしょう)。

ということで対象読者にはかなりオススメなんじゃないでしょうか。 ただし、最初に書いた通り「独学」で「10日」でクリアするのはかなり ハードルが高いと思います (裏を返せば「中級」名乗れるってことでしょう)。

ちょっと(かなり?)推敲が足りませんがこんなもんで。 あ、あとわたしはVisual Studio 使ってプログラム実行しながらという読み方はしてませんので その辺も割り引いておいてください。

本を頂けばこの程度のことは書きますので、他の方からのもお待ちしてます :) (ま、困るほど届くこたあるまい)

■_ 年代物のバグ

ただしハードウェアの。 記事自体は一か月ほど前に書かれたものみたいだけど、HNで今日見つけました。 Uncovering a 30 year-old hardware bug | Hacker News Safe vsp by lft

■_ If Python Had Lambdas

こっちは一年近く前。

If Python Had Lambdas… « Symbo1ics Ideas

If Python Had Lambdas…

By Robert Smith, on April 3rd, 2012

…the world might be a bit of a better place, but not really.

“But Quad, Python does have lambdas. Look!”

>>> double = lambda x: x+x
>>> double(5)
10
>>> quadruple = lambda x: double(double(x))
>>> quadruple(5)
20

I tell you, they're lies.

SICP taught us message passing. Here's a variation of an example they used.

>>> def complex_number(a, b):
...     return (lambda msg:
...                 if msg == "real part":
  File "<stdin>", line 3
    if msg == "real part":
     ^
SyntaxError: invalid syntax

BZZT! No can do. Lambdas can't contain keywords/control flow (well, ternary if). Lambdas contain
expressions. Instead, we have to give it a name.

続きは元記事を読んでのお楽しみ

■_

2013年03月03日

■_

ようやく読み終わった。 が、感想などは明日(以降)にさせてください ○| ̄|_ 10日でおぼえるC#入門教室 (10日でおぼえるシリーズ)

■_

特に意味もなくメモ的に

■_

■_

今日はまたリンクばかりだねえw

#AltDevBlogADay » Floating-point complexities

Floating-point complexities
浮動小数点数の複雑さ

Binary floating-point math is complex and subtle. I've collected here a few of my favorite oddball
facts about floating-point math, based on the articles so far in my floating-point series. The focus
in this list is on float but the same concepts all apply to double.

二進浮動小数点数の演算は複雑かつ微妙です。
わたしはここに articles so far in my floating-point series に基づいて
浮動小数点数演算に関する my favorite oddall facts をいくつか集めました。


The focus in this list is on float but the same concepts all apply to double.
このリストでの focus は float に当たっていますが、同じ concepts はすべて double にも適用できます。


These oddities don't make floating-point math bad, and in many cases these oddities can be ignored.
But when you try to simulate the infinite expanse of the real-number line with 32-bit or 64-bit
numbers then there will inevitably be places where the abstraction breaks down, and it's good to know
about them.

こういった oddities は floting-point math を bad なものにはしませんし多くの場合は無視できます。
しかし、32-bit や 64-bit の数値でもって real-number line の infinite expanse を simulate しようとすると、
then there will inevitably be places where the abstraction breaks down,
and it's good to know about them.


Some of these facts are useful, and some of them are surprising. You get to decide which is which.

これらのことの一部は有用で、一部のものは驚きをもたらすでしょう。
You get to decide which is which.


    Adjacent floats (of the same sign) have adjacent integer representations, which makes generating
    the next (or all) floats trivial
    (同一符号で) 隣接した float は、next floats trivial を generate する隣接した integer
    representaions を持っている


    FLT_MIN is not the smallest positive float (FLT_MIN is the smallest positive normalized float)
    FLT_MIN はfloatの正の最小値ではない (正規化された float の正の最小値)


    The smallest positive float is 8,388,608 times smaller than FLT_MIN
    最小の正の float は FLT_MIN の 8,388,608 分の 1 である。


    FLT_MAX is not the largest positive float (it's the largest finite float, but the special value
    infinity is larger)
    FLT_MAX は float の正の最大値ではない
    (有限の最大値ではあるが、特別な値である無限はさらに大きい)


    0.1 cannot be exactly represented in a float
    float では 0.1 を正確に表現することはできない


    All floats can be exactly represented in decimal
    すべての falot は十進数で正確に表現できる


    Over a hundred decimal digits of mantissa are required to exactly show the value of some floats
    一部の floats の値を正確に show するには十進百桁を超える仮数が必要である


    9 decimal digits of mantissa (plus sign and exponent) are sufficient to uniquely identify any float
    9 桁の仮数(に加えて符号と指数)は任意の float を uniquely identify するには十分である


    The Visual C++ debugger displays floats with 8 mantissa digits
    Visual C++のデバッガーは仮数 8桁で浮動小数点数を表示する


    The integer representation of a float is a piecewise linear approximation of the base-2 logarithm
    of that float
    ある浮動小数点数の整数表現は その float の base-2 logarithm における
    piecewise linear approximation である


    You can calculate the base-2 log of an integer by assigning it to a float
    ある整数値のbase-2 での log の計算を、その整数を float に代入することで可能である。


    Most float math gives inexact results due to rounding
    大部分の浮動小数点数計算の結果は丸めのために正しいものではない


    The basic IEEE math operations guarantee perfect rounding
    基本的なIEEE 算術操作は完全な丸めを保証している


    Subtraction of floats with similar values (f2 * 0.5 <= f1 <= f2 * 2.0) gives an exact
    result, with no rounding
    近い値の float 同士の減算は丸めなしに正確な値が得られる


    Subtraction of floats with similar values can result in a loss of virtually all significant
    figures (even if the result is exact)
    近い値の float 同士の減算はすべての有効桁を失う結果になる可能性がある。


    Minor rearrangements in a calculation can take it from catastrophic cancellation to 100% accurate
    計算における minor rearrangements は 100%正確なものとするのに
    catastrophic cancellation を必要とする可能性がある


    Storing elapsed game time in a float is a bad idea
    elapsed game time を float で格納することは bad idea である。


    Comparing floats requires care, especially around zero
    sin(float(pi)) calculates a very accurate approximation to pi-float(pi)
    浮動小数点数の比較は注意が必要である。特にゼロに近い場合は
    sin(float(pi)) の計算結果は pi-float(pi) に非常に近いものとなる


    From 2^24 to 2^31, an int32_t has more precision than a float – in that range an int32_t can
    hold every value that a float can hold, and millions more
    2^24 から 2^31 の int32_t は float よりも大きな精度を持っている
    この範囲にある int32_t は float が保持できる値すべてよりも多くの値を保持できる


    pow(2.0f, -149) should calculate the smallest denormal float, but with VC++ it generates zero. pow(0.5f, 149) works.
    pow(2.0f, -149) は smallest denormal float (最小の非正規化浮動小数点数)を計算すべきだが
    VC++ はこの式の結果をゼロとする。


    IEEE float arithmetic guarantees that “if (x != y) return z / (x-y);” will never cause a divide
    by zero, but this guarantee only applies if denormals are supported
    IEEE float の算術演算は、“if (x != y) return z / (x-y);”に対して
    ゼロ除算エラーを決して引きおこさない。
    ただしこの guarrantee は非正規化数 (denormals) がサポートされている場合にみ適用される。


    Denormals have horrible performance on some older hardware, which leads to some developers disabling them
    非正規化数は一部の古めのハードウェア上では horrible performance となる
    一部の developer たちはそれ(非正規化数)を disable している


    If x is a floating-point number then “x == x” may return false – if x is a NaN
    もし x が浮動小数点数 (floating-point number) であるなら"x == x" が false を返す可能性がある。
    それは x が NaN のときである


    Calculations done with higher-precision intermediate values sometimes give more accurate results,
    sometimes less accurate results, and sometimes just inconsistent results
    高精度の中間値を伴った計算は、more accurate な結果を give することも
    less accurete な結果を give することも一貫性のない結果となることもある。


    Double rounding can lead to inaccurate results, even when doing something as simple as assigning
    a constant to a float
    二重丸め (double rounding) は、定数の float への代入のような単純なことを行った場合でさえ
    不正確な結果につながる。


    You can printf and scanf every positive float in less than fifteen minutes
    すべての正の float は15分未満で printf や scanf できる。


Do you know of some other surprising or useful aspects of floats? Respond in the comments.

2013年03月02日

■_

行ってきました。トップ - Scala Conference in Japan 2013 とはいえとある事情で午後から参加(と懇親会不参加)ではあったのですが。

割とどの言語のカンファレンス(やそれに類するもの)でも見かける人もちらほらと (オレだオレ)。 Scala ユーザー固有の雰囲気ってのはまだわかりませんでした。 なんとなーくですが、たとえばPerl/Python/Ruby のイベントでの「空気」って 似ているようで違うところもあると思う(感じる)のですよね。 例によってうまく言語化できないのだけど。

今回いくつか見て(聴いて)特に印象に残ったのは 乙女ゲームを支える技術 でした。内容は 昨年、弊社で3本の乙女ゲームと呼ばれるジャンル のソーシャルゲームをplay2 + scalaで開発し、 リリースしました。 当初はチームメンバーのほぼ全員がScala未経験という状態の中、 さまざまな工夫を凝らしながら技術を習得し、リリースまで漕ぎ着けました。 本発表では、Scalaの技術的な側面よりも、チームとしていかにScalaの技術を習得し、 プロダクトコードを書けるレベルまでスキルを押し上げたのか、その工夫についてお話したいと考えております。 ということでしたが、 発表者ご本人もScalaで開発することが決まってから入社されたとかで 「なぜそう決まったのかは分からない(知らない)」のだとか。 そういった状況下、 ペアプログラミングの活用とか週三回朝三十分の勉強会(ネタ本はコップ本)をして全員のレベルを上げていったそうです。 リファクタリングでほとんどJavaなコードからScalaっぽい(らしい)コードへというのにも 興味があるのですが実際のコードの変化をまるごとみるのは無理ですよね。やっぱり (コード片の例示はありましたけど)。

もうひとつ雇用形態にもよるんでしょうが、勉強会の三十分が業務扱いになったのかどうはちょっと気になるw この勉強会「強制参加」ではなかったものの、結構な出席率だったそうです。 また、朝にやっていたことでその日のコーディングで即活かせて効果的だったという こともあったとか。

ということでクロージングセッションでのみずしまさん

そいや、Scala方面では string interpolation の訳語は 文字列補間で決まってるんですかね。ちょっと引っかかるんだけどまあいいか。

■_ 動と静

なんか盛り上がってますが遠巻きに眺めてます はてなブックマーク - 言語機能としての型、概念としての型 - プログラマーの脳みそ 言語機能としての型、概念としての型 - プログラマーの脳みそ Island Life - 型付けと変更の時定数 Jun Mukai's blog: プログラミング言語において、型とはドキュメントである

向井さんの書いた 最近 ChromeOS で起こった問題としては、たとえばこんなものがあります。 に続く部分、「あー、あるある」といった感じがあるのですが、 失敗学じゃないけどこういう事例の調査や研究ってあるんでしょうか。 API 設計に関する資料辺りに出てくるのかな。

ところで大元のコメント欄も大盛況ですが 変数に型がないということの利点について考える - サンプルコードによるPerl入門 みなさんおつきあいありがとうございました。いろんな誤解を与えてしまいましたので、動的な型を持つ言語は、 型を意識しなくてよいので、それなりの信頼性を保って、開発効率がよいという結論にしたいと思います。  本文では、C++とJavaを想定していたので、型推論を含む静的な型を持つ言語の一般論としては却下したいと思います。C++、Javaとの比較だと思って読んでみてください。 「却下」の使い方間違ってない?(そこか) きゃっか【却下】の意味 - 国語辞書 - goo辞書 却下の同義語 - 類語辞典(シソーラス) 自分の主張を取り下げるのは却下とは言わないような (わたしが最後の一文を読み違えている?)。

■_

2013年03月01日

■_

誕生日でも何でもありませんが。 wishlist

■_

こういう場合の「anymore」ってどういうニュアンスなんだろう 「なんでまだC使ってプログラム書くの」みたいな感じになるのだろうけど。

Why Code in C Anymore? | Dr Dobb's

Why Code in C Anymore?

By Andrew Binstock, February 26, 2013

The traditional reasons for preferring C to C++ have been steadily whittled away. Are there any good
reasons to still use C?

A long-time reader of Dr. Dobb's recently asked me why anyone would code in C anymore. This theme
has lately appeared in some comments posted on our site, and earlier in several conversations with
industry figures, particularly at Microsoft. In the early days of C++, there were many reasons to
choose either C or C++ depending on your needs; but as C++ has evolved, a lot of the traditional
distinguishing traits of C have indeed become less advantageous. Because these points are generally
the first to appear in any comparison of the two languages, let's examine them.

Dr. Dobb's の古くからの読者が、最近わたしにまだCでコーディングしている人はなぜそうしているのかと
尋ねてきました。このテーマはわたしたちのサイトに投稿されたコメントにも見つけられます。
また、いくつかの(industry figures についての)対話、とくにMicrosoftにおけるものにおいても
そういったものがありました。初期のC++においては、自分のニーズによってCとC++のいずれを選ぶのかに
ついては多くの理由がありました。しかしC++が進化するに従って、C が持っていたアドバンテージとしての
trasitional distinguishing traits の多くはその優位性を失っていきました。
なぜならそういった点は一般的にそれら二つの言語を比較するときにまず目につくものであるからです。
それでは詳しく見てみることにしましょう。


以下略

肝心なところは元記事を :)

■_

Perl6 (というかRakudo?) 関連のblogだかで見た覚えが >gradual typing

■_


一つ前へ 2013年2月(下旬)
一つ後へ 2013年3月(中旬)

ホームへ


リンクはご自由にどうぞ

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