How has Ruby improved your C++?

P

Phil Tomson

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
 
P

Paul Brannan

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.

Paul
 
E

Edgardo Hames

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

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
--
Encontr=E1 a "Tu psic=F3pata favorito" http://tuxmaniac.blogspot.com
=09
Thou shalt study thy libraries and strive not to reinvent them without caus=
e,
that thy code may be short and readable and thy days pleasant and productiv=
e.
-- Seventh commandment for C programmers
 
A

Ara.T.Howard

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?

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. ;-)

-a
--
===============================================================================
| 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
===============================================================================
 
J

James Britt

Ara.T.Howard said:
...
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?








:)






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
 
A

Ara.T.Howard

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

lol! it's a very unfortunate name to be sure ;-)

-a
--
===============================================================================
| 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
===============================================================================
 
P

Phil Tomson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,978
Members
47,561
Latest member
gjsign

Latest Threads

Top