Skip to main content

Erlang: Toying with Erlang

I'm really interested in distributed computing and concurrency right now. Given that I've been playing with Haskell so much, I thought I'd give Erlang a try since it's all about distributed computing, concurrency, and scalability.

I must admit that it already seems easier for me to read than Haskell. I'm not sure why. As I mentioned before, I do like Erlang-style concurrency, since strangely enough, that's how I had always thought things should work.

I'm fascinated by Mnesia, Erlang's distributed database. Unfortunately, according to this:
Mnesia is not perfect, of course, and its biggest downside at the moment is that its disc storage engine isn't suited for storing large volumes of data (Mnesia was designed for soft real-time applications where the data is stored mostly in RAM), but I hope this will be resolved in the not-too-distant future.
This is a major downer for me because I'm currently interested in terabyte-sized data sets. Nor is there a suitable MySQL driver.

Yaws is the Web application framework for Erlang. I can't say whether it's good or bad, but as a matter of taste, ever since I used Apache's Element Construction Set back in the day, I've had a particular dislike for generating HTML using programming language syntax as is done in Yaws:
%% the little status field in the upper left corner
head_status(User) ->
T =
{ehtml,
{table, [],
{tr, [],
[{td, [{width, "30%"}],
{table, [ {border, "1"}, {bgcolor, beige},{bordercolor, black}],
[{tr, [], {td, [], pb("User: ~s", [User])}}
]}
},
{td, [{align, right}], {img, [{src, "junk.jpg"}
]}}
]
}
}
}.
Yuck :(

Nonetheless, Erlang has already taught me new ways of thinking about distributed computing. I guess I'm wondering if there's anything I can't do the Erlang way in Python. Afterall, consider Candigram, which is an implementation of Erlang concurrency primitives in Python; although Candigram itself doesn't provide microthreads like Erlang. That reminds me, I'm still looking for an answer to my post Limitations of Coroutines via Enhanced Generators.

And if you're wondering--no, I don't know what the hell I'm talking about! I've only been looking at this stuff for like two days! I guess I should just shut up and go back to reading Erlang for C, C++ and Java Programmers. Hmm, I wonder where the tutorial for Python programmers is ;)

Comments

jjinux said…
http://erlang.org/faq/x479.html#AEN513

Ugh, so you mean I won't have regular expressions that support UTF-8?
jjinux said…
More about Mnesia's limitations:

http://erlang.org/faq/x1409.html

The ODBC driver for Erlang:

http://www.erlang.se/doc/doc-5.4/lib/
odbc-2.0.2/doc/html/part.html
Andrew Dalke said…
Try out stackless python.
jjinux said…
I have. I was really looking for the benefits of stackless Python without the heavy-handed approach that it uses to implementing it ;)
Richard said…
I quite liked this simple equivalent to Stackless's tasklets written in lisp or scheme (same difference to me). As you can see from the comment I added, the lisp test case maps pretty much one to one to the Stackless one.
Andrew Dalke said…
I was really looking for the benefits of stackless Python without the heavy-handed approach that it uses to implementing it ;)

Though it's not as heavy-handed as switching to a different language entirely. Think of it as a different language which just happens to support existing Python code and extensions.
Steve Jenson said…
You can fragment mnesia tables to store terabytes of data. Check out
Section 5.3
jjinux said…
Thanks for all the great comments guys!
Bill Mill said…
What about this or this as your erlang mysql driver?
Bill Mill said…
whoops, those two links are to the same driver. Anyway, have you tried it? It looks pretty nice to someone who hasn't tried it.
Anonymous said…
Candygram is spelled w/ a "y", not an "i"
Qrilka said…
Have you tried Erlyweb?
BTW Yaws is actually a Web server not a framework (wich is Erlyweb on top of Yaws)
Anonymous said…
check out yarivsblog.com, this guy yariv is building all kinds of erlang webby stuff....incl a mysql driver, web framework, template language, object-relational mapping, and a macro system.
jjinux said…
> check out yarivsblog.com

Yeah, I was checking it out before. He seemed at the same time brilliant and "young" (meaning, he was doing stuff that I had done before but turned out not to like). I'm sure he's smarter than I am ;)
jjinux said…
> What about this or this as your erlang mysql driver?

Nope, I haven't tried it. I think it came out after I looked last.

> Candygram

My apologies.

> Have you tried Erlyweb?

No, it's new to me.

Wow! So many Erlang comments!

Popular posts from this blog

Drawing Sierpinski's Triangle in Minecraft Using Python

In his keynote at PyCon, Eben Upton, the Executive Director of the Rasberry Pi Foundation, mentioned that not only has Minecraft been ported to the Rasberry Pi, but you can even control it with Python. Since four of my kids are avid Minecraft fans, I figured this might be a good time to teach them to program using Python. So I started yesterday with the goal of programming something cool for Minecraft and then showing it off at the San Francisco Python Meetup in the evening.

The first problem that I faced was that I didn't have a Rasberry Pi. You can't hack Minecraft by just installing the Minecraft client. Speaking of which, I didn't have the Minecraft client installed either ;) My kids always play it on their Nexus 7s. I found an open source Minecraft server called Bukkit that "provides the means to extend the popular Minecraft multiplayer server." Then I found a plugin called RaspberryJuice that implements a subset of the Minecraft Pi modding API for Bukkit s…

Apple: iPad and Emacs

Someone asked my boss's buddy Art Medlar if he was going to buy an iPad. He said, "I figure as soon as it runs Emacs, that will be the sign to buy." I think he was just trying to be funny, but his statement is actually fairly profound.

It's well known that submitting iPhone and iPad applications for sale on Apple's store is a huge pain--even if they're free and open source. Apple is acting as a gatekeeper for what is and isn't allowed on your device. I heard that Apple would never allow a scripting language to be installed on your iPad because it would allow end users to run code that they hadn't verified. (I don't have a reference for this, but if you do, please post it below.) Emacs is mostly written in Emacs Lisp. Per Apple's policy, I don't think it'll ever be possible to run Emacs on the iPad.

Emacs was written by Richard Stallman, and it practically defines the Free Software movement (in a manner of speaking at least). Stal…

ERNOS: Erlang Networked Operating System

I've been reading Dreaming in Code lately, and I really like it. If you're not a dreamer, you may safely skip the rest of this post ;)

In Chapter 10, "Engineers and Artists", Alan Kay, John Backus, and Jaron Lanier really got me thinking. I've also been thinking a lot about Minix 3, Erlang, and the original Lisp machine. The ideas are beginning to synthesize into something cohesive--more than just the sum of their parts.

Now, I'm sure that many of these ideas have already been envisioned within Tunes.org, LLVM, Microsoft's Singularity project, or in some other place that I haven't managed to discover or fully read, but I'm going to blog them anyway.

Rather than wax philosophical, let me just dump out some ideas:Start with Minix 3. It's a new microkernel, and it's meant for real use, unlike the original Minix. "This new OS is extremely small, with the part that runs in kernel mode under 4000 lines of executable code." I bet it&…