36
\$\begingroup\$

As the title said, the challenge is to write the longest sentence by only using the keywords of 1 programming language.

For instance, using the keywords of C++, it is possible to write this sentence:

do not try this float

What can you come up with?

\$\endgroup\$
12
  • 16
    \$\begingroup\$ Shakespeare should be good for this en.wikipedia.org/wiki/… \$\endgroup\$
    – gnibbler
    Commented Jan 9, 2013 at 4:26
  • 3
    \$\begingroup\$ @elssar Yes, so long as you don't abuse them along the lines of en.wikipedia.org/wiki/…. \$\endgroup\$
    – Pubby
    Commented Jan 9, 2013 at 7:10
  • 1
    \$\begingroup\$ You don't need many words to make arbitrarily long sentences. For example, with the C++ keywords you can do "Try this and try this and...". You can famously make an arbitrarily long sentence using only the word "buffalo", and as someone says on this page, you can do the same thing with "char" ("it's not too hard to see fishes of the genus Salvelinus scorching each other, given access to sufficiently powerful flamethrowers"). Maybe it would be more interesting if each word could only be used once? \$\endgroup\$
    – James
    Commented Jan 14, 2013 at 11:57
  • 1
    \$\begingroup\$ I was doing this before this question was posted. I was being quite immature at the time, so I'll warn you about explicit language. chat.stackoverflow.com/transcript/7?m=4671602#4671602 \$\endgroup\$ Commented Jan 18, 2014 at 6:42
  • 6
    \$\begingroup\$ Finally a challenge that the APL guys can't win \$\endgroup\$
    – kb_sou
    Commented Jan 20, 2014 at 22:45

15 Answers 15

46
\$\begingroup\$

C++, 25 unique words, 28 total

True friend, do goto register for this new short public class for private auto operator (while inline, return this signed template), else break & void this long volatile union.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ You can use and instead of &. :) \$\endgroup\$
    – user11779
    Commented Jan 18, 2014 at 0:15
  • \$\begingroup\$ @rightfold I considered it, but I felt counting alternate identifiers would make it too easy, and not all tools recognize them as keywords. \$\endgroup\$ Commented Jan 22, 2014 at 18:38
34
\$\begingroup\$

Mathematica 100 80 unique words

Here's a start. All standard words in Mathematica begin with upper case. this includes I, the square root of negative 1.

On Sunday, And For All Times-- Assuming, On Opening Clear Dynamic Interactive Notebooks For Setting Contours, I Do Not Translate Missing Blue Arrays Which Span Temporary, Asynchronous, And Invisible Characters, Nor Do I Remove Undefined Arrowheads With Editable And Sound Outer Orange Roots Which Magnify Shallow Names Together With False Attributes (Because Most Axes Split Full Inner Kernels In Reverse Order)-- And While I Animate Undefined Quiet Ticks, I Begin With Tolerance And Operate On All Manual Matrices, Interleaving Circle With Cylinder, Boxed Skeleton With Compiled Cuboid, Red Cross With Nearest Timing Pattern, And Join Repeated Unique White Links With Heads ...


In case anyone is interested, here are 500+ words recognized by Mathematica (no additional libraries required). They are not all keywords, but experienced Mathematica programers will know and have used just about all of them.


{Abort, Above, Abs, Accumulate, Accuracy, AddTo, After, Alignment, All, Alternatives, Analytic, And, Animate, Animator, Annotation, Annuity, Antialiasing, Antisymmetric, Apart, Appearance, Append, Apply, Array, Arrays, Arrow, Arrowheads, Assert, Assuming, Assumptions, Asynchronous, Attributes, Automatic, Axes, Axis, Back, Background, Backslash, Backward, Band, Baseline, Because, Beep, Before, Begin, Below, Binarize, Binomial, Blank, Blend, Block, Blur, Bookmarks, Booleans, Bottom, Bounds, Boxed, Break, Button, Byte, Cancel, Cap, Cases, Cashflow, Catch, Ceiling, Cell, Cells, Censoring, Center, Character, Characters, Check, Checkbox, Chop, Circle, Clear, Clip, Clock, Close, Closed, Closing, Coarse, Coefficient, Collect, Colon, Colorize, Column, Commonest, Compile, Compiled, Complement, Complex, Compose, Composition, Compress, Condition, Cone, Congruent, Conjunction, Connect, Constant, Constants, Context, Contexts, Continue, Contours, Control, Convergents, Convolve, Copyable, Correlation, Cot, Count, Covariance, Cross, Cumulant, Cup, Curl, Cycles, Cylinder, Darker, Date, Debug, Decrement, Default, Defer, [Degree], Deinitialization, Deletable, Delimiter, Delimiters, Denominator, Deploy, Deployed, Depth, Derivative, Diagonal, Dialog, Diamond, Differences, Dilation, Dimensions, Direction, Directive, Disjunction, Disk, Dispatch, Display, Distribute, Distributed, Dithering, Divide, Dividers, Divisible, Divisors, Do, Dot, Down, Drop, Dynamic, Editable, Eigenvalues, Element, Eliminate, Empty, Enabled, Encode, End, Enter, Epilog, Equal, Equivalent, Evaluator, Except, Exists, Exit, Expand, Expectation, Exponent, Export, Expression, Extract, Factor, Factorial, Fail, False, File, Filling, Find, First, Fit, Flat, Flatten, Floor, Fold, Font, For, Forward, Frame, Front, Full, Function, Gather, General, Generic, Get, Graph, Graphics, Greater, Grid, Hash, Head, Heads, Histogram, Hold, Hue, Hyperlink, Hyphenation, I, Identity, If, Image, Implies, In, Increment, Inherited, Inner, Input, Insert, Inset, Install, Integer, Integers, Integral, Integrate, Interactive, Interleaving, Interval, Invisible, Item, Join, Joined, Kernels, Label, Labeled, Large, Larger, Last, Latitude, Launch, Left, Legended, Length, Less, Level, Lighting, Limit, Line, Links, List, Listable, Listen, Literal, Locked, Log, Longest, Longitude, Magnification, Magnify, Majority, Manipulate, Manual, Map, Masking, Material, Matrices, Maximize, Mean, Median, Medium, Menu, Mesh, Message, Messages, Method, Minimize, Minors, Missing, Modal, Mode, Modular, Module, Modulus, Moment, Monday, Monitor, Most, Mouseover, Multinomial, Multiplicity, Multiselection, Names, Nearest, Needs, Negative, Nest, Next, None, Nor, Norm, Normal, Normalize, Not, Notebook, Notebooks, Null, Number, Numerator, Off, Offset, On, Opacity, Open, Opening, Operate, Optional, Options, Or, Order, Ordering, Orderless, Orthogonalize, Out, Outer, Over, Overflow, Paclet, Pane, Panel, Paneled, Parallelize, Parameter, Parenthesize, Part, Partition, Paste, Path, Pattern, Pause, Permutations, Permute, Perpendicular, [Pi], Piecewise, Pivoting, Placed, Placeholder, Plain, Play, Plot, Plus, Point, Polygon, Polynomials, Position, Positive, Power, Precedence, Precedes, Precision, Prefix, Prepend, Previous, Print, Probability, Projection, Prolog, Properties, Property, Proportion, Protect, Protected, Pruning, Put, Pyramid, Quantile, Quantity, Quartics, Quartiles, Queueing, Quiet, Quit, Quotient, Radon, Random, Range, Raster, Rasterize, Rational, Rationals, Read, Real, Reap, Record, Rectangle, Reduce, Refine, Refresh, Reinstall, Release, Remove, Removed, Repeated, Replace, Resampling, Rescale, Residue, Resolve, Rest, Return, Reverse, Riffle, Right, Root, Roots, Rotate, Round, Row, Rule, Saturday, Save, Saveable, Scale, Scaled, Scan, Scrollbars, Select, Selection, Sequence, Series, Set, Setbacks, Setter, Setting, Shading, Shallow, Share, Sharpen, Short, Show, Sidebar, Sign, Signature, Simplify, Skeleton, Skip, Slot, Smaller, Socket, Solve, Sound, Sow, Spacer, Spacings, Span, Speak, Sphere, Splice, Split, Square, Stack, Star, Streams, String, Stub, Subfactorial, Subgraph, Subscripted, Subset, Subtract, Sum, Superset, Surd, Syntax, Table, Take, Tally, Temporary, Text, Texture, Therefore, Thread, Threshold, Through, Ticks, Times, Timing, Together, Toggle, Toggler, Tolerance, Tooltip, Top, Total, Trace, Tracers, Translate, Transpose, True, Tube, Tuples, Undefined, Underlined, Underscript, Unequal, Uninstall, Union, Unique, Unitize, Unset, Up, Variables, Vertical, Wedge, Weights, Which, While, Whitespace, With, Word, Write}

\$\endgroup\$
7
  • 17
    \$\begingroup\$ Suddenly, I think Mathematica has too many keywords. \$\endgroup\$
    – Mr. Llama
    Commented Jan 9, 2013 at 17:00
  • \$\begingroup\$ You may have a point. In Mathematica, everything is an expression and all symbols, such as the times-sign, are names when expressed in full, i.e.. long form, e.g. Times. I found 332 common English words in Mathematica. This does not include compound words such as AppendTo nor names of functions, of which there are literally thousands (but they are not really English words). \$\endgroup\$
    – DavidC
    Commented Jan 9, 2013 at 17:54
  • \$\begingroup\$ 332 was the count a few hours ago. I checked, and there are well over 500 English words acceptable for using in Mathematica programs. \$\endgroup\$
    – DavidC
    Commented Jan 9, 2013 at 23:22
  • 1
    \$\begingroup\$ @dude Many Option and Color names aren't in your list ... you could add up another 300, I guess :) \$\endgroup\$ Commented Jan 12, 2013 at 14:52
  • 1
    \$\begingroup\$ Aren't most of these identifiers, not keywords? \$\endgroup\$ Commented Jan 14, 2013 at 17:38
19
\$\begingroup\$

While making sentences is not really my strong suite, here goes nothing -

Python 20 words

Finally, continue with import and raise global yield while class lambda is in break and try and print exec pass.

To help with checking, I wrote some code to check whether the words are in the keyword list or not.

from keyword import kwlist
from re import findall

def kwcheck(sentence):
    """Check whether all the words of a sentence are Python keywords"""
    words= findall(r'\w+', sentence)
    for word in words:
        if word.lower() not in kwlist:
            return False
    return True, len(words)

if __name__ == '__main__':
    sen= raw_input("Enter your sentence: ")
    print kwcheck(sen)
\$\endgroup\$
0
15
\$\begingroup\$

The Importance of Education

-- by A. Coder Guy (written in Python)

Continue class, except if class is not for you.  
With no class, raise and assert!  Or yield, pass,
and break.  Try and continue!  Or - finally - return from class.
\$\endgroup\$
3
  • 5
    \$\begingroup\$ Since when is you a Python keyword? \$\endgroup\$
    – kojiro
    Commented Oct 16, 2013 at 2:04
  • \$\begingroup\$ ha, good catch. Not sure how I can modify it; but feel free to downvote :-) \$\endgroup\$
    – Brigand
    Commented Oct 16, 2013 at 2:46
  • \$\begingroup\$ Is not for self maybe? It's not quite standard usage, but I think it'd be understandable. \$\endgroup\$ Commented Jun 21, 2016 at 20:01
12
\$\begingroup\$

Common Lisp

:In :Common :Lisp :a :keyword :is :simply :a :symbol :which :has :the :KEYWORD :home :package :which :is :true :of :all :symbols :starting :with :a :colon :so :you :can :construct :arbitrarily :long :sentences. :Do :I :win?

This, for example:

(every #'keywordp '(:In :Common :Lisp :a :keyword :is :simply :a :symbol :which :has :the :KEYWORD :home :package :which :is :true :of :all :symbols :starting :with :a :colon :so :you :can :construct :arbitrarily :long :sentences. :Do :I :win?))

Evaluates to T

See http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_k.htm

\$\endgroup\$
9
\$\begingroup\$

c#, 17 words

This looks like pretty reasonable technical mumbo-jumbo.
I guess it can be extended a bit.
foreach is a bit stretching the rules.
Used this keyword list.

Try explicit operator, in case implicit string foreach virtual struct is as unsafe as this volatile lock.

\$\endgroup\$
9
\$\begingroup\$

Factor - 109

"Take my-world and with happy? make items to-do. Pause. Self not happy?"

"Yes<<."

"From oldies?"

"Yes>>. Self sad."

"Haversin, listen, each and every formula become oldies. Become not sad, do-something greater-from-last. Or . My-arch self is_gold<<. Change-is_gold. Go-back where your_event_mask<< make happy? future. Fulfill promise of self. Remember-definition, light are-copies-of happy?"

"Sweetest-day near>> me?. Handle-me, handle-me. Sad self. Home not near>>. Home not near>> at all. Out-of-memory. Sad self, old<< self. Most near>> ones left self long ago."

"Haversin, change-known self. No sad, Haversin. Become happy? Forget what<< keep self from happy? My-arch self want>> self be> not sad. Before leave, remember-error."

"Not remember-error! Error not! My-array has-entry? not of error! Leave error!"

"Smart-if remember-error."

A lot of these are stretches, but it somewhat tells a story, so it makes up for that.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ 1 + for Factor!! \$\endgroup\$
    – cat
    Commented Apr 26, 2016 at 0:14
  • 1
    \$\begingroup\$ Factor's especially good for this because it has no keywords :D \$\endgroup\$
    – cat
    Commented Jun 24, 2016 at 20:19
9
\$\begingroup\$

Applescript, 30 words

I never thought I would post an Applescript answer on PPCG, but given Applescript's natural language design philosophy, it is perfectly suited for this question.

I'm not much of a wordsmith, so here's one just to get us started, but I fully expect others will easily beat this:

Beneath the eighth error, my third script is ignoring the sixth local copy
of the fourth transaction to the seventh property whose reference is given
to repeat every tenth second.

This is constructed just from Applescript's keywords, which are:

Keywords

about above after against and "apart from" around as "aside from" at back before beginning behind below beneath beside between but by considering contain contains continue copy div does eighth else end equal equals error every exit FALSE fifth first for fourth from front get given global if ignoring in "instead of" into is it its last local me middle mod my ninth not of on onto or "out" of over prop property put ref reference repeat return returning script second set seventh since sixth some tell tenth that the then third through thru timeout times to transaction TRUE try until use where while whose with without

The following may or may not be considered valid for this challenge:

Built-in classes and properties

alias application boolean centimetres centimeters character class contents constant "cubic centimetres" "cubic centimeters" "cubic feet" "cubic inches" "cubic metres" "cubic meters" "cubic yards" date "date string" day "degrees Celsius" "degrees Fahrenheit" "degrees Kelvin" feet file frontmost gallons grams id inches integer item kilograms kilometres kilometers length list litres liters metres meters miles month name number ounces paragraph "POSIX file" "POSIX path" pounds quarts "quoted form" real record reference rest reverse "RGB color" running script "square feet" "square kilometres" "square kilometers" "square metres" "square meters" "square miles" "square yards" text time "time string" "unit types" version weekday word yards year

Built-in Commands

activate "ASCII character" "ASCII number" beep "choose application" "choose color" "choose file" "choose file name" "choose folder" "choose from list" "choose remote application" "choose URL" "clipboard info" "close access" copy count "current date" delay "display alert" "display dialog" "display notification" "do shell script" get "get eof" "get volume settings" "info for" launch "list disks" "list folder" "load script" "localized string" log "mount volume" offset "open for access" "open location" "path to" "path to resource" "random number" read round run "run script" say "scripting components" set "set eof" "set the clipboard to" "set volume" "store script" summarize "system attribute" "system info" "the clipboard" "time to GMT" write

Considering/Ignoring attributes

case diacriticals hyphens "numeric strings" punctuation "white space"

\$\endgroup\$
8
\$\begingroup\$

Shakespeare

44 words, 28 unique

Yes, all of these words really have keyword-level significance in Shakespeare. Shakespeare character names, normal nouns and adjectives are also a core part of the language, but I thought they'd bloat the list too much for this exercise.

You must listen to your heart to enter your mind: the heart shall recall the difference between the exit and the return, to let you remember you are your art, and so you are the product of yourself and an act better than yourself.

\$\endgroup\$
7
\$\begingroup\$

Ruby, 41 words

True self, do not begin class break, end class break, ensure class break, redo and redo class break, retry class break, rescue class break, or yield class break, until next class end (or next class module or next class return), or else!

That's just using words listed as actual keywords. There are a lot of other words that act like keywords because they're methods of the kernel or instance methods of Class.

A cheesier approach would start

Do not def "alias","begin","break",...

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

C++.

A lot of repeated words, but a borderline sensible sentence:

If this volatile friend false and do return unsigned public union template throw union
template goto void for false friend not using class, and try switch for new protected
union using true friend, or else catch long, private break using this public operator
switch for explicit union using new virtual friend if union for this friend not long and
true.

Aka: If this moody girl won't sign the marriage license, throw away the license and find a nice new girl--and if that doesn't work out, just try a...virtual union over the "public operator switch".

Oh, as far as exact number of words goes, sorry but I'm too lazy to count.

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

Python, 48 words

class, try (if lambda is in class) and continue as if in break from global import and raise yield for return from exec; else, while lambda is not in class, continue with print import except for def, finally pass 'assert elif' or else del is not for class.

This contains every keyword in keyword.kwlist

I think some explanation is required here: This sentence is said to a school class that is currently in some place called exec. In the class, there are amongst others two people named lambda and def. def should pass the assert elif test because otherwise the DEL (German ice hockey league) is nothing for the class.

\$\endgroup\$
1
  • \$\begingroup\$ <speechless> o.o \$\endgroup\$
    – cat
    Commented Apr 26, 2016 at 0:12
2
\$\begingroup\$

ECMA

A bit of broken English due to the fact that ECMA reserved words contain neither conjunctions nor more than one conjugation of verb. It's really an imperative language!

Do try this new typeof case, with this default catch function.

In this case, break in with this switch. If catch break, return with this new switch; finally throw in with this new function.

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

Perl - several entries

when given tied package untie, unpack and unlink until open, redo each package (link, pack and bind or tie) or dump if not open; next, read map, write state, reverse and return system. (28 distinct words)

bless (not hex) my rand-y flock; continue until values accept no sin; study END times, accept sleep and die; CHECK keys and close each crypt lock. (25 distinct words)

tell our next caller: "use fork and pipe; push, break, delete, kill, and DESTROY." (13 distinct words)

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

Haskell (~29-ish)

In case of foreign type, import data module; where as for all (forall) in qualified class, if hiding, then do default (let in, deriving instance of data family where qualified, otherwise data instance of type family); else type in fix (infix).

In Haskell, data family is a separate keyword from data, likewise with type family, and deriving instance is separate from deriving and instance. I am using forall as two words (counting only one), where as as one (counting two), and infix as two (counting one).

\$\endgroup\$

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