在书中对算法编程语言的选择吗? [英] Choice of programming language in book on algorithms?

查看:132
本文介绍了在书中对算法编程语言的选择吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

跟进我的previous问题,关于一本书的持久性上的算法,请参阅<一href="http://stackoverflow.com/questions/608779/what-are-the-enduring-properties-of-a-book-on-algorithms">here,现在我想问一下,你会用什么语言来写这样一本参考书的例子社会。

Following up on my previous question on the enduring properties of a book on algorithms, see here, now I would like to ask the community what language would you use to write the examples of such a reference book.

我可能不会使用MMIX(!)写的书的例子,但在同一时间,我认为只是假性code会比在真实的语言的例子那么有趣。

I will probably not use MMIX (!) to write the examples of the book, but at the same time, I think just pseudo-code would be less interesting than examples in a real language.

不过,我也很喜欢这本书是为研究人员的资源也是如此。可能是什么社会的选择吗?为什么呢?

Still, I'd also like the book to be a resource for researchers as well. What could be the choice of the community? Why?

答案:我知道这是一个棘手的问题,而且会有几个不同的答案。请注意,答案覆盖整个范围,从装配/ MMIX(!),以Python和伪code。该票和论据强迫我选择的URI明智的办法,有一点需要注意:我的伪code将接近至C,我可能能(无需当然到平台的具体问题,),我很可能会讨论旁注更好的实现(如我们都知道,在数学上证明了该算法的工作原理是远远从实现它的问题)。

Answer: I knew this was a tough question and that there would be several different answers. Notice that answers cover the whole range from Assembly/MMIX(!!) to Python and pseudo-code. The votes and the arguments compel me to choose Uri's sensible answer, with one caveat: my pseudo-code will be as close to C as I possibly can (without going into platform specific issues, of course), and I will possibly discuss better implementations in side notes (As all of us know, mathematically proving the algorithm works is far, far from the problems of implementing it).

这本书是对算法在特定的领域,而不是在一般的算法数学(更聪明人做,会比我好得多的一般算法)。因此,有一件事我认为会增加价值,这样一本书是的算法,我一定会放上网的配套网站(也许在一对夫妇的语言,如果我发现的时候)资源库。

The book is on algorithms in a particular domain, not on the mathematics of algorithms in general (much smarter people have done and will do much better than me on general algorithms). As such, one thing I consider would add value to such a book is the repository of the algorithms, which I will definitely put online in a companion website (maybe in a couple of languages, if I find the time).

感谢所有的答案。我有时觉得我应该把大家谁回答的合着者。 :)

Thanks for all the answers. I sometimes feel I should put everybody who answers as co-authors. :)

推荐答案

一本好书的算法应该写在psueod- code A-LA-CLR ...

A good book on algorithms should be written in psueod-code a-la-CLR...

在我的经验,大多数书籍进入特定语言examplse最终看起来更像是本科教材不是像一个严重的参考和学习的书籍。此外,大多数语言都相当笨重时收集处理(特别是C ++和Java,甚至与仿制药)。所有的细节之间,太多的丢失。你也立刻省去了很多的潜在受众。

In my experience, most books that go into language-specific examplse end up looking more like undergraduate textbook than like a serious reference or learning books. In addition, most languages are fairly clunky when dealing with collections (esp. C++ and Java, even with generics). Between all the details, too much is lost. You're also immediately eliminating a lot of your potential audience.

到特定语言的书的唯一好处是,如果你正在写一本教科书,出版商可以附上一张CD,并添加50 $的建议零售价。

The only advantage to language specific books is that if you were writing a textbook, the publisher could attach a CD and add 50$ to the MSRP.

这是我更容易理解的(可读)伪code的算法。如果我无法弄清楚如何在我的语言,我自己的收藏集实现它,我就麻烦了呢。

It's easier for me to understand an algorithm from (readable) pseudocode. If I can't figure out how to implement it in my language with my own collections, I'm in trouble anyway.

您可以添加到每个伪code列出了注意事项有关实施细节特定语言(例如,使用一个TreeSet的在Java中获得最佳性能,等等。)

You could add to every pseudocode listing a note about implementation details for specific languages (e.g., use a TreeSet in Java for best performance, etc.)

您也可以保持书(反正好主意),在那里你可以有不同的语言实际实现一个独立的网站。没有必要杀死长的打印输出的树木。

You could also maintain a separate website for the book (good idea anyway) where you'll have actual implementations in different languages. No need to kill trees with long printouts.

这篇关于在书中对算法编程语言的选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆