39
votes
\$\begingroup\$

Can you write an aphorism in at most 4 lines of code ?

Code should read as much as possible as an aphorism in plain English and should return the boolean true.

Language: of choice.

Criteria for accepted answer: Most votes in 180 30 days. (8th of July 2014)

Originality: can be an old aphorism but a creative one would be much more appreciated.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ What is the max line length ? \$\endgroup\$
    – kyle k
    Jan 9, 2014 at 23:54
  • \$\begingroup\$ @kyle k, 90 characters should should suffice, mostly for estetic, readability reasons, also good aphorisms tend to be short :) \$\endgroup\$ Jan 9, 2014 at 23:57
  • 1
    \$\begingroup\$ Ruby - !!"[ insert whatever aphorism you want here ]" \$\endgroup\$
    – Doorknob
    Jan 10, 2014 at 2:54
  • 1
    \$\begingroup\$ @DoorknobofSnow That would be a valid answer but I doubt that would get much of the votes. \$\endgroup\$ Jan 10, 2014 at 8:50
  • 1
    \$\begingroup\$ Not sure that Shakespeare quotes qualify as aphorisms. \$\endgroup\$ Jan 24, 2014 at 18:11

49 Answers 49

51
votes
\$\begingroup\$

Python

import this
love = this
this is love, love is not True or False, love is love
# (True, True, True)

Okay, this returns a tuple of Truths, but that itself evaluates as True anyway.

\$\endgroup\$
0
29
votes
\$\begingroup\$

Forth

2 : b or ! 2 ." b" ;
: that s" the questi" on ;
\$\endgroup\$
0
20
votes
\$\begingroup\$

C:

You'll have to squint a bit to read this one :-)

int x(){ int __,L        ;
     return (__ |__ ||__ |__ ,__,__ ,__ ,__ ,__  ,
             __||  1||__ |  1L/L|__||__|1/__|  1L)
                                ;   }

You might notice a potential division-by-zero error on line 3, but this is never executed because the expression evaluates as true before the calculation is performed.

\$\endgroup\$
6
  • \$\begingroup\$ Forest gump! +1 \$\endgroup\$ Jan 9, 2014 at 23:44
  • 8
    \$\begingroup\$ Could you please translate, for those of us without the necessary squinting skills? \$\endgroup\$
    – Bob
    Jan 25, 2014 at 14:32
  • \$\begingroup\$ @Bob Do you want a breakdown of the C code, or a clearer rendering of the ASCII art? \$\endgroup\$
    – r3mainer
    Jan 26, 2014 at 20:41
  • \$\begingroup\$ Oh, the C code is easy enough (__ is an identifier, couple bitwise and logical ORs and comma operators, which are all insignificant because it's all logical ORed with a 1 evaluating to true). It's the ASCII art that's a little difficult to read. \$\endgroup\$
    – Bob
    Jan 27, 2014 at 4:32
  • 3
    \$\begingroup\$ @Bob OK, here's something similar. (Not valid C code, but easier to read, I hope.) \$\endgroup\$
    – r3mainer
    Jan 27, 2014 at 9:23
19
votes
\$\begingroup\$

It's difficult to avoid string literals, comments and tricks fo this kind, but I tried to keep them to a mininum. Also, the first line makes no sense. Well, I had fun doing it

F#

(fun () -> (fun (_) -> // fun fun? wtf
try not <| failwith("me") ; (*but*) with |Failure((*co*)me(*s*)) -> true)("learning"))()
// "Try not to fail with me, but with failure comes true learning

I could also do some declaration abusing, but I ended up not finding a way to return true:

let the,bodies,hit_the=floor(0.0),(),()

or

let the_games=bigint() //pun intended

I really need to stop with the puns.

\$\endgroup\$
18
votes
\$\begingroup\$

C

No string literals or comments:

Better(to,re);main(silent){and();}be(thought,a,fool){}
than(to,open,your,mouth);and(){}remove(all,doubt);

Split over two lines, but one would work fine as well.

When compiled using gcc on Linux (x86-64), this produces an executable which exits with success (exit code 0), the same as the true Unix utility; this being how I choose to interpret the requirement of returning boolean true in a non-scripting language.

Note: notwithstanding the abuse of the "implicit int" rule, the principal trick behind this program is that while a C program that falls off the end of main without a return statement will usually result in a non zero exit code, by calling another function we can set the EAX register which is then used as the exit code of the program. This is of course totally undefined behaviour and utterly non portable.

\$\endgroup\$
17
votes
\$\begingroup\$

Python

war=peace=freedom=slavery=ignorance=strength=0
war is peace|freedom is slavery|ignorance is strength

Power=a=means=it=an=end=0
Power is not (a, means, it is (an, end))

JavaScript

You=true;function BigBrother(){};BigBrother.isWatching=function(y){return y};
BigBrother.isWatching(You)
\$\endgroup\$
15
votes
\$\begingroup\$

C#:

short life = 0;
return (life is short);

"Life is short" (Hippocrates)

\$\endgroup\$
1
  • 3
    \$\begingroup\$ Too bad there is no literal specifiers for shorts! It would be neat to do var life = 0s; \$\endgroup\$
    – Ben Reich
    Jan 24, 2014 at 16:44
14
votes
\$\begingroup\$

Ruby

class String
  def before(b) self < b end
end

A bit lengthy, but gets us a few aphorisms:

"age".before("beauty")
"business".before("pleasure")
"pearls".before("swine")

And (stretching slightly):

dont = []; y = 1
dont.count + y or ('chickens'.before('they hatch'))
\$\endgroup\$
0
11
votes
\$\begingroup\$

Scala

Some apply Double forall _; None isEmpty
\$\endgroup\$
11
votes
\$\begingroup\$

CoffeeScript

2 * @wrong isnt @right

=> true

\$\endgroup\$
10
votes
\$\begingroup\$

C++

bool life = true;
bool fair = false;

assert(life != fair);
\$\endgroup\$
8
votes
\$\begingroup\$

Python

love=[True];all,fair,war=love*3
all is fair in love and war
\$\endgroup\$
7
votes
\$\begingroup\$

An aphorism about http verbs, in

Ruby

puts do
something idempotent but are considered to be unsafe
because if the value at the beginning of a chain of calls is one possibly the value at the
end != 1
\$\endgroup\$
4
votes
\$\begingroup\$

C

if ((ifs && ands) == (pots && pans))
    work_for_tinkers_hands = FALSE;
\$\endgroup\$
4
votes
\$\begingroup\$

Javascript

function be(who) {
   if (who == 'thine own self') {
      return true;
   }
}

An approximation of "To thine own self be true."

I'm kind of fudging with the requirements, since it only returns true in one particular case ... but I'm hoping you'll let it slide because the return value is actually part of the aphorism.

\$\endgroup\$
4
votes
\$\begingroup\$

C

int main(int fear, int* computers){ int

    i; do { !fear; computers[i]; fear; "the lack of them";

} while();return true;}

I do not fear computers, I fear the lack of them.

-Isaac Asimov

\$\endgroup\$
4
votes
\$\begingroup\$

C

main(int I,char **think) {char *a="there"; for (;--I;) a['m'];}
\$\endgroup\$
2
  • 1
    \$\begingroup\$ You can remove the types in declarations. Also something has to be done to a's declaration... It gets in the way when you read \$\endgroup\$
    – mniip
    Jan 24, 2014 at 19:58
  • \$\begingroup\$ I left them because my compiler gave me errors without them, so I wanted to be very adherent :P \$\endgroup\$
    – jmc
    Jan 25, 2014 at 7:54
4
votes
\$\begingroup\$

I got a wonderful error while attempting this:

It's very much inspired by Darren Stone's answer.

TypeError: Cannot use 'in' operator to search for 'tis nobler' in mind to suffer the The Slings and Arrows of outrageous fortune

Javascript

[2].be || ! [2].be ; this.is, "the question"

It returns an implicit true.

Slightly less terse, with a question mark:

[2].be || ! [2].be? is = this: !"the question"
\$\endgroup\$
3
votes
\$\begingroup\$

PHP

$all = array('not well', 'not well', 'not well', 'well'); 
$end = array_pop($all);
$all = ($end == 'well') ? $end : 'not well';
return true;

"All's well that ends well."

\$\endgroup\$
3
votes
\$\begingroup\$

Q

any bird:`int$"hehand"=2^`int$"hebush"

and

(./) 2_iscomp:any 3,'s:"a",'"crowd"

\$\endgroup\$
3
votes
\$\begingroup\$

PHP

An apple a day...

$aphorism = function(){
    for($day=1;$day<=365;$day++) $apple++;
    return ($apple==365) ? true : 'doctor';
};
\$\endgroup\$
3
votes
\$\begingroup\$

Common Lisp

(Do ((as)) ('(I say no)t) as I do)
(time (and 'tide (wait-for 'no-man))) ;requires sbcl
\$\endgroup\$
3
votes
\$\begingroup\$

A bit lazy, but my take.

Python:

life = short = True; art = long = True; life=art
life is short and art is long

JavaScript:

The = word = 'Yoga'
has = been = 'vulgarized'
and = does = not=  mean = anything =Date.now() ,!''
//Swami Rama 
\$\endgroup\$
3
votes
\$\begingroup\$

Lua

-- all search is in vain
function search() end
-- only the void is true
function void() return function() return true end, true end
-- and what remains is to
for ever in void() do repeat search("light") until true end
return true
\$\endgroup\$
3
votes
\$\begingroup\$

JavaScript

return (Do || !Do) || (there == !try);

return 2 * be || !(2 * be);
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Upvote for the Yoda one, but I am thinking there should be a ban on "To be or not to be". \$\endgroup\$ Feb 21, 2014 at 17:53
3
votes
\$\begingroup\$

R

the_whole <- c(-1,-1)
the_part <- -1
the_whole > sum(the_part,the_part)

-Socrates

\$\endgroup\$
2
votes
\$\begingroup\$

Simply-Basic 84

Label 1;a random number between 0 and 1~should be stored in~A
If A is equal to 1 Then Display A End;Stop&Else,Go to label 1
:End; Otherwise destroy quantum transmitters internationally.
Since quantum transmitters are gone, power lost. KA-POW, yes?
\$\endgroup\$
2
votes
\$\begingroup\$

Prolog

waste(not).

want(X) :-
    waste(X).
\$\endgroup\$
2
votes
\$\begingroup\$

Python

be = that = the = question = 1
2 - be or not 2 - be
that is the & question
\$\endgroup\$
2
votes
\$\begingroup\$

Ruby

Not the most elegant solution, but very easy to read

def you_know_meaning(x) true end

!!!("aphorism" != "aphorism" unless you_know_meaning "aphorism")

=> true
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.