<div class="gmail_quote">On 7 February 2012 19:39, Max Bourinov <span dir="ltr"><<a href="mailto:bourinov@gmail.com">bourinov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF"><div>I believe that Erlang is perfect the way it is.</div></div></blockquote><div><br></div><div>I love Erlang's simplicity and it's been pretty much my favorite development platform for the past few years now. I would like to be able to refer to a module *via* some additional context though, whether that is the application it resides in or a package/namespace.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF"><div><br></div><div>I see problem in absence of good IDE/editors for Erlang (yes, emacs is way not perfect).</div>
<div><br></div></div></blockquote><div><br></div><div>Personally I get along fine with vim, but erlide is cool for those who want to use it.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF"><div>
</div><div>If there will be a tool like IntelliJ IDEA for Erlang, there will be no problems with typing very_long_names any more. Auto completion rules.</div><div><br></div></div></blockquote><div><br></div><div>Yes but my point about very_long_module_names is not just that it is ugly and painful to type. I can get autocompletion in vim/emacs today so that's not the issue. The point is that as the number of libraries/applications I am able to choose from increases (and let's face it, they're growing fast) I'm increasingly being forced to deal with module name clashes *or* to put up with very long names which are distracting to look at - they take focus away from the *function* that is being called, which is what *I* want to focus on.</div>
<div><br></div><div>Maybe it's just me, and I'm in no way suggesting I know how to fix this. I would like to be able to run rabbitmq and riak in the same vm without a module name clash though, and it is there that currently one of several things has to happen:</div>
<div><br></div><div>1. both rabbit and riak-<whatever> rename their copy of gen_server2 to riak_gen_server2/rabbit_gen_server2</div><div>2. I let the first one on the code path get loaded and hope to the gods that it *behaves* properly for both applications</div>
<div>3. I give up and run them in a separate vm</div><div><br></div><div>None of these are satisfactory, especially as (1) isn't likely to happen. What might make this go away could be something like:</div><div><br></div>
<div>- module code scoped to "application domains" i.e., to the application the beam file resides in - so as not to clash</div><div>- modules within the same "application domain" referring to one another default to the same domain - so if app1 contains [mod1, mod2] and mod1 calls a function via `mod2:do_it(...)` then the function is resolved to the module `mod2` in the same application domain</div>
<div>- we get the ability to `import` modules from external application domains, so that I can call stuff in other apps when I want to.</div><div><br></div><div>% import everything in kernel and stdlib - this should probably be a default attribute!</div>
<div>-import_app([kernel, stdlib]).</div><div><br></div><div>% import a specific module from a specific app-domain</div><div>-import_mod(rabbitmq, [gen_server2]).</div><div><br></div><div>start() -></div><div>    %% this resolves to the gen_server2 beam which resides in the rabbitmq application</div>
<div>    gen_server2:start(...).</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF"><div></div><div>(there is plugin for idea to write Erlang code, but I didn't find it useful)<br>
</div></div></blockquote><div><br></div><div>I *have* to use intelliJ to write java code, because it's so complicated to write anything in java that without a good IDE it takes forever. I agree wholeheartedly that Erlang is a better language precisely because I *don't* need an IDE to be productive with it.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF"><div>
<br>Sent from my iPhone</div><div><div class="h5"><div><br>On 07.02.2012, at 21:25, Tim Watson <<a href="mailto:watson.timothy@gmail.com" target="_blank">watson.timothy@gmail.com</a>> wrote:<br><br></div><div></div>
<blockquote type="cite"><div><div class="gmail_quote">
On 7 February 2012 11:27, Mihai Balea <span dir="ltr"><<a href="mailto:mihai@hates.ms" target="_blank">mihai@hates.ms</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div style="word-wrap:break-word"><div><br><div><div>On Feb 6, 2012, at 2:38 PM, Tim Watson wrote:</div><br><blockquote type="cite"><div class="gmail_quote">On 6 February 2012 19:24, Jon Watte <span dir="ltr"><<a href="mailto:jwatte@gmail.com" target="_blank">jwatte@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
That is interesting -- it might make it worth it to upgrade to R14.<br>
<br>
Also, we found a module called "gen_server2" that works around this<br>
problem by draining the message queue before calling any callback, and<br>
then dispatching messages based on this list of drained messages. Does<br>
anyone have experience with this module?<br>
<div><br>
</div></blockquote><div><br></div><div>It is part of rabbitmq, which I'm guessing it's reasonable to call *fairly stable and production worthy* lol. I keep a copy as a standalone OTP library application on github, which I update/synchronise periodically with updates from the rabbit hg/git repository. I haven't refreshed it in a while, as we're largely >= R14 now, but I find this approach (of bundling it as a standalone library app) works nicely for making it available across projects, though I'm less reliant on it now as I'm not using the extra features it provides in addition to message queue draining.</div>


</div></blockquote><br></div></div><div>I wish there was an "official" standalone version of gen_server2. Rabbitmq includes it, the Erlang rabbitmq client includes it as well, riak_core too plus a variety of individuals like Tim have created standalone versions based on one of the above. If one attempts to combine, say, riak_core with the rabbitmq erlang client, frustration ensues.</div>


<span><font color="#888888"><div><br></div><div></div></font></span></div></blockquote><div><br></div><div>Actually this issue (of duplicate uses of the same module name) has to do with lack of namespace/package support and isn't so simple to solve - at least based on the myriad discussions on this list regarding the issue, none of which have yielded a satisfactory answer. Personally I think that whilst the java/.net approach of providing a namespace such as org.foobar.appname.package...etc might be flawed/imperfect, but it's a lot better than having clashes. The reason it works well in practise is that you can import modules via their namespace which reduces finger ache and you can always fully qualify a *thing* you want to use if there is a potential clash. Personally, I don't mind renaming gen_server2 to nebularis_gen_server2 but I just don't want to have to type that all the time. On the other hand, if packages were fully supported I could do this:</div>


<div><br></div><div>-import(org.nebularis.gen_server2).</div><div>doodah() -> gen_server2:start(....).</div><div><br></div><div><br></div><div>But of course in todays system there are numerous tools (reltool, cover, etc) that do not work properly with packages *and* you have to import "top level" modules as well, which is just a pain in the arse:</div>


<div><br></div><div>-import(lists). %% but why!!!</div><div><br></div><div>I *know* there are potentially better ways and I fully recognise that there is little difference semantically between a_b and a.b, but it's not a about the separator, it's about the tedium of typing in long names, not to mention the fact the a_very_long_series_of_different_segments_separated_by_underscores is appalling to read.</div>


<div><br></div><div>Personally I'd like to see behaviours and import come together so I can define take the gen_server(2) behaviour and import an implementation at the top level:</div><div><br></div><div>-api(gen_server2, nebularis_genserver2).</div>


<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span><font color="#888888"><div>Mihai</div><div><br></div>

</font></span></div></blockquote></div><br>
</div></blockquote></div></div><div class="im"><blockquote type="cite"><div><span>_______________________________________________</span><br><span>erlang-questions mailing list</span><br><span><a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a></span><br>

<span><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a></span><br></div></blockquote></div></div>
</blockquote></div><br>