From: Phillip Gawlowski Date: 2008-04-28T04:52:15+09:00 Subject: Re: Ruby & Artificial Intelligence -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 M. Edward (Ed) Borasky wrote: | | Well ... programming in "natural" languages has been a dream for | decades. Heck, that was one of the things that was supposedly attractive | about COBOL (and its predecessor, COMTRAN). You can probably still find | code like | | SUBTRACT TAXES FROM GROSS_INCOME GIVING NET_INCOME | | in the COBOL code base. | | Mabye that's why it irks me so when I see Rails code like | | class Order < ActiveRecord::Base | has_many :line_items | end How do you see code like 'a = b unless c' in Ruby, then? Ruby's pretty much trying to become a sort-of-natural language, though not mimicking English (or Japanese), but by staying out of the programmer's way, making code, in fact, easy to read and understand. But with any language, you'll have to know the syntax and grammar of the language used. Just as with natural languages. ;) | Now, if it were "An order has many line items," that would be natural. | But it's the mix of Ruby code and English (class , | ), etc. It's un-natural. I'd rather have straight code. So, you'd prefer if c == true # Or whatever we check here that results in evaluation ~ a = b end over the above example? I'm more curious, than any thing else. I think the quality of DSLs like Rails and Rake, and, in a broader sense, Ruby, is that they look like English, making it easy to understand, but isn't English 'enough', keeping you on your toes when writing code, as you still have to think about what you are actually doing. Natural language is ambiguous in its nature ("Gravity means that every object attracts every other object": Does that sentence mean that all objects attract all other objects, or that all objects attract every second object? It's COIK: Clear Only If Known.), whereas a programming language cannot be ambiguous, creating the thin line to walk when designing a language. And as far as I can see, all these 'natural language' approaches result in an 'English' that is like a second grader writing a novel (Not underestimating your average second grader): very, very bumpy. Take a look at AppleScript, for example. | Rake is another example ... file tasks are named with strings and other | tasks are named with symbols. The whole "when do I use a symbol and when | do I use an ordinary identifier" conundrum is difficult for me. If the identifier shall remain over the course of the program's runtime, use a Symbol, as those don't get garbage collected. Otherwise use a String. That's my rule of thumb, when not using Rails. | I think it's a mistake to try to design languages and programs in a way | that *in theory* attempts to make the code readable to non-programmers. | First of all, non-programmers rarely, if ever, read code. They care | about what the software *does*, not what's under the hood. And second, | it makes the job of the programmer more difficult. I don't think that it is so much about readability for 'non programmers', but about readability and accessibility for domain experts. At least, that is what I take a way from all these DSL talks I've watched in recent months, specifically Val Kilmer's talk 'Ruby and the Art of Domain Specific Languages'[0], and Joe O'Brien's talk 'Domain Specific Languages: Molding Ruby'[1]. [0] http://www.infoq.com/presentations/kilmer-ruby-dsls [1] http://mwrc2008.confreaks.com/08obrien.html - -- Phillip Gawlowski Twitter: twitter.com/cynicalryan ~ I imagine girls and bugs have a dim perception that nature played a cruel trick on them but they lack the intelligence to really comprehend the magnitude of it. -- Calvin -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkgU2WkACgkQbtAgaoJTgL/f/QCgi5C5TYjuNk26TjbwUdOEQag7 QQwAni65VqrlVFVFsf159zFksvsOC7Rx =T5p7 -----END PGP SIGNATURE-----