Re:Poll: What are your liked and disliked programming langua...
by orclev on Thursday October 10, 2013 @04:35PM
(#6529886)
You still need some kind of mapper though to go from the SQL results to your record type, even if it's using convention such as the records fields are named the same as the table columns you're pulling from. I'm not arguing that for instance Hibernate is awesome, just that you need something to fill that gap, and you can do a lot worse than Hibernate, particularly within the limitation imposed by Java. Personally I prefer something like this ( http://hackage.haskell.org/package/esqueleto-1.3.4.2/docs/Da... ), but will usually settle for Hibernate or similar in less powerful languages like Java.
An example from OCaml:
type person = { first_name: string; last_name: string; age: int }
In a language that has some form of anonymous records (like C#'s anonymous object) and structural typing, this would let you work with relations in your language, much in the way you'd use them in SQL.
I personally like treating data as data. It should be immutable, and therefore there is no state to hide, which means there isn't much value in your types being objects.
It also allows for nice things like pattern matching to work with your data.