IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New "Little Language" definition, components
So what is a language?

If the solution is to create a language (not a program, not a module, not a command) than I need to know, what is a language, what is it composed from, when do I know I completed my language, what feature do I need filled to have a complete language.

Many ppl repeat those words about writing your own mini language or high level language ... so something good must be in it, specially since, that at an abstract level this thought is supported, that any program can be viewed as a language, any library, can be thought of as a language


Correct; the difference between a "program" and a "language" is one of perspective. You write a program to walk 100m, turn right, walk 110m, turn right, walk 100m, turn right, walk 110m, and maybe turn right. You write a language to go around the block, instead.

What is missing is, how can this way of thinking, help me create a better program (language) or better module (language)
I think we can start by having a better or a more specific definition of a 'language'


Short answer: [link|http://en.wikipedia.org/wiki/Formal_language|read up on "formal languages"].

A little language possesses a vocabulary of functions, classes, modules, and packages which map to concepts in the problem domain. The elements of the vocabulary interact according to a formal grammar. The concepts are determined by self-declaration of human stakeholders, subject to systematic analysis and organization in order to produce a formal system.

Also, I want to mention, that read in a few article about Ruby, that ruby makes it very easy to write your own mini language, what a tease, as if every body is doin it, yet, when I search, I can't find any book or article who tell u how to create ur own language, the school of "make it a language", is far from ...
being an everyday thing! It's really not that popular, or elaborated upon.


As Ben pointed out, you don't start from scratch when writing a "little language". You start with a generic language (like Ruby or Python or LISP), make up some new primitives (like go_around_the_block()), ignore any primitives which you don't need, and end up with a slang dialect which fits your problem space. It's called "little" because it's embedded within another, larger language.

Ruby "makes it easy" because you can override almost any primitive (even builtin types) to create the behavior that you want. Python doesn't allow you to override builtin types; you have to subclass them.

Cameron Laird [link|http://groups.google.com/groups?th=6c6790175731d644&seekm=m66s52-91c.ln1%40lairds.us#link8|made this point] nicely just this morning on c.l.p.:
Next, Python thumps Java on readability and maintainability. While I don't yet know how to make an iron-clad objective case for this briefly, I'm utterly convinced that Python programs are significantly easier to read "six months later". This matters: much of teamwork is dealing with source code that one doesn't understand. Traditionalists promote Java as a statically-typed language, but this is just a distraction; Python's more graceful expressiveness leads to relatively more focus on correct algorithms and unit tests, while Java is relatively mired in syntax. Programming in Java feels too often like dealing with Java, whereas Python is a leader in letting developers think they're dealing with the application.
New On what makes it easy to do little languages.
Double plus agreement on the "little language" explaination.

Ruby "makes it easy" because you can override almost any primitive (even builtin types) to create the behavior that you want. Python doesn't allow you to override builtin types; you have to subclass them.

I've done several "little languages" in Ruby and although the primitive thing can help, the biggest aid in doing a little language in Ruby is its ability to control the execution of a block of code. I've used Ruby to define mini-languages to (1) control build processes ([link|http://rake.rubyforge.org|http://rake.rubyforge.org]), (2) define data base schemas, (3) define FSM state transitions ([link|http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/118962|http://blade.nagaoka.../ruby-talk/118962]) and (4) build XML structures ([link|http://onestepback.org/index.cgi/Tech/Ruby/BuilderObjects.rdoc|http://onestepback.o...ilderObjects.rdoc]). In all cases it was the Ruby block that made the resulting mini-language natural and easy to use.

The builder example (#4 above) is particularly telling. The idea came from Groovy (another language that supports code block) and was insanely easy to implement in Ruby. I can imagine that doing it in Lisp would also be easy. But I've seen attempts to reproduce it in languages that don't support code blocks (e.g. Python at [link|http://users.binary.net/thehaas/cgi-haas/blosxom.cgi/comp/python/xmlbuilder.html|http://users.binary....n/xmlbuilder.html]) and the results have always been less than the original.
--
-- Jim Weirich jim@weirichhouse.org [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New Good point.
Python comes closest to that by having first-class functions (meaning, you can pass them around as objects). But Ruby's blocks are still miles ahead. Of course, LISP macros take the cake in that department. ;)

Something else I thought of in the shower: dynamic languages win in the little language department because they allow the developer to express a concept in the most appropriate syntax/semantics. For example, you're not stuck implementing go_around(person, community.get_block(13)). By dynamically adding/trapping attributes, and by overriding/subclassing builtins, you can write (Python examples):


  • go_around(person, community.block[13]), or even

  • go_around(person, community[13])

  • person.go_around(community[13])

  • blocks(13, person)

  • community.blocks.13.tour(person)

  • person.morning_walk += blocks[13]



...etc., any of which "does the same thing". This allows the designer to make a "little language" which is easier to use and extend. If you like TIMTOWTDI, you could implement them all simultaneously (but you probably shouldn't).


The Sig:
"Despite the seemingly endless necessity for doing
so, it's actually not possible to reverse-engineer intended invariants
from staring at thousands of lines of code (not in C, and not in
Python code either)."

Tim Peters on python-dev
     Time for good anti-OO battle to take minds off of election - (tablizer) - (77)
         Sorry cant go there - (daemon) - (32)
             How is being locked to a DB more evil than being locked to - (tablizer) - (31)
                 It's best to fit the tool to the job - (FuManChu) - (30)
                     Thanks for that ... +5 insightful - (drewk) - (6)
                         For various definitions of "start" ;) - (FuManChu)
                         On writing the "little language thing ..." - (systems) - (4)
                             Suggestion - (ben_tilly)
                             "Little Language" definition, components - (FuManChu) - (2)
                                 On what makes it easy to do little languages. - (JimWeirich) - (1)
                                     Good point. - (FuManChu)
                     Orthogonal to DB usage - (tablizer) - (22)
                         That's actually a good idea - (drewk) - (17)
                             *Snork* beat me to it :) -NT - (FuManChu)
                             Cure worse than the medicine. - (tablizer) - (15)
                                 "tends to bloat up code" - (admin) - (14)
                                     Your "solution" to such bloat was HQL, yes or no? -NT - (tablizer) - (13)
                                         It was a solution, yes. -NT - (admin)
                                         Since you seem to be slow... - (ben_tilly) - (11)
                                             I did NOT "lose". His solution was variation on SQL - (tablizer) - (10)
                                                 In your universe, perhaps - (ben_tilly) - (9)
                                                     The mapper did not reduce his code size - (tablizer) - (8)
                                                         Bryce, you lost this one already. - (ben_tilly) - (7)
                                                             I did NOT fscken lose. He gave no code-size proof. Zilch. - (tablizer) - (6)
                                                                 Why is code size your (apparently) sole criterion? - (drewk) - (5)
                                                                     You are welcome to present ANY metric you can justify - (tablizer) - (4)
                                                                         Thank you - (drewk) - (1)
                                                                             Usually people don't question those much - (tablizer)
                                                                         We've already been over change scenarios - (admin) - (1)
                                                                             re: We've already been over change scenarios - (tablizer)
                         "Orthogonal" in exactly the same sense as differential gears - (FuManChu) - (3)
                             You just shortened this thread by 200 posts. Cut & Paste. - (Another Scott) - (1)
                                 "[Nobody] ...points out that the cut-and-paste method... - (FuManChu)
                             No, you got me all wrong, dude - (tablizer)
         Repeat after me: - (admin) - (1)
             I never said OO was JUST about inheritance. - (tablizer)
         Amusing to note... - (JimWeirich) - (41)
             re: nouns and noun grouping - (tablizer) - (40)
                 Bryce: control tables are bad - (admin) - (37)
                     Time will erase performance differences - (tablizer) - (36)
                         That's not the main reason why they're bad. - (admin) - (35)
                             Because VC tools are hierarchy-biased. - (tablizer) - (34)
                                 Go read the thread. - (admin) - (33)
                                     You always talk as if I push a grand conspiracy - (tablizer) - (32)
                                         Relational has its place. - (admin) - (31)
                                             Math and Boolean expressions - (tablizer) - (30)
                                                 Ever use Zachary? - (admin) - (29)
                                                     I will believe it only when I see it with my own eyes - (tablizer) - (28)
                                                         - said the blind man (ducks and runs) -NT - (Arkadiy)
                                                         NO. - (admin) - (26)
                                                             You never identified an in-born fault of tables. -NT - (tablizer) - (25)
                                                                 Tables don't make good chairs. - (Another Scott) - (24)
                                                                     Vacuum Tubes - (tablizer) - (23)
                                                                         You can pry my tube guitar amp outta my cold, dead fingers. - (Steve Lowe) - (22)
                                                                             Digital precision can be boring - (tablizer) - (18)
                                                                                 Yes - tubes are IT man - (tuberculosis) - (17)
                                                                                     Heh! That was my first bass amp! - (jb4) - (16)
                                                                                         I don't know whether to be amused or appalled - (tuberculosis) - (15)
                                                                                             Both actually - (jb4) - (14)
                                                                                                 In negotiations - (jake123) - (13)
                                                                                                     Drooooooooool - (Steve Lowe) - (12)
                                                                                                         Didn't get it - (jake123) - (11)
                                                                                                             Bum R! -NT - (jb4) - (10)
                                                                                                                 Oh well. - (jake123) - (9)
                                                                                                                     Talk to your amp tech - (Steve Lowe) - (8)
                                                                                                                         Oh yeah - (jake123) - (1)
                                                                                                                             Had a teacher who did that - (drewk)
                                                                                                                         Re: Talk to your amp tech - (Ashton) - (5)
                                                                                                                             What I'm gaining - (jake123) - (4)
                                                                                                                                 Have you considered an attenuator? - (Steve Lowe) - (3)
                                                                                                                                     Yes I have - (jake123) - (2)
                                                                                                                                         New thread time, maybe...? -NT - (admin)
                                                                                                                                         This might not cost a bundle.. (new thread) - (Ashton)
                                                                             Mesa Boogie Forever -NT - (tuberculosis) - (2)
                                                                                 That'll prolly be my second choice - (jake123)
                                                                                 Feh! The Ultimate was... - (jb4)
                 re: nouns and noun grouping - (JimWeirich) - (1)
                     Can't do a whole lot with your hidden anecdotes - (tablizer)

That was never five minutes!
216 ms