@Roman<br>Thanks for the detailed explanation, those examples were really helpful<br><br>@Jachym<br>Thanks for replying. I am only half way through "Learn you some Erlang" and <div>picking up patterns from whatever I learnt so far from there. At this </div>
<div>moment I don't mind frameworks making decisions for me. But I totally </div><div>understand your point..</div><div><div><br></div><div><div style="text-align:left"><font color="#222222" face="arial, sans-serif"><span style="white-space:nowrap">@Garret</span></font></div>
<div style="text-align:left"><font color="#222222" face="arial, sans-serif"><span style="white-space:nowrap">Thanks, I will give e2 a try. </span></font></div><br><br>On Fri, Nov 30, 2012 at 7:18 PM, Garrett Smith <<a href="mailto:g@rre.tt">g@rre.tt</a>> wrote:<br>
> Roman is spot on correct.<br>><br>> There's a school of thought that says new developers should learn core<br>> Erlang and master it before tackling OTP. IMHO this is wrong. OTP *is*<br>> core Erlang at this point.[1]<br>
><br>> Just use OTP, right away. If the many moving parts of the standard OTP<br>> behaviors seems like a steep learning curve, take a look at e2:<br>><br>> <a href="http://e2project.org">http://e2project.org</a><br>
><br>> e2 is a veneer on top of OTP that, at least in my opinion (I wrote it<br>> for this reason :) makes canonical development a lot easier. You might<br>> start by reading/following the tutorial:<br>><br>
> <a href="http://e2project.org/tutorial.html">http://e2project.org/tutorial.html</a><br>><br>> The tutorial has more to do with general application development in<br>> Erlang than it does in with the specifics of the e2 library.<br>
><br>> Garrett<br>><br>> [1] There's a long history of Erlang that separates the core from OTP.<br>> I understand how books, tutorials, teaching philosophies, and common<br>> wisdom would treat OTP as an advanced topic. But as a relative<br>
> newcomer to Erlang, not having any historical context, etc. I found<br>> this treatment unhelpful in my own learning. IMO "gen_server" (e2<br>> calls these "services" and "tasks" depending on the scenario) is a<br>
> starting point, after one has learned the basics of the language<br>> itself.<br>><br>> On Fri, Nov 30, 2012 at 2:36 AM, Roman Gafiyatullin<br>> <<a href="mailto:r.gafiyatullin@me.com">r.gafiyatullin@me.com</a>> wrote:<br>
>> Hi,<br>>><br>>> In most of the cases one shall not use "simple loop functions": raw process<br>>> cannot participate properly in the supervision tree.<br>>><br>>> If you need some new tricky specific model of behaving - better implement it<br>
>> over gen_server.<br>>> For instance supervisor is a gen_server :)<br>>><br>>> If you need something more low level - use 'gen' module (see how gen_fsm is<br>>> implemented).<br>>><br>
>> --<br>>> Regards<br>>> RG ( +375 33 602 5080, UTC+3 )<br>>><br>>> On Friday, November 30, 2012 at 11:25 am, Vineet Naik wrote:<br>>><br>>> Hello,<br>>><br>>> I am an Erlang newbie and trying to write a simple chat bot as an<br>
>> XMPP external component. I am using exmpp library and following<br>>> along these tutorials[1]<br>>><br>>> So far I have one module `bot_server` that uses the gen_server<br>>> interface. Inside it's `handle_info` callback, incoming messages<br>
>> from various client will be received. To handle and reply to the<br>>> these messages, I am thinking of spawning a "bot" process per<br>>> client. It will stay alive as long as the client is available<br>
>> ie. when the client sends "unavailable" presence, it will die. I<br>>> also need to keep a list of all the alive bot processes in the<br>>> bot_server's state.<br>>><br>>> My question is, would it be appropriate to implement the bot as a<br>
>> gen_server too considering that it needs to handle two calls, one<br>>> for handling incoming message (asynchronous) and second for<br>>> killing itself (synchronous)?<br>>><br>>> In general, when should one use gen_server and when should<br>
>> one write a simple loop function?<br>>><br>>> [1] exmpp tutorials:<br>>> <a href="http://blog.process-one.net/scalable_xmpp_bots_with_erlang_and_exmpp_part_i/">http://blog.process-one.net/scalable_xmpp_bots_with_erlang_and_exmpp_part_i/</a><br>
>><br>>> Thanks,<br>>> Vineet<br>>> _______________________________________________<br>>> erlang-questions mailing list<br>>> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
>> <a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a><br>>><br>>><br>>><br>>> _______________________________________________<br>
>> erlang-questions mailing list<br>>> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>>> <a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
>><br><br><br><br>-- <br>Vineet Naik<br></div></div>