Would you like to build massively parallel, distributed, fault-tolerant, cross-platform, easily maintainable systems with less code and look cool doing it? If so, the opensource programming language Erlang has some real sweet spots for you. If you're unfamiliar with Erlang you may be surprised to learn how battle tested it is: Facebook's chat backend, CouchDB, RabbitMQ, GitHub's backend and Amazon's SimpleDB are all written in Erlang, and every phone call you make is likely helped along by some Erlang somewhere. So how does a functional programming language with Prolog and telecom roots solve so many of the big problems that Enterprisey languages famously stink at? What's so darn special about Erlang? What are the pieces and the tools? What does it look like? How do I (as a C# developer) even get started with Erlang?
OK... you've heard the Erlang success stories, you know the sweet spots, and you're convinced that Erlang is for you. Where does that leave you as a C# developer? In a pretty good spot actually. A team of C# and Erlang developers is a force to be reckoned with because Erlang and .NET are complements--each is lousy at what the other is exceptional at. Realizing this can save you and your company a lot of time, money and headaches. Many C# developers write both JavaScript and SQL scripts; adding Erlang to the mix should be just as natural. So how is it done? What are the best interop strategies? What are the development tools? Can it all be done on Windows? How about unit testing and deployment? What are the risks? How can they be avoided?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class HashCode | |
{ | |
public static string Of(string content) | |
{ | |
var buffer = Encoding.UTF8.GetBytes(content); | |
var sha1 = new SHA1CryptoServiceProvider(); | |
var hash = BitConverter.ToString(sha1.ComputeHash(buffer)).Replace("-", ""); | |
return hash; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Pull this file dowm, make it executable and run it with sudo | |
# wget https://raw.github.com/gist/1418287/build-erlang-r14b04.sh | |
# chmod u+x build-erlang-r14b04.sh | |
# sudo ./build-erlang-r14b04.sh | |
if [ $(id -u) != "0" ]; then | |
echo "You must be the superuser to run this script" >&2 | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Pull this file dowm, make it executable and run it with sudo | |
# wget https://raw.github.com/gist/1603037/build-erlang-r15b.sh | |
# chmod u+x build-erlang-r15b.sh | |
# sudo ./build-erlang-r15b.sh | |
if [ $(id -u) != "0" ]; then | |
echo "You must be the superuser to run this script" >&2 | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Castle.MicroKernel.Registration; | |
using Castle.Windsor; | |
namespace CollectionResolverForGenericInterface | |
{ | |
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
**ER15B 32-bit smp disabled** | |
Erlang R15B (erts-5.9) [async-threads:0] | |
Eshell V5.9 (abort with ^G) | |
1> Fun = fun() -> receive after infinity -> ok end end. | |
#Fun<erl_eval.20.111823515> | |
2> process_info(spawn(Fun), memory). | |
{memory,1308} | |
3> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
namespace System.Linq | |
{ | |
public static class LeftJoinExtension | |
{ | |
public static IEnumerable<TResult> LeftJoin<TLeft, TRight, TKey, TResult>( | |
this IEnumerable<TLeft> left, | |
IEnumerable<TRight> right, | |
Func<TLeft, TKey> leftKeySelector, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class TabSeparatedValueDataLoader | |
{ | |
public static IEnumerable<T> ParseTsv<T>(this string rawTabDeleimetedData, Func<string[], T> mapper) | |
{ | |
IEnumerable<string[]> data = rawTabDeleimetedData.Split(new[] {'\r', '\n'}, | |
StringSplitOptions.RemoveEmptyEntries) | |
.Select(x => x.Split(new[] {'\t'}, StringSplitOptions.None)); | |
return data.Select(mapper); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Pull this file dowm, make it executable and run it with sudo | |
# wget https://raw.github.com/gist/3162027/build-erlang-r15b01.sh | |
# chmod u+x build-erlang-r15b01.sh | |
# sudo ./build-erlang-r15b01.sh | |
if [ $(id -u) != "0" ]; then | |
echo "You must be the superuser to run this script" >&2 | |
exit 1 | |
fi |