c++の話(本当にあった怖い話)
DESCRIPTION
Python hack-a-thon 2010.07 用資料です。TRANSCRIPT
![Page 1: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/1.jpg)
C++の話Python Hack-a-thon 2010.07
2010年7月10日土曜日
![Page 2: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/2.jpg)
自己紹介name:Isoparametric(イソッパ)
blog:http://d.hatena.ne.jp/Isoparametric/
「神様なんて信じない僕らのために」というのを書いてますが、最近Blog更新サボってます……。
明日から本気出す……!
最近仕事でPython/Django書いてますよ
2010年7月10日土曜日
![Page 3: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/3.jpg)
C++の話?
C++は元々Cの拡張のようなもの
1983年にベル研のビャーネ・ストロヴストルップが作った言語
元はC with Classesだった
組み込みとか速度重視の環境ではよく使われる
2010年7月10日土曜日
![Page 4: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/4.jpg)
C++?マルチパラダイム言語と呼ばれる1.手続き型プログラミング2.データ抽象3.オブジェクト指向プログラミング4.ジェネリックプログラミングといった様々なスタイルのプログラムをサポートする言語です
2010年7月10日土曜日
![Page 5: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/5.jpg)
Bjarne Stroustrup
2010年7月10日土曜日
![Page 6: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/6.jpg)
構文と特徴if, for, whileなど基本構文はCと同じ多重継承テンプレート演算子オーバーロード例外処理実行時型情報(RTTI)タイプセーフではない強い静的型付け
2010年7月10日土曜日
![Page 7: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/7.jpg)
設計方針
C++は現場のプログラマにとってプログラミングがもっと楽しくなるために設計された汎用のプログラミング言語である(1986)
設計者はこれが成功した、と捉えている
当時、C++には3つの大きな方針があった
2010年7月10日土曜日
![Page 8: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/8.jpg)
C++はデータ抽象やオブジェクト指向をサポートしながらCと同等の速さを目指した。当時は速いという条件が無ければ、あとは何が良くても負けであった。実際に使われなくても、速くないという噂や偏見だけで葬り去られた。
何よりも速いこと
2010年7月10日土曜日
![Page 9: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/9.jpg)
C++ではCとの互換性を目指した。前からあるシステムに統合したり、以前から使われている制約多いシステムの上で作り出されなければならなかった。また、既存のコードやツールと共存も必須条件だった。
高いポータビリティ
2010年7月10日土曜日
![Page 10: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/10.jpg)
C++では、新しいプログラミングスタイルへの漸進的な移行が可能であった。新しいテクニックの習得には時間がかかるが、企業はプログラマの生産性が学習によって低下することを許容できない。また、中途半端にマスターした新しい考え方を誤用して失敗することを許容できなかった。
漸進的な移行性
2010年7月10日土曜日
![Page 11: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/11.jpg)
C++は現実的で崇高な言語
2010年7月10日土曜日
![Page 12: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/12.jpg)
C++が有用な場面低レベルシステムプログラミング
高レベルシステムプログラミング
組み込み分野
数値処理/科学計算
一般的なアプリケーションプログラミング
2010年7月10日土曜日
![Page 13: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/13.jpg)
ではソースを読もう
2010年7月10日土曜日
![Page 14: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/14.jpg)
#include <iostream>#include <algorithm>#include <boost/array.hpp>using namespace std;// letsboostよりint main(){ boost::array<int, 100> ar; // int ar[100]; for( int i=0; i<ar.size(); ++i ) ar[i] = i * 100;
boost::array<int, 4> ar2 = {{0, 100, 200, 300}};
if( equal( ar2.begin(), ar2.end(), ar.begin() ) ) cout << "same" << endl;
return 0;}
では、boost::arrayを読む2010年7月10日土曜日
![Page 15: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/15.jpg)
/* The following code declares class array, * an STL container (as wrapper) for arrays of constant size. * * See * http://www.boost.org/libs/array/ * for documentation. * * The original author site is at: http://www.josuttis.com/ * * (C) Copyright Nicolai M. Josuttis 2001. * * Distributed under the Boost Software License, Version 1.0. (See * accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group. * See <http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#776> or Trac issue #3168 * Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow) * 10 Mar 2010 - added workaround for SUNCC and !STLPort [trac #3893] (Marshall Clow) * 29 Jan 2004 - c_array() added, BOOST_NO_PRIVATE_IN_AGGREGATE removed (Nico Josuttis) * 23 Aug 2002 - fix for Non-MSVC compilers combined with MSVC libraries. * 05 Aug 2001 - minor update (Nico Josuttis) * 20 Jan 2001 - STLport fix (Beman Dawes) * 29 Sep 2000 - Initial Revision (Nico Josuttis) * * Jan 29, 2004 */#ifndef BOOST_ARRAY_HPP#define BOOST_ARRAY_HPP
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) # pragma warning(push) # pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe# pragma warning(disable:4510) // boost::array<T,N>' : default constructor could not be generated # pragma warning(disable:4610) // warning C4610: class 'boost::array<T,N>' can never be instantiated - user defined constructor required #endif
#include <cstddef>#include <stdexcept>#include <boost/assert.hpp>#include <boost/swap.hpp>
// Handles broken standard libraries better than <iterator>#include <boost/detail/iterator.hpp>#include <boost/throw_exception.hpp>#include <algorithm>
// FIXES for broken compilers#include <boost/config.hpp>
namespace boost {
template<class T, std::size_t N> class array { public: T elems[N]; // fixed-size array of elements of type T
public: // type definitions typedef T value_type; typedef T* iterator; typedef const T* const_iterator; typedef T& reference; typedef const T& const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type;
// iterator support iterator begin() { return elems; } const_iterator begin() const { return elems; } iterator end() { return elems+N; } const_iterator end() const { return elems+N; }
// reverse iterator support#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator;#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310) // workaround for broken reverse_iterator in VC7 typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, iterator, reference, iterator, reference> > reverse_iterator; typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator, const_reference, iterator, reference> > const_reverse_iterator;#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) typedef std::reverse_iterator<iterator, std::random_access_iterator_tag, value_type, reference, iterator, difference_type> reverse_iterator; typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag, value_type, const_reference, const_iterator, difference_type> const_reverse_iterator;#else // workaround for broken reverse_iterator implementations typedef std::reverse_iterator<iterator,T> reverse_iterator; typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;#endif
reverse_iterator rbegin() { return reverse_iterator(end()); } const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
// operator[] reference operator[](size_type i) { BOOST_ASSERT( i < N && "out of range" ); return elems[i]; } const_reference operator[](size_type i) const { BOOST_ASSERT( i < N && "out of range" ); return elems[i]; }
// at() with range check reference at(size_type i) { rangecheck(i); return elems[i]; } const_reference at(size_type i) const { rangecheck(i); return elems[i]; } // front() and back() reference front() { return elems[0]; } const_reference front() const { return elems[0]; } reference back() { return elems[N-1]; } const_reference back() const { return elems[N-1]; }
// size is constant static size_type size() { return N; } static bool empty() { return false; } static size_type max_size() { return N; } enum { static_size = N };
// swap (note: linear complexity) void swap (array<T,N>& y) { for (size_type i = 0; i < N; ++i) boost::swap(elems[i],y.elems[i]); }
// direct access to data (read-only) const T* data() const { return elems; } T* data() { return elems; }
// use array as C array (direct read/write access to data) T* c_array() { return elems; }
// assignment with type conversion template <typename T2> array<T,N>& operator= (const array<T2,N>& rhs) { std::copy(rhs.begin(),rhs.end(), begin()); return *this; }
// assign one value to all elements void assign (const T& value) { fill ( value ); } // A synonym for fill void fill (const T& value) { std::fill_n(begin(),size(),value); }
// check range (may be private because it is static) static void rangecheck (size_type i) { if (i >= size()) { std::out_of_range e("array<>: index out of range"); boost::throw_exception(e); } }
};
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template< class T > class array< T, 0 > {
public: // type definitions typedef T value_type; typedef T* iterator; typedef const T* const_iterator; typedef T& reference; typedef const T& const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type;
// iterator support iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); } const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); } iterator end() { return begin(); } const_iterator end() const { return begin(); }
// reverse iterator support#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator;#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310) // workaround for broken reverse_iterator in VC7 typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, iterator, reference, iterator, reference> > reverse_iterator; typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator, const_reference, iterator, reference> > const_reverse_iterator;#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) typedef std::reverse_iterator<iterator, std::random_access_iterator_tag, value_type, reference, iterator, difference_type> reverse_iterator; typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag, value_type, const_reference, const_iterator, difference_type> const_reverse_iterator;#else // workaround for broken reverse_iterator implementations typedef std::reverse_iterator<iterator,T> reverse_iterator; typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;#endif
reverse_iterator rbegin() { return reverse_iterator(end()); } const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
// operator[] reference operator[](size_type /*i*/) { return failed_rangecheck(); }
const_reference operator[](size_type /*i*/) const { return failed_rangecheck(); }
// at() with range check reference at(size_type /*i*/) { return failed_rangecheck(); } const_reference at(size_type /*i*/) const { return failed_rangecheck(); }
// front() and back() reference front() { return failed_rangecheck(); }
const_reference front() const { return failed_rangecheck(); }
reference back() { return failed_rangecheck(); }
const_reference back() const { return failed_rangecheck(); }
// size is constant static size_type size() { return 0; } static bool empty() { return true; } static size_type max_size() { return 0; } enum { static_size = 0 };
void swap (array<T,0>& /*y*/) { }
// direct access to data (read-only) const T* data() const { return 0; } T* data() { return 0; }
// use array as C array (direct read/write access to data) T* c_array() { return 0; }
// assignment with type conversion template <typename T2> array<T,0>& operator= (const array<T2,0>& ) { return *this; }
// assign one value to all elements void assign (const T& value) { fill ( value ); } void fill (const T& ) {} // check range (may be private because it is static) static reference failed_rangecheck () { std::out_of_range e("attempt to access element of an empty array"); boost::throw_exception(e);#if defined(BOOST_NO_EXCEPTIONS) || !defined(BOOST_MSVC) // // We need to return something here to keep // some compilers happy: however we will never // actually get here.... // static T placeholder; return placeholder;#endif } };#endif
// comparisons template<class T, std::size_t N> bool operator== (const array<T,N>& x, const array<T,N>& y) { return std::equal(x.begin(), x.end(), y.begin()); } template<class T, std::size_t N> bool operator< (const array<T,N>& x, const array<T,N>& y) { return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); } template<class T, std::size_t N> bool operator!= (const array<T,N>& x, const array<T,N>& y) { return !(x==y); } template<class T, std::size_t N> bool operator> (const array<T,N>& x, const array<T,N>& y) { return y<x; } template<class T, std::size_t N> bool operator<= (const array<T,N>& x, const array<T,N>& y) { return !(y<x); } template<class T, std::size_t N> bool operator>= (const array<T,N>& x, const array<T,N>& y) { return !(x<y); }
// global swap() template<class T, std::size_t N> inline void swap (array<T,N>& x, array<T,N>& y) { x.swap(y); }
} /* namespace boost */
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) # pragma warning(pop) #endif
#endif /*BOOST_ARRAY_HPP*/
2010年7月10日土曜日
![Page 16: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/16.jpg)
普通に無理でしたすみません
2010年7月10日土曜日
![Page 17: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/17.jpg)
てか、そんなこと実はどうでもいいので続きはWikipediaでも見てください
http://ja.wikipedia.org/wiki/C%2B%2B
2010年7月10日土曜日
![Page 18: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/18.jpg)
で、
2010年7月10日土曜日
![Page 19: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/19.jpg)
本当にあった怖い話あなたの知らないCとC++の世界
2010年7月10日土曜日
![Page 20: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/20.jpg)
C++の話じゃないの?
俺、最近C++書いてないんだ……で、C++の言語的な話をしてもなあ……
Python好きなみんなはC++とかどうでもいいよね
せっかくなので、怖い話でもします
ということで本当にあった怖い話です
ディープなC++の話とかC++0x(次期標準)の話と思った人ごめんなさい
そういう人はBoost勉強会にでも行ってください
2010年7月10日土曜日
![Page 21: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/21.jpg)
この内容は、
実在の会社、
実在のプロジェクト、
実在のプログラマとは、
一切関係がありません
2010年7月10日土曜日
![Page 22: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/22.jpg)
今日のテーマはこんな感じ2010年7月10日土曜日
![Page 23: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/23.jpg)
スライドの目的
こんな心霊スポットには気をつけましょう
こんな幽霊には気をつけましょう
間違えて心霊スポットに足を踏み入れた場合、いざというときは走って逃げましょう
もしかしたら現状このような霊に取り憑かれている人もいるかもしれないですが、南無南無です
2010年7月10日土曜日
![Page 24: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/24.jpg)
某T都S区C社2010.xx.xx
2010年7月10日土曜日
![Page 25: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/25.jpg)
Tさんは語る……
2010年7月10日土曜日
![Page 26: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/26.jpg)
ディレクトリ構成が機能単位ではなくプログラマの名前幽霊
ご丁寧にソースにまでプログラマの頭文字画像はイメージです
2010年7月10日土曜日
![Page 27: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/27.jpg)
どうしてこうなった?
誰が書いたソースかわかりやすいらしい
困った時に誰に聞いたらいいか一目瞭然らしい
俺のソースなので触ったら殺すぞ、ということらしい
機能被ってる関数とか普通にあるんだけど、なんとかして
2010年7月10日土曜日
![Page 28: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/28.jpg)
どう考えても理由が嘘です本当にありがとうございます
2010年7月10日土曜日
![Page 29: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/29.jpg)
説明するまでもない対策
誰が書いたかは、バージョン管理システムのログからコミットした人間を見ればわかりますよね
ソースは機能単位でわけないと機能が重複しまくって困りますよね
「ソースに名前をつけることでプログラマに責任を持たせる」という人がいたら殴りましょう(実話)
2010年7月10日土曜日
![Page 30: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/30.jpg)
関数の頭にプログラマの名前が付く幽霊
誰がかいた関数かわか(ry
名前が被らなくていいらし(ry
watCheckCollisionとか、名前キモイ
namespaceとか教えてあげましょう
てか、意味解らん
2010年7月10日土曜日
![Page 31: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/31.jpg)
マジで何とかするべき……!2010年7月10日土曜日
![Page 32: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/32.jpg)
幽霊対策
何度も言いますがバージョン管理のログを(ry
名前の管理は普通にnamespaceとか言語の機能を使いましょう
汎用的な名前つけまくる人とかいるけどね(Nodeとか、Listとか、Arrayとか)
2010年7月10日土曜日
![Page 33: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/33.jpg)
バージョン管理システムを使わない幽霊
決まった時刻にネットワークドライブにソースをアップします
後にzipで配布されます
diffは自力でとります
なぜ、なぜなんだ……
お前、それで辛くないのか……
2010年7月10日土曜日
![Page 34: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/34.jpg)
バージョン管理システムがVisualSourceSafe幽霊
いじりたいファイルは大抵ロックされている
俺はこのインターフェイス拡張したいのに
ロックしっぱなしで一週間とかコミットしてくれない
……というかすぐリポジトリがぶっ壊れる
途中で変なエラーで停止してわちゃくちゃになる
2010年7月10日土曜日
![Page 35: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/35.jpg)
コミットは朝しろ帰る前にするなと言う幽霊
ロックしたままビルドが通らないファイルをコミットして帰るプログラマがいるので謎の掟ができる
よって、帰る前にはコミットできない
朝しかコミットしてはいけない……え?
これ、何の為のバージョン管理システムだっけ?
2010年7月10日土曜日
![Page 36: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/36.jpg)
バージョン管理してる意味ねえ
2010年7月10日土曜日
![Page 37: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/37.jpg)
そんな幽霊対策
SubversionかGitを使いましょうよ
BazaarとかMercurialでも良いですけど
VSSとか手動とか正気の沙汰とは……!
あとGUIだけじゃなくてCUIでも憶えようね
2010年7月10日土曜日
![Page 38: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/38.jpg)
手動でビルドテストしなければならない幽霊
コンパイル通るかテストマシンが離れた場所にあり、コミット後のビルドテストをするのに、そこまでいかなければならない
ビルドが自動化されておらず、死ぬほど面倒
CI(Hudsonなど)を勧めると、設定がめんどくさいと言われる
2010年7月10日土曜日
![Page 39: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/39.jpg)
そんな幽霊対策
CI使おうよ、普通に
Hudson! Hudson!
コミットするたび歩いてビルドが通るかテストしにいくとか普通に面倒
コミットしたら、フックスクリプトでビルド走らせて失敗したらメールとかでいいよ
CI=継続的インテグレーションツールです
2010年7月10日土曜日
![Page 40: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/40.jpg)
C++かんけーねーなそろそろ言われると思ってました
2010年7月10日土曜日
![Page 41: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/41.jpg)
C++にまつわる怖い話あなたのまだまだ知らない世界
2010年7月10日土曜日
![Page 42: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/42.jpg)
オレオレコンテナしか信じない幽霊
STL(標準ライブラリ)やBoost(標準化委員会が中心となったOSS)は「信用できない」ので、自分で書いたコンテナしか使わないという人がいる
標準を使えばというとすぐ「バグってるだろ?」とか「バグってたら心配」とか言う
自分が作ったコンテナしか使わないので互換性0、インターフェイスも無茶苦茶
Pythonで例えるとlistやdictが自作2010年7月10日土曜日
![Page 43: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/43.jpg)
ハッシュ(などのデータ構造)は遅いから
使うべきでないという幽霊
ハッシュが配列より遅いと真顔で言う人がいてびびる
データ構造とか理解してる?
いや、そりゃ単純なアクセスは遅いだろうけどさ
Pythonで例えるとdict使うな、な感じ
2010年7月10日土曜日
![Page 44: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/44.jpg)
C++で「よくわからんから」多重継承は禁止すべき
とか言う幽霊
C++で多重継承(インターフェイス継承)できないとか終わった
JavaでInterface使うな、と言われてるレベル
Pythonだと「継承使うな」くらいのレベルかも
インターフェイスで会話できんがな……
2010年7月10日土曜日
![Page 45: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/45.jpg)
正規表現を使うよりCで書いた方が早いと言う幽霊
なんだと……!?
一文字ずつCでパースするとか嫌だお……
文字コード対応どうするんでしょうね?
早いとか言って書いてくれた事ないけどね!
Pythonだと「re禁止」みたいな感じ?
2010年7月10日土曜日
![Page 46: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/46.jpg)
クラスが解らないのでクラスを使ってくれない幽霊
……え?
勉強しようぜ……
「クラスとかよくわからんし」(キリッと言われましても
クラスを使うと動作がおかしい、とか言い出す
いえ、おかしいのはお前の頭です
2010年7月10日土曜日
![Page 47: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/47.jpg)
C++は遅いしか言わない幽霊
定番
「C++遅いし」「Cで書き直したら速くなった」
いや、それは君の書き方の問題だ
「小さな効率のことは忘れ、時間の97%について語ろう。時期尚早な最適化は諸悪の根源だ」(ドナルド・クヌース)
普通にC++遅くないよ
2010年7月10日土曜日
![Page 48: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/48.jpg)
1つのソースコードが10,000行以上でも気にしない幽霊
モジュールに分けられていなくて涙目
公開インターフェイス? なにそれ、おいしいの?
使いたい機能を探すのが苦痛でしょうがない
ソース分割しようぜ……
関数ポインタ乱用とかやめるんだぜ
2010年7月10日土曜日
![Page 49: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/49.jpg)
Luaとか既存のものより優れたスクリプトを
作れるとか言い出す幽霊
普通につくれるわけねーです
LuaとかPythonとか何人が使っていて、何年稼働していると思ってますか?
1社の1エンジニアが即興で作ったものがそれに敵うとでも思ってますか?
「時間があれば作れる」……だと!?
2010年7月10日土曜日
![Page 50: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/50.jpg)
こうした心霊現象が起こる理由
これらの事が起きる理由は大抵「よくわからない」から「知らない」から
多重継承や、標準コンテナ、CIやバージョン管理も何でも「よくわからない」ので使ってはいけないという人がいる
よくわからないのは勉強しないからだよね
いや、マジで勉強してください2010年7月10日土曜日
![Page 51: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/51.jpg)
これはCやC++の問題?
いえ、普通に人間の問題
ただ、昔の人はこれでプロジェクトを回してきたので、過去に疑問をもてなくなってるんだと思われる
本当にあった怖い話を聞いて、老害化しすぎだろ……と思ったら自分を見直しましょう
いつの間にか老害化するのが心霊現象2010年7月10日土曜日
![Page 52: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/52.jpg)
どうしてこうなった?
2010年7月10日土曜日
![Page 53: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/53.jpg)
2010年7月10日土曜日
![Page 54: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/54.jpg)
2010年7月10日土曜日
![Page 55: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/55.jpg)
こんな恐怖に出会ったら
恐怖に立ち向かい自分のプロジェクトだけは守りましょう
なるべく正論で戦いましょう(普通に通じない事があるけど)
まるで正論が通じない事があるのでそう言うときは走って逃げましょう
とりあえず「はいはい」と言うこともあったりなかったり
2010年7月10日土曜日
![Page 56: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/56.jpg)
まとめ
心霊現象には気をつけましょう
突然Cが出ても恐れずC++を使いましょう
C++を使う時は正しく使いましょう
「C++ Coding Standards―101のルール、ガイドライン、ベストプラクティス」を読んで従えばそうそう酷いことにはなりません
盲目的に従うのは駄目よ「なぜ」大事
2010年7月10日土曜日
![Page 57: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/57.jpg)
本当のC++の話
C++の設計と進化
通称D&E(Design and Evolution)
C++の言語設計のお話ですが、Cとの戦いの歴史でもあります
面白いよ! おぬぬめ
2010年7月10日土曜日
![Page 58: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/58.jpg)
なぜ面白いか?
Pythonにあり、Rubyにも入ると言われているキーワード引数はなぜC++に入らなかったか?
商業的にC++には何が期待されていたのか?
言語とライブラリ設計のルールの議論
商業言語は趣味や好みでは作れない
などなど、C++の「なぜ」を解決する本なんです
2010年7月10日土曜日
![Page 59: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/59.jpg)
一時期C++の本を積むのが流行った
2010年7月10日土曜日
![Page 60: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/60.jpg)
2010年7月12日月曜日
![Page 61: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/61.jpg)
どうみても必読本ですね!Blogから
引用させていただきました
2010年7月12日月曜日
![Page 62: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/62.jpg)
最後に
C++の話してねーな
これC++の話ですか?
いえ違います
Python触ってからC++触るのは正直お勧めしません
色々大変なだけだし……! メモリとかメモリとかメモリとかメモリとか
言語設計はさっきの本読んで2010年7月10日土曜日
![Page 63: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/63.jpg)
言語より人間が大事
2010年7月10日土曜日
![Page 64: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/64.jpg)
C++のいいところ話せなくてすみません
2010年7月10日土曜日
![Page 65: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/65.jpg)
C++0xをdisってる人をdisる闇のC++軍団たちとかがTwitterにいて
怖いので黙っておいてください
http://togetter.com/li/66692010年7月10日土曜日
![Page 66: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/66.jpg)
C++闇の軍団に会いたい人はTwitterでC++をdisろう!
2010年7月10日土曜日
![Page 67: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/67.jpg)
闇の噂
2010年7月10日土曜日
![Page 68: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/68.jpg)
フォロー
色んな側面を持つC++も面白いよ
ただ、未だにCの呪縛にとらわれてる
色々楽にしようとすれば楽になるよ
C++のイメージが悪いのは、こういう幽霊がプロジェクトを炎上させたりするからかも
2010年7月10日土曜日
![Page 69: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/69.jpg)
ただ、設計者曰くC++の目的は崇高である:プログラマに、現実世界のプログラムをエレガントさと効率を兼ね備えた形で書く術を提供し、現実世界のコードの抽象度を高め、ひいては多くの真剣なプログラマの労働環境を改善しよう、というものである
C++には理想と現実があり、面白いのは事実です
興味があったら触ってみてくださいね
火傷してもしらんけど2010年7月10日土曜日
![Page 70: C++の話(本当にあった怖い話)](https://reader036.vdocuments.pub/reader036/viewer/2022062511/54b72b864a79591b2d8b45ea/html5/thumbnails/70.jpg)
ご静聴ありがとうございました
2010年7月10日土曜日