Popular just now

ad1

Showing posts with label Erlang. Show all posts
Showing posts with label Erlang. Show all posts

Why not Erlang? The answer in three words...

When I first moved to live and work in Sweden in 1995 I had two ambitions. The first was to get a job working at Ericsson. My mobile phone was an Ericsson model that I was absolutely in love with and was much better than my previous Blaupunkt and Motorola phones. I just had to work for the company that made my new teddy bear. Unfortunately things did not work out. I found myself living in cold north of Sweden where there were no Ericsson offices or factories.

Beginning PHP: Besides PHP, Javascript, Jquery and Mysql what else should I learn?

Ok,  here's my quick answer:

If you want to continue to learn for the future you should learn a language that has true parallel or concurrency support.  The onslaught mobile devices is only going to increase and soon the only way for any web server including those in the cloud to survive will be concurrency, parallel programming and distributed processing.
It took part of the day and some finessing but I finally have a Linux laptop up and runnning on Linux. I started with Linux Mint 8 and changed to xfce because Gnome was too resource hungry for the old IBM thinkpad. The wireless card was recongnized which is what I mostly wanted from Linux Mint. For some reason it is the only linux distro that does this without a lot of hacking.

The machine only has 256mb of ram but with xfce the system is using only 180mb. This makes for some decent speed for a web dev machine. The lastest Linux Mint also has Erlang R13B03 with all the goodies installed by default. This was a time saver. Yaws 1.8.2 is also in the repository and installing it give a working web server using Ubuntus particular flavor of file handling and configuration. What's nice also is that the install is not filled with all the example files in the default localhost directory.

So now I am another step closer to doing some Erlang hacking.

Cleaning up and using mac ports

Had some time to get around to cleaning up the imac and all of its stray installs of Erlang and other software. Now running clean and updated versions of everything via Macports. Looking around at the job scene as it applies to Erlang projects. Trying to get a picture of how things might look in the future with Zotonic CMS.

Tops on the list is getting PHP up and running on Yaws and finding a way to get Drupal to work. thinking of some new ways of using Erlang to increase performance of Drupal by caching via erlang c nodes. Might also be interesting to see how many calls to user_load can be eliminated if the object is placed in the "cloud".

Installing Zotonic on Windows

Installing Zotonic CMS on Windows seems relatively easy.

Erlang : This is straight forward using the Erlang windows installer available from erlang.org

Postgresql : postgresql has had an excellent windows installer for quite a long time.

Zotonic : The bash scripts that do the installation on Linux need to be translated into windows bat files or WSH scripts.

@echo off
set erl="C:\Program Files\erl5.7.4\bin\erl.exe"
set erlc="C:\Program Files\erl5.7.4\bin\erlc.exe"
set ebin=ebin deps\mochiweb\ebin deps\erlang-oauth\ebin deps\webmachine\ebin

%erl% +P 10000000 -pa %ebin% -boot start_sasl -s zotonic


Update: Choosing to go with MinGW and using bash for windows instead of re-writing the shell scripts used to install Zotonic on windows. Since the MinGW/MSYS is an open source ongoing and updated project it should be part of a windows install until such time as a one-click installer is created. Install MinGW without choosing a compiler. Install MSYS and it will choose a compiler for you.

Run:
cd zotonic
make
Create a user according to the installation instructions. I recommend just using the PostgresqlAdmin GUI. It easier and you avoid some syntax errors if you are not familiar with Postgresql.
CREATE USER zotonic WITH PASSWORD 'yourdbpassword';
CREATE DATABASE zotonic WITH OWNER = zotonic ENCODING = 'UTF8';
GRANT ALL ON DATABASE zotonic TO zotonic;
Make some changes to the start script path:
#!c:\MSYS\bin\sh.exe
cd `dirname $0`
exec erl +P 10000000 +K true -pa $PWD/ebin $PWD/deps/*/ebin -boot start_sasl -s zotonic
Then use command:

c:\zotonic>sh start.sh

Some of the other reasons that I want to do this besides a growing interest in learning the Erlang programming language are:

Zotonic is built on an Erlang framework called web machine and the web server framework Mochiweb. While this is nice it would have been even better if it were built from scratch using Yaws and plain Erlang.

New Year 2010 Learn something new every Year

The programmers creed is to "learn a new programming language every year". My personal motto is to "learn a new progamming laguage via a CMS". This because I am a web programmer and like game programmers web programmers have a preferance for a particular development environment. We like to see things running on a web server with lots of users. In my recent contact with Erlang as my next language of choice I have spent a good deal of time using Yaws. While Yaws is a good learning environment for Erlang it does not have a CMS as part of its example package. There is also the problem of Erlang developers using mnesia for the most part and a few jumping on the CouchDB train. While these dbs are okay they are not RDMS and not really suitable for typical web work. So for the last 6 months I have been playing with Erlang while waiting for someone to with more knowledge about Erlang to build a simple and reliable CMS in Eelang using MySQL as a database back end.

This is where Zotonic comes into play. Today on Christmas eve I found Zotonic, a CMS built on Erlang that uses Postgresql as a database. Cool! Perfect! and needed. A nice present for those that want to learn a parallel, functional language like Erlang in a web development situation. I think that Zotonic will be a good change and nice addition to PHP and Drupal. I like the open source Apache 2.0 licensing also. It's just a gut feeling but I think that Zotonic may be the next big CMS to break through and might be the software that pushes Erlang into the limelight as a popular web programming language. Even if they do not I am still putting my chips on the table and giving them all of 2010.

Erlang MySQL connection

Starting to collect all I can on using Erlang, Yaws and MySQL Here is a database connection and query for MySQL

application:start(odbc). ConnString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=test; User=root;Password=ace152;Option=3;". {ok, Conn} = odbc:connect(ConnString, []). Results = odbc:sql_query(Conn, "SELECT * FROM test_table").


Now I need to find out how to iterate through records.