code logs -> 2016 -> Thu, 21 Jul 2016< code.20160720.log - code.20160722.log >
--- Log opened Thu Jul 21 00:00:45 2016
00:38 catalyst [catalyst@Nightstar-bt5k4h.81.in-addr.arpa] has quit [[NS] Quit: Leaving]
00:39 catadroid` [catadroid@Nightstar-bv08n4.dab.02.net] has quit [[NS] Quit: Bye]
00:39 catadroid [catadroid@Nightstar-bv08n4.dab.02.net] has joined #code
01:09 Derakon[AFK] is now known as Derakon
01:37 himi [sjjf@Nightstar-dm0.2ni.203.150.IP] has joined #code
01:37 mode/#code [+o himi] by ChanServ
01:41 Ogredude [quassel@Nightstar-dm1jvh.projectzenonline.com] has quit [[NS] Quit: No Ping reply in 180 seconds.]
01:41 Ogredude [quassel@Nightstar-dm1jvh.projectzenonline.com] has joined #code
01:41 mode/#code [+o Ogredude] by ChanServ
02:06 Turaiel[Offline] is now known as Turaiel
03:17 catadroid` [catadroid@Nightstar-527qii.dab.02.net] has joined #code
03:19 catadroid [catadroid@Nightstar-bv08n4.dab.02.net] has quit [Ping timeout: 121 seconds]
04:07 Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has quit [Connection closed]
04:14 Turaiel is now known as Turaiel[Offline]
04:45 McMartin [mcmartin@Nightstar-rpcdbf.sntcca.sbcglobal.net] has quit [[NS] Quit: Upgrades]
05:05 Derakon is now known as Derakon[AFK]
05:39 McMartin [mcmartin@Nightstar-rpcdbf.sntcca.sbcglobal.net] has joined #code
05:39 mode/#code [+ao McMartin McMartin] by ChanServ
06:23 celticminstrel [celticminst@Nightstar-nhhr58.dsl.bell.ca] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
07:27 Shady [ShadyGuru@Nightstar-8v9css.leh.ptd.net] has joined #code
07:32 Shady [ShadyGuru@Nightstar-8v9css.leh.ptd.net] has quit [[NS] Quit: Yay, he's gone]
07:37 catadroid` [catadroid@Nightstar-527qii.dab.02.net] has quit [[NS] Quit: Bye]
07:42 catadroid [catadroid@Nightstar-527qii.dab.02.net] has joined #code
07:42 catadroid [catadroid@Nightstar-527qii.dab.02.net] has quit [[NS] Quit: Bye]
--- Log closed Thu Jul 21 07:49:16 2016
--- Log opened Thu Jul 21 07:56:34 2016
07:56 TheWatcher [chris@GlobalOperator.Nightstar.Net] has joined #code
07:56 Irssi: #code: Total of 35 nicks [31 ops, 0 halfops, 0 voices, 4 normal]
07:56 mode/#code [+o TheWatcher] by ChanServ
07:57 Irssi: Join to #code was synced in 54 secs
07:58 Reiver [quassel@Nightstar-ksqup0.co.uk] has joined #code
07:58 mode/#code [+ao Reiver Reiver] by ChanServ
08:09 himi [sjjf@Nightstar-dm0.2ni.203.150.IP] has quit [Ping timeout: 121 seconds]
08:11 Kindamoody[zZz] is now known as Kindamoody
10:13 Emmy [Emmy@Nightstar-9p7hb1.direct-adsl.nl] has joined #code
10:13 mode/#code [+o Emmy] by ChanServ
10:15 himi [sjjf@Nightstar-v37cpe.internode.on.net] has joined #code
10:15 mode/#code [+o himi] by ChanServ
10:43 Kindamoody [Kindamoody@Nightstar-0lgkcs.tbcn.telia.com] has quit [Ping timeout: 121 seconds]
11:19
<@TheWatcher>
I fucking hate Jenkins.
11:40 Kindamoody|autojoin [Kindamoody@Nightstar-0lgkcs.tbcn.telia.com] has joined #code
11:40 mode/#code [+o Kindamoody|autojoin] by ChanServ
11:47 catadroid [catadroid@Nightstar-9mlsv2.dab.02.net] has joined #code
11:57
< catadroid>
...too much of my self confidence is wrapped up in knowing irrelevant minutiae about C++
12:38 Kindamoody|autojoin is now known as Kindamoody
12:52 Emmy-werk [NSkiwiirc@Nightstar-41pbej.static.chello.nl] has joined #code
13:54 Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has joined #code
13:54 mode/#code [+qo Vornicus Vornicus] by ChanServ
13:55 Kindamoody is now known as Kindamoody|afk
13:57 Emmy [Emmy@Nightstar-9p7hb1.direct-adsl.nl] has quit [Ping timeout: 121 seconds]
15:47 Emmy-werk [NSkiwiirc@Nightstar-41pbej.static.chello.nl] has quit [[NS] Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
15:48 celticminstrel [celticminst@Nightstar-nhhr58.dsl.bell.ca] has joined #code
15:48 mode/#code [+o celticminstrel] by ChanServ
16:17 catadroid` [catadroid@Nightstar-ihp0lr.dab.02.net] has joined #code
16:21 catadroid [catadroid@Nightstar-9mlsv2.dab.02.net] has quit [Ping timeout: 121 seconds]
16:38 catadroid` [catadroid@Nightstar-ihp0lr.dab.02.net] has quit [[NS] Quit: Bye]
16:38 catadroid [catadroid@Nightstar-ihp0lr.dab.02.net] has joined #code
16:40 Emmy [Emmy@Nightstar-9p7hb1.direct-adsl.nl] has joined #code
16:40 mode/#code [+o Emmy] by ChanServ
17:44 catalyst [catalyst@Nightstar-bt5k4h.81.in-addr.arpa] has joined #code
18:01 gizmore [kvirc@Nightstar-fm3fpb.dip0.t-ipconnect.de] has joined #code
18:47
<@Alek>
gah, closures are making my head hurt.
18:48
<@Alek>
function multiplier(factor) {
18:48
<@Alek>
return function(number) {
18:48
<@Alek>
return number * factor;
18:48
<@Alek>
};
18:48
<@Alek>
}
18:48
<@Alek>
var twice = multiplier(2);
18:48
<@Alek>
console.log(twice(5));
18:50
<&[R]>
Seems like you're understanding them fine there.
18:53
<@abudhabi>
[R]: You can totally use something without understanding it.
18:54
<@abudhabi>
Alek: Which part is hand to understand?
19:00
<@ErikMesoy>
A monad is a first-class monoid in the category of endofunctors, what's so hard to understand?
19:00
<@Tamber>
Uh-huh. Yup. Some of those are words.
19:01
<@abudhabi>
Alek: "multiplier" is a function. In JS, you can treat functions sort of like objects - this includes making sort of instances of them.
19:02
<@abudhabi>
Alek: Here, you are creating an instance of the "multiplier" function with a specified argument, and calling it "twice".
19:03
<@abudhabi>
Alek: Then you are calling "twice" with an argument too. Those two are multiplied, and you get 10.
19:03
<@abudhabi>
Alek: There is a trick here that multiplier returns a function of its own. That's how you get two arguments not overwriting each other.
19:04
<&McMartin>
This is also a simpler example, because the objects closed over (aka "captures", aka "upvalues", depending on who's writing about them) are immutable
19:04
<@abudhabi>
Alek: The "factor" argument gets assigned the first time, and is then baked into the instance.
19:06
< catalyst>
A monad is an abstraction Haskell programmers can use to kid themselves that their language has real world usages
19:06
<@Tamber>
XD
19:06
< catalyst>
The class is an abstraction that allows programmers with no class to get work done
19:06
<@ErikMesoy>
Alek: Maybe it helps to try to mentally disentangle the bits of what's going on. Draw a blackbox around the inner part.
19:06
<@ErikMesoy>
function multiplier(factor) { return blackbox }
19:07
<&[R]>
That won't work, since factor is no longer in the scope.
19:07
<@ErikMesoy>
I said "mentally".
19:07
<@ErikMesoy>
This is not actual code.
19:08
<&McMartin>
I think R is objecting because it's very hard to blackbox the act of closure creation.
19:09
<@ErikMesoy>
You give "2" to Multiplier, and Multiplier does something with the 2 and hands back a 2-related black box. Now you can give "5" to the black box, and the black box does something inside and gives back a 10.
19:09
<&McMartin>
That said, yes, if Alek's pain point is not closures per se but actually function literals, then this is where we need to be
19:17
< ToxicFrog>
Mmmm, closures
19:17
<&McMartin>
Also, since IIRC Alek hasn't actually done work with classical OOP languages my glib transformation of closures to and from OOP objects won't help. :(
19:18
<&McMartin>
On the plus side, JS's implementation of closures is by a wide margin the finest aspect of the language, and it is exactly as suitable for teaching them as Scheme.
19:18
<&McMartin>
The sharp edges surrounding it have to do with other weirdness and not the implementation of closures themselves.
19:19
<&McMartin>
(And that sharp edge is filed off, sort of, in ES6, though the syntax is subtle enough that I do wonder how much sense it will make to someone who didn't already use Lisp)
19:46
< catalyst>
(It's almost like Eich wanted to implement Scheme in the browser)
20:08
<@Alek>
R, I was copy pasting from the book. -_-
20:09
<@Alek>
what I didn't get was how the number came from outside to the inside. something to do with the return function() thing?
20:09
<&[R]>
The inner function retains its scope
20:10
<@Alek>
ah, it returns a second function, got it. that helps. also, getting a bit of rest away from the book helped.
20:10
<&[R]>
Yeah, it took me a while to realize that myself
20:11
<&[R]>
Also, the semi-colons are superfluous. Especially the one after the }
20:11
<&[R]>
That one bothers me
20:11 * Alek points at the book. -_-
20:11
<&[R]>
I know
20:12
<@Alek>
how would it work without assigning multiplier() to a var first? would it even work at all?
20:13
<&[R]>
multiplier(2)(5)
20:13
<@Alek>
O_O
20:13
<@Alek>
well, that's a thing.
20:13
<&[R]>
Though that looks silly and is slightly confusing.
20:14
<&[R]>
Also obviously you can pass it to a function expecting a callback
20:14
<@Alek>
callbacks, that's another thing yet to learn.
20:15
<&[R]>
Callbacks are basically just functions you pass to another function, it's how JS can do async code.
20:15
<&[R]>
eg: file.on('data', function(data) { /* do work with data */ })
20:17
<@Alek>
hmm
20:17 gizmore [kvirc@Nightstar-fm3fpb.dip0.t-ipconnect.de] has quit [Ping timeout: 121 seconds]
20:18
<@Alek>
"Almost any program can be made faster by making it bigger and more convoluted." ahahaha
20:18
<@ion>
O_o
20:18
<&[R]>
Are you doing a project as you learn JS?
20:18 gizmore [kvirc@Nightstar-hlmbsk.dip0.t-ipconnect.de] has joined #code
20:18
<@Alek>
not yet.
20:18
<&[R]>
lolwut
20:18
<@ion>
that's a somehow disturbing sentence
20:18
<&[R]>
What book are you reading?
20:18
<@ion>
Also yeah, I was about to ask what book
20:18
<@Alek>
the only environment the book offers is the in-page sandboxes.
20:18
<&[R]>
Also, MDN is pretty much /the/ JS reference.
20:18
<@Alek>
Eloquent Javascript
20:19
<@Alek>
and I wouldn't have any idea what kind of project to go with, much less environment.
20:19
<&[R]>
Never heard of it.
20:19
<@Alek>
http://eloquentjavascript.net/
20:20
<&[R]>
https://github.com/marijnh/Eloquent-JavaScript <-- supposedly all the code samples are there
20:21
<&[R]>
Oh wow, it's actually the whole book
20:21
<@ion>
Haha, I love this trend of publishing books in public repos like github
20:21
<@Alek>
the website I gave is the whole book. with code samples in inline sandboxes.
20:21
<@Alek>
that I can edit and run.
20:22
<@ion>
also I'm not much of a coder, but that seems like a horrifically javascript-happy comment to make, if your quote about faster more convoluted programs is from there.
20:23
<@ion>
it'd certainly explain a lot of webpages I visit, if that's the sort of advice being given to javascript developers anyhow...
20:26
<@Alek>
wow. the +5 || *3 return recurse is something, that's for sure.
20:26
<@Alek>
yeah, it's from the book. needs a bit of context though, since it's from the recursive functions section.
20:28
<@Alek>
the book gives sample code of using function recursion to find powers from a number and an exponent, mentions a prior sample using loops instead, says the recursive code is simpler and more elegant (and shorter?), and then mentions it takes longer to run.
20:30
<&McMartin>
Suffice to say that the short form there there kind of has it backwards
20:30
<&McMartin>
It's more "optimizing for performance damages readability and maintainability, which is why you do it last and only when you can prove you need to"
20:30
<&McMartin>
The claim that a recursive solution is cleaner and simpler than an iterative solution is... a claim to evaluate on a case-by-case basis.
20:31
<&McMartin>
For an example from my current project, say I want to split 1+2+3+4 into a set of three individual additions of two terms.
20:32
<&McMartin>
If I want to group them (1+(2+(3+4))), then it turns out recursion is much simpler
20:32
<&McMartin>
But if I want to group them(((1+2)+3)+4) then iteration is actually just as clean.
20:32
<&McMartin>
Know both techniques; you'll eventually pick up a feel for it.
20:33
<&McMartin>
(They can be transformed into one another mechanically, but the results of that are pretty much always ugly.)
20:33
<~Vornicus>
(the way most systems work is the latter
20:34
<&McMartin>
Right, and if you shift focus over to the functional languages, they usually have functions with names you can read as "fold left" and "fold right", which is the general case of my example above.
20:34
<&McMartin>
Fold Right pretty much has to be recursive, Fold Left can be iterative.
20:34
<&McMartin>
(Fold Right is the kind of problem where if you do it with a loop, you end up implementing your own version of function call semantics by hand, so you really should just be making function calls.)
20:37
<~Vornicus>
(clearly, reverse it, then foldl :P)
20:37
<~Vornicus>
(don't do it that way)
20:37 * ErikMesoy mutters dark curses on "optimize for performance"
20:37
<&McMartin>
(Doesn't preserve results)
20:38
<&McMartin>
ErikMesoy: You say that, but then you have people who perform SQL queries that return 50,000 rows of which they read one, and say "well, premature optimization is the root of all evil! :shrug:"
20:39
<@ErikMesoy>
McMartin: Yeah, and people doing O(n^3) calls that could be done in O(n).
20:39
<@ErikMesoy>
I know about it in theory. But in practice I mostly seem to encounter stuff that doesn't so much need "optimization" as "you're doing it wrong, stop doing it wrong".
20:40
<&McMartin>
The polite term for that is "algorithmic optimization"
20:40
<&McMartin>
But yeah, that goes way back, too. If the slow one is simpler or smaller people will go for it if it's good enough for the initial use case.
20:40
<@ErikMesoy>
"optimization" I associate with things more like going from (n^2) to (n log n).
20:40
<&McMartin>
Yes, exactly that
20:41
<&McMartin>
A bunch of old 8-bit European videogames actually used bubble sort to scene-sort their sprite displays, because that was fast enough to do once a frame at 50Hz
20:41
<&McMartin>
People cracking it for the North American scene had to rewrite the rendering code to use an n log n sort instead to retain a stable 60Hz display
20:41
<&McMartin>
Even so I can't say the first guys were "doing it wrong".
20:42
<&McMartin>
There's also issues like "how big does N get"
20:42
<&McMartin>
If N is never going to be above, like, 6, you're probably good to go for O(2^N).
20:43
<&McMartin>
I'm pretty comfortable saying "if you're in a world where low-level performance tuning matters, you shouldn't be writing in a scripting language"
20:44
<@ErikMesoy>
Corollary: Seeing as I'm writing in a scripting language, I shouldn't do anything where performance tuning matters?
20:44
<&McMartin>
There's an amazing book that's a retrospective on assembly language programming the x86 from the Pentium back to the 8088, by a guy who did engine work for both iD and MS
20:45
<&McMartin>
He hammers your point here hard, and includes the fantastic line "There is nothing more sad than fast slow code"
20:45
<&McMartin>
(By which he means hyper-optimized bubble sorts and such)
20:45
<&McMartin>
ErikMesoy: If you gotta, I'd say go the classic Python route of "use the script for glue and logic, use the best algorithms there, have them coordinate operations implemented in a systems language"
20:46 gizmore|2 [kvirc@Nightstar-sh49ni.dip0.t-ipconnect.de] has joined #code
20:46
<&McMartin>
Even in Python you might find something like "oh hey, using a sorted set instead of an unsorted one alters performance by X% because of our specific workload" or whatnot
20:46 gizmore [kvirc@Nightstar-hlmbsk.dip0.t-ipconnect.de] has quit [Ping timeout: 121 seconds]
20:46
<&McMartin>
Those don't hurt
20:46
<&McMartin>
But you should probably leave a memo to your future self about why you're doing something that looks weird
20:58 catalyst [catalyst@Nightstar-bt5k4h.81.in-addr.arpa] has quit [[NS] Quit: Leaving]
20:58 catalyst [catalyst@Nightstar-bt5k4h.81.in-addr.arpa] has joined #code
21:43 jerith [jerith@Nightstar-ip7ar2.slipgate.net] has quit [[NS] Quit: Press Ze Button!]
21:51
<&jeroud>
If you want fast Python code, use pypy.
21:53 jerith [jerith@Nightstar-ip7ar2.slipgate.net] has joined #code
21:53 mode/#code [+ao jerith jerith] by ChanServ
21:53 jerith [jerith@Nightstar-ip7ar2.slipgate.net] has quit [A TLS packet with unexpected length was received.]
21:58 jerith [jerith@Nightstar-ip7ar2.slipgate.net] has joined #code
21:58 mode/#code [+ao jerith jerith] by ChanServ
22:14 VirusJTG [VirusJTG@Nightstar-6i5vf7.sta.comporium.net] has quit [Connection closed]
22:14 VirusJTG [VirusJTG@Nightstar-6i5vf7.sta.comporium.net] has joined #code
22:14 mode/#code [+ao VirusJTG VirusJTG] by ChanServ
22:24 thalass [thalass@Nightstar-rfp.o7s.158.104.IP] has joined #code
22:24 mode/#code [+o thalass] by ChanServ
22:31 thalass is now known as Thalass|dinopunching
22:46
<@Alek>
just don't let anyone else play with your pypy.
22:47 catadroid` [catadroid@Nightstar-7i94ot.dab.02.net] has joined #code
22:48
<&McMartin>
Incidentally, the "amazing book" I mentioned earlier is also available online, albeit as a PDF
22:48
<&McMartin>
http://www.drdobbs.com/parallel/graphics-programming-black-book/184404919
22:51 catadroid [catadroid@Nightstar-ihp0lr.dab.02.net] has quit [Ping timeout: 121 seconds]
22:54 Turaiel[Offline] is now known as Turaiel
22:59 catalyst [catalyst@Nightstar-bt5k4h.81.in-addr.arpa] has quit [[NS] Quit: Leaving]
23:22 Derakon[AFK] is now known as Derakon
23:24 catadroid` [catadroid@Nightstar-7i94ot.dab.02.net] has quit [Ping timeout: 121 seconds]
23:29 Emmy [Emmy@Nightstar-9p7hb1.direct-adsl.nl] has quit [Ping timeout: 121 seconds]
23:40 Thalass|dinopunching is now known as Thalass
--- Log closed Fri Jul 22 00:00:01 2016
code logs -> 2016 -> Thu, 21 Jul 2016< code.20160720.log - code.20160722.log >

[ Latest log file ]