News for hackers. Stuff that matters.
Re:A Scala DSL for currency-related operations by eldavido on Friday March 27, 2015 @06:57PM (#9279594)
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.

Re:A Scala DSL for currency-related operations by lambdista on Saturday March 28, 2015 @07:57AM (#9281207)
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

Re:A Scala DSL for currency-related operations by bronty on Saturday March 28, 2015 @09:25AM (#9281413)
Cool, I've added it to the list of financial DSL resources at http://dslfin.org/resources.html

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

Re:A Scala DSL for currency-related operations by lambdista on Monday March 30, 2015 @07:52AM (#9288875)
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.

Re:A Scala DSL for currency-related operations by alexatkeplar on Friday March 27, 2015 @06:38PM (#9279508)
Cool! We open-sourced a complementary project at Snowplow a while back: https://github.com/snowplow/scala-forex/