# Need a short nontrivial example program

**URL:** <https://www.ruby-forum.com/t/need-a-short-nontrivial-example-program/186620>\
**Category:** Ruby\
**Created:** [April 9, 2010, 9:27pm UTC](https://www.ruby-forum.com/t/need-a-short-nontrivial-example-program/186620 "2010-04-09T21:27:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3d9bf3/32.png) [@jcain](https://www.ruby-forum.com/u/jcain)\
**Post date:** [April 9, 2010, 9:27pm UTC](https://www.ruby-forum.com/t/need-a-short-nontrivial-example-program/186620/1 "2010-04-09T21:27:01Z")

</div>

I’m a member of the ACM at my university (Wichita State), and we are  
allowed  
to participate in the College of Engineering’s open house. We decided to  
do  
an arduino project b/c it seemed like the kind of thing that would be  
accessible to engineers.

A while back, I read  
[http://talklikeaduck.denhaven2.com/2009/09/03/red-light-green-light](http://talklikeaduck.denhaven2.com/2009/09/03/red-light-green-light) and  
loved the idea. So we decided to create a traffic light controlled by  
the  
Arduino, which receives commands from a test suite like RSpec, that  
reflect  
the status of the tests.

But how to show this off to the engineers?

Ruby is easy to learn, and with a good prebuilt test suite offering  
helpful  
explanations of why it failed, and what you might do to make it not  
fail, I  
think that I could sit a reasonably capable person down and have them  
write  
a program.

So I am looking for ideas about what this program should be. I want it  
to be  
nontrivial, because I want them to walk away thinking “holy crap, I just  
did  
something cool that I could see myself using at some point in the  
future”.  
And I want it to be short so that a number of people can give it a try.

For example, I really love the TweetStream example program (  
[http://github.com/intridea/tweetstream/blob/master/examples/growl\_daemon.rb](http://github.com/intridea/tweetstream/blob/master/examples/growl_daemon.rb)),  
where you can have your Mac growl at you every time someone makes a  
tweet  
with a given keyword. But I think most engineers here don’t have macs so  
will be harder to appreciate this. Plus, I’m not sure how to test some  
of  
that stuff, and to see it in action, you would kind of have to spam your  
twitter account.

Anyway, looking for ideas.  
-Josh

---

<div class="post-metadata">

**Author:** ![jcain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3d9bf3/32.png) [@jcain](https://www.ruby-forum.com/u/jcain)\
**Post date:** [April 9, 2010, 9:44pm UTC](https://www.ruby-forum.com/t/need-a-short-nontrivial-example-program/186620/2 "2010-04-09T21:44:05Z")

</div>

Josh C. wrote:

> I’m a member of the ACM at my university (Wichita State), and we are  
> allowed  
> to participate in the College of Engineering’s open house.

[…]

> So I am looking for ideas about what this program should be. I want it  
> to be  
> nontrivial, because I want them to walk away thinking “holy crap, I just  
> did  
> something cool that I could see myself using at some point in the  
> future”.  
> And I want it to be short so that a number of people can give it a try.

So the ruby-warrior thing doesn’t excite you? 😉

It can be tough; what is really exciting for an engineer? They have a  
very meticulous personality, point-by-point, attention to detail.

Maybe recreating Dwemthy’s array in front of their eyes?

---

<div class="post-metadata">

**Author:** ![jcain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3d9bf3/32.png) [@jcain](https://www.ruby-forum.com/u/jcain)\
**Post date:** [April 9, 2010, 10:03pm UTC](https://www.ruby-forum.com/t/need-a-short-nontrivial-example-program/186620/3 "2010-04-09T22:03:20Z")

</div>

On Fri, Apr 9, 2010 at 2:44 PM, Aldric G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> So the ruby-warrior thing doesn’t excite you? 😉

I actually played with it back whenever Ryan announced it on his  
Twitter.  
But I had to read a lot of specs and source to figure out what was  
available  
to my robot, and how to have him do things. I put it down b/c I could  
see it  
was going to eat up a lot of time that I needed to devote to other  
priorities.

> It can be tough; what is really exciting for an engineer? They have a  
> very meticulous personality, point-by-point, attention to detail.
> 
> ## Maybe recreating Dwemthy’s array in front of their eyes?
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

I’m really hoping for something that can be done in under 10 minutes  
(the  
format is not yet clear to me, I have a meeting with the people putting  
it  
on, but I may have to give a presentation, in which case, the whole  
thing  
should take under 10 min).

The TweetStream example is less than 15 lines of code. The final product  
doesn’t need to be that short necessarily, but shorter is still better.

---

<div class="post-metadata">

**Author:** ![jcain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3d9bf3/32.png) [@jcain](https://www.ruby-forum.com/u/jcain)\
**Post date:** [April 10, 2010, 10:23am UTC](https://www.ruby-forum.com/t/need-a-short-nontrivial-example-program/186620/4 "2010-04-10T10:23:55Z")

</div>

On 09.04.2010 21:26, Josh C. wrote:

> So I am looking for ideas about what this program should be. I want it to be  
> nontrivial, because I want them to walk away thinking “holy crap, I just did  
> something cool that I could see myself using at some point in the future”.  
> And I want it to be short so that a number of people can give it a try.

What about a simply simulation of some system’s behavior that appeals to  
engineers? Something from their domain. If you do a clean separation  
between simulation framework and the specific simulation you might even  
end up using it for something else.

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![jcain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3d9bf3/32.png) [@jcain](https://www.ruby-forum.com/u/jcain)\
**Post date:** [April 9, 2010, 10:37pm UTC](https://www.ruby-forum.com/t/need-a-short-nontrivial-example-program/186620/5 "2010-04-09T22:37:18Z")

</div>

No! Not Dwemthy’s Array! You will most assuredly look like a fool when  
your Rabbit gets trashed by the Industrial Raver Monkey as he’s  
desperately trying to choke down leafy heads of lettuce!

–  
Michael J.

> **[WebMD - Better information. Better health.](http://mjijackson.com/)**
>
> The leading source for trustworthy and timely health and medical news and information. Providing credible health information, supportive community, and educational services by blending award-winning expertise in content, community services, expert...

@mjijackson

---

<div class="post-metadata">

**Author:** ![jcain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3d9bf3/32.png) [@jcain](https://www.ruby-forum.com/u/jcain)\
**Post date:** [April 10, 2010, 4:53pm UTC](https://www.ruby-forum.com/t/need-a-short-nontrivial-example-program/186620/6 "2010-04-10T16:53:11Z")

</div>

On Sat, Apr 10, 2010 at 7:47 AM, Josh C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> If I understand what you’re saying, you mean something like a truth table  
> maker?  
> -Josh

Hmm, I’ve been thinking about this, It could probably be done easily  
with  
tree top. But formatting output might require arcane knowledge.

---

<div class="post-metadata">

**Author:** ![jcain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3d9bf3/32.png) [@jcain](https://www.ruby-forum.com/u/jcain)\
**Post date:** [April 10, 2010, 2:50pm UTC](https://www.ruby-forum.com/t/need-a-short-nontrivial-example-program/186620/7 "2010-04-10T14:50:15Z")

</div>

On Sat, Apr 10, 2010 at 3:20 AM, Robert K.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> What about a simply simulation of some system’s behavior that appeals to  
> [http://blog.rubybestpractices.com/](http://blog.rubybestpractices.com/)

If I understand what you’re saying, you mean something like a truth  
table  
maker?  
-Josh

---

<div class="post-metadata">

**Author:** ![jcain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3d9bf3/32.png) [@jcain](https://www.ruby-forum.com/u/jcain)\
**Post date:** [April 10, 2010, 4:55pm UTC](https://www.ruby-forum.com/t/need-a-short-nontrivial-example-program/186620/8 "2010-04-10T16:55:32Z")

</div>

On 10.04.2010 14:48, Josh C. wrote:

> > > did  
> > > something cool that I could see myself using at some point in the future".  
> > > And I want it to be short so that a number of people can give it a try.
> > 
> > What about a simply simulation of some system’s behavior that appeals to  
> > engineers? Something from their domain. If you do a clean separation  
> > between simulation framework and the specific simulation you might even end  
> > up using it for something else.

> If I understand what you’re saying, you mean something like a truth table  
> maker?

No. I thought more of a simulation of some mechanism (maybe mechanical  
or whatever). You’d have a framework that would operate the simulation  
and components that exhibit specific behavior. Say you could model a  
basic with detectors for the fill level which open and close a valve  
which controls water flow. You could create a simplified log of the  
current fill level over time. Something like that.

Kind regards

robert
