早すぎる最適化
Nick CraverはStackOverflowのアーキテクチャリード。
The main problem I almost always see with “premature optimization” is someone without context calling it “premature” in the first place. For people working hard on the 3% every day, the saying gets really old, really fast.
— Nick Craver (@Nick_Craver) 2018年7月8日
《早すぎる最適化》に関する一番の問題点といえば、ほぼ毎回、これまでの流れを何もわかってないやつがやってきて二言目には「早すぎる」と口出ししてくることかな。《残りの重要な3%》で日々戦ってる連中は、そんな風に言われるのにもう飽き飽きしてるわけだけど。
“Premature optimization is the root of all evil” is almost always used as a blanket statement. I get frustrated when people treat it that way because it says “I’m repeating this without even bothering to read the quote” loud and clear. It’s also just a terrible quote.
— Nick Craver (@Nick_Craver) 2018年7月8日
《早すぎる最適化は諸悪の根源》って言われるときはいっつも総論でしかないし、そういう言われ方はモヤモヤする。要するに「引用元をちゃんと読んだこともないのに、一つ覚えしてます」ってことでしかないもんなー。そういう引用の仕方はほんと酷いよ。
So let's talk about it, because optimization is one thing, but knowing when to optimize and when not to is something that challenges a lot of developers. When do we optimize? Well, it depends. Everything (EVERYTHING) in life is a tradeoff. Time spent optimizing is no different.
— Nick Craver (@Nick_Craver) 2018年7月8日
最適化はそれはそれでよく話し合う方がいいと思うけど、いつ最適化をやるべきか・やらざるべきか自分にはわかってる、とかいうのはまた別の話で、それは多くの開発者に異議を唱えてるも同然だよ。いつ最適化するか?そんなの場合によるから。人生なんでも(どんなことでも)トレードオフだし。最適化に使った時間だって同じこと。
How often does it run?
— Nick Craver (@Nick_Craver) 2018年7月8日
How important is the time it takes to run?
How important are the resources it uses?
What's the opportunity cost of those occupied resources?
What else would the optimizer be doing?
How often does the thing change?
How much maintainability is on the table?
何回実行する?
実行時間はどのぐらい大事?
リソース使用量はどのぐらい大事?
リソースを占有することからくる機会費用は?
オプティマイザーは他にどんなことをする?
状況が変わる頻度は?
保守性はどのぐらい考慮されている?
バーチャルYouTuberになります。
今日からバーチャルYouTuberクラウディアさんになりますのでよろしくお願いします。
Amazon Goに行ってきたよ
猫にもC#にも関係ないけど、たまにはこういう記事も書きます。
Amazon Goはワシントン州シアトルのダウンタウン近く(2131 7th Ave, Seattle, WA 98121)にあります。
営業時間は月曜〜金曜の午前7時〜午後9時です。土日は閉店しています。
店に入るにはクレジットカードを登録したAmazonのアカウントとAmazon Goモバイルアプリ(iOS/Android)が必要です。
水曜の夕方に行ったのですが、全然並んでなく、すぐ入れました。
店の前で店員が「アプリはインストール済みですか?」と尋ねています。希望者には買い物袋をくれます。
入り口にはゲートがあり、Amazon Goアプリで表示した2次元バーコードをスキャンするとゲートが開きます。この写真は入店後、店の内側から撮ったもの。
なるほど、グローサリー(食料雑貨店)とはコンビニっぽい感じなのですね。
Amazonが買収した高級スーパーWhole Foods Marketのプライベートブランド"365 Everyday Value"の商品棚。
お酒コーナーには店員がいて、写真入り身分証明証(パスポートなど)の提示を求めています。なるほど、レジがないので、ここでチェックするんですね。
天井や棚の上にはカメラがあり、客の動きをトラッキングしています。それと、棚自体に重量センサーもあり、それらを合わせて取り出した商品を認識するとのことです。
チョコレートがあります。ひとつ買ってみましょう。
なお、誰かと一緒に店に入ったとしても、他の人の袋に商品を入れたり、他の人の袋から商品を取り出したりしてはいけないそうです。(最初に商品を掴んだ人のアカウントに請求が来ます。)
欲しいものを袋に放り込んだら、あとはゲートを通って店を出るだけです。
店を出て数分後に、購入した商品の明細がAmazon Goアプリに通知されます。(リアルタイムではありません。)
今回の買い物時間は9分弱でした。まあ狭い店ですし、長居するようなところではないですね。
いやあ、面白い体験でした。
.NETに型クラスを……の話ふたたび
以前の記事でこんなことを書いてたのですが
もちろんCLRにもILにも型クラス的なものなんかないわけで、オダスキー教授が言うところの「貧者の型クラス(pdf)」を使う、つまり型に適合するメソッド群をインスタンスとして渡してやるしか方法はないわけですが(ちなみにScalaでは、そのインスタンスを暗黙的に生成したり渡したりできる仕掛けがある)。
2014-04-29 - 猫とC#について書くmatarilloの雑記
(追記)ん?型クラス(もどきインスタンス)、
2014-04-29 - 猫とC#について書くmatarilloの雑記new()
制約をつけられるんじゃないの?
ちょっと違うアプローチを実験してる人がいる模様。
visualfsharp/concepts at master · crusso/visualfsharp · GitHub
長めのドキュメントを読むと……
static class Overloads { public static bool Equals<EqA, A>(A a, A b) where EqA : struct, Eq<A> => default(EqA).Equals(a, b); }
なるほど、型クラス(もどきインスタンス)を構造体で作れば、new T()
とかしなくてもdefault(T)
でいけるのか。
Microsoft Build 2016 セッションリスト
公開されました。→シアターセッションが追加で公開されました。
https://channel9.msdn.com/Events/Build/2016
ついでなので、JSON形式にしてみましたよ。
https://gist.github.com/matarillo/f292b7865062beb65b05
Build 2016の個人的に興味あるセッションは以下。
- Moving Forward with ASP.NET | Build 2016 | Channel 9
- XamarinのMiguelとNat、MSのパートナーディレクターAmanda、あとch9のSethがCh9 Stageに出てくる
- (追記)たぶん "Xamarin Live" のはず
- XamarinのMiguelとNat、MSのパートナーディレクターAmanda、あとch9のSethがCh9 Stageに出てくる
- Getting Started in Open Source with Scott Hanselman | Build 2016 | Channel 9
- Hanselmanのシアターセッション。
- Linux Command Line on Windows | Build 2016 | Channel 9
- The Future of C# | Build 2016 | Channel 9
- What's New in TypeScript? | Build 2016 | Channel 9
- The Future of .NET Languages | Build 2016 | Channel 9
- Getting Started with F# on .NET Core | Build 2016 | Channel 9
- How Google Uses TypeScript | Build 2016 | Channel 9
- Python: Fill in the Gaps | Build 2016 | Channel 9
- 言語もの。C#は岩永さんのRoslynまとめで大体カバーできてる節はあるけど ;-) TypeScriptはAltJSの中で確固たる地位を築いたねえ。
- .NET Overview | Build 2016 | Channel 9
- .NET Core | Build 2016 | Channel 9
- ドトネト。Coreだけじゃなくて全体像も一応押さえておきたい
- Introducing ASP.NET Core 1.0 | Build 2016 | Channel 9
- Deploying ASP.NET Core Applications | Build 2016 | Channel 9
- ASP.NET Core Deep Dive into MVC | Build 2016 | Channel 9
- Web Platform: An Inside Look at What’s New for Microsoft EdgeHTML, ChakraCore, F12 Tools, and Microsoft Edge Extensions | Build 2016 | Channel 9
- Microsoft Edge: What's Next for Microsoft's New Browser and Web Platform | Build 2016 | Channel 9
- A Lap Around ChakraCore – Microsoft’s Open Source JavaScript Engine | Build 2016 | Channel 9
- Edgeはまだ常用するのはちょっと…だったんだけど、機能拡張も公開されて、盛り上がるか。
- Cross-Platform Mobile with Xamarin | Build 2016 | Channel 9
- Cross-Platform Mobile with Cordova and Ionic Framework | Build 2016 | Channel 9
- Cross-Platform at Microsoft: Xamarin, Cordova, Unity and C++ Panel | Build 2016 | Channel 9
- Working with Microsoft on Open Source: Cordova and ReactNative | Build 2016 | Channel 9
- Native iOS, Android, & Windows Apps from C# and XAML with Xamarin.Forms | Build 2016 | Channel 9
- Xplat/モバイルもの。Cordova開発は、日本だとアシアル社のMonacaでもいいんだけど、Ionicも注目
- Azure Functions Under the Hood | Build 2016 | Channel 9
- Introducing Azure Functions | Build 2016 | Channel 9
- Azureはあんまり興味ないけど、一応新しいものは見ておきたい。
- The Magic Mirror: Powered by a Hosted Web App and Windows 10 on Raspberry Pi | Build 2016 | Channel 9
- しばらく前によく見かけた、RaspPIで魔法の鏡を実装するやつかな。
- Designing Compelling Mixed Reality Experiences | Build 2016 | Channel 9
- Windows Command Line Improvements | Build 2016 | Channel 9
- NativeScript and Visual Studio Code: Together at Last! | Build 2016 | Channel 9
- Intelligent Systems: Advanced Analytics in Action for Retail, Healthcare and Manufacturing | Build 2016 | Channel 9
- Insight from Exhaust, Enriching Your Applications with Data | Build 2016 | Channel 9
- The Future of Visual Studio (Visual Studio "15" Preview) | Build 2016 | Channel 9
- Azure Service Fabric for Developers | Build 2016 | Channel 9
- HoloLens - Devs behind "Share your ideas" | Build 2016 | Channel 9
- Building HyperScale Web and Mobile Applications with Azure AppService | Build 2016 | Channel 9
- Windows in the Enterprise | Build 2016 | Channel 9
- Setting the Stage: The Application Platform in Windows Server 2016 | Build 2016 | Channel 9
他にも、ホログラム/HoloLensものが増えてて、そちらも興味深い。
Alea GPUというCUDA C#ライブラリでC++に匹敵する性能が出た
とのこと。(neueccさんのツイートで知った)
http://blog.quantalea.com/?p=9871
OpenCLやる前にSIMD使い切れっていう幻想……の話はもういいです^^
今回のはOpenCLじゃなくてCUDAですが。