|
| From: | Brandon J. Van Every |
| Subject: | Re: [Chicken-users] Re: Integrating unit tests into source code |
| Date: | Fri, 15 Dec 2006 03:30:11 -0800 |
| User-agent: | Thunderbird 1.5.0.8 (Windows/20061025) |
Peter Bex wrote:
On Thu, Dec 14, 2006 at 03:41:44PM -0800, Brandon J. Van Every wrote: Well, even SciTE appears to support "folding," which seems to be the gratuitous expansion and collapse of code you don't want to look at. So if your editor could "fold" the contract, then the clutter wouldn't be an issue. So it seems that the time is now, for some tools that are somewhat evolved. you won't need files and there's no problem with lumping everything together because you select your own preferred view for the particular task you're working on. Unfortunately (?), that time isn't here yet and we have to make do with imperfect plaintext-editors (though paredit.el really helps). One mustn't apologize for Emacs. Those cardboard stands at the grocery stores with all the dimes and quarters in them? They're for the Emacs users.
You needn't read between the lines, just re-read what I've written elsewhere in this ever lengthening thread. I don't oppose contract programming. I'm generally in favor of any testing method, good comments, and things that resemble literate programming. However, I think there are probably limits to what contract programming can do for people, so I'm not inclined to oversell it. It would be one heckuva specification language that could handle any arbitrary problem domain, with clarity and aplomb. I think there will be head scratching, same as always. It isn't that different from writing small, clear, concise test cases. I bet once you've seen a few programs that work like this, you will gradually learn how to read them and that will mean a productivity increase. When you first came into contact with a recursive Scheme program, didn't you think it was very difficult to read? I *still* think it's difficult to read. I think *C* code is difficult to read. Code is difficult to read. I'm sure specifications in the form of contracts, if done properly, are a lot more terse than tests. Which is exactly why I'm so fiercly opposed to inline tests. As an example: A big project I'm working on at work has a core library that has to be tested well. The library is only 400 lines of Ruby code (it builds on existing classes), but it has ~1400 tests. That is an awfully big test:code ratio. You really don't want to have these tests inlined! I don't value terseness. I am opposed to gratuitous required verbosity, like VariableNamesThatMustBeReallyLong, but that's not the same thing as valuing terseness. If you read CMakeLists.txt, you will see it is far from terse. It certainly isn't bloated, everything in there actually does something, but it became a lot more verbose when I tutorialized the whole thing. Whether something is 400 or 800 lines of code really isn't the issue. The issue is how long does it take to write it, and how long does it take to read it. If it's longer but clearer, that's better. If it's longer and straightforward, rather than being terse and fancy, that's better. The worst code I wrote in CMakeLists.txt is the stuff where I gratuitously macrotized the lists of files. It's much easier to maintain a manual list of files, because people can actually find things and add/delete them, without needing to understand any oh-so-clever macros. I think Perl sucks. That's pretty much the epitome of terseness at the expense of intelligibility.
Well, I don't like the computer industry, or how most programmers behave in it. Tests may miss significant situations people just didn't think of at the time. Same goes for contracts, by the way. Right, which is why I'm not inclined to oversell contracts. If you do not want to read code, you shouldn't be in the programming business. Hey that's like saying if you don't want to read Microsoft APIs, you shouldn't be in the programming business. Bull-oney! There's all kinds of things in programming I don't *want* to do. The question is *will* I do them? Yeah, I'll read / funge other people's code *if* it does something for me, or *if* I'm getting paid. Otherwise, it's a complete waste of my time. Sitting around reading other people's code ain't one of the joys.
No, it's not preference. What I stated above is fact. You are going to run into situations where "A happens, then B happens, then C happens" is easier to debug. Now, how often you write that sort of code, or have to deal with that sort of code, depends on what you're up to.
Should Scheme be a pure declarative language? Nope. Should OCaml? Nope. I don't believe in pure programming languages. When you straitjacket people with The One True Paradigm, all you do is complicate things for someone else's real world problem. Of course, from your perspective it should right now, but what if you need to write some entirely different type of program? Wouldn't you like to do it the best way possible, and in Chicken? Macros are a two-edged sword, requiring judicious use. The common wisdom is, don't use 'em unless that's the only way to get the job done. I suppose we just have to agree to disagree on this issue. Maybe a user poll about what approach to take is in order? No, not really. Having declarative contract programming available is fine. Forcing people to use it is wrong. Expecting everyone to think it's the greatest thing ever, is unrealistic. Some people will do contracts and others will do tests. Cheers, Brandon Van Every |
| [Prev in Thread] | Current Thread | [Next in Thread] |