|
|
|
Sponsored Link •
|
|
Advertisement
|
Bill Venners: Differentiate between declarative and imperative languages. What are the advantages and disadvantages of both?
Dave Thomas: I prefer to code declaratively, because at the business level we're not executing a series of instructions. We're dealing with data. The longer I can keep my code at the data level, the closer I'm coding to the application domain. If I can find a way to express the program in terms of data and the relationships between data, I find that keeps me at a higher level longer. Alternatively, if I need to control, or if I need to be very specific about the order in which I do things, then I want to get down to the imperative level. What I don't want to do is jump back and forth between the two models in the same chunk of code. Because then you get the whiplash effect that Andy was talking about. You go back and forth and back and forth and you aren't sure what you're doing. Everything gets muddled up. If I can instead keep things nice and separate, I find I can focus very strongly on whether I am doing application level code or low level geeky code.
Andy Hunt: Declarative programming is really another example of programming
closer to the user's domain. Look at SQL. SQL is a great example, because it is primarily a
declarative language. With a typical select statement, you say, "Get me these fields from this
table." You don't say how. Your don't say in SQL, "Chase down this pointer. Get this file
off disk. Chase through this btree index. Optimize it." You don't say any of that. You say,
"This is what I need. You go figure it out. Go get this for me." That's getting closer to
programming the intent of the user: "I want this. I don't care how you do it. Just make it
happen."
Come back Monday, April 14 for Part VII of this conversation with Pragmatic Programmers Andy Hunt and Dave Thomas. If you'd like to receive a brief weekly email announcing new articles at Artima.com, please subscribe to the Artima Newsletter.
When do you use domain languages? When do you program in low-level bits and bytes?
Discuss this article in the News & Ideas Forum topic,
Progamming Close to the Domain.
Resources
Andy Hunt and Dave Thomas are authors of The Pragmatic Programmer, which is available on Amazon.com at:
http://www.amazon.com/exec/obidos/ASIN/020161622X/
The Pragmatic Programmer's home page is here:
http://www.pragmaticprogrammer.com/
Dave Thomas was not the first person I've interviewed who mentioned the arcade
game Whack-a-Mole. James Gosling also called upon the versatile Whack-a-Mole
metaphor while pointing out that it is sometimes hard in
engineering to know if you've solved a problem or moved it:
http://www.artima.com/intv/gosling34.html
The Agile Manifesto is here:
http://agilemanifesto.org/
Ward's Wiki, the first WikiWikiWeb, created by Ward Cunningham, is here:
http://c2.com/cgi/wiki?WelcomeVisitors
Extreme Programming: A Gentle Introduction:
http://www.extremeprogramming.org/
XProgramming.com: An Extreme Programming Resource:
http://www.xprogramming.com/
|
Sponsored Links
|