Poll on Eval in Ruby.

  • Thread starter Kazimir Majorinc
  • Start date
K

Kazimir Majorinc

I am Lisp programmer and I write an article on
issues as macros, fexprs and eval. I want to
compare opinion of Ruby and Lisp programmers on eval.
Some readers might think that such post constitute
spam on Ruby newsgroup, but I believe that resulting
information will not be completely devoid of value
- even for Ruby community.

If you want to contribute few seconds, the poll is
on my blog, on the top of the right column.

http://kazimirmajorinc.blogspot.com

Thanks,
 
D

David Masover

I want to
compare opinion of Ruby and Lisp programmers on eval.
...
If you want to contribute few seconds, the poll is
on my blog, on the top of the right column.

http://kazimirmajorinc.blogspot.com

There wasn't an option for "Absolutely essential for the one time out of a
billion you actually need it. Otherwise, avoid it entirely."

I can't remember the last time I used eval directly in Ruby, and I've seen it
maybe once or twice in library code. I've also seen it abused by people who
really should know better. 90% of the time you find yourself reaching for eval,
you're Doing It Wrong. Another 9% of the time, you're working around a missing
language feature, and it'd be better to fix that feature, or at least bury your
use of eval deep in a library.

But there was the time I used Javascript on HD-DVD, which had many
limitations, including not having eval. And many of its other limitations
could've been worked around if there had been an eval. A simple example:
Downloading and executing code was complex and often disruptive -- eval
would've made it trivial.

So... I avoid languages that don't have eval. But I avoid using eval in the
languages I use. Does that make sense?
 
K

Kazimir Majorinc

So... I avoid languages that don't have eval. But I avoid using eval in the
languages I use. Does that make sense?

It has, David. I think it is, lets say,
developed form of "useful but overused"
opinion.
 
D

David Masover

It has, David. I think it is, lets say,
developed form of "useful but overused"
opinion.

Well, except that I'm not making any statement about how people use it,
because I don't know. The few examples I've found don't point to any sort of
systemic overuse -- if there's a language feature, someone has found a way to
abuse it.
 
L

lith

If you want to contribute few seconds, the poll is
on my blog, on the top of the right column.

Are we talking about

a = 'foo'
b = 'a + "bar"'
eval "'yummy ' + #{b} * 2"

or about

class A
def initialize
@x = "foo"
end
end

A.new.instance_eval {@x}
 
J

Jesús Gabriel y Galán

Are we talking about

=A0 =A0a =3D 'foo'
=A0 =A0b =3D 'a + "bar"'
=A0 =A0eval "'yummy ' + #{b} * 2"

or about

=A0 =A0class A
=A0 =A0 =A0 =A0def initialize
=A0 =A0 =A0 =A0 =A0 =A0@x =3D "foo"
=A0 =A0 =A0 =A0end
=A0 =A0end

=A0 =A0A.new.instance_eval {@x}

I thought we were talking about all eval version (eval, instance_eval,
class_eval, etc) so I answered the one that was "has it's place" or
something like that.

If we are talking exclusively about pure eval, I agree with David, I
almost never use it.

Jesus.
 
K

Kazimir Majorinc

THE RESULTS OF THE POLLS
========================

.. Lisp Python Ruby

Eval is evil,
harmful or at
least unnecessary 2 (4.9%) 7 (21.9%) 0 (0.0%)
----------------------------------------------------------
Eval is useful
but overused 11 (26.8%) 6 (18.8%) 9 (29.0%)
----------------------------------------------------------
Eval has just the
right place 16 (39.0%) 10 (31.3%) 19 (61.3%)
 

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,142
Messages
2,570,818
Members
47,362
Latest member
eitamoro

Latest Threads

Top