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

49 Answers 49

1
2
2
votes
\$\begingroup\$

JAVA

public static boolean think(){return true;}public static boolean so()
{return true;}public static boolean be(){return true;}static{boolean i=true;
    System.out.println((i==think())?so():i==be());
}

I think so i be --Descartes

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

C++

int main() {
  int right,might;
  might==right;
}

Might is right.

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

Haskell

Be original!

do otherwise

It returns True.

\$\endgroup\$
1
vote
\$\begingroup\$

Rebol

Rebol []
between: :if thought: expression: true lies: func ['a 'b] [a != b]

between thought and expression [lies a lifetime]

Some explanation

The above code translates to:

if thought and expression [lies word-arg1 word-arg2]

The if statement is true so the lies function is called which returns true as along as the two arguments provided are different.

\$\endgroup\$
1
vote
\$\begingroup\$

Perl

sub between (&@) { $_[1] if $_[0]->() } sub lies { $_[0] ne $_[1] }
my ($thought, $expression) = (1,1);

between {$thought and $expression} lies a => 'lifetime';

NB. Above works fine with (or without) strict and warnings pragmas.

\$\endgroup\$
1
vote
\$\begingroup\$

Ruby vs Friedrich Nietzsche

=> class Lie
=>   def self.is_a_condition_of?(life);true;end
=> end
=> Lie.is_a_condition_of?("life") # => true
\$\endgroup\$
  • 1
    \$\begingroup\$ You're admitting also that self is a condition of life :) +1 \$\endgroup\$ – Eduard Florinescu Jan 27 '14 at 12:19
1
vote
\$\begingroup\$

Is my use of the literal string true cheating?

This is an AutoHotkey script:

Be("true") to yourself

Be(msg) {
    MsgBox % msg
}
\$\endgroup\$
1
vote
\$\begingroup\$

Rebol

love: true 
war:  false

if true? any [love is blind and war is hell] [make love not war]
\$\endgroup\$
1
vote
\$\begingroup\$

Javascript

get: with(this) 1;

I think this makes sense.

Edit: was notified it didn't return true, well now it does.

\$\endgroup\$
  • \$\begingroup\$ Doesn't return true \$\endgroup\$ – Eduard Florinescu Feb 4 '14 at 20:41
1
vote
\$\begingroup\$

Not one of my favourite songs, still a great album.

PHP

$_GET['this'] or die(!0);

Reads as: Get this or die! (No!)

Get This
Slipknot
1999

\$\endgroup\$
1
vote
\$\begingroup\$

T-SQL

I made several attempts at this challenge before arriving at an answer that expresses truth through the code itself. After a few attempts at turning favorite quotes into pithy code translations, I realized the way to go was to set aside quotation entirely and let the language of choice simply speak the wisdom it is capable of speaking.

Since SQL is verbose, I have chosen to break this 4-line program into more lines for ease of reading without horizontal scrolling. The properly "golfed" version may be found on this SQLFiddle.

DECLARE @mindInTurmoil BIT = 'True'
Samsara: SELECT 'equanimity' AS Attitude, 0 AS Ego INTO #Self
    WHERE @mindInTurmoil = 'True' 
IF (SELECT TOP 1 Attitude FROM #Self ORDER BY Ego) = 'equanimity' 
    SET @mindInTurmoil = 'False' ELSE GOTO Samsara
SELECT CASE @mindInTurmoil 
    WHEN 'True' THEN 'False' WHEN 'False' THEN 'True' END AS Liberation

Returns:

Liberation
----------
True
\$\endgroup\$
1
vote
\$\begingroup\$

Java (probably others too)

boolean hasExceptions(Rule rule) { return rule != this; }

"There are always exceptions, except to this rule." - by me.

\$\endgroup\$
1
vote
\$\begingroup\$

JavaScript

function healthy_community(diversity){
    return (diversity === true) ? true : false;
}
healthy_community(true);
\$\endgroup\$
  • \$\begingroup\$ why not just return diversity ? \$\endgroup\$ – Eduard Florinescu Feb 26 '14 at 22:27
  • \$\begingroup\$ well if you pass 'kinda sorta' it will return false. it must be absolutely true in type and value. \$\endgroup\$ – Richard Andrew Lee Mar 3 '14 at 16:41
1
vote
\$\begingroup\$

Groovy

short Short;
short life = Short;
assert life.is(Short);
\$\endgroup\$
1
vote
\$\begingroup\$

Java

for (Person person : people) {
    if (!HouseTypeEnum.GLASS_HOUSE.equals(person.getResidence().getHouseType()))
        throw new StonesException();
}
\$\endgroup\$
  • 1
    \$\begingroup\$ Two problems: This doesn't compile because we don't have a Person class or a HouseTypeEnum or a StonesException or (etc). Also "should return the boolean true." This code doesn't return any value. \$\endgroup\$ – Justin May 16 '14 at 21:13
1
vote
\$\begingroup\$

Mathematica

 mo[thing__] := MemberQ[{thing}, money | problems | True]
 mo[money~mo~problems]
\$\endgroup\$
1
vote
\$\begingroup\$

Javascript

with = javascript = we = can = create = any = aphorism = returning = true;
\$\endgroup\$
  • \$\begingroup\$ Yes, but is it creative? ;) \$\endgroup\$ – Doorknob May 16 '14 at 23:47
1
vote
\$\begingroup\$

C

This quote is a line from My Fair Lady. See here https://www.youtube.com/watch?v=uVmU3iANbgk

#include <stdio.h>
/*the rain */int /*Spain falls*/ main/*ly*/(){return puts("on the plane")>0?1:0;}
\$\endgroup\$
0
votes
\$\begingroup\$

TI-BASIC 

2_be or not(2_be)
\$\endgroup\$
1
2

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