

My problem with computer science pseudocode - nih
http://beauty-of-imagination.blogspot.co.uk/2012/10/my-problem-with-computer-science-pseudo.html

======
jmaicher
Unfortunately I can't see the pseudo code you are criticizing. But I have a
degree in CS and I'm familiar with the notion of pseudo code and the way it's
usually written in academic papers.

I agree with you that the way code is written matters a lot in practice. But
in academic papers, usually the idea, the runtime and the correctness of
algorithms have a higher priority than implementation details. Sure, you can
write more readable pseudo code, but I haven't come across an algorithm in a
paper that I wasn't able to understand. In fact, I do often like the way it is
written.

Who says that computer scientists are necessarily great programmers? That's
not the case. Universities (at least in Germany) doesn't teach you how to be
an "elite grade developer", as you said. They teach fundamental concepts in
computer science.

Why recursion? If you approach a problem with mathematics then thinking in
terms of functions and recursion is very natural. Recursion is a fundamental
mathematical concept and it's often easier to reason about recursive functions
(inductive proofs).

~~~
ObnoxiousJul
I noticed <http://en.wikipedia.org/wiki/Binary_heap> had a (slighlty) improved
version of the binary Heap copy pasted from the same book.

------
acqq
I read the book much better than Rodrigo's Python code. The book writes about
"max-heaps." Rodrigo tries to rewrite is to apply it on an array, uses
confusing names where simple one letter names suffice, rewrites tail recursion
which is anyway obvious that it can be substituted with a while loop,
producing, at least for me, much less readable code. By the way, even in the
production code I do use one letter names for local variables in the functions
that span a few lines and where their use is obvious.

------
m0skit0
I have to diagree with your PoV for recursion. I personally don't have any
problems if an alogrithm is iterative or recursive, specially if the
recursivity is as simple as in your example. In fact, in such cases
recursivity is even simpler to understand than iteration IMHO.

~~~
johnbender
I came here to say something similar. I would go further and assert that once
you're comfortable with recursion it's nearly always preferable where
reasoning about execution is the primary concern. Discarding the mental
overhead associated with index accounting and temporary variable state has a
lot of value.

------
Xcelerate
This is a general problem with academic books/papers. Authors rarely focus on
making their work as easily understandable as possible. Instead, the goal
almost seems to be the opposite -- how obscure sounding can I make this paper
(so that I appear really smart) while still maintaining correctness?

It's very frustrating. We get it: you're smart. Now quit using words like
"complecting" and quit using elliptic modular forms when addition and
subtraction would suffice instead.

EDIT: Alright, so the downvotes indicate my post was a little rant-ish (I
don't get downvoted much on here so it disturbs me when I do). I apologize for
that. There were a few papers that I read recently where some of the words
were very obtuse and I couldn't think of a good reason for choosing those over
simpler and more communicative words. "Authors rarely..." was likewise an
exaggeration.

But I do stand by my point that clear communication is something I think
technically-oriented people should focus on. Perhaps courses could be offered
where you describe a complex subject and then others in the class comment on
what areas were the most confusing. This is different than a peer-review
process in that you're not necessarily focusing on the accuracy of the
material but the clarity of its expression.

~~~
xanmas
Speaking as the author of multiple academic articles (theoretical physics), I
would fundamentally disagree with your assessment. We usually are trying our
absolute hardest to communicate a new advance in the field in anywhere from
4-8 pages, references and introduction included. We're essentially trying to
sum up (in my case) 2 years of work in as short of a space as possible so, to
do this, we assume that the reader has a working knowledge of the foundations
of the field but provide references to this. The references serve to 1)
provide evidence for unoriginal claims that you make (every sentence that
communications an unoriginal result should have a citation) and 2) allow those
who are unfamiliar with the field to pick up the basics as quickly as
possible.

Unfortunately, some of our prose is a bit obtuse because it's reasonably
common for scientists to blow off their humanities courses because they're not
science -- not realizing that most of our career will depend on the quality of
our writing. You shouldn't confuse our incompetence with malice though.

~~~
Xcelerate
Sorry, I guess a few bad experiences lately have given me in to hyperbole. I
do research myself and at least with some of the papers I've read recently,
I've noticed questionable vocabulary choices. I can't think of a reason for
using certain obtuse words when a simpler word would be much clearer, but as
you say, perhaps it is just the word that the researcher thought most apt.

~~~
xanmas
Don't worry, I felt the same when I was starting to read papers as a graduate
student but I came to realize that in cases like the one where you mentioned
elliptic modular forms being introduced to vastly overcomplicate something, it
was usually done to make something true in a far more general set of space.

For me in physics? That came about when I started reading papers where people
were doing stuff with differential geometry on manifolds. I couldn't, for the
life of me, figure out why people would talk about a wedge product when a
cross product would have sufficed until about 6 months later when it clicked
that doing something in a coordinate agnostic framework allows you to prove
things for any coordinate system and create general formulas that just need a
few things "plugged in."

I'm not going to pretend to know that that's why elliptical modular forms are
being used in your context but everytime something has seemed needlessly
overcomplicated, I've come to realize after some thinking that it's done with
a view towards generality.

------
Turing_Machine
If you're looking for algorithms with real code, Sedgewick is pretty good.

<http://www.amazon.com/gp/product/032157351X>

Disclaimer: I haven't actually seen this edition, which uses Java. My old
edition uses C.

Disclaimer #2: I still look into my copies of Sedgewick and Knuth fairly
regularly. CLR(S), not so much. Your mileage may vary.

------
pawelwentpawel
I remember going through _Introduction to Algorithms_ back in high school. Not
only I had problems with understanding it in general but in addition it was a
translation. A very bad translation.

I'm a big fan of _The Algorithm Design Manual_ by Skiena. This is the book
that I usually recommend.

------
comex
Since Google Books seems to not always want to display the code, here's a
screenshot:

<http://imgur.com/q7TII>

~~~
ralfn
That no longer works either. Dropbox is not a good way to share pics to
potentially large groups of people. Just use imgur.

~~~
comex
Fixed, thanks.

------
mememememememe
CRS book is okay... but it's way too complex for undergraduate. I rather
listen to lectures than reading this book. I think even talent programmers
have to agree with me that CRS is a reference, not a textbook for teaching.
It's only for people who have done enough algorithms and data structure and
want a reference book.

