Skip to content

Tag Archives: Erlang

Erlang Native Implemented Functions – NIF

07-Dec-09

Erlang has long had a love hate relationship with external code. There is now “experimental” code in the latest R13B03 release that has support for what they are calling Native Implemented Functions. It is a very basic interface with only 4 functions required to be implemented and a struct and macros for defining your public [...]

Ternary Like Operation in Erlang

02-Dec-09

I have to parse the TXT records from DNS responses for my inet_mdns project. The valid key values pairs look like one of the following three formats: “key=value” “key=” ( key with an empty/no value ) “key” means the same thing as “key=true” so in Java I would write something like. public String processKeyValue(final String [...]

Refactoring my Erlang code to be more functional

01-Dec-09

Here is what my procedural “C/C++/Java” style syntax paradigm mind created, it worked but it isn’t as functional as I think it should be. Here is what I came up with. % process the dns resource records list process_dnsrec(_Sub,{error,E}) ->     io:format("Error: ~p~n", [E]); process_dnsrec(Sub,{ok,#dns_rec{anlist=Responses}}) ->     process_dnsrec1(Sub,Responses). % test to see if a dns_rr.domain is subscribed [...]

How to get a timestamp in milliseconds from Erlang

30-Nov-09

This is pretty simple, the ubiquitous milliseconds since 1970-01-01 timestamp and it isn’t part of the Erlang standard library. % gets a timestamp in ms from the epoch get_timestamp() ->     {Mega,Sec,Micro} = erlang:now(),     (Mega*1000000+Sec)*1000000+Micro.

Bonjour / Zeroconf in Erlang with Caching Responses with Subscriptions

30-Nov-09

I have the basic logic for caching of DNS response records based on subscriptions. Thanks to everyone on the Erlang Discussion mailing list and in particular to Rob Carlton for getting me over an hump and helping me make progress on this project, I really appreciate the help and hope that I am creating something [...]

Git vs Subversion on OSX

29-Nov-09

As a long time Subversion user, I am going to try and use Git for a while. I am on OSX again and Git is much nicer to deal with than on Windows. For my latest side project ( inet_mdns ), I am working on a native Erlang Bonjour/Zeroconf implementation. I am still probably going [...]

Counters in Erlang

20-Nov-09

I want to be able to keep multiple statistics counters in my server applications. With some help from the friendly people on the erlang-discussion mailing list I came up with this implementation of how to create counters in Erlang. I considered all the solutions suggested and for my needs this worked out the best. I [...]

Bonjour / ZeroConf in Erlang

15-Nov-09

Here is the beginnings of a Bonjour / ZeroConf module in Erlang. I always like to ZeroConf all my servers I write so I don’t have to play the xml/properties/ini file game with how a server or clients connect to each other. All my previous Python and Java servers have used bindings to a C [...]

Python/Twisted vs Erlang/OTP

15-Oct-09

A long time user of Python and Twisted, I have used Python and Twisted to developed some production systems that processed 60 – 80 million messages a day. It wasn’t pretty but the code base was fairly small and it worked, but not simply. Our deployment machines were Sun T1000 Niagara based machines. We were [...]