

A Scala DSL for currency-related operations - lambdista
https://github.com/lambdista/money

======
eldavido
Ruby/Scala: Keep the language small, "Let our community enhance/extend the
language" by writing DSLs (this, Rails, Chef), even at the expense of
consistency

Python: Consistency trumps all, ship a large, complete stdlib, make programs
easy to read because everything you need is included, and everyone does things
more or less the same

Python's way provides better readability, but at the expense of power, IMO.

Thanks for posting, I have a friend who works at Zen Payroll and we were
talking about whehter something like this could work well for modeling the tax
code.

Also sidenote, Martin Fowler's book on DSLs is pretty decent, check it out.

~~~
lambdista
Thank you! I agree with you with regard to the fact that every DSL is a
language "per se" that needs to be learned and so it amplifies a language
syntax weight but, in general, IMHO a static language "readability" is better
than a dynamic one's.

Since Python is a dynamically typed language its function signatures do not
say much. Take, for example, the following Python definition:

def append(xs, x): ...

By reading this function signature you can't say anything about it. What are
the parameter types? What does it return? Or, does it actually return anything
at all? Same reasoning about Ruby being itself dynamic as well.

Now consider the same example in Scala:

def append[T](xs: List[T], x: T): List[T] = ...

Just by reading the signature you can say many things, such as this method
takes a list of some type T and a value of type T and returns a list of type
T.

I'm not dissing dynamically typed languages here. I understand there are
situations where a dynamic language may be the best choice. What I'm saying is
that when it comes to "readability" a static language wins over a dynamic one
in terms of pieces of information given just by reading function signatures.

I've already read Martin's book and found it brilliant. Thank you for the hint
anyway.

Cheers

------
bronty
Cool, I've added it to the list of financial DSL resources at
[http://dslfin.org/resources.html](http://dslfin.org/resources.html)

What application domain are you working in that you know all the currencies at
compile-time?

~~~
lambdista
I'm not working in any application domain in particular. That DSL just popped
in my mind one morning at around 4.00 A.M. when I generally wake up to
urinate. :)

Of course I didn't code all the currencies by hand. I just got the currency
list from the Internet and then, using a RegExp, I generated the code.

------
alexatkeplar
Cool! We open-sourced a complementary project at Snowplow a while back:
[https://github.com/snowplow/scala-forex/](https://github.com/snowplow/scala-
forex/)

