Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Rails Idioms + Django Templates + Erlang Power = Chicago Boss (chicagoboss.org)
143 points by paulsmith on Oct 1, 2009 | hide | past | favorite | 79 comments


Here's a few things I experienced when building an erlang webapp 4 years ago:

During dev, I had a server live for users to play with. The data structures were in flux, there was zero traditional data input protection. My users were domain experts, no tech background and would type in all sorts of odd inputs as there was no training or documentation on how to use the webapp. But I never once had data corruption issues and never once did the server crash. I was able to run this "test" server with no admin or headaches while I was doing dev.

The reasons are due to a few characteristics of erlang:

1 - you write concrete pattern matching, not abstract object containers. So a controller or model function would spec out a clear data structure that was expected as input. Anything else failed right at the point where the data didn't fit the patterns and guards.

2 - each request is handled by an isolated erlang process that fails gracefully and doesn't effect the rest of the system. So my early testers would get error dumps from the server for bad data inputs but they never corrupted the data or crashed things. I was able to take these error messages from test users to see how they were using the system incorrectly.

3 - Single assignment and functional programming were a big win in terms of writing once, testing once (not writing separate test code), and knowing that that piece of code was solid and I could move on.

The app was very responsive. All requests were ajax and this system felt like the server was running on the same box as the web browser. When we had errors, the erlang error message almost always showed the crash at exactly the point in the code that needed attention.

These characteristics speak to the power of the dev process, not scalability which is what you normally hear about erlang.


The language and development tools have exploded the last 4 years, both inside and outside Ericsson and especially after Armstrong's book and work on R12 started. I have a blog post brewing on all the improvements, here's an outline

===================

string, regex handlers, faster file I/O:

- "re" module replaces "regex"

- faster iteration over large binaries, R13A

- avoid io:get_line using raw access

-----------------------------

metaprogramming/"DSL"

- deep exploring parse_transform

----------------------

frameworks, database, middleware

- couchdb, nitrogen, mochiweb, erlyweb,and now the boss!

- thrift, ejabberd, rabbitMQ,

----------------------------

debug, trace, static code analysis; verify program behavior

- dialyzer, tidier (Sagonas and Avgerinos)

- mcErlang model checker

- quick check application vs. specification

-------------------------

data structures

- destructive / mutable byte arrays (HiPE BIF)

- shared immutable data structure

----------------------

tail recursion

- Ericsson expanding as fast as they can (e.g. "andalso",

-------------

SMP, run queues,

----------

build systems, distribute your app

- rake - faxien, sinan (erlware)

==============

Yah, this could be a long post, take a while to draft too.

Dunno the state of scala, clojure and haskell /GHC docs these days, but to explore the dark corners of erlang dev, you ahve to do a lot of mailing list and google digging.

(and read Cesarini/Thompson book, which is equal to best software books ever, modulo fair number of typo's)


would you mind sharing your blog address ? i tried looking for it in your profile, but couldn't really find any pointers to it. thanks !


http://isthiserlang.blogspot.com/

nothing there yet, I've only been erlanging for a month or 2. But: i have been workiing on a better documentation database, you can email for details if interested:

base: genetanigmailcom; insert periods, after positions 4 and 13 and "at" you know where..gene


What do you work with now? If it's not erlang, what prompted you to not use erlang?


That's a good question. I've been using merb lately. I started with rails and didn't like it but thought ruby was ok. The main reason for going with ruby was to be able to hire other programmers and get out of the way of coding everything myself. I assumed 3 years ago when I made the decision that I would eventually be able to hire others. This has not worked out as planned. I am still coding everything. It turns out erlang has taken off enough that it may be reasonable to do a new project in erlang. I'm still not a fan of using erlang for writing view templates, but choices for this have improved greatly as well. When viewing the erlang vs. ruby programmer talent pool, there is a gut feel that the erlang pool may have a higher quality ratio although its a much smaller pool.

I can tell you that although merb is a nice framework, I still end up digging through code at times to find bugs that would be much easier to spot if it were in erlang.


When you say that hiring others hasn't worked out as planned, have you had a hard time finding talent or you just haven't been in a place that hiring outside help was a viable option?

Sorry for all the questions, I just think it's an interesting insight to what happens if you pick a language / framework that isn't terribly mainstream.


I was speaking about long term funding for my projects. I ended up with funding in spurts which made it hard to keep any programmer on long term. So I ended up doing most of it myself. Given this hindsight, this means I could chose language and framework for their tech merits only and not worry about placing bets on programmer community growth and costs.

I started a new webapp two months ago. I ended up using merb again because I already have a merb app in production and could leverage my investment. Merb is obviously not mainstream and even less so now that the project is mostly discontinued in lieu of rails 3.

If I knew now about the length of these projects and my limited funding, I may have stayed with erlang. It was a tough call to let go of it and go with ruby/rails and then have to go to merb due to rails not satisfying my needs to ensure the app only did the things I expected it to do. This is a key issue with rails. Its too complex for some needs. Some apps have a need for simpler frameworks due to security concerns, which was big in my case.


Rails is pretty mainstream now, though, isn't it?

I think it's tough hiring good Ruby/Rails people because they're all busy. And those that aren't, are probably not good to begin with...

(I think the OP mentioned "hasn't worked out as planned" with regards to hiring Rails talent, not erlang)


Sorry, it was 2 thoughts conveyed poorly. Question 1 was whether he was having a hard time finding rails people or just that he didn't need more people.

Then my statement was more directly referring to the Erlang piece of it.

One of the things that crosses my mind every time I start leaning towards one of the more exotic languages is whether or not I'll ever be able to find someone to maintain the software later.


FWIW, I've read several accounts of companies switching from Rails to PHP because they couldn't find enough developers (or didn't like negotiating with the few available ones).

Of course good PHPers are probably busy too.


Why would there be something generalizable about rails programmers, or any language for that matter. Honestly, this whole notion always seems so out there.


Culture. Obviously the generalization will be lossy - not all Ruby devs are the stereotypical super-ninja-rockstars, nor are all Java devs preoccupied with building the Leaning Tower of Layered Abstractions, but still. Culture matters.


didn't like negotiating

I have never heard of a company scrapping a business deal because the world ran out of lawyers or accountants. The problem isn't a lack of developers, the problem is a lack of developers at the price the company is willing to pay.


Erlang is, IMO, a less well-rounded tool than Ruby in some ways. It does some things really well, but other things not well at all. If you take something like Java or Python, you're likely to be able to do anything with it, even if it's not really the best fit. With Erlang, you'll be the best at some things, and not good at all for others.

Also, Ruby is way less verbose than Erlang. A lot of pattern matching code seems to fail the "don't repeat yourself" in some ways - you write a lot of the same things, and just one changes.


Having used Erlang, Ruby, and Java in production, I can say all these langs offer the ability to do just about anything. Its a matter of style with each lang having strengths and weaknesses. Also a matter of library choice so you don't have to roll your own for everything. Erlang a few years ago had many libraries missing for mainstream web app needs. Although Java and ruby have multiple options in almost every category, erlang seems to have "enough" options these days.

I don't agree that erlang fails the "don't repeat yourself" test. In fact, I think ruby fails this test miserably in that you have to write so much test coverage. Although Ericsson devs wouldn't agree with this, I found that my code was my tests. I think the difference of opinion has to do with how the apps are used. My apps were end user web apps and my code was solid enough to be its own tests. Ericsson's code is enterprise grade telecom switches and their business model demands test coverage far beyond what most web apps demand. If you tried to write telecom switching code in ruby, your tests line count would be multiples, perhaps an order or magnitude, greater than the line count of the Ericsson erlang tests.

Ruby is class based OO programming, erlang is functional oriented. My erlang webapp line count was very reasonable. I'm not sure I would have fewer lines of ruby for the same app. The syntax sugar that makes ruby so appealing is a drawback as well at times: the code can be ambiguous with the only way to be certain of what it does being to write tests. Erlang syntax takes getting used to, it certainly doesn't have the immediate appeal as ruby. But it makes up for this in that once you are comfortable reading erlang, you can simply read the code and be certain of what it does and that it does it correctly.


What I mean by repeating yourself is code like this:

    skip_past_separator([]) ->    
	[];
    skip_past_separator([$; | Rest]) ->
	Rest;
    skip_past_separator([$, | Rest]) ->
	Rest;
    skip_past_separator([_ | Rest]) ->
	skip_past_separator(Rest).
(From mochiweb). That sort of thing appears to pop up with some frequency in Erlang code, and it seems wasteful.


It's not wasteful, it is just putting the "logic" into the pattern matching at the function selection level. In Erlang you can usually take the first level of case/if statements or arg parsing and put them into the function definition. You do end up repeating certain patterns when defining the function head, but it lets you get away with a lot less repetition in the body of the function.

Different strokes I guess, but in my experience I found myself repeating code a lot less in Erlang due to the functional nature of the language and because it made certain bits of repetition in the code more obvious due to the "shape" of code in my editor.


I'm guessing your example is a matter of factoring and how/if the frameworks/libs suite your needs. Rails provides DLSs which have just the right interface to allow you to not repeat yourself in many use cases. If your erlang libraries do not, thats a function of the lib/frameworks, not the language.


In terms of "suiting my needs", that's an example from mochiweb itself, so my needs have nothing to do with it.

In terms of refactoring... I've seen code like that scattered through Erlang often enough to have a slight dislike for it (it is not a Major Problem with the language, and pattern matching is elegant).

And to some degree - it is a function of the language:

     foobar(a, b, c=1) ...
is a lot less code than

     foobar(A, B) -> ...;
     foobar(A, B, C) -> ....
So I will stand by my statement that Ruby is generally more succinct than Erlang, which is something that strongly pushes me towards using Ruby for most things, and Erlang only where it really shines.

I don't dislike Erlang - quite the contrary - I first encountered it professionally in 2003 and have dabbled now and then with it. I just think it can be a bit "uneven" - which makes me think it will likely never catch on as a very widespread general language.

And I don't believe in "the right tool for the job" - most people are going to know a few languages (at best) and stick with them, because for most things, it's cheaper in terms of overall effort to do something with a language you know than doing it with something you don't and have to learn (also likely not doing as good a job, because you're new to it), even if the result isn't perfect. So languages that are niche only, in my mind, are probably going to be less popular than they could have been if they were more general purpose.


If you're not matching on variable numbers of arguments, you can just have 1 function sig and a case statement.

The thing I dislike most about erlang, besides the lack of a good macro system, is that the repl is full of annoying special cases, so you have to actually stick your code in a file with a proper module name and compile it in order to test stuff :(


Pattern matching with functions is more 'idiomatic' Erlang, though, than case statements. At least that's what I've seen.


Perhaps a call to dropwhile could be used instead:

http://www.erlang.org/doc/man/lists.html


If anybody is looking for a competent Erlang guy, give Rusty a shout:

http://news.ycombinator.com/user?id=RKlophaus

I met the guy in D.C. and he lives and breathes Erlang.


In less than 20 lines you've just converted me from a fence-sitter to someone that is going to install erlang and mess around with it.

Thanks!


This is by Evan Miller, whom this crowd may know from what was once titled the "Balls Out Guide to Nginx Module Development":

http://www.evanmiller.org/nginx-modules-guide.html


I dunno, I'm pretty interested in playing with it. I'm a little cautious of trashing this based on the claims so far without seeing where it goes. Anyone remember the iPod thread on Slashdot that declared it as a useless product that would never take off? For all I know there was a similar one about Rails.

It does make some big claims, but I've been looking for a reason to mess with Erlang for a while and this seems pretty neat.


Sounds like a good project! is the name an americanized version of "Tokyo Tyrant"?


I can't wait working with "Chicago Boss" web framework with the upcoming "London Queen" Ajax framework and "Moscow Oligarch" distributed SCM.


It needs a "Chicago Closet" to go with it.


Capone's Vault.


Are Django Templates really that worthwhile to be compatible with? They seem quite annoying to me...


"APIs will change, features may be broken, your car may explode when you turn the ignition, etc."

I think I'll wait awhile on this one...


Yeah, I'm with you. I haven't found a way to load my car into a test sandbox where failure doesn't result in the loss of the car.


I have yet to find a way to get my car in a test sandbox* where success doesn't result in the loss of the car.

*Note: for this to work, you will need a large sandbox. If it is too small, your car will be fine, but just try explaining what happened to the sandbox to your kid.


This website's is a wreckage in IE8, just so you know.


With IE7, the site is basically empty. There's nothing after the line with the links to api, .... download on any of the pages.


Site wasn't made for IE users, it was made for developers.


I use IE and I'm pretty sure that I'm a developer.

What makes you so sure that I'm wrong about the latter?

My other open window is running emacs; it's where I've been writing Python code for App Engine for the past few weeks. If that doesn't qualify me as a developer, please describe the requirements, as I've been writing code since the late 70s.


I've been a lurker for a while but this comment has prompted me to create an account.

Of course the previous poster is making a generalization. If you're in the minority of developers using IE, good for you.

Developers are usually smarter than to use a browser with appalling performance and a plethora of bugs (that never get fixed) when much better choices are just a few clicks away.

This is probably a troll, but i'm hitting reply anyway...


> Developers are usually smarter than to use a browser with appalling performance and a plethora of bugs (that never get fixed) when much better choices are just a few clicks away.

So the problem is that I'm "not smart" (enough). Okay - so I'll ask a dumb question. Are those the only relevant criteria for choosing a browser? Or, are they merely always dominant?

> This is probably a troll, but i'm hitting reply anyway...

Not at all. I'm open to self-improvement.


To compare, I use a Mac and a FreeBSD box linked with synergy at work. Use uzbl on the FBSD box, safari on the Mac.

Frankly, I can't begin to fathom why you would willing use IE when the Chrome plugin, Firefox, Chrome itself, Safari, and various smaller webkit browsers are available to you.

I've never really seen the advantage of using Emacs unless you're a lisp hacker. Seriously. Also the keyboard shortcuts on Emacs are rather similar to a lot of the universal shortcuts on OS X, which you don't appear to use either.

So either potential mutual benefit you could derive from using Emacs is being left for dead.

Also, you're a developer and you're using the very browser that's holding back our ability to build universal and standards compliant web sites/apps? Seriously?

You're just a part of the problem, regardless of vocation.

As for editing, I use Textmate/Gedit for code, vi for unixy stuff.

>> Developers are usually smarter than to use a browser with appalling performance and a plethora of bugs (that never get fixed) when much better choices are just a few clicks away.

>So the problem is that I'm "not smart" (enough). Okay - so I'll ask a dumb question. Are those the only relevant criteria for choosing a browser? Or, are they merely always dominant?

rubs face Okay.

You're knowingly using a browser that is buggy, slow, insecure, and is holding back the entirety of the web app dev community.

Relevant criteria? That's all there is to the matter! Unless you're being paid to use that abhorrent bucket of bile I can't fathom a legitimate reason to utilize it as a developer. Standards compliance, stability, performance, security...yeah...uh, what else factors into your choice of browsers, the phase of the bloody moon?


Sometimes I browse in IE because Chrome, Safari, Firefox, Opera, Arora are full of tabs that I have yet to digest.


whistles loudly

YC haet you. :P


>>>Chicago Boss is fully asynchronous, using one single process to handle hundreds or thousands of simultaneous requests<<<

>>>All other web frameworks will break down and cry if you ask them to process more than a few dozen simultaneous requests on a single machine.<<<<

Isn't this what facebook Tornado, Orbited and all the other servers using select()/epoll() solves?


Erlang's whole I/O and scheduling model is optimized for this design in a way that Python's simply isn't.


Sure, but they aren't using Erlang.


Having worked on several Rails projects and now working on a large erlang application, I'm not sure that bringing Rails idioms to erlang is a good or desirable thing.

I also find it somewhat funny that it includes an ActiveRecord port - an object-relational mapper in a functional language to talk to a non-relational backend (tokyo tyrant).


blocked at work for potentially unsafe content? wow, this must be powerful


How is Chicago Boss different from Rails/Django/Mason/CakePHP/My Favorite MVC Framework?

Chicago Boss is fully asynchronous, using one single process to handle hundreds or thousands of simultaneous requests, and thus it solves the classic c10k problem. All other web frameworks will break down and cry if you ask them to process more than a few dozen simultaneous requests on a single machine. Chicago Boss is built with Erlang, the same platform used by banks and telecoms to achieve unprecendented scalability and (no exaggeration) 99.9999999% reliability.

Oh my


The Nine nines of reliability often quoted is for the availability of a complete distributed system, including maintenance downtime.

A typical single Ericsson AXD 301 switch had a target of 5 nines of reliability without network redundancy, which is 5mins/year, including planned outages. see http://www.erlang.se/publications/Ulf_Wiger.pdf

One of the advantages of these switches was that they could manage 95% throughput at 150% load (Throughput then drops linearly to 40% at 1000% sustained load), which is also extremely useful, although not mentioned often.


it solves the classic c10k problem.

Of course, this is the problem you get once you've solved the hard problems already, which is how to get that many visitors in the first place. At this point you have the money to buy a bunch of servers, typically, so this is aimed at people who are really great at getting incredible numbers of hits, but really poor at monetizing them.


It depends ... say you've got a nice project going on, still in infancy, and you post its link on sites like reddit and HN to get feedback. 2000 visitors instantly hit the link and your site crashes exactly when you need it more to stay alive.

Premature optimization is the root of all evil and all that, but going at the other extreme is equally not the smartest thing you can do.

An application like 37signals Basecamp can grow organically over time as the application is maturing and more and more users discover it and start paying for it. But if your project's success depends on the number of users you have (e.g. a social app), it makes sense to think about scaling and reliability a little beforehand.

Remember Twitter? It's still a mystery to me how this app survived having so many outages. Maybe they where lucky, maybe the social aspects where worth it for its users, but that doesn't mean your application will survive if facing such problems.


But isn't it true that scaling is not linear with dollars/development effort spent?


Depends on the application domain and design.


It reminds me of those Powerthirst videos on YouTube.


MUNCTIONAL PROGRAMMING FOR REAL MEN

http://www.youtube.com/watch?v=1yH_j8-VVLo


Buzz + Buzz + Buzz = Boss

Looks interesting, though.


A little bombastic, but I got a chuckle out of this line:

All other web frameworks will break down and cry if you ask them to process more than a few dozen simultaneous requests on a single machine.


The most basic cause for bad technical decisions are wrong assumptions about technology.

If you believe every other web framework will get crushed with a few dozen simultaneous requests, you will be absolutely sure this is the solution you have been waiting for.

I am curious to try Erlang out, but I know exactly how many dozen requests my current tools can handle. And it's a lot more than a couple.


I'd be interested in some numbers. Is it "a few"? "some"? Give us some vague quantifiers here!


Before I roll-out apps to the folks who will really torture them in production-like servers, I play with about 100 simultaneous connections.


100 is really only a few dozen :)


but it's close to 10 dozen...which is almost a dozen dozen...

I dunno. Vagueries. :)


Gross.


But that is on a notebook. The numbers the server folks put them through are much higher.


Usually it's not the web framework itself that is unable to process the requests, but the web application in which one http request ends up in a few database requests, and the database is the real bottleneck.

By writing something in Erlang does not make your program automagically perform well (and this applies to CouchDB too).


Will his default data store choice (Tokyo Tyrant) solve this? It could be a bit too early to answer that.


Short answer is no. Most of the "slow" queries that happen in databases are usually complicated select/join/update statements -- the same can happen for key/value databases. Even with TC, you're still programmatically writing the code to do the query and if you write slow code, your query will still be slow. The sweet sweet technology isn't going to magically solve anyone's problems.


Chuckle?

Ignorance and/or disenguity(sp?) pisses me off. I'll read more but I'm getting the impression that people behind BOSS are one or more of inexperienced, clueless, full of them selves and thus not worth my time.


If you can't get more than a couple dozen req/sec out of other things, you probably won't manage it with this, either.


I strongly dislike developing web front-ends in Erlang. However, if you are interested in doing so, please also see the comparably stable http://erlyweb.org/ by Yariv, who is a visible figure in Erlang web development.


I'd like trying this to fine-grain my Erlang skills.


a.k.a. Al Capone


Such a great pitch for a web framework.


Geographically: The University of Chicago

[edit]: Hey down-modder: It's the last entry on his website. What's the -1 for? Are you saying those of us from Chicago shouldn't be proud of our institutions? Asshat.


My guess is that saying "Geographically: University of Chicago" doesn't really add anything to the conversation. Also, it wasn't in the linked page when I went there, so maybe there was some confusion.

Although, I just downmodded you because it seems like you've got a tough time being civil.


The server's IP is definitely not a UofC IP.


you've never talked to anyone in chicago before, have you? zing!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: