A Pythonista's Impressions of Erlang

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Joe Armstrong (AL/EAB)


> -----Original Message-----
> From: owner-erlang-questions
> [mailto:owner-erlang-questions]
> Sent: den 12 januari 2005 12:06
> Cc: erlang-questions
> Subject: Re: A Pythonista's Impressions of Erlang
>
>
> Speaking of string operations, I need to add (or remove) the
> /  at the
> end of an URL if it is absent (or present).
>
> I only ended in writing ugly code like that:
>
> RootUrl=
> if
>         list:last(SiteRoot) =/= $/ ->
>                 SiteRoot ++ [$/];
>         true ->
>                 SiteRoot
> end
>
> Is there an elegant way to do last character manipulation?
>

  No

   Actually you're code will crash if SiteRoot is empty - since an empty list
has no last element.

  Now you might think that since

        "string" ++ Var

 Is a legal pattern that you could write your function like this:


        add_slash(X = _ ++ "/") -> X;
        add_slash(X)            -> X ++ "/".

 But you would be wrong.
 
 To do it this way involves a quick hack to the compiler
of a rather simple parse_transform to change the semantics of
the compiler.

 Actually I see no reason why patterns like Var ++ StringLiteral should not
be compiled, especially since StringLiteral ++ Var *is* allowed - and therefore
disallowing Var ++ StringLiteral violates the principle of least astonishment.

 Failing that you'll have to hide the code in a function. Something like this

        aardvark([])  -> "/";
        aardvark(Str) ->
                case lists:last(Str) of
                  $/ -> Str;
                _  -> Str ++ "/"
                end.

  This function is very difficult to name (append_a_slash_at_the_end_of_string_if_there_isnt_one)
isn't a good name, so I've called it aardvark until somebody comes up with a better name

  Now there might be a better way. Suppose the resultant string is
just going to be output somewhere.

  Then instead of doing Str ++ "/" (which is an expensive operation)
you just build a deep list [Str,"/"] (which is a cheap operation)
and send this to your I/O routines which happily flatten the data as it is output.

  Note this programming style is very common -

  I write loads of stuff like:

  mkList(L) -> ["<ul>",
                     map(fun({I,J}) ->
                             ["<li>", mk_href(I,J) "</li>"]
                           end,
                "</ul>"].

  mkHref(I, J) -> ["<a href='">,I,"'>",J,"</a>"].

  happy in the knowledge that these things will eventually get flattened on output.

  If you absolutely need a flat version of L just call sneaky_flatten(L)

  Where

        sneaky_flatten(L) -> binary_to_list(list_to_binary(L)).

 
  Cheers

/Joe

 


Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Thomas Lindgren-5

>  To do it this way involves a quick hack to the
> compiler
> of a rather simple parse_transform to change the
> semantics of
> the compiler.
>
>  Actually I see no reason why patterns like Var ++
> StringLiteral should not
> be compiled, especially since StringLiteral ++ Var
> *is* allowed - and therefore
> disallowing Var ++ StringLiteral violates the
> principle of least astonishment.

Some objections:

X ++ "string" would compile into string searching
(linear time), rather than pattern matching (constant
time).

There might be multiple matches, what to do about
those? (May I suggest backtracking? :-)

What about nested patterns, e.g.,
   "foo:" ++ X ++ "=" ++ Y?
Will your simple parse transform really be all that
simple once we consider all the cases? (Perhaps the
best solution is to write it and see.)

However, I'll agree that more generally it might be
nice to have some sort of regexp patterns, especially
when doing the string processing tasks that tend to
pop up. (Parsing text based protocols, say?)

Also, regexps/string operations on binaries might be
more familar to people used to "strings as arrays".

Best,
Thomas



               
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - Get yours free!
http://my.yahoo.com 
 



Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

bryan
I went through the thread and was pleasently surprised as i think it turned out
pretty nice, but I noted that while people ragged on the guys understanding of
erlang (at least from my viewpoint it seemed like ragging) there was a general
quiet were the difficulties of finding resources, documentation etc. were
discussed. Any takes on that subject?



Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Bengt Kleberg-4
bry wrote:
> I went through the thread and was pleasently surprised as i think it turned out
> pretty nice, but I noted that while people ragged on the guys understanding of
> erlang (at least from my viewpoint it seemed like ragging) there was a general
> quiet were the difficulties of finding resources, documentation etc. were
> discussed. Any takes on that subject?

the best (imho) way to access erlang documentation is through this
interface:

http://www.corelatus.com/~matthias/modules.html


bengt


Reply | Threaded
Open this post in threaded view
|

Eddie and Distributed Erlang

Eranga Udesh-5
In reply to this post by bryan
Hi All,

I was studying Eddie implementation and found it uses it's own
synchronization method to manage the distribution of it's applications. For
example it's master_server has a synchronization part, which monitors other
master_server and if the active one (global) goes down, another one take
it's place.

Why doesn't Eddie use Erlang Kernel module's distributed application
mechanism?

In a distributed application, is there any use of having a supervisor, which
starts the application module? I guess the kernel dist_ac handles that part,
correct?

Thanks in advance!
Eranga




Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Jani Hakala-5
In reply to this post by bryan
bry writes:

> I went through the thread and was pleasently surprised as i think it
> turned out pretty nice, but I noted that while people ragged on the
> guys understanding of erlang (at least from my viewpoint it seemed
> like ragging) there was a general quiet were the difficulties of
> finding resources, documentation etc. were discussed. Any takes on
> that subject?
>
There are missing links in www.erlang.org

Getting started page:
 Getting started slowly
 Getting started very very very slowly
 Documentation in PDF

These refer to missing files in
 http://www.erlang.org/doc/r9c/doc/getting_started/ 


Also in the about page there is bad link to
     http://www.erlang.org/doc/r9c/doc/index.html 

Jani Hakala


Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Matthias Lang-2
In reply to this post by Bengt Kleberg-4
Bengt Kleberg writes:

 > the best (imho) way to access erlang documentation is through this
 > interface:

 > http://www.corelatus.com/~matthias/modules.html

I'm glad others find it useful, but I suspect it's not of much use to
a beginner---the whole idea is that you already know what you're
looking for.

bry wrote:

 > I went through the thread and was pleasently surprised as i think
 > it turned out pretty nice, but I noted that while people ragged
 > on the guys understanding of erlang (at least from my viewpoint
 > it seemed like ragging) there was a general quiet were the
 > difficulties of finding resources, documentation etc. were
 > discussed. Any takes on that subject?

Here's what he wrote about documentation:

  | Documentation: Most of the links to documentation on erlang.org are
  | broken. When you finally do get to the docs (mysteriously at erlang.se
  | instead of erlang.org), there are some real gems. When you click on
  | "Complete List of BIFs" (BIF = built-in function) in the reference
  | manual, you get "For a complete list of BIFs, their arguments and
  | return values, refer to erlang(3).".
  |
  | The kicker? When I downloaded and installed Erlang, the man pages
  | either weren't installed or weren't put in the right place. So, as a
  | newbie, I am left digging away from the main erlang site just to find
  | out what the f$%$ing built-in functions are. Not a good sign.

Broken links: yes, there are quite a few. It'd help if he noted which
ones were broken (he does point in the general direction further down
in the blog). Finding broken internal links shouldn't be hard... Maybe
someone would care to recommend a tool.

Aside: every time I update the FAQ, I go through all the links
manually and check they work. And each time I do that, I find a couple
of dozen links which are broken, but there's no mechanical way of
checking, because the destination still give me a page, just not the
page I wanted. Classic example: xml.net was once a site with some Java
XML software. Now it has nothing to do with XML and includes ads for
"adult friend finder".

The "Complete List of BIFs" is indeed pretty lame. See it for yourself
at

  http://www.erlang.se/doc/doc-5.4.3/doc/reference_manual/introduction.html#1.4

it's probably a left-over from when the documentation was just
man-pages. It should be a link to

  http://www.erlang.se/doc/doc-5.4.3/lib/kernel-2.10.3/doc/html/erlang.html

I don't get the "kicker" at the end. I can't see how to improve the
download page:

       http://www.erlang.org/download.html

either you download the documentation or you don't. Seems perfectly
clear to me. Maybe he was using a broken RPM.

Matt


Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Thomas Lindgren-5
In reply to this post by bryan

--- bry wrote:

> ... there was a general
> quiet were the difficulties of finding resources,
> documentation etc. were
> discussed. Any takes on that subject?

Personally, I've never had any difficulty in seeing
the existing docs (no broken links to be found either)
nor have I heard a lot of complaining about it. So the
broken links sounded like a local problem to that
poster.

Resources: the existing docs are fairly good, and the
new reference manual seems a fine thing for getting
started with programming. If anything, my problem has
been that it's difficult to find your way around all
the masses of available docs.

Examples and user contributions can be found directly
from the main page. Good.

Jungerl and some other SourceForge projects might be
invisible from the turrets of the mighty fortress of
Ericsson, so that's a possible drawback.

Not getting the man/html stuff when you download the
source tarball might or might not be a problem.
Perhaps the download page could be reorged?

OK, now let's compare www.erlang.org to the sites of
some similar languages. First www.python.org. That
site has:

immediately seen sidebars:
- "What is Python" (missing on erlang.org, or found in
FAQ)
- "Python Versions"
- "Documentation"
- "Community"
a main announcements page,
a search bar,
and a (possibly) nicer layout with a larger, more
readable font (on my Linux Firefox browser).

Actual downloads seem a bit less convenient on
python.org -- you get to the tarballs more quickly on
erlang.org.

The Python site seems to branch into different Python
versions fairly quickly, while erlang.org does not.
Not sure whether this is an advantage?

Next, looking at Ruby (www.ruby-lang.org), we can see
almost the same organization as python on the main
page. On downloads, they mark "the stable release".
Maybe the erlang download page should show "the stable
release" too, apart from having it on the top of the
page :-) (Actually, I think it would be a good idea to
mark the "standard Erlang/OTP download" more clearly.)

Next: Perl.org starts with "About Perl", "Online
documentation", "Get Perl" and a default download in
the top left corner. Actually downloading it involved
some link chasing, so here Erlang wins again. Nothing
special about the site, as far as I can tell. I think
CPAN is the cool thing about Perl's community
(www.cpan.org).

There are newsgroups, comp.lang.{python,ruby,perl} but
no comp.lang.erlang.

The example languages all seem to have anonymous cvs
and so on, which Erlang does not. But that's how we do
it, at this point.

There is, possibly, more involvement and contributions
to the language, distribution, libraries,
documentation and website from "outsiders" for
python/ruby/perl than Erlang. That's not so strange,
given Erlang's roots and constraints, but perhaps that
too could be improved as a "resource"? (It's one of
the benefits of open source, after all.)

Well, those are my 2 pence.

Best,
Thomas



               
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail 


Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Björn Gustavsson-3
In reply to this post by Jani Hakala-5
Thanks!

I have corrected the broken links.

/Bj?rn

Jani Hakala <jahakala> writes:

> bry writes:
>
> > I went through the thread and was pleasently surprised as i think it
> > turned out pretty nice, but I noted that while people ragged on the
> > guys understanding of erlang (at least from my viewpoint it seemed
> > like ragging) there was a general quiet were the difficulties of
> > finding resources, documentation etc. were discussed. Any takes on
> > that subject?
> >
> There are missing links in www.erlang.org
>
> Getting started page:
>  Getting started slowly
>  Getting started very very very slowly
>  Documentation in PDF
>
> These refer to missing files in
>  http://www.erlang.org/doc/r9c/doc/getting_started/ 
>
>
> Also in the about page there is bad link to
>      http://www.erlang.org/doc/r9c/doc/index.html 
>
> Jani Hakala
>

--
Bj?rn Gustavsson, Erlang/OTP, Ericsson AB


Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Fredrik Thulin-3
In reply to this post by Matthias Lang-2
On Thursday 13 January 2005 11.28, Matthias Lang wrote:
...
> Broken links: yes, there are quite a few. It'd help if he noted which
> ones were broken (he does point in the general direction further down
> in the blog). Finding broken internal links shouldn't be hard...
> Maybe someone would care to recommend a tool.

Linkchecker

 http://linkchecker.sourceforge.net/

apparently does the job. I tried it with two levels of recursion on
doc.html (linkchecker -r2 http://www.erlang.org/doc.html) but it didn't
turn up anything serious. Just some broken links in links.html (oh the
irony ;) ) :

Does not resolve :

http://csmctmto.interpoint.net/didx/python_erlang.html 
http://www.catseye.mb.ca/erlang/

Returns 404 Not Found :

http://www.bluetail.com/~joe/sae_r7b/sae.html

And a mirror that does not seem to be up, linked from mirrors.html :

http://erlang.stacken.kth.se/

/Fredrik


Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Håkan Huss-2
The "Getting started quickly"-tutorial contains two broken links at
the very end (Digging deeper), which point into
http://www.erlang.org/doc/r7b/doc/...

/H?kan

> On Thursday 13 January 2005 11.28, Matthias Lang wrote:
> ...
> > Broken links: yes, there are quite a few. It'd help if he noted which
> > ones were broken (he does point in the general direction further down
> > in the blog). Finding broken internal links shouldn't be hard...


Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Björn Gustavsson-3
Thanks! Corrected now.

/Bj?rn

H?kan Huss <huss01> writes:

> The "Getting started quickly"-tutorial contains two broken links at
> the very end (Digging deeper), which point into
> http://www.erlang.org/doc/r7b/doc/...
>
> /H?kan
>
> > On Thursday 13 January 2005 11.28, Matthias Lang wrote:
> > ...
> > > Broken links: yes, there are quite a few. It'd help if he noted which
> > > ones were broken (he does point in the general direction further down
> > > in the blog). Finding broken internal links shouldn't be hard...
>

--
Bj?rn Gustavsson, Erlang/OTP, Ericsson AB


Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Matthias Lang-2
In reply to this post by Fredrik Thulin-3


Matthias> Broken links [....] Maybe someone would care to recommend a tool.

Fredrik> Linkchecker (http://linkchecker.sourceforge.net/)

Oh the irony! It's a python tool.

I was almost relieved when it didn't work perfectly out of the box (it
chokes on LANGUAGE=en_SE:en_US:en_GB:en, works fine for
LANGUAGE=en_US)

;-)

Matthias


Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Chris Pressey
In reply to this post by Fredrik Thulin-3
On Thu, 13 Jan 2005 14:45:19 +0100
Fredrik Thulin <ft> wrote:

[of links.html]
> Does not resolve :
>
> http://www.catseye.mb.ca/erlang/

Wow, that brings back memories...

If you want to change it, I guess the present-day equivalent is

    http://catseye.webhop.net/projects/?keyword=erl

Or you can just remove it.

-Chris


Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Chris Pressey
In reply to this post by Thomas Lindgren-5
On Thu, 13 Jan 2005 03:12:01 -0800 (PST)
Thomas Lindgren <thomasl_erlang> wrote:

[...]

> The example languages all seem to have anonymous cvs
> and so on, which Erlang does not. But that's how we do
> it, at this point.
>
> There is, possibly, more involvement and contributions
> to the language, distribution, libraries,
> documentation and website from "outsiders" for
> python/ruby/perl than Erlang. That's not so strange,
> given Erlang's roots and constraints, but perhaps that
> too could be improved as a "resource"? (It's one of
> the benefits of open source, after all.)

Well, perhaps this is too obvious to mention, but the most logical way
for Erlang to leverage the "resources" of "outsiders", i.e. engage the
community, would be to open up development as well as source.  For
example, make the source repository public (as you note,) make the
bugtracker public, make the docs open-source, etc.

-Chris


Rob
Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Rob
In reply to this post by Chris Pressey
Chris Pressey wrote:

> On Thu, 13 Jan 2005 14:45:19 +0100
> Fredrik Thulin <ft> wrote:
>
> [of links.html]
>
>>Does not resolve :
>>
>>http://www.catseye.mb.ca/erlang/
>
>
> Wow, that brings back memories...
>
> If you want to change it, I guess the present-day equivalent is
>
>     http://catseye.webhop.net/projects/?keyword=erl 

> Or you can just remove it.

Please, don't remove it - the examples Chris has of esoteric languages,
games and other projects written in erlang are valuable given the
limited number of available erlang programs from different coders.
Creative implementations of small language interpreters are useful code
templates for all kinds of projects.

Chris, is there a way to get a simplified form of the project pages so
that one could do a recursive wget to easily pull all the files for a
given project (the current pages loop around due to the sorting option
links)? I don't see a way to do it other than one file at a time, am I
missing something obvious?

Thanks.



Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Luke Gorrie-3
Rob <erlq> writes:

> given the limited number of available erlang programs from different
> coders.

You have seen the Jungerl (jungerl.sourceforge.net) right?




Rob
Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Rob
Luke Gorrie wrote:
> Rob <erlq> writes:
>
>>given the limited number of available erlang programs from different
>>coders.
>
> You have seen the Jungerl (jungerl.sourceforge.net) right?

Definitely, I appreciate the work put into jungerl, but I meant "limited
  number" compared to other languages - CPAN, etc
With OpenFlax, we have 4 (?) http server examples, not that we need many
more but certainly it fits in the middle between pico and yaws.

I also meant that no links to any erlang code should be dropped because
they are all important unless they display some abhorrent qualities,
even those are sometimes useful in their own way.
http://ansuz.sooke.bc.ca/software/molester/

And, I think every language needs at minimum, one brainf*ck interpreter
The most beautiful one I've seen (gui-wise):
http://decode.ateneo.edu/martin/brainfuck/



Reply | Threaded
Open this post in threaded view
|

A Pythonista's Impressions of Erlang

Chris Pressey
In reply to this post by Rob
On Thu, 13 Jan 2005 23:06:05 -0800
Rob <erlq> wrote:

> Chris Pressey wrote:
> > On Thu, 13 Jan 2005 14:45:19 +0100
> > Fredrik Thulin <ft> wrote:
> >
> > [of links.html]
> >
> >>Does not resolve :
> >>
> >>http://www.catseye.mb.ca/erlang/
> >
> >
> > Wow, that brings back memories...
> >
> > If you want to change it, I guess the present-day equivalent is
> >
> >     http://catseye.webhop.net/projects/?keyword=erl 
>
> > Or you can just remove it.
>
> Please, don't remove it - the examples Chris has of esoteric
> languages, games and other projects written in erlang are valuable
> given the limited number of available erlang programs from different
> coders. Creative implementations of small language interpreters are
> useful code templates for all kinds of projects.
>
> Chris, is there a way to get a simplified form of the project pages so
> that one could do a recursive wget to easily pull all the files for a
> given project (the current pages loop around due to the sorting option
> links)? I don't see a way to do it other than one file at a time, am I
> missing something obvious?

There should be links to tarballs at the top of each project's root
page.  So for example, on:

    http://catseye.webhop.net/projects/animals/

there's a link to

    http://catseye.webhop.net/projects/animals-2004.0919.tgz

You should also be able to use a Subversion client to pull down the
latest files for a project, like so:

    svn checkout svn://catseye.mine.nu/animals/current animals

But I haven't tested this extensively yet (which is why there's nothing
on the site that indicates that it's possible yet...)  If you'd like to
confirm that it works, that'd be great.

Thanks,
-Chris


Reply | Threaded
Open this post in threaded view
|

minor documentation typo

Charles Blair
lists(3):

              splitwith behaves as if it had been defined as fol-
              lows:

              splitwidth(Pred, List) ->
                     ^


12