为什么程序员对c语言很难_程序员的悲伤阶段:或者语言翻译比看起来难

为什么程序员对c语言很难

为什么程序员对c语言很难

One's mind should be pretty clear when programming. I'm a decent enough programmer, but I'm not a bad-ass programmer. At least not anymore.

编程时应该头脑清晰。 我是一个足够体面的程序员,但我不是一个糟糕的程序员。 至少现在没有了。

Back in the day, before marriage, before diabetes, before babies, when I was sleeping a full 8 hours, I could code some nice stuff. Now it's just a miracle it compiles. When it does.

回到那天,在结婚之前,在糖尿病之前,在婴儿之前,当我整整睡了8个小时时,我可以编写一些不错的东西。 现在,它只是一个奇迹。 什么时候做。

I also tend to, um, not think. At all.

我也倾向于,嗯,不认为。 完全没有

I have been looking into OpenID lately, and had the privilege of meeting the CEO of JanRain, Scott Kveton (pronounced 'k'-vee-ton', but real fast, like the first two syllables are one) and mentioned that I was pleased they had made a .NET compatible OpenID library available (Andrew Arnott has wrapped it in a nice ASP.NET 2.0 Web Control).

我最近一直在研究OpenID,并且有幸与JanRain的首席执行官Scott Kveton会面(发音为“ k' -vee-ton”,但速度很快,就像前两个音节一样),并提到我很高兴他们提供了一个.NET兼容的OpenID库(Andrew Arnott将它包装在一个不错的ASP.NET 2.0 Web Control中)。

I was thinking I'd add OpenID support to Corillian's Voyager eFinance Server as a Proof of Concept, as our authentication system is pluggable. It'll be a nice demo, as our CardSpace one already works great.

我当时以为我将向Corillian的Voyager eFinance Server添加OpenID支持作为概念证明,因为我们的身份验证系统是可插入的。 这将是一个不错的演示,因为我们的CardSpace已经可以很好地运行了。

I went and download the .NET OpenID Library preparing for a few hours of tedious work.

我去下载了.NET OpenID库,准备了几个小时的繁琐工作。

Tangent

切线

The .NET OpenID library is written in Boo - I blogged about Boo in 2005 (I wonder if Ayende will update his Boo Reflector support for Reflector 5.0?) - which is a language that is damn-near Python. You can convert your code to Boo with this online tool if you want to play. Here's some Boo examples versus C# 2.0.

.NET OpenID库是用Boo编写的-我在2005年向Boo发了博客(我不知道Ayende是否会更新Reflector 5.0的Boo Reflector支持?),这是该死的Python语言。 如果您想玩游戏,可以使用此在线工具将代码转换为Boo 以下是Boo与C#2.0的一些示例

Right now the best and easiest way to write Boo is to use SharpDevelop, the Open Source IDE. Boo is a first-class language within SharpDevelop, along side VB and C#, and includes all the usual good stuff like debugging and what-not.

现在,编写Boo的最佳和最简便的方法是使用SharpDevelop(开放源代码IDE) Boo是SharpDevelop中一流的语言,与VB和C#并存,并且包括所有常用的好东西,例如调试和非常规。

The OpenID .NET Library, as I said, is written in Boo, very likely because the original library was written in Python and Boo offered not only a clear porting direction, but also made the developer comfortable. More on this later.

OpenID的.NET库,正如我所说的,是写在嘘,很可能是因为原来的库是用Python编写的嘘不仅提供一个明确的方向移植,也使开发商舒适 稍后对此进行更多讨论。

I figured this evening I'd "port" the Boo source for this library over to a "proper C# library" so the masses wouldn't have to sweat Boo. This experience let me through the...

我想今天晚上我会将这个库的Boo源代码“移植”到“适当的C#库”,这样群众就不必为Boo出汗了。 这次经历让我经历了...

程序员悲伤的阶段* (Phases of Programmer Grief*.)

休克 (Shock)

I was of course, like any religious zealot C# programmer, shocked and offended and looked on with disbelief that anyone would use any language that wasn't the One True Way® to produce perfectly viable and runnable IL. Microsoft's whole multi-language, single-runtime was just to prove a point to the Java guys right? I looked at the code with disdain

当然,我就像任何 虔诚的 C#程序员一样,震惊又得罪了,并且怀疑地相信任何人都会使用非One TrueWay®的任何语言来产生完全可行和可运行的IL。 Microsoft的整个多语言,单一运行时只是向Java专家证明了一点吗? 我不屑地看着代码

Shock is often accompanied by numbness...

休克常常伴随着麻木。

No curly braces? Duck typing? Is this how these people live and code? Freaks. Toy Languages, man, toy languages.

没有大括号? 鸭打字? 这些人是这样生活和编码的吗? 怪胎。 玩具语言,人,玩具语言。

否认 (Denial)

At this point, I don't think it'll be hard to port this. The library includes NUnit Tests, but as the library is structured with a lot of things marked internal to the assembly, there's two libraries. The main one, and the test one - but the code is also compiled into the test assembly. I started marking things public, and separated the two.

在这一点上,我认为移植起来并不困难。 该库包含NUnit测试,但是由于该库的结构包含很多在程序集内部标记的内容,因此有两个库。 主要的一个和测试的一个-但是代码也被编译到测试程序集中。 我开始将事物标记为公开,然后将两者分开。

I've already missed the forest for the trees here, and I'm happily stepping on butterflies in my quest for the big game.

我已经为这里的树木而错过了森林,而我为追求大型游戏而高兴地踩着蝴蝶

My goal was to use the Test library, as is, to test my glorious new C# library - the one I hadn't started yet. If the same tests passed on my C# version, shiny. I started poking around the code, trying to get an idea on where to start. The library includes a Server and an Consumer, and since I just needed the Consumer in the short term, I figured I start there.

我的目标是照原样使用Test库来测试我辉煌的新C#库-我还没有开始的库。 如果在我的C#版本上通过了相同的测试,则显示光泽。 我开始仔细研究代码,试图从何处入手。 该库包括一个服务器和一个使用者,并且由于我只是在短期内需要该使用者,所以我认为我从这里开始。

讨价还价 (Bargaining)

There's not THAT much code in the consumer, but there's not only a number of utility classes, but there's also a bunch of Boo language-specific collections and such. Also, as .NET 2.0 doesn't include Diffie-Hellman support (Orcas does, BTW), the OpenID library referenced Mono.Security to get there BigInteger class and Diffie-Hellman support.

使用者中没有太多代码,但是不仅有许多实用程序类,而且还有一堆特定于Boo语言的集合等等。 此外,由于.NET 2.0不包括Diffie-Hellman支持(Orcas包括BTW),因此OpenID库引用了Mono.Security以获得BigInteger类和Diffie-Hellman支持。

ASIDE: Be aware that Mono is GPL'ed Mono Libraries are MIT X11. Mono produces IL, and Mono libraries are CLS compliant, you can reference them in your Windows .NET applications happily, and they'll work fine 99.9% of the time. Adding a Mono library to my Windows .NET CLR program doesn't make it run under Mono, it's just referencing a library. Some people, like myself (yesterday) look down on this like we look down on C# programs referencing Microsoft.VisualBasic.dll, but hey, it's tested code I didn't have to write...you'll no doubt see my own personal epiphany coming later in this post...

ASIDE:请注意, Mono是GPL的 Mono库是MIT X11 Mono产生IL,并且Mono库符合CLS,您可以在Windows .NET应用程序中愉快地引用它们,并且99.9%的时间都可以正常工作。 将Mono库添加到Windows .NET CLR程序中并不会使其在Mono下运行,而只是引用了一个库。 像我本人(昨天)这样的人看不起这个,就像我们看不起引用Microsoft.VisualBasic.dll的C#程序一样,但是嘿,它是经过测试的代码,我不必编写...毫无疑问,您会看到我自己的代码个人顿悟即将在此职位的后面...

I thought I might write my own Diffie-Hellman...

我以为我可以写我自己的Diffie-Hellman ...

Note that I'm getting totally off the main task-at-hand already here...but I've not noticed it...yet...

请注意,我已经在这里完全完成了手头的主要任务...但是我还没有注意到它...但是...

...or find one that was already done. If I could just remove that Mono.Security reference...

...或找到已经完成的任务。 如果我可以删除那个Mono.Security参考...

有罪 (Guilt)

I started to feel bad, who am I to remove this library? Someone's worked hard on it, it shipped, let's leave it be, and get to the real work. Maybe I can find a better way to port this...ah, yes, Reflector!

我开始感到难过,我要删除该库吗? 有人为此付出了艰辛的努力,将其交付了,让我们离开它,继续进行真正的工作。 也许我可以找到一种更好的方式来移植这个……嗯,是的,Reflector!

I'm completely delusional...lack of sleep?  Analysis paralysis or just complete lack of thought? Ah, too much soda, perhaps? High blood sugar?

我完全是妄想...睡眠不足? 分析瘫痪或只是完全缺乏思想? 啊,苏打水太多了吗? 高血糖?

I'll just reflector the assembly and decompile it into C#. Heh, maybe I'll use Denis Bauer's FileDisassembler. There's probably some Boo specific stuff, but I'll yank that, no problem. It might be sinful, but no one is looking.

我将只反射该程序集并将其反编译为C#。 嘿,也许我会用Denis Bauer的FileDisassembler 。 可能有一些特定于Boo的东西,但我会提出质疑,没问题。 它可能是有罪的,但没人在看。

Of course, Boo assemblies include dozens of anonymous generated types and adapters to make Boo's closures work (it was designed before Anonymous Delegates could be used for closures) as well as for type inference.

当然,Boo程序集包含数十种匿名生成的类型和适配器,以使Boo的闭包能够正常工作(它是在将Anonymous Delegates用于闭包之前设计的)以及用于类型推断的。

Gosh...this decompiled C# code isn't even close...this may express the intent to the computer, but it doesn't reflect the Programmer's Intent at all.

天哪...这个反编译的C#代码甚至还没有关闭...这可能表达了计算机的意图,但它根本不反映程序员的意图。

愤怒 (Anger)

Stupid piece of crap Reflector! Man, Lutz can't even decompile to something I can freaking read!

愚蠢的废话反射器! 伙计,卢茨(Lutz)甚至无法将其反编译为我能读的东西!

Remember that IL is the applesauce on its way to becoming apple juice. Note that Stupid Scott is pissed here because Lutz's Reflector can't turn applesauce back into an apple. Darn Reflector and the Laws of Abstraction.

请记住,IL是成为苹果汁的苹果酱。 请注意,愚蠢的Scott在这里很生气,因为Lutz的Reflector无法将苹果酱变回苹果 达恩反射器和抽象定律。

Shoot...this is going to take longer than I thought. Now I've got to just freaking write thing whole thing from scratch by actually thinking and understanding what the code is intending to do! Man, I wasn't planning to think tonight, I just wanted to get OpenID on my blog.

射击...这将花费比我想象的更长的时间。 现在,我必须通过实际思考和理解代码打算做什么从头开始编写整个事情! 伙计,我不打算今晚思考,我只是想在我的博客上获取OpenID。

萧条 (Depression)

I'm not a good programmer! I've been coasting on charm for at least the last three years. I remember what closures were in college, but I've been using .NET 1.1 for the last five years and it dulls the senses...I might as well just give up and become a nurse.

我不是一个好的程序员! 至少过去三年,我一直在追求魅力。 我记得大学里关闭的是什么,但是过去五年来我一直在使用.NET 1.1,这使感觉变得迟钝了……我不如放弃并当一名护士。

接受与希望 (Acceptance and Hope)

Wait a second. I've already got a library that works. It's got unit tests. It depends on a tested and released Mono library and a 3 year old non-mainstream language, but it works. It's been used and implemented live before and someone has already wrapped it into an even better and more useful abstraction. Maybe it'll work after all. 

等一会儿。 我已经有一个可以使用的图书馆了。 它有单元测试。 它取决于经过测试和发布的Mono库以及使用3年的非主流语言,但是它可以运行以前已经现场使用和实现了它,有人已经将包装成一个更好,更有用的抽象。 也许毕竟可以。

The moral of this story is that my time would have been better spent learning Boo, reading the source, and using the Library. The source came with a NAnt Task, but I just created a Boo Project in SharpDevelop - THAT wasn't wasted time.
After I'd learned enough Boo, if I really wanted a C# version, for whatever reason, I should have just written it from scratch using the public interface as a template and the Programmer Intent, written in Boo, as my algorithmic scaffolding. Hindsight is 20/20.

这个故事的寓意是,我最好把时间花在学习Boo,阅读资料和使用图书馆上。 源代码附带了一个NAnt任务,但是我只是在SharpDevelop中创建了一个Boo项目-并没有浪费时间。 在我学到足够的Boo之后,如果出于任何原因我真的想要C#版本,我应该只使用公共接口作为模板并以Boo编写的Programmer Intent作为我的算法框架从头开始编写它。 后见之明是20/20。

Now, how do I get my evening back?

现在,我该如何恢复我的夜晚?

* With Tongue Placed Firmly in Cheek.
** Image
stolen from here.

*将舌头牢固地放在脸颊上 **图像从这里被盗

翻译自: https://www.hanselman.com/blog/the-programmer-phases-of-grief-or-language-translation-is-harder-than-it-looks

为什么程序员对c语言很难

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值