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

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

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

Post 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).
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post 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)...
Help us help you: attach a .love.
User avatar
IMP1
Prole
Posts: 43
Joined: Mon Oct 03, 2011 8:46 pm

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

Post by IMP1 »

Is there anything actually wrong with the yoda conditions, or is it just unusual and so harder to read?
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

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

Post 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.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

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

Post 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.
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

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

Post 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.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

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

Post 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(_)
                              [_]=_[_]                    [_[_]]_[_._]=#"_._"_[
                       _[_._]]=_[_](_[_[_._]*_             [_._]],_[_._],_[_._
                    ]).._[_](_[(_[_._]+_[_._]/_[_._         ])*_[_._]],_[_._]/
                _[_._]+_[_._]/_[_._],_[_._]).._[_](_[_       [_._]*_[_._]],_
             [_._]+_[_._]-_[_._]/_[_._],_[_._]+_[_._]-_[       _._]/_[_._]
           ).._[_](_[_[_._]*_[_._]],_[_._],_[_._]).._[_](_[         _
         [_._]*_[_._]],_[_._]/_[_._]-_[_._]           ,_[_._
        ]/_[_._]-_[_._])_[_[_._]*_[_._]+_               [_._]-
      _[_._]/_[_._]]=(_)_[_[_._]*_[_._]+                  _[_._
     ]+_[_._]/_[_._]]=(_)_[#_+_[_._]/_[                    _._]]
    =_._[_[#_-_[_._]-#_/#_]]_[_[#_]]=_[                    #_](_[
   _[_._]].."(".._[#_-#_/_[_._]].."('"                     .._[_[_
  ._]]..[[("\\'..(...+#_*(_[_._]+_[_._]                   ))..'")')
  )()]])_[_[#_]]=_[_[_._]][_[_[#_]](_[_.                 _]*_[_._])
 .._[_[#_]](#_-_[_._]/_[_._]).._[_[#_]](_               [_._]+_[_._]
 +_[_._]/_[_._]).._[_[#_]](_[_._]^_[_._]-_[_         ._])]_[_[_[#_]](
 #_)]=#_*#_/_[_._]_[_[_[#_]](#_)]=_[_[_[#_]](#_)]+_[_[_[#_]](#_)]/_[(
 _._)]_._[_[    _[#_]](_[_[_[#_]](#_)]+#_-_[_._],_[_[_[#_]](#_)]+#_-
 #_/#_,_[_[_[   #_]](#_)]+#_/_[_._],_[_[_[#_]](#_)]+#_-#_/_[_._], _[
 _[_[#_]](#_)   ]+#_+#_/#_)](_[_[#_+_[_._]-_[_._]]](#_*#_/_[_._]-_[_.
 _],_[_[_[#_]   ](#_)]+_[_._]    /_[_.   _],_[  _    [_[#_]](#_)]+#_
 /_[_._]+_[_.   _],_[_[_[#_]](   #_)]+   #_/   _[_.   _]+_[_._],_[_[
  _[#_]](#_)]   +#_-_[_._]-_[_   ._]/_   [_._  ],#_   +#_+_[_._]-_[
  _._]/_[_._]   ,#_*(_[_._]+_[   _._])   -_[_.    _   ],_[_[_[#_]](
   #_)]+#_-_[   _._]-_[_._ ]/_   [_._]   ,_[_   [_[   #_]](#_)]+#_
    -#_/#_,_[   _[_[#_]](  #_)   ]+#_/   _[_   ._]+   _[_._],_[_[
     _[#_]](     #_)],#   _+#_    +#       _    /# _  + #_/#_,_[_
     [_[#_               ]](#_)     ]+_   [_._    ]-_  [_._]/_[_
      ._],_[_[_[#_]](#_)]+#_-_[_._]/_[_._],(_[_._])^_[_._]*(_[
        _._]+_[_._]/_[_._])+_[_._],_[_[_[#_]](#_)]+_[_._]*_[_
         ._],#_+#_+#_/#_+#_/#_,#_*#_/_[_._]+_[_[_[#_]](#_)]/
            _[_[_[#_]](#_)],_[_[_[#_]](#_)]+#_+_[_[_[#_]](
              #_)]/_[_[_[#_]](#_)]+_[_[_[#_]](#_)]/_[_[
                 _[#_]](#_)],_[_[_[#_]](#_)]-_[_._]))
                    _._=_[_[_._]][_[_[_[#_]](#_)]
                         ]_[(#_)^#_-(#_)-#_]=
                                 _._
Last edited by Roland_Yonaba on Fri Sep 21, 2012 6:56 pm, edited 1 time in total.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

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

Post 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
User avatar
Nsmurf
Party member
Posts: 191
Joined: Fri Jul 27, 2012 1:58 am
Location: West coast.

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

Post 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... :)
OBEY!!!
My Blog
UE0gbWUgd2l0aCB0aGUgd29yZCAnSE1TRycgYXMgdGhlIHN1YmplY3Q=
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

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

Post 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
Lua is not an acronym.
Post Reply

Who is online

Users browsing this forum: No registered users and 106 guests