Page 2 of 3

Re: Do You Have (Or Have You Seen) Twitches in Programming ?

Posted: Thu Sep 20, 2012 8:25 am
by BlackBulletIV
Exactly. Most of the smaller elements of code style is mere opinion, though that opinion is often dear to us (it is in my case anyway).

Re: Do You Have (Or Have You Seen) Twitches in Programming ?

Posted: Thu Sep 20, 2012 10:12 am
by Robin
I only care about coding style when it affects readability. Using a Smurf Naming Convention, taking Lua's "no significant white space" to the extreme (in either direction)...

Re: Do You Have (Or Have You Seen) Twitches in Programming ?

Posted: Thu Sep 20, 2012 5:00 pm
by IMP1
Is there anything actually wrong with the yoda conditions, or is it just unusual and so harder to read?

Re: Do You Have (Or Have You Seen) Twitches in Programming ?

Posted: Thu Sep 20, 2012 5:12 pm
by Inny
IMP1 wrote:Is there anything actually wrong with the yoda conditions, or is it just unusual and so harder to read?
They exist as a defensive measure against C's assignment syntax being a valid conditional statement. For instance, this is a common bug in C:

Code: Select all

if (c = 5) doSomething();
/* Branch is unconditional, as 5 is logically true. C is unintentionally modified. */
In languages where an assignment statement inside a conditional is a syntax error (like Lua), then it's unnecessary to practice the force with readability.

Re: Do You Have (Or Have You Seen) Twitches in Programming ?

Posted: Fri Sep 21, 2012 2:03 pm
by Roland_Yonaba
That's a total abomination.
Yep, valid Lua code:

Code: Select all

_={_=_G}for--[[]]__--[[]]in(next),_["_"]do(_)[_]=(__)_[#_[_]],_[_[_]:byte(-#"#"
)+#_[_]-(#{}+#"(#''"*#"*#*#*"*#"_[_[]]")]=_[_],_[_]end(_)[_]=_._[_[#""]]{[_._[_
[#""]]]=_}_[""]=_._[_._[_[#[=[=#=]=]*-((#[=[#[=]#]=]))]](_._[_[-#[[_[-#[#_[_]]]
](_))]_[";"]=_._[_[#"#"+(#")#^")^#"#^"]]_["'"]=[[sub]]_['"']=_[""][_["'"]]_["/"
]=[[/_)=.,[#"('*:^;+]]_["'"]=_[""][_['"'](_[-#[[=[=]=]]],-#",_",-#"..").._["'"]
]_["["]=_['"'](_[-#"#-]_"],#",",#{_}).._['"'](_[-#"-"],#",",#"#").._['"'](_[-(#
"^#^")^#"^#"],#"-",#"(").._['"'](_[#_[-#"#"]*-#"[#"],#_[-#"#"],#_[-#"#"]).._[''
..'"'](_[-#[[=[]=]]],#_["/"]/#_["/"],#"/").._['"'](_[-(#"#)-")^#[[""]]],-#"-,",
-#[=[[]]=])_["]"]=_['"'](_[-#_[-#"-"]],#",",#"#").._[";"](_["["]..[=[('\]=]..(#
'#).'*#',..]]'*#'",#"#",'-#'(').."')")().._['"'](_[-#_[-#"-"]],-#_[-#"-"]-#"-",
-#_[-#"-"])_['_']=_[";"](_["["]..'(_[""].'.._[";"](_["["]..[[('\]]..((#_["/"]+#
"'")*#"#*("*#"..").."')")().._['"'](_[#_[-#"_"]*#"[_"],-#"#-,",-#"(,").._['"'](
_[-#_["/"]],-#",",-#"(")..'(_["/"],...,#"#","")-#"#")')_[";"](_["'"](_["'"]([[]
#/#)[([;#.))."[,[:[:[+)/,#[+#)[:[.)))^)^#/#)[([;#.))."[,[:[:[+)/,#[+#)[:[.)))^]
]],"[^".._["/"].."]",""),"(.)(.)",_[";"]("_['.'],_['#']=...".._["["].."(_['']."
.._["]"].."(_['_'](...)*#_['/']+_['_'](_['#'])))")))(...)_={#{...},#{#{}},#"#"}
And it prints "Hello world!".
Seen on Corsix.

Re: Do You Have (Or Have You Seen) Twitches in Programming ?

Posted: Fri Sep 21, 2012 5:54 pm
by Inny
[quote="Roland_Yonaba"][/quote]

Oh man, that reminds me of that javascript program that can essentially do anything without using any alphanumeric characters. It boiled down to floating into the window and getting the characters you needed from the names of functions you knew would be there.

I'm guessing this program is doing the same, though to be honest, with the string.char command, and the len operator working on strings, you can get everything you want. The challenge is iterating _G to find print, and finding char in the string table, before you can build the characters you want. Then you can do some bit maths to get the characters you want. For instance:

Code: Select all

  A = string.char( (#'##')^(#'######') + (#'#') )
This is going to bake my noodle this weekend. I'll probably be back here on sunday night with my own version of this.

Re: Do You Have (Or Have You Seen) Twitches in Programming ?

Posted: Fri Sep 21, 2012 6:53 pm
by Roland_Yonaba
Inny wrote:This is going to bake my noodle this weekend. I'll probably be back here on sunday night with my own version of this.
Great, looking forward seeing that. Be sure to dispose a fire-extinguisher near your workplace.
Just in case you'll see smoke coming out your ears.

To keep going, just seen some ASCII arts with Lua. Still on Corsix.
Yep, that's Lua Logo.
The original code on the blog is not valid, though. It errs.
Above is a fixed version, found on Codepad.

Challenge opened, who's going to propose the same for Löve ? :crazy: :crazy:

Code: Select all

                                                                _={_=_G
                                                              }for--[[--]]__
                                                            in(next),_["_"]do
                                                           (_)[_]=(__)_[#_[_]]
                                                          =_[_]_[_]="sub"end(_)
                              [_]=_[_]                    [_[_]]_[_._]=#"_._"_[
                       _[_._]]=_[_](_[_[_._]*_             [_._]],_[_._],_[_._
                    ]).._[_](_[(_[_._]+_[_._]/_[_._         ])*_[_._]],_[_._]/
                _[_._]+_[_._]/_[_._],_[_._]).._[_](_[_       [_._]*_[_._]],_
             [_._]+_[_._]-_[_._]/_[_._],_[_._]+_[_._]-_[       _._]/_[_._]
           ).._[_](_[_[_._]*_[_._]],_[_._],_[_._]).._[_](_[         _
         [_._]*_[_._]],_[_._]/_[_._]-_[_._]           ,_[_._
        ]/_[_._]-_[_._])_[_[_._]*_[_._]+_               [_._]-
      _[_._]/_[_._]]=(_)_[_[_._]*_[_._]+                  _[_._
     ]+_[_._]/_[_._]]=(_)_[#_+_[_._]/_[                    _._]]
    =_._[_[#_-_[_._]-#_/#_]]_[_[#_]]=_[                    #_](_[
   _[_._]].."(".._[#_-#_/_[_._]].."('"                     .._[_[_
  ._]]..[[("\\'..(...+#_*(_[_._]+_[_._]                   ))..'")')
  )()]])_[_[#_]]=_[_[_._]][_[_[#_]](_[_.                 _]*_[_._])
 .._[_[#_]](#_-_[_._]/_[_._]).._[_[#_]](_               [_._]+_[_._]
 +_[_._]/_[_._]).._[_[#_]](_[_._]^_[_._]-_[_         ._])]_[_[_[#_]](
 #_)]=#_*#_/_[_._]_[_[_[#_]](#_)]=_[_[_[#_]](#_)]+_[_[_[#_]](#_)]/_[(
 _._)]_._[_[    _[#_]](_[_[_[#_]](#_)]+#_-_[_._],_[_[_[#_]](#_)]+#_-
 #_/#_,_[_[_[   #_]](#_)]+#_/_[_._],_[_[_[#_]](#_)]+#_-#_/_[_._], _[
 _[_[#_]](#_)   ]+#_+#_/#_)](_[_[#_+_[_._]-_[_._]]](#_*#_/_[_._]-_[_.
 _],_[_[_[#_]   ](#_)]+_[_._]    /_[_.   _],_[  _    [_[#_]](#_)]+#_
 /_[_._]+_[_.   _],_[_[_[#_]](   #_)]+   #_/   _[_.   _]+_[_._],_[_[
  _[#_]](#_)]   +#_-_[_._]-_[_   ._]/_   [_._  ],#_   +#_+_[_._]-_[
  _._]/_[_._]   ,#_*(_[_._]+_[   _._])   -_[_.    _   ],_[_[_[#_]](
   #_)]+#_-_[   _._]-_[_._ ]/_   [_._]   ,_[_   [_[   #_]](#_)]+#_
    -#_/#_,_[   _[_[#_]](  #_)   ]+#_/   _[_   ._]+   _[_._],_[_[
     _[#_]](     #_)],#   _+#_    +#       _    /# _  + #_/#_,_[_
     [_[#_               ]](#_)     ]+_   [_._    ]-_  [_._]/_[_
      ._],_[_[_[#_]](#_)]+#_-_[_._]/_[_._],(_[_._])^_[_._]*(_[
        _._]+_[_._]/_[_._])+_[_._],_[_[_[#_]](#_)]+_[_._]*_[_
         ._],#_+#_+#_/#_+#_/#_,#_*#_/_[_._]+_[_[_[#_]](#_)]/
            _[_[_[#_]](#_)],_[_[_[#_]](#_)]+#_+_[_[_[#_]](
              #_)]/_[_[_[#_]](#_)]+_[_[_[#_]](#_)]/_[_[
                 _[#_]](#_)],_[_[_[#_]](#_)]-_[_._]))
                    _._=_[_[_._]][_[_[_[#_]](#_)]
                         ]_[(#_)^#_-(#_)-#_]=
                                 _._

Re: Do You Have (Or Have You Seen) Twitches in Programming ?

Posted: Fri Sep 21, 2012 6:55 pm
by coffee
Inny wrote:
Roland_Yonaba wrote:
Oh man, that reminds me of that javascript program that can essentially do anything without using any alphanumeric characters. It boiled down to floating into the window and getting the characters you needed from the names of functions you knew would be there.
BTW " let's talk about Javascript." that remind me a video

https://www.destroyallsoftware.com/talks/wat

from an old post with more coding jokes
viewtopic.php?f=3&t=7570&p=47719

Re: Do You Have (Or Have You Seen) Twitches in Programming ?

Posted: Sat Sep 22, 2012 8:27 pm
by Nsmurf
That lua logo is **AWESOME** :awesome: :awesome: :awesome:

I'd say the worst habit of mine is not indenting. When I start coding, I just want to get something up and running, so I don't think about indenting, then it ends up as a habit, and I'm to lazy to go back and fix to :( If I start with something that's indented though, I'm fine... :)

Re: Do You Have (Or Have You Seen) Twitches in Programming ?

Posted: Sat Sep 22, 2012 9:03 pm
by qaisjp
Nsmurf wrote:That lua logo is **AWESOME** :awesome: :awesome: :awesome:

I'd say the worst habit of mine is not indenting. When I start coding, I just want to get something up and running, so I don't think about indenting, then it ends up as a habit, and I'm to lazy to go back and fix to :( If I start with something that's indented though, I'm fine... :)
I only do that when writing test code, but I cannot handle too much code like that. I do it plenty times in lua.org/demo.html because i cba to press space 4x