Couple of questions. First, is dynamic typing truly necessary for this level of coding? I know it is commonly used that way, but I have seen some tricks in static languages that work just as well. (The Lift folks have a good api for pulling from a database, and that is ignoring squeryl. Sadly, I'm ignorant of Haskel libraries for this sort of thing. I'm also more ignorant than I care to be on LINQ.)
Secondly, I think this is what was referred to when it was said the majority of "dynamic" programs are actually quite static. (Or would this program work correctly if I renamed that column to "SpecificIdentifier" or some nonsense?) I understand that ResultSet has its type altered for this section of code, but one could have just as easily defined a specific subtype of ResultSet for this section, because it will always require that specific type. Plus side to the latter approach, mistakes can be found at compile time. :) On Sun, May 8, 2011 at 2:21 PM, phil swenson <[email protected]> wrote: > Lets say you are iterating through database records and one of columns is "id" > > def id = resultSet.id > > Or from the original blog post: > > def books = new XmlSlurper().parse("books.xml") > books.book.each { > println "Title = ${it.title}, Author: ${it.author.@firstname} > ${it.author.@lastname}" > } > > import groovy.sql.Sql > sql = Sql.newInstance("jdbc:mysql://host/db", "username", "password", > "com.mysql.jdbc.Driver") > sql.eachRow("select * from tableName", { println it.id + " -- > ${it.firstName} --"} ) > > > > On Sun, May 8, 2011 at 11:25 AM, Josh Berry <[email protected]> wrote: >> On Sun, May 8, 2011 at 9:30 AM, phil swenson <[email protected]> wrote: >>> well the article was called "java.next()" >>> >>> But why not have the best of both worlds? Static typing/type >>> inference. Optional dynamic typing where it makes sense. >> >> Within a given program, I'm curious of an example where dynamic typing >> actually "makes sense." Wasn't there a study that showed even in >> traditional dynamic languages, the majority of the runtime behavior >> was consistent with a static type model? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "The Java Posse" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/javaposse?hl=en. >> >> > > -- > You received this message because you are subscribed to the Google Groups > "The Java Posse" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/javaposse?hl=en. > > -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
