Wikipedia:Reference desk/Archives/Computing/2016 February 26

{{#ifeq:{{PAGENAME}}|Special:Undelete| |{{#if:|

}} {{#ifeq:{{NAMESPACE}}|Wikipedia|{{#switch:{{NAMESPACE}}|= |
}}|{{error:not substituted|Archive header}}
}}}} {{#if:|
}}
width = "100%"
colspan="3" align="center" | Computing desk
width="20%" align="left" | < February 25

! width="25%" align="center"|<< Jan | February | Mar >>

! width="20%" align="right" |{{#ifexist:Wikipedia:Reference desk/Archives/Computing/2016 February 27|February 27|Current desk}} >

align=center width=95% style="background: #FFFFFF; border: 1px solid #003EBA;" cellpadding="8" cellspacing="0"
style="background: #5D7CBA; text-align: center; font-family:Arial; color:#FFFFFF;" | Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is {{#ifexist:Wikipedia:Reference desk/Archives/Computing/2016 March 7|an archive page|a transcluded archive page}}. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.

__TOC__

= February 26 =

Programming language "cheat sheets" in the form of example programs

Anyone know of good programming language "cheat sheets" in the form of example programs that illustrate a language's syntax and features? I'm trying to find resources like that for common programming languages and could use some pointers. Thanks. --134.242.92.97 (talk) 00:59, 26 February 2016 (UTC)

:[http://rosettacode.org/wiki/Rosetta_Code Rosetta Code] is very popular. For example, you can see [http://rosettacode.org/wiki/Euler_method Euler's Method] implemented in some fifty or more languages, including an example solution to solve Newton's Law of Cooling; or [http://rosettacode.org/wiki/Reverse_a_string reverse a string of characters] implemented in some 169 programming languages. Nimur (talk) 01:08, 26 February 2016 (UTC)

::Thanks for the links, as well as those from others who responded so far. I forgot to say in my original questions that I was particularly interested in example programs that have been crafted to illustrate a lot of the basic syntax/features in a relatively small amount of code (a page or two, not much longer than that). The programs don't need to solve any meaningful problem, but the density of syntax/features demonstrated should be high. A good example program should, for instance, illustrate

::* the basic layout and "routine" parts of a program

::* the syntax for single-line and block comments

::* common conventions, e.g. capitalization style of identifiers

::* the built-in data types

::* how you'd import functions, types, classes, constants from another module

::* the syntax for defining a class, its constructor & other methods

::* the basic control structures supported & their syntax

::* how you'd do file I/O in the language

::* the scope rules

::* the features for supporting exception handling

::* ...

::Are there compact example programs crafted to demonstrate these for different languages? --134.242.92.97 (talk) 15:32, 26 February 2016 (UTC)

:::This will only work if you only consider languages that are essentially identical except for their syntactic sugar. In actual fact, some programming languages are fundamentally different and have very different concepts. It is not merely a matter of learning which punctuation marks and bracket/whitespace conventions apply.

:::For example: read through our article on these languages: APL, Verilog, and Haskell. How do you assign a variable in Haskell? You don't. How do you write a for-loop in Verilog? You don't. How do you ... I mean ... how do you think you might learn APL from a "cheat sheet"? You have to conduct a lot of structured learning before you can even find where the source-code is in a sample APL program listing.

:::Nimur (talk) 16:35, 26 February 2016 (UTC)

::::The "cheat sheets" are not intended to be a learning tool, but a handy refresher of the basics of something that I don't use regularly. For example, I don't have a regular need to write bash scripts, but on the occasions I do, I'd often have trouble recalling how to do something that I've looked up months before. There's always the man page, but I find a well-crafted example program to be much easier and more user-friendly for the purpose. --134.242.92.97 (talk) 17:01, 26 February 2016 (UTC)

:For less common programming languages you can look at [http://codegolf.stackexchange.com/ codegolf]. Many problems have solutions in multiple languages, like [http://codegolf.stackexchange.com/questions/4707/outputting-ordinal-numbers-1st-2nd-3rd this one]. They are trying to make the code as short as possible, so readability suffers, but it may be useful to you none the less. [http://www.roesler-ac.de/wolfram/hello.htm This page] and [http://c2.com/cgi/wiki?HelloWorldInManyProgrammingLanguages that one] show you the famous Hello World program in many languages. The Quixotic Potato (talk) 09:29, 26 February 2016 (UTC)

::The question has been updated so I'll update my answer: I am not sure if something like that exist, but there is something very similar that may be useful to you. On the internet there are many snippet collections for many different programming languages (Google: snippet collection c++/python/COBOL/Fortran/whatever). What you want is basically a collection of snippet collections. Google has already done that for you, and they've helpfully sorted out the best ones for each programming language. The Quixotic Potato (talk) 02:25, 27 February 2016 (UTC)

::This site has the lyrics to [http://www.99-bottles-of-beer.net/ 99 Bottles of Beer] in over 1500 languages. It's great fun although probably not much use for learning. This thread [http://www.edugeek.net/forums/general-chat/72483-cheat-sheets.html] on an IT techies forum has hundreds of links to cheat sheets. As it's a forum, some links might be dead but I always look here when I'm after a cheat sheet. --TrogWoolley (talk) 10:21, 26 February 2016 (UTC)

Facebook comments' history

On Facebook, you sometimes get those inane posts asking you to "name a city without an A" or similar. Completely pointless. But occasionally a facebook friend has posted a comment. When there are 800,000+ comments, how do you find out what your friend wrote? -- SGBailey (talk) 22:05, 26 February 2016 (UTC)

:Isn't there an option to only read comments from friends ? (If you have friended all those people making inane comments, I suggest you unfriend them.) StuRat (talk) 23:31, 26 February 2016 (UTC)

::And if you're interested in why those things show up, give [http://daylandoes.com/facebook-like-scams/ this] a read. As you may have suspected, it's a scam to increase the value of the Facebook account so the cockroach who created it can sell it off. Matt Deres (talk) 03:44, 28 February 2016 (UTC)