Open Side Menu Go to the Top

01-27-2013 , 05:17 PM
I originally was going to write a 2,000 word wall of text, but as they say, a picture is a thousand words.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
01-27-2013 , 06:58 PM
Quote:
Originally Posted by daveT
I originally was going to write a 2,000 word wall of text, but as they say, a picture is a thousand words.
i propose a compromise:

Code:
                              _,add8ba,
                            ,d888888888b,
                           d8888888888888b                        _,ad8ba,_
                          d888888888888888)                     ,d888888888b,
                          I8888888888888888 _________          ,8888888888888b
                __________`Y88888888888888P"""""""""""baaa,__ ,888888888888888,
            ,adP"""""""""""9888888888P""^                 ^""Y8888888888888888I
         ,a8"^           ,d888P"888P^                           ^"Y8888888888P'
       ,a8^            ,d8888'                                     ^Y8888888P'
      a88'           ,d8888P'                                        I88P"^
    ,d88'           d88888P'                                          "b,
   ,d88'           d888888'                                            `b,
  ,d88'           d888888I                                              `b,
  d88I           ,8888888'            ___                                `b,
 ,888'           d8888888          ,d88888b,              ____            `b,
 d888           ,8888888I         d88888888b,           ,d8888b,           `b
,8888           I8888888I        d8888888888I          ,88888888b           8,
I8888           88888888b       d88888888888'          8888888888b          8I
d8886           888888888       Y888888888P'           Y8888888888,        ,8b
88888b          I88888888b      `Y8888888^             `Y888888888I        d88,
Y88888b         `888888888b,      `""""^                `Y8888888P'       d888I
`888888b         88888888888b,                           `Y8888P^        d88888
 Y888888b       ,8888888888888ba,_          _______        `""^        ,d888888
 I8888888b,    ,888888888888888888ba,_     d88888888b               ,ad8888888I
 `888888888b,  I8888888888888888888888b,    ^"Y888P"^      ____.,ad88888888888I
  88888888888b,`888888888888888888888888b,     ""      ad888888888888888888888'
  8888888888888698888888888888888888888888b_,ad88ba,_,d88888888888888888888888
  88888888888888888888888888888888888888888b,`"""^ d8888888888888888888888888I
  8888888888888888888888888888888888888888888baaad888888888888888888888888888'
  Y8888888888888888888888888888888888888888888888888888888888888888888888888P
  I888888888888888888888888888888888888888888888P^  ^Y8888888888888888888888'
  `Y88888888888888888P88888888888888888888888888'     ^88888888888888888888I
   `Y8888888888888888 `8888888888888888888888888       8888888888888888888P'
    `Y888888888888888  `888888888888888888888888,     ,888888888888888888P'
     `Y88888888888888b  `88888888888888888888888I     I888888888888888888'
       "Y8888888888888b  `8888888888888888888888I     I88888888888888888'
         "Y88888888888P   `888888888888888888888b     d8888888888888888'
            ^""""""""^     `Y88888888888888888888,    888888888888888P'
                  Normand    "8888888888888888888b,   Y888888888888P^
                  Veilleux    `Y888888888888888888b   `Y8888888P"^
                                "Y8888888888888888P     `""""^
                                  `"YY88888888888P'
                                       ^""""""""'
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-27-2013 , 06:59 PM
e i pi,

the dragon book is a classic, so your instincts were right on.

Last edited by tyler_cracker; 01-27-2013 at 06:59 PM. Reason: not that i've read it, but it appears on the bookshelves of many developers i trust
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-27-2013 , 07:44 PM
So it appears once again my job is being redefined in such a way that I don't quite qualify for it and I'll probably have to stop dicking around and learn java or groovy. Any tips on good source material? Also, could really use some pointers to documentation on how to read a java dump, suggestions would be welcomed.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-27-2013 , 07:57 PM
Quote:
Originally Posted by e i pi
I got a used copy for $10 off abebooks.com. I'm half expecting a box full of dust to show up and wonder if its the book I ordered.

I also grabbed this for $4 despite not quite expecting to be able to understand it (yet). I mostly just liked the dragon on the cover lol.

The dragon book is a classic but also pretty legendary for being rather crappy at the same time.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-27-2013 , 11:16 PM
It's one of the recommended books for the compilers course on coursera, https://www.coursera.org/course/compilers

I'm ok with it just looking cool for the 4 bucks I spent on it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-28-2013 , 12:22 AM
Anyone planning on taking any of the algorithms classes on coursera that are coming up? Would be nice to have a study partner.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-28-2013 , 07:46 AM
Quote:
Originally Posted by clowntable
The dragon book is a classic but also pretty legendary for being rather crappy at the same time.
This is the impression I've been getting, but it must be a terribly difficult subject if this is the best book out there, so what do you do?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-28-2013 , 01:41 PM
gullanian: did you figure out the NAT issue? I'm just curious if/when you do what the solution was. Need to know how far off my out-of-my-ass speculations were :P
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-28-2013 , 01:50 PM
@Well named unfortunately not, we have sort of hit a brick wall with that and have put the project on hold for a little bit anyway as we have other work we need to do.

We highly confident it's solvable, so I think we're going to work on developing the game locally. We've written lag simulation, jitter simulation and packet loss simulation into the client so we can still do a lot of testing and get the game nearer completion. As we learn more about networks as we go along we'll hopefully be able to figure it out or pay someone to fix it!

Learning more about networking as we play with it, it's quite surprising the internet works! It feels like a big hack IPv6 solves a lot of these issues I believe (but will have to wait many years before we can ignore IPv4)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-28-2013 , 01:52 PM
That SO aggregator someone posted as a show HN looks promising.

www.stack-ed.com
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-28-2013 , 02:03 PM
it's interesting to call IPv4 a big hack. Definitely NAT is a hack, but I think an argument could be made that IP is the most robust and successful software engineering ever. I mean it's basically been the same for what, 40 years? Obviously lots of changes all around, but not really in TCP/IP, other than fixing buggy implementations.

<3 TCP/IP

good luck with your game.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-28-2013 , 02:07 PM
Sorry didn't mean IPV4 was a hack, just all the networking devices and NAT stuff inbetween two points A lot of very different HW that behaves very differently. A lot of respect for the people who do networking on more complex things!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-28-2013 , 02:11 PM
Quote:
Originally Posted by Gullanian
Sorry didn't mean IPV4 was a hack, just all the networking devices and NAT stuff inbetween two points A lot of very different HW that behaves very differently. A lot of respect for the people who do networking on more complex things!
Agreed!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-29-2013 , 08:28 PM
Was watching a lecture from MIT's 6.00SC course on their OCW.

In the lecture code, a function is defined like this:

Code:
def sort(L, lt = lambda x,y: x < y):
I believe the lecturer said this is called a functional argument, and that it is an important concept. I don't understand how that second argument works. Can anyone help explain it?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-29-2013 , 08:32 PM
Not sure what language that is (python?), but off the top of my head, that looks like just a default argument, that happens to be a function that takes two arguments, and returns whether the first is less than the second.

So if I'm right you could call it like this:

Code:
sort(something_to_sort, lambda x,y: x >= y)
In fact, just tried all this in python and yes, it is python and yes, it does work.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-29-2013 , 09:46 PM
Yup it is Python.

If you look at the entirety of the lecture code, I don't see where the function lambda is defined to be used as an argument to the function.

Edit: Or is the function even lambda? I think what I don't understand is where the function is coming from and what the function does.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-29-2013 , 10:55 PM
Lambda is a python keyword. Google lambda functions and python.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-30-2013 , 12:46 AM
Quote:
Originally Posted by Urinal Mint
Was watching a lecture from MIT's 6.00SC course on their OCW.

In the lecture code, a function is defined like this:

Code:
def sort(L, lt = lambda x,y: x < y):
I believe the lecturer said this is called a functional argument, and that it is an important concept. I don't understand how that second argument works. Can anyone help explain it?
I think what the lecturer means is that the code is passing a function as an argument to the function sort.

The way I think of lambdas is as "function literals", similar to how you can have string literals or integer literals in code

Code:
"abcdef" # string literal
123 # integer literal
[1,2,3] # list literal
lambda a,b,c: a+b-c # function literal
In Python, lambdas can only have a single statement in their function body - that statement is evaluated and returned when the function is called.

The format is
Code:
lambda <args here>: <statement here>
which is equivalent to a function with the simple body
Code:
return <statement here>
e.g.
Code:
def myfun(a,b,c):
  return a+b-c

# is equivalent to

myfun = lambda a,b,c: a+b-c
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-30-2013 , 01:10 AM
i agree with the instructor that truly understanding this concept is a critical step toward enlightenment.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-30-2013 , 01:37 AM
Quote:
Originally Posted by Urinal Mint
Yup it is Python.

If you look at the entirety of the lecture code, I don't see where the function lambda is defined to be used as an argument to the function.

Edit: Or is the function even lambda? I think what I don't understand is where the function is coming from and what the function does.
lambda is the keyword to create functions without naming them. In Python:

Code:
lambda (args): foo
Is equivalent to:

Code:
def f(args): return foo
except the first one doesn't define an "f".
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-30-2013 , 08:25 AM
Ahh it's a key word! Thanks, that makes more sense now
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-30-2013 , 08:29 AM
Take a look at this step-by-step. Suppose you start with:

Code:
def cube(x):
    return x*x*x

def square(x):
    return x*x

def sum(x, y):
    return x + y
You can define default arguments in Python

Code:
def sum(x = 1, y = 2):
    return x + y

>>> sum()
3
You can pass functions as arguments in Python.

Code:
def cube(x):
    return x*x*x

def square(x):
    return x*x

def sum(f, x, y):
    return f(x) + f(y)

>>> sum(square, 2, 3)
13

>>> sum(cube, 2, 3)
35
You even pass in default arguments for functions!

Code:
def cube(x):
    return x*x*x

def square(x):
    return x*x

def sum(f = square, x = 2, y = 3):
    return f(x) + f(y)

>>> sum()
13
Lamdba is basically the above, except that lamdba is an anonymous function. Pay attention:

Code:
def sum(x, y):
    return lambda x, y: x + y

sum(2, 3)
<function <lambda> at 0x022959F0>
You can also default the lambda as an argument to ans:

Code:
def sum(x, y, ans = lambda x, y: x + y):
    return ans

sum(2, 3)
<function <lambda> at 0x022959F0>
So, you want the answer?

Code:
def sum(x, y, ans = lambda x, y: x + y):
    return ans(x, y)

>>> sum(2, 3)
5
Ah! You have to pass the arguments into the function again.

Of course, this is an egregious example, but its interesting to play around with it a bit:

Code:
def cube(x):
    return x*x*x

def square(x):
    return x*x

def sum(f, x, y, ans = lambda x, y: x + y):
    return ans(f(x), f(y))
The mirrion dollar question, though, is can you override the default?

Code:
>>> sum(square, 2, 3, lambda x, y: x*y)
36
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-30-2013 , 08:35 AM
What problem does using lambdas solve?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-30-2013 , 09:20 AM
Lambdas in Python? They make your code hard to understand while increasing the cool factor by 1000%.

Don't you want your code to look cool?

Last edited by daveT; 01-30-2013 at 09:21 AM. Reason: I have no clue what they solve in Python... obviously
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

      
m