Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

This is not exactly a programming challenge, but a programming-related word challenge. If this is not fit for the site then feel free to close.


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?

share|improve this question
12  
Shakespeare should be good for this en.wikipedia.org/wiki/… –  gnibbler Jan 9 '13 at 4:26
    
Are repetitions allowed? –  elssar Jan 9 '13 at 7:07
3  
@elssar Yes, so long as you don't abuse them along the lines of en.wikipedia.org/wiki/…. –  Pubby Jan 9 '13 at 7:10
    
Is the score the total number of words, or just unique words? –  Sir_Lagsalot Jan 9 '13 at 22:13
1  
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 –  Kendall Frey Jan 18 at 6:42

12 Answers 12

up vote 23 down vote accepted

Mathematica 100 words (or slightly fewer, if repeats are not counted)

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). (Just ignore the backslashes.) 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, Bra, 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}

share|improve this answer
11  
Suddenly, I think Mathematica has too many keywords. –  GigaWatt Jan 9 '13 at 17:00
    
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). –  David Carraher Jan 9 '13 at 17:54
    
332 was the count a few hours ago. I checked, and there are well over 500 English words acceptable for using in Mathematica programs. –  David Carraher Jan 9 '13 at 23:22
    
@dude Many Option and Color names aren't in your list ... you could add up another 300, I guess :) –  belisarius Jan 12 '13 at 14:52
1  
Aren't most of these identifiers, not keywords? –  Geoff Reedy Jan 14 '13 at 17:38

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.

share|improve this answer
    
good answer! It was extremely amusing! –  Pranit Bauva Jan 12 '13 at 8:26
1  
You can use and instead of &. :) –  rightføld Jan 18 at 0:15
    
@rightfold I considered it, but I felt counting alternate identifiers would make it too easy, and not all tools recognize them as keywords. –  Sir_Lagsalot Jan 22 at 18:38

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)
share|improve this answer
1  
+1 for the checking code! –  Sanjay Manohar Jan 9 '13 at 23:42

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.

share|improve this answer

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.
share|improve this answer
    
Since when is you a Python keyword? –  kojiro Oct 16 '13 at 2:04
    
ha, good catch. Not sure how I can modify it; but feel free to downvote :-) –  FakeRainBrigand Oct 16 '13 at 2:46

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",...

share|improve this answer

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.

share|improve this answer

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

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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"

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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