Getting Started with Erlang and Nitrogen

Getting Started with Erlang and Nitrogen

Introduction

As I had yet another idea for a startup, I fired up Visual Studio and started implementing a small demo...

Flexing my idea muscle; trying to build a POC for another startup idea #startup10 #ElliottWavetwitter.com/ToJans/status/…

— Tom * suǝssuɐſ (@ToJans)  September 6, 2012

However, the main feature that would elevate my example requires a lot of interaction, and quite frankly, interaction is a pain in web apps IMO, as there is still a mental shift between frontend and backend. For this particular thing I needed the distance to be as small as possible, so I started searching and found Erlang...

One more last video before I go to bed vimeo.com/8258045 #erlang #nitrogen #riak

— Tom * suǝssuɐſ (@ToJans)  September 12, 2012

I will not go into the details why this looks like a perfect match, because I would like to build an MVP first, but I can tell you that it resembles the bee's knees at this current moment to me... So how do I get started? This is a walkthrough where I will post my progress... This post will evolve as I manage to get further....

Installation

Well, I still work on windows, so I downloaded the binary erlang package from here:  https://www.erlang-solutions.com/downloads/download-erlang-otp

I downloaded the win x64 binary and ran it, as simple as that; mission #1 accomplished; a few more to go.

The Web Framework

Well, I decided to go for nitrogen, as it looks pretty neat IMO, so I created a nitrogen folder and downloaded the windows package from  http://nitrogenproject.com/downloads  and unzipped it.

#2 accomplished

Hello world 

I copied the whole nitrogen package to a new folder called HelloWorld - how original - opened a cmd window in the folder, and this is what I typed and the result..

Getting Started with Erlang and Nitrogen

So I opened up Windows explorer and checked... Aha!

Getting Started with Erlang and Nitrogen

I copied the bin path, went back to my hello-world folder, right-clicked start.cmd and chose for edit, and assumed replacing 5.7.5 (the Erlang version in the nitrogen package) with 5.9.2 would be enough, but then I noticed: there is also and erts-5.7.5 subfolderfolder in the hello world project, which looks like it contains the whole erlang version...

So I decided to look a bit closer...

When running the commands from the batch file manually with the installed erlang  (i.e. the one from c:\program files) I get a crash on the execution of the last line, so it compiles, but refuses to run. So I decide to uninstall erlang, as I assume it is some kind of a version conflict, and I probably do not need the installation anyway.

So I removed the installed Erlang, and also found out I had another (32-bit) version installed, so I removed that one as well...

However, when I try to compile using the following statement I still get an error:

C:\blah\nitrogen\helloworld>"erts-5.7.5\bin\erl.exe" -pa %PA% -make
Could not load module C:\Program Files\erl5.7.5\erts-5.7.5\bin\erlexec.dll.

So I decided to go looking for erlang 5.7.5 for windows.... But then it hit me; google to the rescue: https://groups.google.com/forum/?fromgroups=#!topic/nitrogenweb/0vXvXwLvBOM

So I should probably reinstall the Erlang binaries I first installed and try to build nitrogen myself...

Let's try again....

Ok, installed the initial erlang version again (had to kill an apparently still running erlang proces).

Now I went looking into a nitrogen tutorial ( http://nitrogenproject.com/doc/tutorial.html ) and pulled in thenitrogen source code from github .

I browsed a bit further in the git project, and found this document mentioned on the readme: "Compiling Nitrogen on Windows"... There they advise to install Erlang for win R15B02 for windows and install it in the folder "c:\erl5.9 ", so I installed yet another erlang (5.9.2), but now in the recommended folder, and tried running nitrogen again; here's what happened:

Getting Started with Erlang and Nitrogen

As it still does not work, I assume it is time to try and compile the thing...

So I add  c:\erl5.9\bin to the path in my environment settings.

Now I install msysgit using the netinstaller , not the regular one , and install into the default  c:\msysgit

You need to use this version, as this downloads the source for git and enables you with a complete mingw build environment, which allows you to build the nitrogen source code as well...

Building git apparently seems to take a few minutes...

... And some more...

And we're finally there!!! 

Getting Started with Erlang and Nitrogen

Now time to clean up the folders and pull in the sourcecode and build it...

Getting Started with Erlang and Nitrogen

And we fail again... 

Getting Started with Erlang and Nitrogen

So I am now digging into the rebar mailing lists: http://lists.basho.com/pipermail/rebar_lists.basho.com/2011-September/001074.html

Aha, found it; I simply have to make sure c:\msysgit\bin is contained in the PATH environment variable; it now fetches all dependencies....

Getting Started with Erlang and Nitrogen

Crap... Now I get a compile error in nitrogen itself...

Getting Started with Erlang and Nitrogen

So I checked to see if there was any Erlang feedback available on twitter...

Well, the live blogging experiment is certainly a challenge: still not able to run nitrogen on windows #erlang#help corebvba.be/blog/post/Live…

— Tom * suǝssuɐſ (@ToJans)  September 13, 2012

In the mean time I'll start looking at the source over at github; maybe I have a stable branch or similar...

Aha, I found an open issue regarding the mimetypes library on github, but apparently there's not a lot of response there....  https://github.com/spawngrid/mimetypes/issues/10

Currently in the process of digging in the source code of the mimetypes lib, and I also received a good tip from Neil:

tojans top tip - buy a mac :)

— Neil Robbins (@NeilRobbins)  September 13, 2012

Ok; I took a small break; looks like the problem is actually in the post_compile script for the mimetypes; currently debugging erlang script!!! 

Getting Started with Erlang and Nitrogen

My understanding of erlang is growing slowly   ... Looks like this file just extracts all method definitions, since these have not changed, there is no need to change it, so I just commented the whole enchilada (gist here: https://gist.github.com/3714046 ) et voila, it compiles!

Getting Started with Erlang and Nitrogen

AAAAAAAAAAAAAAAAAAAAARGH ! 

Still no go; I'll call it a day for today, as I have some other stuff to do as well, and this took way longer then I hoped.... Laters!

Getting Started with Erlang and Nitrogen

Put the Live Blog on hold, as it took to much of my time already... To be continued #erlang #nitrogencorebvba.be/blog/post/Live…

— Tom * suǝssuɐſ (@ToJans)  September 13, 2012

<script src="http://www.codeproject.com/platform.twitter.com/widgets.js"></script>

I'm back

A new day, new ideas, so I started looking at the google groups, and apparently I'm not the first one having this problem:  http://groups.google.com/d/msg/nitrogenweb/KoBJCXr5SEI/UhgkWWTp09wJ .

So let us try that....

Uninstalled all erlang..

Removed original folder

Now downloading and installing windows release from  http://www.erlang.org/download_release/6  in "C:\Program Files\erl5.7.5", not the (x86) folder.

Double click start.cmd in the nitrogen folder, it should open up the erlang console. surf to http://localhost:8000 et voila !!! FINALLY !!!

Getting Started with Erlang and Nitrogen

Finally

I wrote a small follow-up post .

你可能感兴趣的:(erlang)