└── README.md /README.md: -------------------------------------------------------------------------------- 1 | coffeescript-from-hell 2 | ====================== 3 | 4 | Title says it all, doesn't it? 5 | 6 | Believe it or not: all of the snippets below are valid coffeescript and mostly compile into something weird... 7 | 8 | 9 | ## Online coffeescript compiler 10 | [http://usefulthink.github.io/coffeescript-from-hell/](http://usefulthink.github.io/coffeescript-from-hell/) (by @pixelass and @ZauberNerd) 11 | 12 | [Example](http://usefulthink.github.io/coffeescript-from-hell/#this%20is%20a%20compiler%20for%20fun%20in%20CoffeeScript%0A%0Astory%3A%0A%20%20it%20happened%20while%205%20in%20many%20nerds%20drank%20many%20of%20beer%20and%20try%20to%20do%20fun%20while%20they%20play%20in%20CoffeeScript%20until%20this%20is%20what%20is%20the%20result%0A%0Aif%20you%20do%20not%20believe%20in%20this%20magic%20then%20scroll%20right%20and%20see%20for%20yourself%20in%20this%20example%0Ait%20is%20true%0Athis%20is%20valid%20and%20compiles%20in%20JavaScript%0A%0Arecommended%3A-%3E%0A%20%20have%20alcohol%20in%20blood%20for%20fun%20in%20here%0A%20%20it%20is%20best%20if%20it%20is%20beer%20%0A%20%20that%20is%20responsible%20for%20drunk%20in%20head%0A%20%20not%20too%20much%20or%20you%20is%20going%20in%20bed%0A%20%20gin%20and%20tonic%20is%20ok%20if%20it%20is%20better%20for%20you%20in%20taste%0A%20%20also%20not%20too%20much%20of%20it%20or%20you%20is%20a%20waste%0A%0Anow%20try%20to%20play%20for%20yourself%20in%20here) (by @pixelass) 13 | ```coffee 14 | this is a compiler for fun in CoffeeScript 15 | 16 | story: 17 | it happened while 5 in many nerds drank many of beer and try to do fun while they play in CoffeeScript until this is what is the result 18 | 19 | if you do not believe in this magic then scroll right and see for yourself in this example 20 | it is true 21 | this is valid and compiles in JavaScript 22 | 23 | recommended:-> 24 | have alcohol in blood for fun in here 25 | it is best if it is beer 26 | that is responsible for drunk in head 27 | not too much or you is going in bed 28 | gin and tonic is ok if it is better for you in taste 29 | also not too much of it or you is a waste 30 | 31 | now try to play for yourself in here 32 | ``` 33 | 34 | ## Some normal sentences that are totally valid coffeescript 35 | 36 | [we don't need it](http://coffeescript.org/#try:Drink%20a%20lot%20for%20yourself%20in%20the%20pub%20when%20you%20need%20it%20-%20me%20and%20my%20friends%20dont%2C%20do%20you%3F) (by @usefulthink) 37 | ```coffee 38 | Drink a lot for yourself in the pub when you need it - me and my friends dont, do you? 39 | ``` 40 | [ballmers peak](http://coffeescript.org/#try:do%20not%20try%20coffeescript%20if%20you%20have%20alcohol%20in%20your%20blood) (by @levito) 41 | ```coffee 42 | do not try coffeescript if you have alcohol in your blood 43 | ``` 44 | [ball games](http://coffeescript.org/#try:throw%20the%20ball%20and%20try%20to%20catch%20it) (by @ZauberNerd) 45 | ```coffee 46 | throw the ball and try to catch it 47 | ``` 48 | [future?](http://coffeescript.org/#try:do%20you%20know%20if%20this%20is%20the%20future%3F) (by @levito) 49 | ```coffee 50 | do you know if this is the future? 51 | ``` 52 | [you = _error](http://coffeescript.org/#try:try%20to%20drink%20beer%20until%20youre%20drunk%20if%20this%20isnt%20happening%20do%20not%20stop%20unless%20they%20catch%20you) (by @ZauberNerd) 53 | ```coffee 54 | try to drink beer until youre drunk if this isnt happening do not stop unless they catch you 55 | ``` 56 | [one pint](http://coffeescript.org/#try:drink%20for%20each%20of%20your%20friends%20one%20pint%20of%20beer%20unless%20youre%20drunk%20then%20stop%20or%20not%20go%20to%20work%20the%20next%20day) (by @ZauberNerd) 57 | ```coffee 58 | drink for each of your friends one pint of beer unless youre drunk then stop or not go to work the next day 59 | ``` 60 | [robot overlords](http://coffeescript.org/#try:I%20for%20one%20in%20many%20welcome%20our%20new%20robot%20overlords%20when%20they%20have%20cookies%20in%20their%20spaceship) (by @ZauberNerd and @usefulthink) - [with instrumentation](http://goo.gl/SUk8X7) 61 | ```coffee 62 | I for one in many welcome our new robot overlords when they have cookies in their spaceship 63 | ``` 64 | [ball games 2](http://coffeescript.org/#try:we%20try%20to%20throw%20the%20ball%20until%20you%20catch%20it%3B%20at%20least%20one%20in%20many.%20if%20this%20isnt%20happening%20until%20dawn%20while%20we%20practice%20go%20home) (by @ZauberNerd) 65 | ```coffee 66 | we try to throw the ball until you catch it; at least one in many. if this isnt happening until dawn while we practice go home 67 | ``` 68 | [coding style](http://coffeescript.org/#try:switch%20your%20coding%20style%0A%20%20when%20your%20coworker%20isnt%20fluid%20in%20coffeescript.%0A%20%20if%20he%20is%20fluid%20then%20do%20try%20to%20use%20it%20for%20everything%20in%20your%20company) (by @ZauberNerd) 69 | ```coffee 70 | switch your coding style 71 | when your coworker isnt fluid in coffeescript. 72 | if he is fluid then do try to use it for everything in your company 73 | ``` 74 | 75 | [about coffeescript](http://goo.gl/VcL5KX) 76 | ```coffee 77 | while coffeescript can be done in a beautyful way, a lot of it may 78 | break unless you pay a lot of attention. 79 | thats not how we like it 80 | 81 | writing is easy - but reading... #( 82 | ``` 83 | 84 | [don't like coffeescript](http://usefulthink.github.io/coffeescript-from-hell/#coffeescript%20is%20not%20my%20kind%20of%20language.%20The%20syntax%20is%20ugly%20and%20not%20understandable%20while%20it%20might%20be%20fun%20for%20people%20in%20ruby%20teams...%20%0Aunless%20he%20is%20a%20good%20developer%20and%20can%20do%20everything%20good%20then%20he%20can%20try%20to%20use%20it%20%0A) (by @pixelass) 85 | ```coffee 86 | coffeescript is not my kind of language. The syntax is ugly and not understandable while it might be fun for people in ruby teams... 87 | unless he is a good developer and can do everything good then he can try to use it 88 | ``` 89 | 90 | [feed dog or cat](http://usefulthink.github.io/coffeescript-from-hell/#feed%20dog%20if%20dog%20is%20hungry%20unless%20cat%20is%20hungry%0Aif%20cat%20is%20hungry%20then%20feed%20cat%20and%20do%20not%20feed%20dog%20until%20cat%20is%20not%20hungry%20and%20only%20feed%20dog%20when%20cat%20is%20not%20hungry) (by @pixelass) 91 | ```coffee 92 | feed dog if dog is hungry unless cat is hungry 93 | if cat is hungry then feed cat and do not feed dog until cat is not hungry and only feed dog when cat is not hungry 94 | ``` 95 | 96 | [double negatives](http://usefulthink.github.io/coffeescript-from-hell/#you%20isnt%20not%20true%20in%20real%20and%20i%20isnt%20not%20do%20nothing%20wrong) (by @pixelass) 97 | ```coffee 98 | you isnt not true in real and i isnt not do nothing wrong 99 | ``` 100 | 101 | [timetravel](http://usefulthink.github.io/coffeescript-from-hell/#tomorrow%20is%20new%20Date.%20now%20is%20today%20while%20yesterday%20is%20not%20today%20or%20tomorrow) (by @pixelass) 102 | ```coffee 103 | tomorrow is new Date. now is today while yesterday is not today or tomorrow 104 | ``` 105 | 106 | [twitter](http://usefulthink.github.io/coffeescript-from-hell/#if%20you%20tweet%20%40SomeBody%20then%20it%20is%20%20him%20or%20her%20%20in%20that%20tweet...%0A%0Aexamples%3A%20%0A%20%201%3A%20%40GregorAdams%20is%20crazy%20in%20CSS%20and%20CSS%20isnt%20%20CoffeeScriptShit%0A%20%202%3A%20%40ZauberNerd%20is%20awesome%20in%20JavaScript%20and%20does%20not%20like%20CoffeeScript...%0A%0A%20%20) (by @pixelass) 107 | ```coffee 108 | if you tweet @SomeBody then it is him or her in that tweet... 109 | 110 | examples: 111 | 1: @GregorAdams is crazy in CSS and CSS isnt CoffeeScriptShit 112 | 2: @ZauberNerd is awesome in JavaScript and does not like CoffeeScript... 113 | ``` 114 | 115 | ## Famous Quotes 116 | [evidence](http://coffeescript.org/#try:absence%20of%20evidence%20is%20not%20evidence%20of%20absence%0A%0A~%20Carl%20Sagan) (by @Shoom) 117 | ```coffee 118 | absence of evidence is not evidence of absence 119 | 120 | ~ Carl Sagan 121 | ``` 122 | 123 | [life](http://coffeescript.org/#try:Life%20is%20what%20happens%20while%20you%20are%20busy%20making%20other%20plans%0A%0A~%20John%20Lennon) (by @Shoom) 124 | ```coffee 125 | Life is what happens while you are busy making other plans 126 | 127 | ~ John Lennon 128 | ``` 129 | 130 | [be yourself](http://coffeescript.org/#try:always%20be%20yourself...%20unless%20you%20suck%0A%0A~%20Joss%20Whedon) (by @Shoom) 131 | ```coffee 132 | always be yourself... unless you suck 133 | 134 | ~ Joss Whedon 135 | ``` 136 | 137 | [stay in bed](http://coffeescript.org/#try:Dont%20stay%20in%20bed%20unless%20you%20can%20make%20money%20in%20bed%0A%0A~%20George%20Burns) (by @Shoom) 138 | ```coffee 139 | Dont stay in bed unless you can make money in bed 140 | 141 | ~ George Burns 142 | ``` 143 | 144 | [flying](http://coffeescript.org/#try:Flying%20is%20learning%20how%20to%20throw%20yourself%20at%20the%20ground%20and%20miss%0A%0A~%20Douglas%20Adams) (by @Shoom) 145 | ```coffee 146 | Flying is learning how to throw yourself at the ground and miss 147 | 148 | ~ Douglas Adams 149 | ``` 150 | 151 | [success vs value](http://coffeescript.org/#try:try%20not%20to%20become%20a%20man%20of%20success%2C%20but%20rather%20try%20to%20become%20a%20man%20of%20value%0A%0A~%20Albert%20Einstein) 152 | ```coffee 153 | try not to become a man of success, but rather try to become a man of value 154 | 155 | ~ Albert Einstein 156 | ``` 157 | 158 | ## Make them do things by adding some bootstrap code 159 | 160 | [batman](http://coffeescript.org/#try:%23%20bootstrap%0Agotham%3D0%3Bashes%3D8%3Bhelp%3D'%20Batman!'%3Bdont%3D''%3Byou%3Ddie%3D(a)-%3Ea%0Ashall%3D-%3Edocument.write%20gotham%2B%2B%2Fhelp%2C%5C%0A%23%20%2Fbootstrap%0A%0A%23%20orig%20quote%3A%20%22When%20Gotham%20is%20ashes%2C%20you%20have%20my%20permission%20to%20die.%22%0A%23%20%3E%0A%0Aif%20gotham%20is%20ashes%20then%20help%20else%20dont%0Ayou%20shall%20not%20die%20until%20gotham%20is%20ashes%0A%0A%23%20%3C) (by @ZauberNerd and @levito) 161 | ```coffee 162 | # bootstrap 163 | gotham=0;ashes=8;help=' Batman!';dont='';you=die=(a)->a 164 | shall=->document.write gotham++/help,\ 165 | # /bootstrap 166 | 167 | # orig quote: "When Gotham is ashes, you have my permission to die." 168 | # > 169 | 170 | if gotham is ashes then help else dont 171 | you shall not die until gotham is ashes 172 | 173 | # < 174 | ``` 175 | 176 | ## A little bit of "language" "features" 177 | 178 | ```coffee 179 | myFunction = (a,b,c) -> console.log a, b, c 180 | 181 | # now, lets call this, right - great that we may skip the parentheses, right? 182 | myFunction 1, 2, 3 183 | myFunction a:1, b:2, c:3 184 | myFunction 1, b:2, c:3 185 | myFunction a:1, b, c 186 | ``` 187 | 188 | ## Other programming languages 189 | 190 | [Clojure](http://usefulthink.github.io/coffeescript-from-hell/#%3B%3Bthis%20is%20valid%20Clojure%3A%3D%3E%0A%0A%20%20(defn%20recur%20%5Bx%5D%0A%20%20(if-not%20(zero%3F%20x)%20%0A%20%20%20%20(recur%20(%2B%20x%20x))%20%0A%20%20%20%20(recur%20(%2B%20x%201))))%0A%0A%20%20(recur%20(1))%0A%0A%0A%20%20(if%20(Boolean.%20false)%0A%20%20%20%20%22logical%20true%22%20%0A%20%20%20%20%22logical%20false%22)%0A%0A%0A%20%20(defn%20copy-file%20%5Bsource-path%20dest-path%5D%20%20%0A%20%20(io%2Fcopy%20(io%2Ffile%20source-path)%20(io%2Ffile%20dest-path)))%0A%0A%0A%20%20(copy-file%20%0A%20%20%22%2Fhome%2Fusername%2Fsquirrel.txt%22%20%0A%20%20%22%2Fhome%2Fusername%2Fburt-reynolds.txt%22)%0A) (by @pixelass) 191 | 192 | ```coffee 193 | ;;this is valid Clojure:=> 194 | 195 | (defn recur [x] 196 | (if-not (zero? x) 197 | (recur (+ x x)) 198 | (recur (+ x 1)))) 199 | 200 | (recur (1)) 201 | 202 | 203 | (if (Boolean. false) 204 | "logical true" 205 | "logical false") 206 | 207 | 208 | (defn copy-file [source-path dest-path] 209 | (io/copy (io/file source-path) (io/file dest-path))) 210 | 211 | 212 | (copy-file 213 | "/home/username/squirrel.txt" 214 | "/home/username/burt-reynolds.txt") 215 | 216 | ``` 217 | --------------------------------------------------------------------------------