Welcome to the Code Critique forum. Here we are focusing on reading and critiquing specific code snippets. To get the discussion started, your hosts have chosen 5 programs to analyze, ranging across the uses (and abuses) of computer programing.
1. The first example belongs to the original use of computers, i.e. solving mathematical equations too complex or time consuming to be done by hand with the desired data set. This C++ program models the Schroedinger Equation, which describes how the quantum state of a physical system changes in time. Do not be alarmed. You do not have to have a background in physics or higher mathematics to appreciate the implications of scientific analysis based on crunching large amounts of data and how a computer program privileges certain results. Screenshots are available as well as the extremely interesting pseudo-code which describes how the program is supposed to work using a hybrid syntax of English and code.
2 & 3. Next we have two examples of obfuscated code; code which has been intentionally altered to obscure its meaning, either as a brain-teaser or to hide malware from virus scanners and users. Representing the brain-teasers, we have a visually intriguing and arithmetically simple (if tedious) method for getting the first four digits of pi. The malware example redirects you to a malicious website.
4. The fourth snippet is a single line of Perl used to redirect a website (hopefully for beneficial or at least more transparent purposes). Let your imagination run wild on all the little bits of mundane code that structure and direct our internet experiences.
5. Finally, we have a program that draws randomly generated recursive trees (in the mathematical and arboreal sense). The code itself is an exemplar of logical elegance as are the fleeting images it generates. Coincidence? I think not.
So these are our examples. Feel free to refer to these examples in your initial posts, but we also encourage you to contribute snippets that you're interested in reading in a group setting.
Here are some potential questions to ask while critically reading code:
- At the "global" level: What's the history and context of the code/program? Whats the purpose of the software? Who wrote it? Who funded it? Who developed it, extended it, maintained it?
- At the platform level: How do constraints of the platform impact the shape and performance of the code?
- At the program level: What language was it written in, and why? What is the programming paradigm? What libraries does it draw upon?
- At the character level: How do the individual and strings of characters combine to make meaning? What resonances do the signs have with other sign systems including natural language?
- At the code level: Is code ugly or beautiful? Does it matter and why? Is the code efficient in achieving its goal (in building databases, in performing textual markups, in aggregating data online, etc)
- How does one's choice of programming environment influence the coding/reading experiences?
**WARNING: NOT ALL CODE WILL POST PROPERLY IN THE COMMENTS. YOU CAN TRY TO PLAY WITH SLIGHTLY EDITING YOUR CODE SO IT WILL BE ACCEPTED, OR POST YOUR CODE TO PASTIE.ORG AND LINK TO IT HERE. OR TAKE A SNAPSHOT OF THE CODE AND POST IT AS AN IMAGE. We are working on a more elegant solution, so please be creative in your workarounds :-) Apologies and thank you for your patience!**
Let the revels begin!