![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#31 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
6.factorial is actually written and invoked as the integer method, factorial (6), right? While it's simple enough not to be too confusing, it's really merely cute and not an addition of power or even of ease. I don't mean to be recalcitrant about it, but it's precisely the sort of thing I'm talking about. You have to adapt a person to x.f() when the person is perfectly familiar with f(x), and adapt 'em for no real gain.
I'm not saying that Ruby is alone in this effort. I'm not enthralled by Python's use of the term, comprehension. I have to admit that it's accurate, at a stretch. Mostly, we mentally interpret "comprehension" as "an ability to understand the meaning or importance of something", even though there IS the definition, "the ability to give meaning to information". One could stretch that to Python's usage, but I think I would have cast about for more common terminology. (By the same token, I'd never have named the C++ thangy "reference" -- it effs up a perfectly good and widely-useful term )
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#32 | |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 646
Rep Power: 4
![]() |
Quote:
class Integer
def factorial
(1..self).inject(1) { |product, each| product * each }
end
endAll I can say is that I definitely understand where you're coming from. :p
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
|
#33 |
|
Newbie
|
I'd say C++, then Python. I guess I'm still sorta new to both, but I started on C++. It makes everything else so easy. As for OS, I perfer Mac OS X, because it's based off of unix, so it's the best of both worlds. Outside of that, Feodra or Ubuntu are good Linux distros.
__________________
Use the best: Linux for servers, Mac for graphics, Windows for Solitaire. |
|
|
|
|
|
#34 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Regarding Ruby and Python, I find, like DaWei did, that Python has a syntax that is more easily understandable. Ruby is more powerful than Python with its blocks and continuation support and whatnot, but you can see the Perl influences in Ruby that add messy ambiguity to the language. For instance, brackets are optional for function calls ("x.y z" is the same as "x.y(z)"), and returns are optional for methods (by default, the last object referenced is used).
Also, as DaWei points out, whilst blocks are powerful, they can also be difficult to understand. List comprehensions are less powerful, but more easily read by human beings. Ruby's object model, on the other hand, is very nice indeed, and seems a lot cleaner than Python's. You can also alter base classes like "string" in Ruby, which you cannot in Python (by design). Ruby's way of customising classes and objects seems more natural and less laboured than how Python achieves it: In ruby: foo = SomeClass.new
class <<foo
def extraFunction
"An extra function"
end
endfoo = SomeClass()
def extra_function(self):
return "An extra function"
foo.extra_function = extra_functionAs for which to use first, Python or C++, I'm for Python on the sole reason that it's easier to learn, and gives faster results to the beginning student. |
|
|
|
|
|
#35 |
|
Programmer
Join Date: Jun 2006
Location: New York
Posts: 43
Rep Power: 0
![]() |
yes i know this thread is a little old but whatever.
I've kept hearing about ruby and ruby on rails and how it was great and everything but I guess I haven't looked it over enough to find a reason to use it instead of python. Python to me is basically a new and improved, object oriented perl, and it doesn't force you to be object oriented like java does. You do whatever the hell you want. And the whitespace thing, I dont even notice that anymore. I like it as it forces you to write neat, readable code unlike that perl mess; there was actually a contest to see who could write the most unreadable perl code; forgot who created it... The best thing about it to me is it's polymorphism: i = ['3', '2', '1'] i = 'astring' i = {} i = aclass() i = 'whatever_friggin'_want' I started to learn c++ first, mostly everything else will seem easy after that and you'll appreciate python/ruby more. In the real world it works the same way, you have to be a coder(detail) for a while before becoming an analyst(abstraction). (you can also be datailed in python if you want, like I said it lets you do whatever you want)
__________________
It's not complex if you know what you're doing... |
|
|
|
|
|
#36 |
|
Hobbyist Programmer
Join Date: Oct 2005
Location: Ohio
Posts: 177
Rep Power: 0
![]() |
To tell you the truth I don't like either of them but if I had to go with one I'd choose C++.
|
|
|
|
|
|
#37 |
|
Programmer
Join Date: Jun 2006
Location: New York
Posts: 43
Rep Power: 0
![]() |
What language do you like then? (why?)
__________________
It's not complex if you know what you're doing... |
|
|
|
|
|
#38 | |
|
Hobbyist Programmer
|
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|