what'what s thiss , ken?怎么读

该如何优雅地黑 C++?
按投票排序
转一首脍炙人口的弹唱 So Much Drama in the PhD 出自
Yo, MC Plus Plus, my rhymes are so phat,
I'm PSPACE-complete but I'll reduce you to 3-SAT.
My crew is so hard that we roll in NP,
And bitches dereference my pointer for free.
When I'm linear probing they're like, "Damn that's gigantic,"
I showed it to your mom and she used Hoare semantics.
She jumped like JNE
up onto my erection
And I picked up that ho like straight garbage collection.
("That's right, mark-and-sweep on these nuts, bitch.")
My lyrics get stolen by sucker MCs,
I gotta sign my rhymes with PGP;
But I keep on generatin' like a CFG
'Cause there's so much drama in the PhD.
What's wrong MC Plus Plus, am I making you nervous?
Even skanky fat hoes give you denial of service.
You'll probably go to jail before you write your dissertation
So prepare your asshole for some in
&Uhhh& Penetration, as they fill it up with jism,
It's too bad you aren't closed under homomorphism.
Your problem, Plus Plus, is that your typing isn't strict:
In ML my type is real
and your type is 'a dict.
I control my flow better than TCP,
I rep the west coast like Eazy-E,
You best not front if you can't pass the GRE,
'Cause there's so much drama in the PhD.
My flow is so intense that I will overflow your buffer,
Corrupt your stack pointer makin' all your data suffer.
I've got saturated edges but your flow is sparser,
Real gangstas sip on Y instead you generate a parser.
While you're busy poppin' stacks I'll pop a cap in your skull,
While you smoke your crack pipe I'm gonna pipe you to
/dev/null.
I may not have a label but I
I'm an unsigned long int
and you're an 8-bit char.
Your mom circulates like a public key,
Servicing more requests than HTTP.
She keeps all her ports open like Windows ME,
Oh, there's so much drama in the PhD.DWORD
to your moms, I
I've got more rhymes that San Jose's got dotcoms.
I rep the Farm like 50 reps Queens,
With more power than multitape Turing Machines.
Blowin' up the rap scene faster than factorial functions,
I'm dope like PNP transistors and I'll saturate your junctions.
By the time you've rhymed one line, I'v
You rap in exponential time and I'm big-O of log(n).
I run gmake and gcc,
And I ain't never called malloc
without calling free.
I'll beat your ass until it's colored like a red-black tree
'Cause there's so much drama in the PhD.完整歌词 附上音频
是时候上这个链接了。On the 1st of January, 1998,
gave an interview to the IEEE’s ‘Computer’ magazine..Naturally, the editors thought he would be giving a retrospective
view of seven years of object-oriented design, using the language he
created.By the end of the interview, the interviewer got more than he had
bargained for and, subsequently, the editor decided to suppress its
contents, ‘for the good of the industry’ but, as with many of these
things, there was a leak..Here is a complete transcript of what was was said, unedited, and unrehearsed, so it isn’t as neat as planned interviews..You will find it interesting….Interviewer:
Well, it’s been a few years since you changed the world of software design, how does it feel, looking back?Stroustrup:
Actually, I was thinking about
those days, just before you arrived. Do you remember? Everyone was
writing ‘C’ and, the trouble was, they were pretty damn good at it..
Universities got pretty good at teaching it, too. They were turning out
competent - I stress the word ‘competent’ - graduates at a phenomenal
rate. That’s what caused the problem..Interviewer:
Problem?Stroustrup:
Yes, problem. Remember when everyone wrote Cobol?Interviewer:
Of course, I did tooStroustrup:
Well, in the beginning, these guys were like demi-gods. Their salaries were high, and they were treated like royalty..Interviewer:
Those were the days, eh?Stroustrup:
Right. So what happened? IBM got
sick of it, and invested millions in training programmers, till they
were a dime a dozen..Interviewer:
That’s why I got out. Salaries dropped within a year, to the point where being a journalist actually paid better..Stroustrup:
Exactly. Well, the same happened with ‘C’ programmers..Interviewer:
I see, but what’s the point?Stroustrup:
Well, one day, when I was sitting
in my office, I thought of this little scheme, which would redress the
balance a little. I thought ‘I wonder what would happen, if there were a
language so complicated, so difficult to learn, that nobody would ever
be able to swamp the market with programmers? Actually, I got some of
the ideas from X10, you know, X windows. That was such a bitch of a
graphics system, that it only just ran on those Sun 3/60 things.. They
had all the ingredients for what I wanted. A really ridiculously complex
syntax, obscure functions, and pseudo-OO structure. Even now, nobody
writes raw X-windows code. Motif is the only way to go if you want to
retain your sanity..Interviewer:
You’re kidding…?Stroustrup:
Not a bit of it. In fact, there was
another problem.. Unix was written in ‘C’, which meant that any ‘C’
programmer could very easily become a systems programmer. Remember what a
mainframe systems programmer used to earn?Interviewer:
You bet I do, that’s what I used to do..Stroustrup:
OK, so this new language had to
divorce itself from Unix, by hiding all the system calls that bound the
two together so nicely. This would enable guys who only knew about DOS
to earn a decent living too..Interviewer:
I don’t believe you said that….Stroustrup:
Well, it’s been long enough, now,
and I believe most people have figured out for themselves that C++ is a
waste of time but, I must say, it’s taken them a lot longer than I
thought it would..Interviewer:
So how exactly did you do it?Stroustrup:
It was only supposed to be a joke, I
never thought people would take the book seriously. Anyone with half a
brain can see that object-oriented programming is counter-intuitive,
illogical and inefficient..Interviewer:
What?Stroustrup:
And as for ’re-useable code' - when did you ever hear of a company re-using its code?Interviewer:
Well, never, actually, but….Stroustrup:
There you are then. Mind you, a few
tried, in the early days. There was this Oregon company - Mentor
Graphics, I think they were called - really caught a cold trying to
rewrite everything in C++ in about ‘90 or '91. I felt sorry for them
really, but I thought people would learn from their mistakes..Interviewer:
Obviously, they didn’t?Stroustrup:
Not in the slightest. Trouble is,
most companies hush-up all their major blunders, and explaining a $30
million loss to the shareholders would have been difficult.. Give them
their due, though, they made it work in the end..Interviewer:
They did? Well, there you are then, it proves O-O works..Stroustrup:
Well, almost. The executable was so
huge, it took five minutes to load, on an HP workstation, with 128MB of
RAM. Then it ran like treacle. Actually, I thought this would be a
major stumbling-block, and I’d get found out within a week, but nobody
cared. Sun and HP were only too glad to sell enormously powerful boxes,
with huge resources just to run trivial programs. You know, when we had
our first C++ compiler, at AT&T, I compiled ‘Hello World’, and
couldn’t believe the size of the executable. 2.1MBInterviewer:
What? Well, compilers have come a long way, since then..Stroustrup:
They have? Try it on the latest
version of g++ - you won’t get much change out of half a megabyte. Also,
there are several quite recent examples for you, from all over the
world. British Telecom had a major disaster on their hands but, luckily,
managed to scrap the whole thing and start again. They were luckier
than Australian Telecom. Now I hear that Siemens is building a dinosaur,
and getting more and more worried as the size of the hardware gets
bigger, to accommodate the executables. Isn’t multiple inheritance a
joy?Interviewer:
Yes, but C++ is basically a sound language..Stroustrup:
You really believe that, don’t you?
Have you ever sat down and worked on a C++ project? Here’s what
happens: First, I’ve put in enough pitfalls to make sure that only the
most trivial projects will work first time. Take operator overloading.
At the end of the project, almost every module has it, usually, because
guys feel they really should do it, as it was in their training course.
The same operator then means something totally different in every
module. Try pulling that lot together, when you have a hundred or so
modules. And as for data hiding. God, I sometimes can’t help laughing
when I hear about the problems companies have making their modules talk
to each other. I think the word ‘synergistic’ was specially invented to
twist the knife in a project manager’s ribs..Interviewer:
I have to say, I’m beginning to be
quite appalled at all this. You say you did it to raise programmers'
salaries? That’s obscene..Stroustrup:
Not really. Everyone has a choice. I
didn’t expect the thing to get so much out of hand. Anyway, I basically
succeeded. C++ is dying off now, but programmers still get high
salaries - especially those poor devils who have to maintain all this
crap. You do realise, it’s impossible to maintain a large C++ software
module if you didn’t actually write it?Interviewer:
How come?Stroustrup:
You are out of touch, aren’t you? Remember the typedef?Interviewer:
Yes, of course..Stroustrup:
Remember how long it took to grope
through the header files only to find that ‘RoofRaised’ was a double
precision number? Well, imagine how long it takes to find all the
implicit typedefs in all the Classes in a major project..Interviewer:
So how do you reckon you’ve succeeded?Stroustrup:
Remember the length of the
average-sized ‘C’ project? About 6 months. Not nearly long enough for a
guy with a wife and kids to earn enough to have a decent standard of
living. Take the same project, design it in C++ and what do you get?
I’ll tell you. One to two years. Isn’t that great? All that job
security, just through one mistake of judgment. And another thing. The
universities haven’t been teaching ‘C’ for such a long time, there’s now
a shortage of decent ‘C’ programmers. Especially those who know
anything about Unix systems programming. How many guys would know what
to do with ‘malloc’, when they’ve used ‘new’ all these years - and never
bothered to check the return code. In fact, most C++ programmers throw
away their return codes. Whatever happened to good ol' ‘-1’? At least
you knew you had an error, without bogging the thing down in all that
‘throw’ ‘catch’ ‘try’ stuff..Interviewer:
But, surely, inheritance does save a lot of time?Stroustrup:
Does it? Have you ever noticed the
difference between a ‘C’ project plan, and a C++ project plan? The
planning stage for a C++ project is three times as long. Precisely to
make sure that everything which should be inherited is, and what
shouldn’t isn’t. Then, they still get it wrong.. Whoever heard of memory
leaks in a ‘C’ program? Now finding them is a major industry. Most
companies give up, and send the product out, knowing it leaks like a
sieve, simply to avoid the expense of tracking them all down..Interviewer:
There are tools…..Stroustrup:
Most of which were written in C++.Interviewer:
If we publish this, you’ll probably get lynched, you do realise that?Stroustrup:
I doubt it. As I said, C++ is way
past its peak now, and no company in its right mind would start a C++
project without a pilot trial. That should convince them that it’s the
road to disaster. If not, they deserve all they get.. You know, I tried
to convince Dennis Ritchie to rewrite Unix in C++..Interviewer:
Oh my God. What did he say?Stroustrup:
Well, luckily, he has a good sense
of humor. I think both he and Brian figured out what I was doing, in the
early days, but never let on. He said he’d help me write a C++ version
of DOS, if I was interested..Interviewer:
Were you?Stroustrup:
Actually, I did write DOS in C++,
I’ll give you a demo when we’re through. I have it running on a Sparc 20
in the computer room. Goes like a rocket on 4 CPU’s, and only takes up
70 megs of disk..Interviewer:
What’s it like on a PC?Stroustrup:
Now you’re kidding. Haven’t you
ever seen Windows ‘95? I think of that as my biggest success. Nearly
blew the game before I was ready, though..Interviewer:
You know, that idea of a Unix++ has really got me thinking. Somewhere out there, there’s a guy going to try it..Stroustrup:
Not after they read this interview..Interviewer:
I’m sorry, but I don’t see us being able to publish any of this..Stroustrup:
But it’s the story of the century. I
only want to be remembered by my fellow programmers, for what I’ve done
for them. You know how much a C++ guy can get these days?Interviewer:
Last I heard, a really top guy is worth $70 - $80 an hour..Stroustrup:
See? And I bet he earns it. Keeping
track of all the gotchas I put into C++ is no easy job. And, as I said
before, every C++ programmer feels bound by some mystic promise to use
every damn element of the language on every project. Actually, that
really annoys me sometimes, eve. I almost like the language after all
this time..Interviewer:
You mean you didn’t before?Stroustrup:
Hated it. It even looks clumsy,
don’t you agree? But when the book royalties started to come in… well,
you get the picture..Interviewer:
Just a minute. What about references? You must admit, you improved on ‘C’ pointers..Stroustrup:
Hmm. I’ve always wondered about
that. Originally, I thought I had. Then, one day I was discussing this
with a guy who’d written C++ from the beginning. He said he could never
remember whether his variables were referenced or dereferenced, so he
always used pointers. He said the little asterisk always reminded him..Interviewer:
Well, at this point, I usually say ‘thank you very much’ but it hardly seems adequate..Stroustrup:
Promise me you’ll publish this. My conscience is getting the better of me these days..Interviewer:
I’ll let you know, but I think I know what my editor will say..Stroustrup:
Who’d believe it anyway? Although, can you send me a copy of that tape?Interviewer:
I can do that.
“C++ is double-plus good!” —《1984》
借用 Ken Thompson说过的一个段子:"假如, 图灵来到了现代,我们怎么教他使用计算机呢?好, 先教他开机, 咔咔, 按一下那个按钮.机器打开了, 下一步, 要教他编程语言.好, 我们选C++吧, 拿出C++的manual, 咻! 完蛋了, 一辈子(就在这样的翻Manual中)完了!" -- Ken Thompson 于2013年ACM图灵集会上如是说.----------UUpdate:
自问自答,转自stackoverflowC++ is a modern language where your parent can't touch your privates but your friends can!
life is too short to learn c++.
当你拿着C++做的锤子,一切看起来都像是手指。
上图说话利益相关:西安某电大学学生。这是我们辅修专业课表,贵校领导就这样让那个字通过了审核,传阅于广大学子中-_-#蛤蛤。
最近写了一片槽文,博客链接 -------------- 全文如下 --------------欧欧匹代码的格局,是和别的编程模式不同的:首先要有一个构造函数;基类里只定义了函数的形式,可以随时通过派生增加不同的实现。那些程序员们,每每学会了继承和多态,便可以接一个项目,——这是十年前的事,现在至少要懂得设计模式,——靠柜台外站着,写些代码换一个鸡蛋灌饼吃;倘若懂一些多线程的知识,便可以在鸡蛋灌饼里加火腿肠,或者里脊了,如果懂得语言的实现原理,那就能做一些底层代码的优化,换一盘炒菜。但这些程序员,多是初级水平,大抵没有这样深入。只有懂得内存模型的,才能接一些底层的项目,打开调试器和剖析器,慢慢的坐着优化代码。我从十二岁起,便在村口的githoverflow工厂里当学徒,师傅说,我逻辑思维太差,怕学不会静态类型语言,就写些shell脚本吧。shell脚本虽然容易写,但语法容易含混不清的地方也不少。字符串和数组的功能很弱,条件判断的语法也很奇特,有时要对特殊字符手动做两重转义,然后通过。在这种情况下,写脚本也很为难。所以过了几天,师傅又说我干不了这事。幸亏荐头的情面大,辞退不得,便改为专管测试的一种无聊职务了。我从此便整天的站在测试机前,专管运行测试脚本。虽然没有什么失职,但总觉得有些单调,有些无聊。师傅是一副凶脸孔,程序员也没有好声气,教人活泼不得;只有夕甲甲到厂里,才可以笑几声,所以至今还记得。夕甲甲是站着编程而手动管理内存的唯一的程序员。他用的开发语言语法臃肿;结构杂乱,代码间时常夹些#ifdef;一堆乱蓬蓬的充当接口的.h文件。虽然是手动管理内存,可是经常出现野指针,要么忘了初始化,要么释放后没有设置成NULL。他写的代码,总是满屏的奇技淫巧,叫人半懂不懂的。因为他姓夕,又总觉得自己的技术天下第一,别人便用“甲乙丙丁”的第一个字,替他取下一个绰号,叫做夕甲甲。夕甲甲一到厂,所有的程序员便都看着他笑,有的叫道,“夕甲甲,你的代码又出新bug了!”他不作答,对柜里说,“来两个鸡蛋灌饼,一杯豆浆。”便把Thinkpad摆好。他们又故意的高声嚷道,“你一定又把人家的内存搞泄漏了!”夕甲甲睁大眼睛说,“你怎么这样凭空污人清白……”“什么清白?我前天亲眼见你搞崩了Windows的内存,吊着打。”夕甲甲便涨红了脸,额上的青筋条条绽出,争辩道,“内存没释放不能算泄漏……没释放!……程序员的事,能算泄漏么?”接连便是难懂的话,什么“new/delete配对使用”,什么“谁申请谁释放”之类,引得众人都哄笑起来:厂内外充满了快活的空气。听人家背地里谈论,夕甲甲原来也读过CS博士,但终于没有去做学术,又不会营生;于是愈过愈穷,弄到将要讨饭了。幸而还会写点代码,便替人家做几个游戏,换一碗饭吃。可惜他又有一样坏毛病,便是内存泄漏。运行不到几秒,便连程序带数据,一齐崩掉。如是几次,叫他写游戏的人也没有了。夕甲甲没有法,便只好做些最简单的外包项目。但他在我们厂里,品行却比别人都好,就是从不留bug;虽然间或一时不能解决,暂时记在wiki上,但不出一月,定然修复,从wiki上删去了夕甲甲的名字。夕甲甲写过半页代码,涨红的脸色渐渐复了原,旁人便又问道,“夕甲甲,你当真会写代码么?”夕甲甲看着问他的人,显出不屑置辩的神气。他们便接着说道,“你怎的连半行代码也没有贡献给linux内核呢?”夕甲甲立刻显出颓唐不安模样,脸上笼上了一层灰色,嘴里说些话;这回可是全是“狗屎Linus”之类,一些不懂了。在这时候,众人也都哄笑起来:店内外充满了快活的空气。在这些时候,我可以附和着笑,师傅是决不责备的。而且师傅见了夕甲甲,也每每这样问他,引人发笑。夕甲甲自己知道不能和他们谈天,便只好向孩子说话。有一回对我说道,“你学过编程么?”我略略点一点头。他说,“学过编程,……我便考你一考。const int *和int const *,有什么区别?”我想,讨饭一样的人,也配考我么?便回过脸去,不再理会。夕甲甲等了许久,很恳切的说道,“不知道罢?……我教给你,记着!这些语法应该记着。将来做程序员的时候,写代码要用。”我暗想我和程序员的等级还很远呢,而且我们师傅也从不用裸指针;又好笑,又不耐烦,懒懒的答他道,“谁要你教,两个没区别,都是指向常量的指针。如果你想用指针常量,要写int * const。”夕甲甲显出极高兴的样子,将手里的破鼠标敲着电脑桌,点头说,“对呀对呀!……const有四种用法,你知道么?”我愈不耐烦了,努着嘴走远。夕甲甲刚在Visual Studio里新建一个空文件,想在里面写代码,见我毫不热心,便又叹一口气,显出极惋惜的样子。有几回,邻居孩子听得笑声,也赶热闹,围住了夕甲甲。他便给他们一人写了一个Hello World。孩子看完,仍然不散,眼睛都望着屏幕。夕甲甲着了慌,伸开五指将屏幕罩住,弯腰下去说道,“error了,编译器报error了。”直起身又看一看屏幕,自己摇头说,“error error!哀乎哉?error也。”于是这一群孩子都在笑声里走散了。夕甲甲是这样的使人快活,可是没有他,别人也便这么过。有一天,大约是程序员节前的两三天,师傅正在慢慢的release代码,打开wiki,忽然说,“夕甲甲长久没有来了。还有十九个bug没修复呢!”我才也觉得他的确长久没有来了。一个喝酒的人说道,“他怎么会来?……他打折了腿了。”师傅说,“哦!”“他总仍旧是搞崩内存。这一回,是自己发昏,竟搞崩了GFW的内存。他家的内存,搞得的吗?”“后来怎么样?”“怎么样?先是去喝茶,后来是打,打了大半夜,再打折了腿。”“后来呢?”“后来打折了腿了。”“打折了怎样呢?”“怎样?……谁晓得?许是死了。”师傅也不再问,仍然慢慢的做他的release。程序员节过后,函数式编程是一天比一天热门,看看连Java都开始支持lambda表达式;我整天的做测试,也须了解什么是闭包了。一天的下半天,没有一个要测试的项目,我正合了眼坐着。忽然间听得一个声音,“来一个鸡蛋灌饼。”这声音虽然极低,却很耳熟。看时又全没有人。站起来向外一望,那夕甲甲便在柜台下对了门槛坐着。他脸上黑而且瘦,已经不成样子;带一本破Thinkpad,盘着两腿,下面垫一个电脑包,用草绳在肩上挂住;见了我,又说道,“来一个鸡蛋灌饼。”师傅也伸出头去,一面说,“夕甲甲么?你还有十九个bug没修呢!”夕甲甲很颓唐的仰面答道,“这……下回修罢。这一回是现场通过,鸡蛋要好。”师傅仍然同平常一样,笑着对他说,“夕甲甲,你又内存泄漏了!”但他这回却不十分分辩,单说了一句“不要取笑!”“取笑?要是不泄漏,怎么会打断腿?”夕甲甲低声说道,“跌断,跌,跌……”他的眼色,很像恳求师傅,不要再提。此时已经聚集了几个人,便和师傅都笑了。我煎了鸡蛋灌饼,拿出去,放在门槛上。他打开电脑开始写代码,见他满手是泥,原来他便用这手走来的。不一会,他提交代码,通过了测试和review,便又在旁人的说笑声中,坐着用这手慢慢走去了。自此以后,又长久没有看见夕甲甲。到了Rust 1.0发布的时候,师傅打开wiki说,“夕甲甲还有十九个bug呢!”到Golang 2.0发布的时候,又说“夕甲甲还有十九个bug呢!”到Scala 3.0发布的时候可是没有说,再到Rust又演进了一个版本也没有看见他。我到现在终于没有见——大约夕甲甲的确死了。写于二零一五年夏
看Quora上的阿三如何用魔戒优雅的黑C++。
Why doesn't C++ have a garbage collector?Because there would be nothing left!from 楼主给的Stack overflow
引用C++ FQA Lite,这是一系列仿 C++ FAQ Lite进行的吐槽:
这图黑得高端且优雅。这图黑得高端且优雅。
c很容易在你开枪时伤着自己,c++很少发生这种情况,但如果一旦发生,它很容易直接轰掉你整条腿。
21天教你学会C++
咳咳,欧美的文胸尺码分得似乎不像咱们这么模糊。介于C cup和D cup之间有一种尺寸。它叫做:C++

我要回帖

更多关于 what s this 教学反思 的文章

 

随机推荐