That’s what it takes to write an Hello World program in Erlang, after you installed the Erlang system on your machine.
Here’s the program itself:
What does that means? Briefly:
function to the outer world. It means the other modules can call this function. What does the “/0″ means? It means the “hello_world” function with 0 parameters. In Erlang, you can have different functions with the same name and different number of parameters.
To run your program you must start the Erlang shell first:
Try it, and understand it. Next time will be a little bit more complex!
Note: if you guess why by copying and pasting the code you get a lot of errors, that’s because SciTe, the editor I use, exports the code with fancy double quotes. That’s a good reason to not being lazy and write the program by yourself! Writing it’s a nice way of learning!
Your first Erlang program in less than 1 minute! (Lesson 1)
[…] You’re first Erlang program in less than 1 minute! (Lesson 1) Posted in Erlang, Programming by admin on the April 26th, 2007 […]
Hey! Great article. I have been thinking of getting into Erlang for some time now, and now, am just waiting for Armstrong’s book to be published. I did enjoy your article, and it gives me a way to get my hands dirty while I wait. I did have a comment, and it has nothing to do with the article, but you have a sidebar panel on your blog, which I believe should be “Categories”, and not “Categoires” (unless I am missing something). Again, great article, looking forward to your “advanced” posts…
- Raju
[…] } Federico Feroldi: You’re first Erlang program in less than 1 minute! (Lesson 1) 2007-04-26 20:50 작성 Begin to learn Erlang programming starting from a small Erlang program. […]
Thanks for spotting the typo, Raju. Fixed!
[…] ErlangFederico Feroldi: Your first Erlang program in less than 1 minute! (Lesson 1)Begin to learn Erlang programming starting from a small Erlang program. It just takes you less than […]
Federico Feroldi: Your first Erlang program in less than 1 minute! (Lesson 1) Process-one: Web development in Erlang: SlideAware experience Federico Feroldi: Erlang helps Rails to scale Philip Robinson: Erlang Macro Processor (v2), Part V Philip Robinson: Erlang Macro Processor (v2), Part IV
There are two things that make erlang fun - and by fun I really mean a complete pain in my ass. First is the notion of functional programing. Second is the “concurrent” aspect. Each of these ideas have precious little “foo made easy” docs. Both these are gonna cause offense to Object Nazis; however, both these ideas seems to have powerful traction with the notion of business applications. It some sense, I’d say this is Cobol 2.0 - the bastard child.
Seriously, these functional languages make way more sense in the business world than any object oriented concepts. I’m so glad that none seems to acknowledge the functional alternative. It validatea the idea that my professor really did have his head where the sun don’t shine.
I wish there was more talk about applying erlang to more typical business applications. For example, get a request, log the input, do the action, log the response, send the response.
Erlang does have a hump on its syntax. I would be real hot to see some merging of Haskel, R and Erlang - of course that is both syntax and libraries. As a user, I would rather stuff just work. I don’t wanna learn more syntax, but perhaps I’m mal adjusted.
Hey, thanks for the article - nice to see more entry-level articles about Erlang ![]()
One thing I spotted though - in your instructions to run the code, you have:
hello:helloworld().
I think you’re missing an underscore in there i.e.:
hello:hello_world().
thanks again for the article, I’m looking forward to seeing more
Michael
Funny yes indeed lots of errors but simple enough to deal with even for someone even running Erlang for the first time to deal with ;D
I tried it in Eclipse ErlIde and got the errors immediately but ran it via shell after creating a new text file.
You did know you specified the command line incorrectly, right or was that also part of the test? ;D
Michael, Nala: thanks for having spotted these issues, I’m now sure about the law that says “all programs have bugs”, even the Hello World programs! Thanks indeed! ![]()
Toh guarda chi si becca con linkedin… ecco dove eri finito! Ci hai mica uno straccio di mail? ![]()
Ora mi incuriosisci con l’erlang, e dire che dovevo studiarmi già apl e lisp…
Saludos
Piero
Well enjoyed it, it was a good first program to try.
It did however take me more then a minute but that was because I had to install Erlang first. Ain’t Linux great if you have your package manager setup right you can read this article, install some of the required software, and test it out all in a matter of minutes. Let’s see someone get that done in less then ten minutes under windows ;D
I definitely am enthused about this Erlang I was considering Lisp but think Erlang is a better choice.