Forum: Ruby :-(

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
:-(
38a8230ed3d5c685558b4f0aad3fc74b?d=identicon&s=25 Joe Van Dyk (Guest)
on 2006-02-28 02:14
(Received via mailing list)
Someone needs to make a "C++ for Ruby programmers" book.  I'm getting
assigned to work on a C++ project now and it's making me cry.  Not
only have I forgotten all of the C++ that I used to know, I actually
have to compile stuff!

I guess I should get more experienced in C++, as variety is good.  But
it's still painful.

Joe
19f65b7dca6831edf989224b5ebd3fe0?d=identicon&s=25 Tsume (Guest)
on 2006-02-28 02:44
(Received via mailing list)
On Tue, 2006-02-28 at 10:12 +0900, Joe Van Dyk wrote:
> Someone needs to make a "C++ for Ruby programmers" book.  I'm getting
> assigned to work on a C++ project now and it's making me cry.  Not
> only have I forgotten all of the C++ that I used to know, I actually
> have to compile stuff!
>
> I guess I should get more experienced in C++, as variety is good.  But
> it's still painful.

Heres a patch

Tsume

--- Programming_Project.old 2006-02-28 10:42:13.000000000 +0900
+++ Programming_Project 2006-02-28 10:43:57.000000000 +0900
@@ -1 +1 @@
-Project must be creating using C++
+Project must be creating using C++. Also, embedding ruby is okay.
Bf6862e2a409078e13a3979c00bba1d6?d=identicon&s=25 Gregory Seidman (Guest)
on 2006-02-28 02:44
(Received via mailing list)
On Tue, Feb 28, 2006 at 10:12:22AM +0900, Joe Van Dyk wrote:
} Someone needs to make a "C++ for Ruby programmers" book.  I'm getting
} assigned to work on a C++ project now and it's making me cry.  Not
} only have I forgotten all of the C++ that I used to know, I actually
} have to compile stuff!
}
} I guess I should get more experienced in C++, as variety is good.  But
} it's still painful.

Think of the compiler as the interpreter, and templates as duck-typed
Ruby.
Do as much as you can with meta-programming, since it should be
comfortable
from a Ruby background. The rest... the rest is just syntax.

} Joe
--Greg
70c8da82d09d3866222976ab8978133c?d=identicon&s=25 Daniel Nugent (Guest)
on 2006-02-28 03:07
(Received via mailing list)
Just include the Ruby extension binaries and write it using the Ruby C
calls!
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2006-02-28 03:37
(Received via mailing list)
On 2/27/06, Joe Van Dyk <joevandyk@gmail.com> wrote:
> Someone needs to make a "C++ for Ruby programmers" book.  I'm getting
> assigned to work on a C++ project now and it's making me cry.  Not
> only have I forgotten all of the C++ that I used to know, I actually
> have to compile stuff!
>
> I guess I should get more experienced in C++, as variety is good.  But
> it's still painful.
>

In addition to what the others mentioned, you can also write Ruby code
that spits out C++ for you:
http://www.codegeneration.net/cgia/
9377764fa3b08a1c7bf702d373ee653a?d=identicon&s=25 Karl von Laudermann (Guest)
on 2006-02-28 15:46
(Received via mailing list)
Joe Van Dyk wrote:
>
> I guess I should get more experienced in C++, as variety is good.  But
> it's still painful.

As a professional software engineer, I've used a number of different
languages throughout my career, both professionally and personally. I
agree that variety is good; the more languages you've used, the broader
your perspective gets and the better a programmer you become
indepentent of the language that you're currently using.

That said, it's been almost 4 years since I've had to code in C++, and
I'll die a happy man if I never have to use that particular language
again. :-/
31e038e4e9330f6c75ccfd1fca8010ee?d=identicon&s=25 Gregory Brown (Guest)
on 2006-02-28 16:45
(Received via mailing list)
On 2/27/06, Joe Van Dyk <joevandyk@gmail.com> wrote:
> Someone needs to make a "C++ for Ruby programmers" book.  I'm getting
> assigned to work on a C++ project now and it's making me cry.  Not
> only have I forgotten all of the C++ that I used to know, I actually
> have to compile stuff!
>
> I guess I should get more experienced in C++, as variety is good.  But
> it's still painful.

As I've been painfully drudging through a C++ & OO Design course, I've
found that using Rake for automating builds and Cutee for unit tests
makes life a little less... sucky?
149379873fe2cb70e550c6bff8fedd0c?d=identicon&s=25 Jeffrey Schwab (Guest)
on 2006-02-28 17:41
(Received via mailing list)
Joe Van Dyk wrote:
> Someone needs to make a "C++ for Ruby programmers" book.  I'm getting
> assigned to work on a C++ project now and it's making me cry.  Not
> only have I forgotten all of the C++ that I used to know, I actually
> have to compile stuff!
>
> I guess I should get more experienced in C++, as variety is good.  But
> it's still painful.

I love the C++ programming language.  I'm not going to compare it to
other languages (and thereby risk jihad), but there is a part of me that
will always consider C++ the One True Language.  It is extraordinarily
verbose, and the syntax, uh, leaves something to be desired, but C++
offers remarkably powerful facilities at both the lowest and the most
abstract levels.  It has fantastic support for both static and dynamic
techniques, and a well-tuned C++ program can have mind-blowingly great
performance without sacrificing conceptual simplicity.

If you have any trouble at all, surf on over to comp.lang.c++.moderated.
  You may be as amazed as I always am at the brilliance of many of the
contributors.  Wear your thick skin, though; the conversation tends to
be a little harsher there than in the dynamic language groups. :)
38a8230ed3d5c685558b4f0aad3fc74b?d=identicon&s=25 Joe Van Dyk (Guest)
on 2006-03-01 02:49
(Received via mailing list)
On 2/27/06, Gregory Seidman <gsslist+ruby@anthropohedron.net> wrote:
> Do as much as you can with meta-programming, since it should be comfortable
> from a Ruby background. The rest... the rest is just syntax.
>
> } Joe
> --Greg

1.  Templates (that aren't in the STL) scare me.
2.  I've looked at the source code for the Boost library and ran away
screaming.
3.  If I did write code like that, then not many people in my group
would be able to easily grok my code.  Perhaps they'll just need to
bone up on the newest C++ stuff and read the requisite 8 books before
touching my code.
31e038e4e9330f6c75ccfd1fca8010ee?d=identicon&s=25 Gregory Brown (Guest)
on 2006-03-01 02:56
(Received via mailing list)
On 2/28/06, Jeffrey Schwab <jeff@schwabcenter.com> wrote:

> If you have any trouble at all, surf on over to comp.lang.c++.moderated.
>   You may be as amazed as I always am at the brilliance of many of the
> contributors.  Wear your thick skin, though; the conversation tends to
> be a little harsher there than in the dynamic language groups. :)


No MINASWAN to protect you over there? :-(
Eb9493c94d8db9887e5f15284d2c767f?d=identicon&s=25 unknown (Guest)
on 2006-03-01 03:13
(Received via mailing list)
In article <20060228014338.GA22949@anthropohedron.net>,
Gregory Seidman  <gsslist+ruby@anthropohedron.net> wrote:
>Do as much as you can with meta-programming, since it should be comfortable
>from a Ruby background. The rest... the rest is just syntax.

Lots and lots of syntax....

Just a crazy idea: we've got SWIG that lets us access our C++ objects in
Ruby,
how about something that goes the other way so that Ruby class
definitions get
translated to C++ code?

Phil
D111305c32e46f7dd2794a956208d347?d=identicon&s=25 E. Saynatkari (Guest)
on 2006-03-01 03:19
Joe Van Dyk wrote:
> On 2/27/06, Gregory Seidman <gsslist+ruby@anthropohedron.net> wrote:
>> Do as much as you can with meta-programming, since it should be comfortable
>> from a Ruby background. The rest... the rest is just syntax.
>>
>> } Joe
>> --Greg
>
> 1.  Templates (that aren't in the STL) scare me.
> 2.  I've looked at the source code for the Boost library and ran away
> screaming.
> 3.  If I did write code like that, then not many people in my group
> would be able to easily grok my code.  Perhaps they'll just need to
> bone up on the newest C++ stuff and read the requisite 8 books before
> touching my code.

Does this help?

  template<typename duck>
  void quack(duck& d) { duck.quack(); }


E
D111305c32e46f7dd2794a956208d347?d=identicon&s=25 E. Saynatkari (Guest)
on 2006-03-01 03:21
E. Saynatkari wrote:
> Joe Van Dyk wrote:
>> On 2/27/06, Gregory Seidman <gsslist+ruby@anthropohedron.net> wrote:
>>> Do as much as you can with meta-programming, since it should be comfortable
>>> from a Ruby background. The rest... the rest is just syntax.
>>>
>>> } Joe
>>> --Greg
>>
>> 1.  Templates (that aren't in the STL) scare me.
>> 2.  I've looked at the source code for the Boost library and ran away
>> screaming.
>> 3.  If I did write code like that, then not many people in my group
>> would be able to easily grok my code.  Perhaps they'll just need to
>> bone up on the newest C++ stuff and read the requisite 8 books before
>> touching my code.
>
> Does this help?
>
>   template<typename duck>
>   void quack(duck& d) { duck.quack(); }

(Insert about eight thousand lines of compilation
 errors and then s/duck.quack/d.quack/.)

> E


E
Ff63c03fd68754adbadd2c6314646bef?d=identicon&s=25 Bill Guindon (agorilla)
on 2006-03-01 04:43
(Received via mailing list)
On 2/27/06, Joe Van Dyk <joevandyk@gmail.com> wrote:
> Someone needs to make a "C++ for Ruby programmers" book.  I'm getting
> assigned to work on a C++ project now and it's making me cry.  Not
> only have I forgotten all of the C++ that I used to know, I actually
> have to compile stuff!

Well, I'm sure this is still limited, but maybe it's a ray of hope:
http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/rub...
2d0f17b478aa748b34afec2e5ec07b8d?d=identicon&s=25 Anthony DeRobertis (Guest)
on 2006-03-01 16:00
(Received via mailing list)
Joe Van Dyk wrote:

> 1.  Templates (that aren't in the STL) scare me.

#include <iostream>

template<int i> struct Factorial {
        static const int F = i * Factorial<i-1>::F;
};

template<> struct Factorial<1> {
        static const int F = 1;
};

int main() {
        std::cout << Factorial<5>::F << std::endl;
        return 0;
}

Now that wasn't so scary, right?

> 2.  I've looked at the source code for the Boost library and ran away
> screaming.

Setting your font size smaller â?? to 1pt, for example â?? can help with
that.

> 3.  If I did write code like that, then not many people in my group
> would be able to easily grok my code.  Perhaps they'll just need to
> bone up on the newest C++ stuff and read the requisite 8 books before
> touching my code.

Well, perhaps they'd decide to read the much smaller stack consisting of
the Pickaxe book first, then :-D
149379873fe2cb70e550c6bff8fedd0c?d=identicon&s=25 Jeffrey Schwab (Guest)
on 2006-03-01 17:18
(Received via mailing list)
Joe Van Dyk wrote:
>>
>>Think of the compiler as the interpreter, and templates as duck-typed Ruby.
>>Do as much as you can with meta-programming, since it should be comfortable
>>from a Ruby background. The rest... the rest is just syntax.
>>
>>} Joe
>>--Greg
>
>
> 1.  Templates (that aren't in the STL) scare me.

They shouldn't.  Read C++ Templates by Vandevoorde & Josuttis, and
you'll never want to delay anything until run-time again.

> 2.  I've looked at the source code for the Boost library and ran away screaming.

Most people do.  Boost is notoriously hard on compilers.  Most C++ code
does not look like Boost.  It does give you a tremendous amount of
functionality in one fell swoop, but you probably don't need it.

> 3.  If I did write code like that, then not many people in my group
> would be able to easily grok my code.  Perhaps they'll just need to
> bone up on the newest C++ stuff and read the requisite 8 books before
> touching my code.

1. You don't have to write code like that.

2. This "stuff" is not new.

3. Expecting the people who read your code to know the basics of the
language is not unreasonable, especially for such an incredibly
well-documented and standardized language.
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-03-01 22:49
(Received via mailing list)
On Mar 1, 2006, at 10:00 AM, Anthony DeRobertis wrote:

> template<> struct Factorial<1> {
>         static const int F = 1;
> };
>
> int main() {
>         std::cout << Factorial<5>::F << std::endl;
>         return 0;
> }
>
> Now that wasn't so scary, right?

Mine compiles faster:

#include <iostream>
int main( ) {
      std::cout << 120 << std::endl;
}
This topic is locked and can not be replied to.