I used to keep blogging stuff on my site on my server, but frankly - writing and fixing your own tools every time you just want to jot down a little thought gets old. Now that I'm on Blogspot every day anyway for the house, I might as well start new blogs for new thinking threads.
So that's what this is. A new thread of thinking. If you're reading this, well, that's weird. It's more just for me. But hey, thanks for reading - drop me a comment if you find something neat. I hope you will, with time.
So ... what's semantic programming? That's kind of what I want to answer over the next arbitrary period of time; the notion is something I've been mulling over for about fifteen years, maybe more, and it just keeps coming back.
The key insight (well, in addition to hexapodia) is that programming to date has focussed on syntax, whereas it's maybe time to start being more explicit about semantics.
What do I mean by that? Let's consider something sort of like a real-world example; say, a script to harvest some information from a website and put it into a database. (This example will probably crop up again and again over the course of this blog.) Since we're human, we approach this by taking a browser and going to the site in question and reading it, and forming some kind of mental model of the information there. Then we map that onto a structure of tables, and we sit down and write some Perl (say) to walk along the site and load the data into the tables.
Along the way we wrote some SQL to define the tables, and more to insert the data, and so on. The table columns have names that mean something to us in English or Thai or something.
At the end of the process, we test the program and see that it is good, and on the seventh day we rest, while the program runs merrily along and populates our tables for us, doing what software does best.
OK. That's the baseline. We've used our human domain knowledge and our smart-monkey proclivity to build semantic structures, then we've expressed some syntax to define data and procedure. The syntax can be tested or maybe even proved correct (well, probably not, but you get my meaning) but - this is the important part - nothing in that system can be said to understand the domain. It expresses the domain, in a way; another programmer can come and read the code (even without comments) and will probably be able to come up with something like the original domain we learned about.
What semantic programming should do is to encode some of that domain knowledge and semantics into the overall system. Ultimately, it should encode all of it.
Why? I'm glad you asked.
The more semantically sophisticated the system is that we build, the more easily we can adapt it. Instead of the script being the system, the script is now simply an expression of the system; the system itself more closely approximates the set of knowledge and concepts the programmer built in her brain during the programming process.
By changing the concepts at a higher level, and allowing those changes to propagate into the expression accurately (i.e. by metaprogramming instead of programming), we eliminate a lot of error. Moreover, if the system understands what it should be doing, then - potentially - it should be able to run spot checks on its results - sanity checks. It should be able to generate its own unit tests based on the semantic knowledge of how its own components should work.
In short, the smarter the program, the less it is a program.
Yeah, yeah, I know. This is impossible. That's why this blog isn't going to be publicized. It's just my notes. If you're reading it, and it's any time earlier than about 2011, and if you want to pull the alpha geek? Don't. I'll delete negative comments as soon as I see them. Positive comments are welcome.
It's like when I bought my house. I hadn't even seen it when we closed, of course (entirely remote) but when I told my dad we were moving back into the area and where the house was, I told him, "No matter what you see there, no matter what condition it's actually in, when you call me next, I only want to hear validation." He laughed; I think that might have been the most honest moment we've ever shared.
Same applies here. No matter how stupid this is, don't tell me. I'm just using you as a focus to verbalize my thoughts anyway.
Update, November 6, 2011: a brief retrospective.
No comments:
Post a Comment