How has Ruby improved your C++?

It's often said that learning a new language will help you look at things
differently and thus also improve how your program in other languages you
know. I occasionally program in C++ and I'm in one of those occasions
now so I'm thinking about how knowing Ruby has influenced my C++
programming.

One thing that comes to mind is that I'm more likely now to pass around
function pointers as a way to emulate yield. The function passed in can
be evaluated at every step of an iteration, for example, to test for some
condition.

Anyone got other examples of how your C++ programming has been influenced
by your Ruby knowledge?

Phil

This is a common C++ idiom, actually, but usually it involves a function
object rather than a function pointer, since calls into the function
object can often be more easily inlined.

Paul

···

On Tue, Oct 25, 2005 at 02:42:01AM +0900, Phil Tomson wrote:

One thing that comes to mind is that I'm more likely now to pass around
function pointers as a way to emulate yield. The function passed in can
be evaluated at every step of an iteration, for example, to test for some
condition.

Ruby has ruined my C++
blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/148046

Ruby has ruined my Java
blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/148100

Cheers,
Ed

···

On 10/24/05, Phil Tomson <ptkwt@aracnet.com> wrote:

Anyone got other examples of how your C++ programming has been influenced
by your Ruby knowledge?

--
Encontrá a "Tu psicópata favorito" http://tuxmaniac.blogspot.com
  
Thou shalt study thy libraries and strive not to reinvent them without cause,
that thy code may be short and readable and thy days pleasant and productive.
-- Seventh commandment for C programmers

templates and generic programming: they are as close to duck typing as you
can get - implement the required signature and you're off. the vigra toolkit
i've been using is a great example of this. i've also realized the
__massive__ speed hit you incur if you write c++ without templates that i'd
say c++ is not of enough value to bother without them.

the biggest improvement, of course, is that i don't need to write much c++
anymore. :wink:

-a

···

On Tue, 25 Oct 2005, Phil Tomson wrote:

It's often said that learning a new language will help you look at things
differently and thus also improve how your program in other languages you
know. I occasionally program in C++ and I'm in one of those occasions now
so I'm thinking about how knowing Ruby has influenced my C++ programming.

One thing that comes to mind is that I'm more likely now to pass around
function pointers as a way to emulate yield. The function passed in can be
evaluated at every step of an iteration, for example, to test for some
condition.

Anyone got other examples of how your C++ programming has been influenced by
your Ruby knowledge?

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
anything that contradicts experience and logic should be abandoned.
-- h.h. the 14th dalai lama

===============================================================================

Ara.T.Howard wrote:

...
templates and generic programming: they are as close to duck typing as you
can get - implement the required signature and you're off. the vigra toolkit

I first parsed this as 'Viagra toolkit', and thought, won't that just make things harder?

:slight_smile:

James

···

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys

In article <20051024175148.GE2140@atdesk.com>,

···

Paul Brannan <pbrannan@atdesk.com> wrote:

On Tue, Oct 25, 2005 at 02:42:01AM +0900, Phil Tomson wrote:

One thing that comes to mind is that I'm more likely now to pass around
function pointers as a way to emulate yield. The function passed in can
be evaluated at every step of an iteration, for example, to test for some
condition.

This is a common C++ idiom, actually, but usually it involves a function
object rather than a function pointer, since calls into the function
object can often be more easily inlined.

Yes, this is probably true, but it took a trip through Ruby-land for me to
'get it' in C++ (and yes, I should probably be using functors).

Phil

lol! it's a very unfortunate name to be sure :wink:

-a

···

On Tue, 25 Oct 2005, James Britt wrote:

Ara.T.Howard wrote:

...
templates and generic programming: they are as close to duck typing as you
can get - implement the required signature and you're off. the vigra toolkit

I first parsed this as 'Viagra toolkit', and thought, won't that just make things harder?

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
anything that contradicts experience and logic should be abandoned.
-- h.h. the 14th dalai lama

===============================================================================