"Algorithms that forget their history are doomed to repeat it."
- Stuart Russel & Peter Norvig. Artificial Intelligence. A Modern Approach. Second Edition, 2003 p. 82.
"In some very early implementations of Basic, the manual actually suggested removing comments from a program in order to improve its performance."
- Michael L. Scott. Programming Language Pragmatics. Second Edition, 2006, p. 16.
~ The first implementations were interpreters, but it's still a bit of a controversial thing to put into a manual.
"Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do."
- Donald E. Knuth. Literate programming. The Computer Journal, 27(2):97–111, May 1984.
Sunday, November 7, 2010
Monday, June 7, 2010
Latter optional arguments evaluating to values of former arguments
Code series: This series has to do with the day-to-day ideas that come up as I code. It is often the case that these ideas are already implemented in a language other then the one used, and sometimes it is even the case that the idea comes from my lack of knowledge or oversight of some feature in a programming language. If you notice such subtleties, please comment, I'm more happy to learn from my mistakes than to keep following false, or already implemented ideas.
I've come across this issue several times, but this is probably the first time I've had the time to formalize it. Sometimes in a function definition you make use optional arguments with default values. In essence I find this to be a shorthand to overloading the function with another signature, and calling that base function from there, however, that is apparently not the case in any known to me implementation of a programming language that actually supports optional arguments in function signatures.
You almost always are able to evaluate some expression as the default value, and while code-blocks would certainly make things look even more complex, I think they should be allowed if one wishes to use them, but that is rarely needed, it just so happens that default values are more often than rather simple to compute. It is therefore sometimes pleasant that one can do the following in e.g. Python:
From which I deduce that the scope is local to each variable, I wander why this is? As I've most certainly seen uses of the latter case but never the former?
Would've sure be nice for those variables to be evaluated within the same scope.
I've come across this issue several times, but this is probably the first time I've had the time to formalize it. Sometimes in a function definition you make use optional arguments with default values. In essence I find this to be a shorthand to overloading the function with another signature, and calling that base function from there, however, that is apparently not the case in any known to me implementation of a programming language that actually supports optional arguments in function signatures.
You almost always are able to evaluate some expression as the default value, and while code-blocks would certainly make things look even more complex, I think they should be allowed if one wishes to use them, but that is rarely needed, it just so happens that default values are more often than rather simple to compute. It is therefore sometimes pleasant that one can do the following in e.g. Python:
def nice(a, b = 1 + 2):
My problem lies with the scope, consider this Python code:
def nice (a, b = a)
Unfortunately this is not allowed, yielding the error:
NameError: name 'a' is not defined
NameError: name 'a' is not defined
From which I deduce that the scope is local to each variable, I wander why this is? As I've most certainly seen uses of the latter case but never the former?
Would've sure be nice for those variables to be evaluated within the same scope.
Monday, May 31, 2010
Saturday, May 1, 2010
Datalogy Quotes of the Day #2
This one will be more realistic than the previous, I've actually gathered some quotes from the stuff I've seen/read this week:
"Programming is like writing inductive proofs."
- Jyrki Katajaine, April 23rd 2010, Datalogy department at the University of Copenhagen, Algorithms and Data Structures, Lecture 2: Divide and conquer.
~At least for me it's just as exciting, I'm told a plane could fall down while I'm coding and I wouldn't notice, same goes for when I do inductive proofs.
"The book [red. CLRS 3ed] is the syllabus, this here [red. the lectures] - this is entertainment."
- Jyrki Katajaine, April 26th 2010, Datalogy department at the University of Copenhagen, Algorithms and Data Structures, Lecture 3: Sorting.
"The key to being a succesfull developer is laziness, [...], and it's like the right kind of laziness, but it's essemtially insuring that you limit the amount of manual labour that you have to go through as you maintain [red. or develop] your application further down the road."
- Ben Galbraith, April 8th 2010, Stanford Engineering, Mobile Application Development, Lecture 2: Web Skills Introduction to Web Development and HTML 5, ca. 14:12-14:30.
Friday, April 23, 2010
Introducing Datalogy Quotes of the Day
Inspired by Arjen Dijksman's Physics Quotes of the Day, I've decided to introduce a new meme to my blog-posts - Datalogy Quotes of the Day. Now, unlike Arjen I do not (yet) read as many scientific papers on Datalogy, but have my sources for at least the next few months, and by that time I guess I'll have to speed up on my reading, hopefully with other benefits for my education :)
"Code doesn't lie, comments might."
- Anonymous programmer
"Software and cathedrals are much the same – first we build them, then we pray."
- Samuel T. Redwine
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Rick Osborne
"Code doesn't lie, comments might."
- Anonymous programmer
"Software and cathedrals are much the same – first we build them, then we pray."
- Samuel T. Redwine
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Rick Osborne
Wednesday, April 7, 2010
Search, now without space
Find one thing wrong with this image(hint: search or type URL):
Found it yet?
.
.
.
.
No?
.
.
.
.
Really?
.
.
.
.
The space bar is missing, so there you go - search, now without space.
P.S. Of course you can hit the search button on the Android device again and go to the 'Quick Search Box' but that's a different feature entirely. Oh, and for those curious about 'the Android device':
Found it yet?
.
.
.
.
No?
.
.
.
.
Really?
.
.
.
.
The space bar is missing, so there you go - search, now without space.
P.S. Of course you can hit the search button on the Android device again and go to the 'Quick Search Box' but that's a different feature entirely. Oh, and for those curious about 'the Android device':
Sunday, April 4, 2010
The rules of replace all
The following is a list of rules I believe one should follow if one ever thinks of using the 'replace all' feature in a text editor/IDE. All rules are equally important, except the first one which is more important than the rest.
- NEVER REPLACE ALL.
- NEVER replace all on something you didn't write.
- Perform a cost/benefit analysis each time you dare to think of using 'replace all'. Replace manually if there is ANY COST AT ALL.
Subscribe to:
Posts (Atom)