The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Sublanguages: Embedded general-purpose languages

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Christian Neukirchen

Posts: 188
Nickname: chris2
Registered: Mar, 2005

Christian Neukirchen is a student from Biberach, Germany playing and hacking with Ruby.
Sublanguages: Embedded general-purpose languages Posted: Aug 31, 2006 9:13 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Christian Neukirchen.
Original Post: Sublanguages: Embedded general-purpose languages
Feed Title: chris blogs: Ruby stuff
Feed URL: http://chneukirchen.org/blog/category/ruby.atom
Feed Description: a weblog by christian neukirchen - Ruby stuff
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Christian Neukirchen
Latest Posts From chris blogs: Ruby stuff

Advertisement

In the past, Ruby often has been popularized as a language suitable for building DSLs (Domain Specific Languages). Its flexible syntax (e.g. mostly optional parentheses or newline as statement terminator) and language facilities like blocks or powerful run-time introspection and metaprogramming make this possible.

Domain specific languages are, nomen est omen, specific to a certain domain that in some ways deserves programmability. Therefore, while certain languages considered as DSLs are in fact Turing-complete (think of XSLT, sendmail.cf or TeX), they aren’t very suitable for general-purpose programming. For Rubyists, this is no problem, given that embedded DSLs implemented in Ruby often can use the full power of Ruby.

However, Ruby is powerful enough not only to implement embedded DSLs, but also to implement embedded general-purpose languages. I’ll name these sublanguages.

Why sublanguages, if you have Ruby?, the sceptic may ask. The reason is easy: while libraries implement functions, sublanguages implement programming paradigms.

Out of the box, Ruby already supports some programming paradigms pretty well. These are:

  • Class-based object oriented programming, since “everything” in Ruby is an object; this probably is Ruby’s main paradigm.

  • Functional programming with powerful and side-effect free methods in the core (e.g. due to Enumerable) and code as first-class objects (Proc).

  • Imperative programming due to modifyable variables, sequential execution and eager evaluation.

These three paradigms probably are the ones the creator of Ruby cared most about, which is why they are so well-supported by core Ruby. They also are the three most popular paradigms as of today.

However, due to Ruby’s flexibility, it is relatively easily possible to also implement other programming paradigms in Ruby. In a series of posts, I hope to present implementations of these:

  • Prototype-based object oriented programming, featuring object-orientation not by defining classes, but by cloning and refining objects. (Inspired by Self and Io).

  • Concurrent programming, with Erlang style processes and message passing.

  • Declarative logic programming, as seen in Prolog.

Please note that almost everything is possible to implement using Ruby with some ugly hacks. I’ll try to avoid these very hard to make the code suitable to a general public, and not only for academic use. It’s still very hard to encode these paradigms with reasonable speed compared to a proper native implementation. Wherever possible, I’ll try to make useful optimizations.

Code can be found at my darcs repositories.

NP: Spiritualized—Cool Waves

Read: Sublanguages: Embedded general-purpose languages

Topic: Things You Shouldn't Do In Rails Previous Topic   Next Topic Topic: Rear Window

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use