- 1 Aphorisms (good to follow or just keep in mind)
- 2 About Clean Code and Internet Graffiti
- 3 How to handle huge code and comments
- 4 Obsessed??
- 5 PARI/GP and gnuplot implementations [Polyspiral].
- 6 Hailstone sequence version 2 (& not ONLY)
- 7 Hailstone sequence, version 2
- 8 a note about user talk sections
Aphorisms (good to follow or just keep in mind)
From my OEIS Wiki user page.
Socrates (470 BC - 399 BC)
"As for me, all I know is that I know nothing."
Terence (195 BC - 159 BC)
"There are as many opinions as there are people: each has his own correct way."
"Nothing is so difficult but that it may be found out by seeking."
Edgar Rice Burroughs (1875 - 1950)
"We are, all of us, creatures of habit."
[Find more on my OEIS Wiki user page and much more on Wikiquote.]
About Clean Code and Internet Graffiti
The following is a short list of bad practices in programming industry (related to the code only):
- Very long historical and/or technical preludes.
- Multiple comments (almost on each line).
- Decorating code, e.g., using tricky frames for comments, also, unnecessary multiple pound and other signs,
- Obsession with tabbing (code is shifted too far to the right side). And opposite: totally avoiding identification.
- Splitting one statement (fitting one line) into 5 lines. And opposite: putting 10 and more statements on 1 line..
- Code leftovers: not used definitions, variables, code fragments for testing, etc.
- Typos in the code.
All of these bad practices you can find here on Rosetta Code.
Doesn't matter what contributing author, or somebody else thinks about it, - it is still a bad practice known and avoiding for decades.
If you have/had a job as a programmer/developer for a solid company or university producing software (including Web pages) it is well known fact for you that your supervisor will not allow/tolerate any of these bad practices.
Main reason is always - money. Such "dirty", not structured code is difficult to read and maintain.
I'm not gonna write an article here. Just google please: "bad programming practice", and you will find hundreds of pages devoted to it. But be reasonable in selecting some advises. For example, you can find advises about comments ranging from "too many is bad" to "not enough is bad", but also: "Do not write code that needs comments."
The good rule of thumb in this case is following: If function (method, etc.) is 5-10 lines of code or less then describe briefly function purpose and calling parameters only (if any).
Here is another contradictory advise popular in many documents, books, etc.: "use white spaces to make code more readable". But, contrary, it is not a bad practice/habit to use minimal number of white spaces.
Decorating code and using not related images are considered an "Internet graffiti" by some authors/bloggers. But more often it is called just trash and spam.
Regarding "preludes" here on RC I would say they are OK, but better place would be on related language page, e.g., with titles like "Interesting historical notes", "Useful XXX language tips", etc.
The main reason: task pages becoming too big and looking through them sometimes is really difficult.
Here is another sample. My VoeLib.gp page (pure text file) on OEIS Wiki became too big, and I've got automatic Wiki message: "Your page is bigger than 32K. Please reduce its size. Some browsers can't handle big pages". This forced me to split my page into 2 pages. Soon we will have the same problem here on RC. See another even more appropriate suggestion below.
How to handle huge code and comments
Here is a very good sample how to handle big chunk of code and, additionally, how to deal with huge comments.
Task page AVL tree has C++ 3 versions.
Note that first version has a realy huge chunk of code. But "More elaborate version" has no code,- just a link: "See AVL_tree/C++".
It links to: "AVL tree/C++" page with huge code, and this page has a typical "Discussion" link that leads to:
Talk page titled "Talk:AVL tree/C++". So, put all notes you want here. AnatolV (talk)
<<This is copied from Dragon curve Discussion page. Just added 1 related reply.>>
Some contributors are obsessed with:
- Very long historical and technical preludes;
- Multiple comments (almost on each line);
- Unnecessary multiple pound and other signs.
All this makes code "dirty", hard to read and maintain. I'm just curious: who will read such preludes, comments?
An obvious sample is the first version of dragon curve in R. I thought that contributor is for sure obsessed with pounds...
Or trying to camouflage original code... Although original code has a lot of pounds too, but RC contributor added even more! LOL See for yourself: rstudio-pubs-static.s3.amazonaws o com/185483_0f31b11d2def43aea33658b5b7908cf3.html
Team MEOW: Eric Lewis, Ricky Hardiyanto, Yanna Chen - CityTech. May 29, 2016
BTW, it’s impossible to find who is the contributor of the first version of R.--AnatolV
- Probably not a great idea to make disparaging remarks about other peoples code. That being said, it's a public wiki. If there is code that is unidiomatic or messy, clean it up. Just be aware that some users are very protective of their contributions and coding styles.
- As far as who contributed the first R example, looks like it was Werewolff519; see this revision --Thundergnat (talk) 12:58, 4 March 2017 (UTC)
- TYVM Thundergnat! Now I can see: he attached solution to Perl with no comments. I did the same when I started here. LOL But later I've found it is useful to leave a short comment. I was hoping the contributor is one of the authors of the cited article. But, in general, it doesn't matter for me.
- I will continue discussion on my Talk page. (not today, I have too many logins) -- AnatolV (talk)
- @Thundergnat: I have 2 issues with your suggestion to "clean it up": 1st, I prefer author or at least admin do it; 2nd, it is "eating" my logins. I did edited a few typos, wrong tag using, etc. But soon I've found: my (actually everybody but admins) logins are restricted. See my post on talk:Short Circuit page "Problems and a few suggestions".
- I try to pick my battles. Coding style is usually not one of them. I made that suggestion solely to point out that if it bothers you, you have the power to do something about it.
- I am not aware of there being any restrictions on the number of logins anyone (who hasn't been completely blocked) can make, admin or not. I get the "You have cookies disabled" notice about 1 out of 5 times I try to log in. Usually if I wait 30 seconds or so and retry it goes through the second time. Not always, but usually. --Thundergnat (talk) 22:59, 6 March 2017 (UTC)
- Thundergnat: I know for sure how busy you are doing editing job. RC should have a dozen of active editors (not 2-3 like now).
- Regarding restricting logins with fake messages: It was proven by me in discussion with other admin. Please find it here on this page below.
- [In Chrome: 1st click on page; then type [Ctrl+f]; then type in popped-up find bar: FAKE. That's it.]
PARI/GP and gnuplot implementations [Polyspiral].
Hailstone sequence version 2 (& not ONLY)
First of all, you did suggest to leave it as is, just delete red warning…Why did you suggest it?? Now you’ve changed your mind?? LOL
- No, my intent was to leave an "out" because some
peoplecomputer programmers get very upset on having their errors pointed out, so I tried to make the "incorrect" flag as polite and ignorable/deletable as possible. I have no control of the color of the error/warning tags, and there is a limited amount of types (of error/warning tags) that are available for this kind of programming error (especially if the output is correct). I forgot about the tag "needs improvement", but that sounded a bit too strong. If you read around Rosetta Code tasks a bit, you may have noticed that I have quite a few ==task clarification=='s for even small things like using the word integer instead of number, and suchlike. One of my pet peeves is that some Rosetta Code draft tasks get promoted to a full task pretty fast, and some draft tasks remain around forever (especially some classic problems), irrespective of what the guidelines say. -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
It was a good suggestion, because only in the case than result would be = 100K, it would require to go to 100K-1 in range setting. This is only a search range, and it is > than set by task. May be, next time better correct task setting to <= 100K? What do you think?
- It wasn't my Rosetta Code task that was entered, so it's a bit late for that now. If you think the authors of the programming entries are sensitive, you should find out how sensitive the authors are of their entries for the Rosetta Code tasks (problems). I don't know why the author of the task choose those words (and believe me, there are some strange verbiage on some Rosetta Code tasks), but it was the author's choice of words, and I surely didn't want to change the task's wording at this late date (if it were a draft task, it would be a different story). One alternative is to simply change the programs, that's what this Rosetta Code programming chrestomathy website was meant to do. But, if you ever tried to change a programming entry that someone else entered (even though that is permitted and even encouraged), woe be thou! A (surprising) amount of programmers are very sensitive and possessive (egotistical?) of "their" code, even though there is a warning at the bottom of every Rosetta Code task concerning this very issue. -- Gerard Schildberger (talk)
- The range error thing is similar to a Rosetta Code task asking you to list all the primes from 1 ───► 10,006 (inclusive), and you used the range 2 ───► 10k. Now, your answer would still be correct, but the program, however, is still wrong (well, incorrect at the least), even though the answer(s) is/are identical. I don't mind using the lower limit of 2 as that's the first prime, and that is common usage for various lower limits. It is important to code a correct program and show (and honor the intent of the search limits) that the specified limit be used, both for the answers and the computer program's internal structure (such as the aforementioned limits). -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
Second, formally you are right, but you know, I’ve seen a lot of outputs, ignoring all task requirement, even outputting nothing… And it is OK?? No reddish warning?? It IS OK for me. But I like to see result, especially pictures, if it is possible. [See more samples below.]
- Yes, there're a lot of output(s) that is/are incorrect and/or wrong, and also missing completely, and some that don't even address some (or all) of the output requirements, and still others that show something completely different. I'm not a Rosetta Code administrator, so I try to tread pretty lightly, especially after I got into a tiff (well, tiffs) with a particular user (who eventually became the only user to be banned for life from Rosetta Code) --- and this was after he was warned and banned twice (as I recall). Ever since then, I felt like I was tarnished (with a pretty wide brush after that cyber bullying) and I've been pretty hesitant when flagging programming examples (or their output) with an incorrect flag. Your replies have made me realize that flagging others would be a costly endeavor and incur too much wrath (or flame wars?) for correcting such a simple error. -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
Last, I’ve discovered that RosettaCode Wiki using FAKE messages to limit login of certain users to pages. This is not nice and not correct.
- I can't agree with you more. I don't know how troublesome this issue is to other (very active) Rosetta Code users. I suppose the intent was to limit robot (bot) updates and the like, I don't really know. I can't begin to tell you how much time I've wasted trying to figure out what was wrong, and doing as "they" suggested: logout and then login again, ... nothing worked; I've reset my cookie settings (on both of my browsers), even though it was obvious that the cookies were being updated (arrgh!), and all sorts of other miscellaneous and sundry things. The one thing that always worked for me was to go to sleep (as it always seemed to happen to me very late at night (or rather, in the early morning). What only fixed the problem was the passage of time, as it turned out. -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
- On my terminal screen, they appear in orange. -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
Note: right below it,- my user name from cookie.. It’s a big LOL
Of course, everything is OK with my browser setting. RosettaCode Wiki is not the one and only site I’m publishing blogs, notes, scripts, etc. Check my user page on OEIS Wiki, for example. I’ve analyzed situation and discovered a probable cause. I was listed as over active!??: http://rosettacode.org/wiki/Special:ActiveUsers AnatolV (Talk | contribs) [34 actions in the last 30 days] How do they get this number??
- I think "they" (or it) counts the number of previews and/or updates (possibly even SAVEs) ... I don't know. Hopefully, one of the Rosetta Code administrators would know and hopefully address (any maybe fix) this annoying and wasteful problem. -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
OK, I have only 10-12 scripts published (since January, not in the last 30 days), but also about 15 pictures, plus 3-4 times editing (all postings). Is it too much?? LOL
- Yes, I've been hit/effected (with that "lock-out") many times. I just wait for a chunk of minutes (and work on something else), and it will usually correct itself (so to speak) by my not doing anything (of all things!). I agree, it is a royal pain in the ole neckhole, by cricket! It is such a waste of my productive time, and it is so discouraging and off-putting if you're not-in-the-know of what's happening. It sure leaves a sour taste in my mouth. -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
As I said,- it’s not correct actions somebody set within RosettaCode Wiki! Do you know why?? Because it could mean that RosettaCode Wiki site was hacked, or I was redirected to imposter’s site, etc.
- No, you weren't hacked. You should contact Michael Mol (username Short Circuit) the inventor/founder of the Rosetta Code website), or one of Rosetta Code administers. He (or they) would be able to answer (and maybe even address/fix) your concerns (and my concerns as well). This may be part of their solution to try to limit (or fix) the "spamming" thingy that is happening on Rosetta Code (where users are putting person non-Rosetta Code stuff) in their user pages to gain link counts to their personal websites to gain Google favored status (the more links, the further up the Google presentation of websites ya go when searches are done for particular keywords --- at least, that is how I understand it). -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
Even to post this note I need to log in. Waiting when I would be allowed to LOG IN!?? You see?? This is a real problem! LOL
In OEIS Wiki we have better options: we can send email directly to any user and any editor. Sometimes it is handy.
EDITING ISSUES: Are you bombarding all others who set 100K (not 100K-1) too?? Stop it!! Please.
- No, I'm not bombarding anybody, yours was the only one, and I just happened to notice the incorrect (as per the limit) computer program (which had the correct results, however). Try not to be so sensitive about your code. It's a simple thing to correct. That is one reason I made the "kinda"/"sort of" comment about being incorrect, and it could be just deleted and ignored, depending on your receptiveness to making a computer programming change. -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
- No, I didn't go looking for that (or them). Now knowing that there are so many, I certainly don't want to mark that many as incorrect (or some flavor of "incorrect" or "needs improvement", but I don't feel that strongly that needs is a good word choice). You can imagine the ire from all those (irate) programmers, whose integrity of their programs would/could be ... ah, ... tested or challenged. It always astonishes me how (overly) sensitive the egos are of some computer programmers. No sense in beating that particular hornet's nest with a stick. -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
Note: some of authors “cheating” in output, saying: <100K, or so. I think they met you… LOL
- That's not "cheating", that's programming correctly, as they are meeting the task's requirements (in a strict sense) correctly in honoring/following the intent of what limit to use. -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
There are a lot of real editing work for editors, e.g.: • Ring, has incomplete task and no output. • SNUSP, Bracmat, Buelesque have no output. • Task 2, uBasic/4tH, Bourne Shell, MUMPS have incomplete solution. • LOLCODE has typos in the description. Easy to fix it by editor. + incomplete task,- OK 4 me. • A lot of samples having actually output are not using Output tag. This is really easy to correct even by editor… Just saying.
- As far as typos, finger-blunders, misspellings, punctuations, et al; I would make the changes necessary. It behooves everyone to have clean and correct descriptions (to aid in searching, if anything), not to mention readability and comprehension. As far as the use of the output template, I don't like to use it as it doesn't honor my use of it; I like to say (on a single header line): output when using yada-yada-yada for the input: (or some such wording). -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
In some cases incomplete solution is reasonable.
- There is a special Rosetta Code tag for programming entries that have an entry, but don't show the output. There are almost tons of those. Of what I've seen and understood, it's been the Rosetta Code administrators or the author of the Rosetta Code task that do the flagging of those type of entries (although, it's my understanding that anybody can mark the entries). I just did one flag or this Rosetta Code task to see how it would be received and/or resolved. From your responses, I realized that would be opening a real bad can of worms. -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
Suggestion: May be editors should create Wiki tag “Incomplete task solution” (not red, but normal one, like Output tag). So, editors and/or authors can use it to mark such solutions.
- I agree whole heartedly (I can't change the color of the tags), and the incorrect (red) tag was the only one that appeared to address the situation. This whole area of discussion (me thinks) needs some serious discussion/direction by the-powers-that-be. -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
A few scripts starting from 3, one even from 7, but it’s ok with me, because I know for sure there is nothing interesting in the first 7 sequences.
FINALLY: Are you gonna put reddish memo everywhere? Over all 80+ languages I’ve listed?? Just because you can? Let it go!
- No, I addressed my concerns (above). Like I previously said, some programmers just don't want to correct their programs, and it won't be the first time that even experienced programmers get tripped up on a fencepost type problem. I've tried to explain about fixing the program to adhere to the task's requirements. As far as what I can do, anybody can flag (or change, for that matter) any program or it's output. Some task's authors are very exact about (the presence of) a program's output, some don't care a wit and let others do the flagging --- still others just simply go away and never (seem to) come back to oversee their creations. It's a pretty wide mixture here in Rosetta Code land. -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
Variety of presentation is good, unless it has essential errors, wrong results.
- I couldn't agree with you more (as I try to make my programming entry's output have as much verbiage as possible to make it crystal clear what is being presented), but there are some people who think the output(s) should all look pretty much the same, so as to make comparisons of the various programming entries easier. Six of one, a half-dozen of the other. -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)
Best regards, AnatolV
Hailstone sequence, version 2
Actually, I was hoping that you'd just correct the PARA/GP program (version 2) instead of ignoring the reason behind the incorrect (sort of) flag.
To make the program correct, just change the statement:
- Search range: 1..100000
- Search range: 1..99999
The task's requirement is ... "Show the number less than 100,000 which ...".
(The underlining is mine.)
Although, as I had already mentioned, as it so happens, the 100 thousandth number doesn't affect the longest sequence, but the upper bounds of the search is still incorrect, but the answer isn't wrong.
a note about user talk sections
It would be nice if you could append your comments after the original by prefixing your reply (on a new line) with a single colon (:), or as many colons (such as ::) as needed. The use of colons will indent your replay to make it easier to identify response(s) to the original text.
After that, sign your name to your sentences with two (or more) minus signs (--) followed by four tilde symbols (~), the minus signs appends an eyecatcher of two minus signs, and the following is also appended to the eyecatcher with your user id (or user name), the section type in parenthesis, and the time and date.
Of course, your reply (or rather, replies) was/were quite lengthy, and had quite a bit of varied content, so a new talk section was probably a better choice.
Also, I believe it is customary to add sections in chronological order. I don't think it's specifically stated as such, but that's what I understand from observations. There appears to be quite a number of unwritten ... rules (or maybe conventions is a better choice of words). -- Gerard Schildberger (talk) 06:22, 22 April 2016 (UTC)