The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2015-12-26

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:03 ZoffixWin The sister language of Perl 5 has been released, along with the compiler Rakudo implementing it: https://perl6advent.wordpress.com/2015/12/25/christmas-is-here/
00:03 ZoffixWin jberger, ^ you wanted a ping :)
00:13 sri looks like it's been banned from the hackernews frontpage
00:13 sri prolly because people have been submitting that other post from yesterday with the same title
00:14 ZoffixWin heh
00:15 sri you laugh, but the end result will be that many will only see that useless post from yesterday
00:15 ZoffixWin TBH, I don't really care :)
00:25 preaction http://videolang.net/words/your%20point%20so/1
00:26 ZoffixWin lulz
00:27 damaya_ joined #mojo
00:32 jberger ZoffixWin: tweeted
00:33 jberger I still would have liked a stronger message, but the list of contributors was impressive
00:38 batman jberger, sri: I would like to chip in $0.02 as well on delay :)
00:39 batman Easier to write readable code imo.
00:39 batman (Might be because I haven't gotten the right introduction to promises though)
00:42 sri thing about promises is that a lot of people understand them
00:45 sri when delays come up, often the first question is "is that like promises?"
01:19 jberger Promises certainly has a majority of the mindshare
01:20 jberger At least from the alternatives to pure callbacks
01:20 damaya joined #mojo
01:20 jberger The question is, do more people do futures than pure callbacks
01:21 jberger Because imo the translation from callbacks to delays is easier than to futures
01:21 jberger But if everyone is already using futures then the battle is lost
01:25 SmokeMachine joined #mojo
01:33 PryMar56 joined #mojo
01:42 damaya using has, if I have something like has redis => sub { Mojo::Redis2->new }; and a concurrency of 500, will it create 500 Mojo::Redis2 objects?
01:44 damaya Or just one that gets used? Because, I keep getting "socketpair(): Too many open files at /usr/local/lib/perl/5.18.2/Net/DNS/Native.pm line 47."
02:56 batman damaya: 500
02:56 batman has redis => sub { state $redis = Mojo::Redis2->new }; # 1 instead of 500
02:56 batman depends though... if this is an application "has", then it shouldn't make more than the number of workers you have
02:57 batman but it's different if it's in a controller
03:17 noganex joined #mojo
03:52 voldemortensen joined #mojo
04:04 bpmedley https://bitbucket.org/snippets/bpmedley/rKoBk <-- How does this look?
04:04 bpmedley https://github.com/kraih/mojo/compare/master...brianmed:master
05:56 damaya thanks batman, I had tried doing state but ended up with the same error. I set the concurrency to 450 and it worked though,
06:01 buu So uh
06:01 buu How do I make $template->render( template => "foo/bar" ); use ...
06:01 buu oh
06:02 buu Well that's a major mistake.
06:07 cpan_mojo Mojolicious-Plugin-HandlebarsJSRenderer-0.06 by RMZG https://metacpan.org/release/RMZG/Mojolicious-Plugin-HandlebarsJSRenderer-0.06
06:08 jberger Don't use state in a "has" attribute
06:13 buu ?
06:14 buu oh
06:14 buu So what exactly does $c->render( template => 'foo', {hash} ); do?
06:14 jberger buu: it would try to render a template named template
06:15 jberger And assign/localize the hashref to a stash key named foo
06:15 buu You know, that would make sense, but it wasn't calling my renderer
06:16 jberger Your renderer?
06:17 damaya jberger: Why shouldn't you use state in a has? Is it ok to use it in a helper? I've been using state in has/helpers for a while now.
06:17 buu Hrm
06:17 jberger damaya: helper yes
06:17 buu jberger: A better question is why on earth don't you get an actual error message
06:18 jberger But the callback for has is a lazy builder for when an attribute isn't initialized
06:19 jberger So with state (depending on how the callback is invoked) you might get reuse of that one instance in strange ways
06:19 buu If I do render( template => whatever) and it can't find the template, why doesn't it say that instead of the generic "no route found"
06:19 jberger buu: an odd number of arguments means that the first one is a template name
06:20 kaare joined #mojo
06:21 buu Yes I got that
06:21 buu See the next question
06:21 jberger buu: ok
06:21 buu Is there even any situation where you'd want to call ->render and continue on after failing to produce output?
06:22 jberger I think I know the answer deep in my brain somewhere, but I've been in Christmas mode (and awake) for too long to adequately answer
06:22 jberger buu: think automatic rendering
06:22 buu I wonder if it's just an ugly hack to make 404s work
06:23 buu jberger: Yes automatic rendering has odd implications but I'm talking about actually calling $c->render
06:23 jberger buu: see also http://mojolicio.us/perldoc/Mojolicious/Controller#render_maybe
06:23 buu It seems pretty likely that everyone on the planet would assume $c->render would produce output or die
06:23 buu Or at least produce some kind of diagnostic
06:24 jberger It's also basically just what's documented in render
06:24 buu Well, Controller#render doesn't document that
06:25 buu I'm sure it's mentioned somewhere
06:25 buu Probably hidden in some paragraph in a guides section
06:25 buu " or call "reply->not_found" in
06:25 buu Mojolicious::Plugin::DefaultHelpers if no response could be generated"
06:25 jberger buu: it diss
06:25 buu Ok I missread that
06:26 bpmedley buu  : Do you have a smallish example?
06:26 jberger Does, but you just found it
06:26 jberger bpmedley: any example where the template doesn't exist
06:26 buu Yep
06:26 bpmedley Would you pastie, pls?  Or, did you already fix it?
06:27 buu bpmedley: ?
06:27 bpmedley Oh!  Sorry, I misread the quesiton.
06:27 buu sub foo { $_[0]->render(template => "not a template") }
06:28 jberger Perl -Mojo -E 'a ("/" => { template => "aaaaaaa" })->start' daemon
06:28 jberger (Not too bad for on a phone :p)
06:28 jberger (Other than the capital P)
06:29 buu perl -Mojo -E 'a ("/" => { template => "aaaaaaa" })->start' get /
06:29 jberger even better
06:29 buu I wonder how many hours I personally have spent trying to figure out that "route not found" actually meant "failed to find a template"
06:30 jberger I have that on my mental speed dial now
06:31 jberger (That metaphor isn't going to work in a few years is it? )
06:31 buu heh
06:32 buu Favorites list?
06:32 buu Not sure there's a word we replace it with
07:14 bpmedley buu : Are you familiar with this code: https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Routes.pm#L199 ?
07:23 buu Not specifically, why?
07:24 bpmedley I believe that's executed by the renderer for the route.  So, that's the logic that shows the 404 not found page, I think.
07:33 buu 176   return $maybe ? undef : !$self->helpers->reply->not_found
07:33 buu 177     unless defined $output;
07:34 * buu shrugs
07:57 ivan_ joined #mojo
08:21 damaya_ joined #mojo
08:42 dod joined #mojo
08:48 dod joined #mojo
09:01 Vandal joined #mojo
09:11 sri why has nobody told buu that there is no "route not found" page?
09:12 pink_mist buu: I think there is no "route not found" page
09:12 pink_mist sri: better? :P
09:12 sri much! :)
09:14 buu My bad "None of these routes could generate a response for your GET request for /search, maybe you need to add a new one?
09:14 buu Is *completely* different
09:15 sri if you want to get snippy, do that somewhere else please
09:15 buu 03:11 < sri> why has nobody told buu that there is no "route not found" page?
09:16 buu You *constantly* attack questions with meaningless responses
09:16 buu left #mojo
09:17 sri how dare i try help people before i know 100% the correct answer
09:17 sri some people...
09:23 sri but seriously, you guys see it as a "route not found" page? since nobody said anything?
09:23 sri it's supposed to be a generic "no response generated" page
09:24 damaya joined #mojo
09:50 ryozi joined #mojo
09:58 sh4 joined #mojo
10:05 damaya joined #mojo
10:09 sue joined #mojo
10:09 trone joined #mojo
10:36 kes joined #mojo
10:45 bpmedley sri : Before I read the code I didn't realize the page was saying that "no message has been rendered" as opposed to, "no route was found".
10:55 bpmedley https://bitbucket.org/snippets/bpmedley/rKoBk <-- sri, May I ask what you think of this and https://github.com/kraih/mojo/compare/master...brianmed:master ?
11:09 bpmedley_ joined #mojo
11:17 sri bpmedley_: what are you trying to achieve with that branch?
11:17 bpmedley_ A reasonable approach to Promises.
11:17 sri the promise itself is not the problem at all
11:18 sri we'd use a custom implementation anyway
11:18 sri the big questions are how to integrate promises into the rest of mojolicious
11:18 sri and if we want promises instead of delays at all
11:19 sri like jberger said before, most apis are just continuation passing style, and promise-ifying them is prety ugly
11:20 bpmedley_ My personal opinion is that Promises are more familiar with people and might help gain more interest.  Also, why deprecate delays?
11:21 sri because we can only teach one approach in the docs
11:21 sri in fact, we can barely teach one
11:21 sri two approaches would be a mess, and raise the barrier drastically
11:22 bpmedley_ I'm wondering if there would be disaster if old code no longer worked in production once a user upgraded.
11:22 sri it would be mojolicious 7.0
11:22 kaare joined #mojo
11:22 bpmedley_ I understand that there would be a new version; however, I believe that might inhibit a lot of users from upgrading.
11:23 sri i don't follow
11:24 sri we have been making breaking changes since forever
11:24 bpmedley_ That's true; however, converting delays to promises would be significant, I wager.  Although, maybe not if people use steps a lot.
11:25 bpmedley_ Just feels like forcing people to convert from delays to promises would be significant.  Perhaps it's just early.. :-0
11:25 sri of course it would be significant
11:26 sri like i said before, if we can't make drastic changes like that anymore, even if they are the right thing to do, i'll be leaving the project
11:26 sri then mojolicious would just be over
11:26 sri (for me)
11:27 bpmedley_ Given that, I believe Promises have a lot of merit.  People simply expect to see a jQuery like way of doing async code.
11:28 bpmedley_ For example, in that talk you posted a few days ago, there was a question if Mojo used promises.
11:28 sri that said, i have no idea where your sudden affinity for backwards compatibility is coming from
11:28 sri it's so not mojolicious
11:29 sri to follow the web is literally the second rule http://mojolicio.us/perldoc/Mojolicious/Guides/Contributing#Rules
11:29 sri and the web is choosing promises
11:31 bpmedley_ I hadn't read your comments on how adamant you were about making such changes; so, I need to keep up more.. :)
11:31 sri btw. the w3c has a guide for designing new apis with promises https://www.w3.org/2001/tag/doc/promises-guide
11:32 bpmedley_ Cool
11:33 sri bpmedley_: re your branch, i see a few red flags
11:33 sri like you have only one type of callback
11:34 sri a ->then() always accepts two
11:34 sri one for success and one for failure
11:34 bpmedley_ Yes, that's a fact.  I need to add support for success and error.
11:34 sri you're throwing around timers way too much
11:35 sri all you have to do is make sure the callbacks don't get invoked before the next tick, that's all
11:35 sri no need to preemptively wrap everything
11:36 sri ->then() always returns a new promise
11:36 sri if you want to do an implementation, i strongly recommend you start by turning the spec into a bunch of tests https://promisesaplus.com/
11:37 damaya joined #mojo
11:37 bpmedley_ Fantastic feedback!
11:37 bpmedley_ What's a better way to handle the callbacks without timers?
11:38 sri i'm not nearly done ;p
11:38 sri your callbacks may return promises
11:39 sri and you need to make those promises a condition for reolving the promise returned by ->then()
11:40 bpmedley_ Hrmm.  I'm confused, callbacks may return promises?
11:42 sri yes, that's very very important, and really the essence of promises
11:43 sri i made an example a few days ago
11:43 sri $ua->aget('http://...')->then(sub { $ua->aget('http://...') })->then(sub {...})
11:45 sri or, let me put it another way
11:45 sri $ua->aget('http://first')->then(sub { $ua->aget('http://second') })->then(sub { say 'third' })
11:46 sue joined #mojo
11:46 sri you return promises to avoid callback hell
11:49 sri where delays use $delay->begin to avoid nested callbacks, promises use return values with new promises
11:49 sri which become a condition for the resolution of the promise returned by ->then()
11:50 bpmedley_ https://bitbucket.org/snippets/bpmedley/78ozg <-- So, order would be: 1) http://first; 2) http://second; 3) qbert; 4) third ?
11:51 sri yes
11:51 sri you got it
11:52 bpmedley_ Cool.  I appreciate the feedback!
11:52 sri and the "say 'qbert'" could be replaced with a new promise to make the chain even longer
11:54 sri what's also really comfortable, is that you can do ...->then(sub { say 'third' })
11:54 sri oops
11:54 sri ...->then(sub { say 'third' })->catch(sub { ... })
11:54 sri and errors anywhere in the chain get propagated to that ->catch() callback at the end
11:55 bpmedley_ I don't see "catch" in that promises spec page - is there only one catch perl promise chain?
11:55 bpmedley_ perl => per
11:55 sri ah, ->catch() is in the javascript api spec
11:56 sri it's just an alias for ->then(undef, sub {...})
11:58 sri allright
11:58 sri so on to real problems :)
11:58 sri $ua->aget('http://...')->then(sub ($tx) {...}, sub ($err) {...})
11:59 sri what would $err be?
11:59 bpmedley_ Let me think
11:59 sri or, when would a rejected even happen?
12:00 sri it's really tough in the Mojo::UserAgent case
12:00 sri Mojo::Pg has it a lot easier
12:01 sri ther we have an actual $err argument passed to the callback
12:01 sri but Mojo::UserAgent has $tx->error
12:01 sri and if we only passed that value to the callback, debugging would get really hard
12:02 bpmedley_ Can the arguments to the onFulfilled and onRejected be context dependent?  So, $err would be $tx?
12:02 sri that's considered bad style usually https://www.w3.org/2001/tag/doc/promises-guide#reasons-should-be-errors
12:03 sri of course we don't have real error classes in perl... so...
12:06 bpmedley_ So, you're wondering if we need to use something like Mojo::Exception for the $err argument in the onRejected sub?
12:15 sri seems like unnecessary complexity
12:20 bpmedley_ Hrmm, I'm going to go dive some more into code.. I promise.. :-P
12:31 sri ;p
12:45 sri you know, i think the worst thing about delays is that the concept doesn't have a catchy name
12:47 sri even the most popular implementation of the pattern doesn't have one https://github.com/caolan/async
13:12 punter joined #mojo
13:22 kyshtynbai joined #mojo
13:23 damaya joined #mojo
13:39 kyshtynbai Hi everyone. Maybe someone can help me with Mojo::Pg's 'query' method's return value. If I do not get any field via sql query, the returning value shuold be undef, shouldn't it? But it doesn't and is always true. Here's the code Hi everyone! What will the method query of class Mojo::Pg return if there's no matches in WHERE clause? I thought it shoudl return undef, but either it doesn't or I'm missing something. Here's code:
13:39 kyshtynbai http://pastebin.com/bk9DF69A
13:39 kyshtynbai oh. copy paste is broken sorry
13:43 sri http://mojolicio.us/perldoc/Mojo/Pg/Database#query
13:46 trone joined #mojo
13:47 kyshtynbai but what if WHERE clause in 'select' doesn't match anythig? Like my $post_id = 9999999; my $res = $db->query('select post from posts where post_id = ?, $post_id); Should $res be true in this case?
13:47 sri yes
13:49 sri oh, we actually have a task for a volunteer here
13:50 sri make sure that every method that can return undef has it documented
13:50 damaya kyshtynbai: sri is not very helpful. why not do if $res->hash->{post}?
13:50 kyshtynbai I see. Than how do I throw a 404 message? Could you please advice how to perform a check if $res contains something valuable or just an "empty" object? I guess I can perform $res->hash and than check the hash but is this a correct methid
13:50 kyshtynbai oh
13:51 sri umm
13:51 kyshtynbai I see.
13:51 sri why am i being attacked all the time today?
13:51 damaya kyshtynbai: that's the method I use, but I imagine TMTOWTDI as they say.
13:51 bpmedley_ Odd day for that, as well.  It's Mojo's bday, right?
13:51 sri you know what, i'll stop trying to help now
13:51 damaya I'm not attacking you, promise. I was just saying that the link is not very helpful with regards to the question.
13:52 sri and yes, it is
13:52 kyshtynbai Thanks everyone :)
13:52 damaya Sorry, I should probably just go to bed, because that did come off harshly.
13:52 damaya kyshtynbai: Hope that helps. I imagine there's a better way to do it, but that's how I've been doing it.
13:52 bpmedley_ 🎂
13:52 kyshtynbai I see!
13:52 damaya And it works for me :)
13:53 damaya How old is Mojo today?
13:56 damaya btw, sri, I don't expect you to be helpful, considering you do most of the work on mojolicious, and considering I imagine you get a lot of questions in here, constantly. I know I teach a Linux class and I always get, "I have to set up a lab for a homework assignment. How do I do it?" kind of questions, and I'm not helpful either.
13:56 damaya :)
13:57 bpmedley_ In other news damaya turns into an oddly speaking english duck when tired.
13:57 damaya haha
13:57 mullagain joined #mojo
13:57 damaya Alright, that's my cue. G'night everyone. sri, if you want a volunteer for documentation, I'd be glad to help out. Let me know.
13:58 damaya Any way I can participate is greatly appreciated.
14:22 sri i need a break, jberger is in charge now, will be back in a few weeks or so
14:26 ZoffixWin \o
14:29 pink_mist take care sri, hope you come back invigorated =)
15:17 * jberger looks around
16:18 * ZoffixWin looks asquare
16:21 jberger ZoffixWin++
16:32 jberger jnthn's p6 release post is good
16:33 jberger Still not the "show this to your pm" post, but nice
16:33 ZoffixWin pm?
16:33 jberger Project manager
16:34 * ZoffixWin is still hesitant to use P6 for anything serious.
16:34 jberger ZoffixWin: that's the big problem here
16:34 ZoffixWin And by serious I mean used by customers
16:34 jberger This should have been the jump up and down telling "now go use this"
16:34 ZoffixWin jberger, I wouldn't really call it a problem. There are still bugs to shake out and Ecosystem modules to write.
16:35 jberger If it wasn't ready for that, they needed to make sure that it was
16:35 ZoffixWin The primary deliverable was the language, not the compiler.
16:36 ZoffixWin Now that the spec is frozen, the focus will be on fixing bugs, and hopefully more people will be willing to write ecosystem modules (or at least, not waste time fix broken modules due to spec changes)
16:36 esh joined #mojo
16:38 jberger ZoffixWin: you and others might say that but jnthn understood and said so in his post
16:38 jberger No one cares about a language spec
16:38 jberger They want something they can use
16:38 ZoffixWin Right, and it's not there yet.
16:39 ZoffixWin So we could announce the language spec or keep it quite, just 'cause people want something to use.
16:39 jberger They the p6 community missed a big opportunity
16:39 ZoffixWin I don't see an alternate set of events
16:39 ZoffixWin No we haven't.
16:40 jberger I hope you're right, but you don't get many big events
16:40 jberger Release day, especially for something this long in the making is something that people notice
16:41 sh4|2 joined #mojo
16:41 jberger I've had several times in the last few years (starting with jnthn's talk at mojoconf) where I saw something cool about p6 at a talk
16:42 jberger Then went to try it and it was either incomplete or totally undocumented
16:42 jberger It makes sense, I'm not blaming anyone, and yet the wind leaves your sails
16:42 esh_ joined #mojo
16:43 jberger Trying to capitalize on an exciting moment is not a bad thing
16:48 trone joined #mojo
16:51 mikegrb joined #mojo
16:51 haarg joined #mojo
16:53 bpmedley joined #mojo
16:59 lluad joined #mojo
17:16 hernan604 joined #mojo
17:58 bpmedley https://github.com/kraih/mojo/compare/master...brianmed:master <-- Thoughts?  (https://bitbucket.org/snippets/bpmedley/q8obp)
18:32 tim_ joined #mojo
18:38 thowe_ joined #mojo
18:48 dod1 joined #mojo
18:50 thowe joined #mojo
18:57 dvinciguerra joined #mojo
19:00 juikuen joined #mojo
19:07 dod joined #mojo
19:21 bpmedley jberger : May I ask what you think about ^^
19:27 PryMar56 joined #mojo
19:44 jberger bpmedley: well I have no experience with promises
19:45 bpmedley Understood.  Thx.
19:46 jberger IMO if we were going to use promises is probably at least crib parts from some of leoNerd's stuff
19:46 bpmedley I've certainly looked at and copied 'n pasted some of it.
19:46 bpmedley Perhaps there are more opportunities for sharing.
19:47 trone_ joined #mojo
19:49 dod joined #mojo
20:05 dod joined #mojo
20:35 punter joined #mojo
22:16 sue joined #mojo
23:26 cpan_mojo Mojolicious-Command-snoodoc-0.05 by CURTIS https://metacpan.org/release/CURTIS/Mojolicious-Command-snoodoc-0.05
23:57 bpmedley joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary