Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Ruby or Python?
Index -> General Programming
Goto page Previous  1, 2, 3, 4  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
wtd




PostPosted: Sat Dec 08, 2007 11:32 am   Post subject: Re: RE:Ruby or Python?

McKenzie @ Sat Dec 08, 2007 11:00 pm wrote:
Oops, minor mistake. These Python for loop need range():

Python:
code:

  for i in 1..range(n):


Quite right. Thanks for catching that.
Sponsor
Sponsor
Sponsor
sponsor
Geminias




PostPosted: Sat Dec 08, 2007 1:24 pm   Post subject: Re: Ruby or Python?

What I gather is Scheme/LISP can be used to produce elegant solutions in select cases. But, given the lack of large scale applications created with this language, it appears I was correct that Scheme has a syntax that creates mental hurdles, which makes code harder to maintain. Can we all agree on that?

EDIT: By the way have any of you actually studied software engineering or do you think that because you can write complex one-lined code that no one else can figure out you are brilliant coders?

From an engineering perspective my opinions are justified. You don't need to be a guru of a language to point out that it's syntax can cause maintainability issues.
Naveg




PostPosted: Sat Dec 08, 2007 1:56 pm   Post subject: RE:Ruby or Python?

You're missing the point. To anyone who knows scheme, the brackets make perfect sense. In fact, I've always been of the opinion that brackets make things clearer - in almost any language. I've never been a fan of memorizing operator precedence tables, for example, when I can just avoid any possible problems by using more brackets.
gvc




PostPosted: Sat Dec 08, 2007 2:06 pm   Post subject: ~

Geminias @ Sat Dec 08, 2007 1:24 pm wrote:
What I gather is Scheme/LISP can be used to produce elegant solutions in select cases. But, given the lack of large scale applications created with this language, it appears I was correct that Scheme has a syntax that creates mental hurdles, which makes code harder to maintain. Can we all agree on that?



Definitely not. The examples in this thread are bogus, as are the Scheme solutions, as is the assumption that no large software projects are written in Lisp/Scheme.

Here's an excerpt from an email I received the other day from the former CTO of a company that was sold for 1.3 billion dollars:

http://groups.google.com/group/uw.cs.cs241/browse_thread/thread/6d1f732e0a6faf1e#858fd6e11b5caa6d

Draw your own conclusions. As for printing "hello" three times:

(define (print-hello x)
(printf "hello ~a\n" x)
(printf "hello ~a\n" x)
(printf "hello ~a\n" x))

To print n times.

(define (print-hello x n)
(cond ((> n 0)
(printf "hello ~a\n x)
(print-hello (- n 1)))))

I'll leave it as an exercise to you to figure out the printf codes
to line up the output. You don't seriously think that that is a
reason for selecting a particular language?

The point about Scheme is that the core language is extremely
simple and precisely defined. You can do anything you want in
the core language, and there are libraries for every conceivable
hacker-type thing you might want to do, like writing a web server
or a video game or whatever.

Python, Ruby and the like have a complicated set of builtin stuff
that make writing *certain* problems simple, aren't themselves
necessarily easy to understand or to apply to non-trivial problems.

Now two of my examples that you can feel free to translate so
as to show us how Ruby or Python trivializes them.

(1) trivial example: read 3 integers and print their sum

(+ (read) (read) (read))

(2) less trivial example: the compiler prototype for cs241 at Waterloo

http://www.student.cs.uwaterloo.ca/~cs241/a09/wlgen.ss

here's a Java version if you prefer

http://www.student.cs.uwaterloo.ca/~cs241/a09/WLGen.java
gvc




PostPosted: Sat Dec 08, 2007 2:25 pm   Post subject: Scheme textbook

You can dowload Dr. Scheme here: http://www.plt-scheme.org/

Follow the link "How to design computer programs" to find an on-line copy
of the introductory text that is used at Waterloo. It assumes no programming
experience and teaches both Scheme and Computer Science from scratch.

If you already know how to program you can read the first dozen chapters
fairly quickly but you should read them as Scheme requires a different
mind-set from what you might have acquired by learning other languages.
PaulButler




PostPosted: Sat Dec 08, 2007 3:28 pm   Post subject: Re: Ruby or Python?

Geminias @ Sat Dec 08, 2007 1:24 pm wrote:
What I gather is Scheme/LISP can be used to produce elegant solutions in select cases. But, given the lack of large scale applications created with this language, it appears I was correct that Scheme has a syntax that creates mental hurdles, which makes code harder to maintain. Can we all agree on that?


I provided a few examples of successful, large LISP apps that I knew of, which I think is enough to show that it is possible to write a LISP app of that scale (existential proof?). If you require evidence that lots of people are using LISP, you aren't going to find it, because LISP just isn't that common. So if you want to use popularity as a measure of how good a language is, LISP will not be that appealing.

I will admit that Scheme/LISP does add mental hurdles. But these mental hurdles didn't scare me away from learning Scheme, because I recognized them as the same sort of hurdles that I encountered when I went from BASIC to C (no GOTO? How do I program without GOTO?) and C to Java/C++ (object-oriented programming).

Geminias wrote:

EDIT: By the way have any of you actually studied software engineering or do you think that because you can write complex one-lined code that no one else can figure out you are brilliant coders?


I am in CS at UWaterloo, as are at least a few of the others in this discussion. I never claimed to be a brilliant coder, but writing complex one-lined code that no one can read is a skill I have acquired and am quite proud of Razz.

Geminias wrote:

From an engineering perspective my opinions are justified. You don't need to be a guru of a language to point out that it's syntax can cause maintainability issues.


Maybe not a guru, but having some experience in it would help your case rather than just deciding that it is unmaintainable based on ugly syntax. LISP is known for being more expressive than imperative languages, at least in some cases. I don't know a whole lot about real-world maintainability (do you?), but it would seem to me that in theory less code would mean more maintainable code.
wtd




PostPosted: Sat Dec 08, 2007 5:11 pm   Post subject: Re: ~

gvc @ Sun Dec 09, 2007 3:06 am wrote:
The examples in this thread are bogus


They are trivial, yes. But I like to keep early stuff small so it's easy to fit into a student's brain.

A series of small victories, leading to something larger is perhaps the best way to look at my approach.
Geminias




PostPosted: Sat Dec 08, 2007 6:55 pm   Post subject: RE:Ruby or Python?

Grr.. I hate when people mutilate my sentences. Or perhaps you are too young to know that "lack of" does not mean "none". If i had meant no large scale applications have been created with Scheme I would have said something to the effect of: "No large scale applications were created in Scheme." Yes my tone is condescending right now, so feel free to be pissed off cause you're an idiot! (Does not apply to those who know what 'lack of' means.)

To be fair, I can't with certainty say that Scheme code is less maintainable than: insert_language_name_here. Because for one thing there are far less programmers who use Scheme than C.

However, there isn't exactly an overwhelming amount of large scale (and successful) applications written in Scheme as I already pointed out...

I agree I can always learn more about Scheme and perhaps I underestimate it's usefulness, but after writing my own emacs extensions in LISP I always had the sense that I was lost when I read through the Emacs source code. I don't think any amount of knowledge is going to convince me that Scheme has a syntax as conducive to maintainability as python and even C. I suppose Scheme is a step up from IA32 assembly but I'd still place it in between asm and C in terms of how easy it is to write maintainable code.

Well, that's my two cents anyway. Note I never said nothing could change my mind, its just I doubt anything will.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Sat Dec 08, 2007 7:31 pm   Post subject: RE:Ruby or Python?

Do not mistake the complexity of an API (which is what Emacs LISP amounts to) for inherent complexity of the core language. I am not familiar with Emacs LISP, so I suspect that if I were to just jump into it, I'd feel rather lost as well.

Keep in mind that Scheme and Lisp programmers work from a somewhat different frameset than programmers in other languages. Typically, a programmer takes a problem and breaks it down to a point where it can be expressed in the desired programming language.

A Lisper frequently builds up the language to a point where it is more convenient to express the solution for the given program. You'll hear the term "domain specific languages" thrown around. Scheme and Lisp's syntax is highly flexible, lending it to this kind of customization.
PaulButler




PostPosted: Sat Dec 08, 2007 8:32 pm   Post subject: Re: RE:Ruby or Python?

Geminias @ Sat Dec 08, 2007 6:55 pm wrote:
Grr.. I hate when people mutilate my sentences. Or perhaps you are too young to know that "lack of" does not mean "none". If i had meant no large scale applications have been created with Scheme I would have said something to the effect of: "No large scale applications were created in Scheme."


I never denied that there is a lack of LISP/Scheme applications. In fact, I outwardly admitted it when I said "If you require evidence that lots of people are using LISP, you aren't going to find it [...]". Instead, I argued that there were enough examples of applications that worked to show that these languages can be used on a large scale. Again, if you want evidence that a lot of people are using these languages, you will not find it. If you are choosing languages by popularity, LISP and Scheme don't even make the list.

Geminias wrote:

Yes my tone is condescending right now, so feel free to be pissed off cause you're an idiot! (Does not apply to those who know what 'lack of' means.)


A condescending tone and personal attacks don't bother me coming from someone who has never met me, if you think it helps you get the point across. But I would disagree with you there as well.

Geminias wrote:

To be fair, I can't with certainty say that Scheme code is less maintainable than: insert_language_name_here. Because for one thing there are far less programmers who use Scheme than C.

However, there isn't exactly an overwhelming amount of large scale (and successful) applications written in Scheme as I already pointed out...


There are many more C programmers than Schemers. If that is what matters for you, by all means, go with C. Picking food by the same criteria would get you McDonald's.

(I'm not comparing C with McDonald's; C is a useful language)

Geminias wrote:

I agree I can always learn more about Scheme and perhaps I underestimate it's usefulness, but after writing my own emacs extensions in LISP I always had the sense that I was lost when I read through the Emacs source code. I don't think any amount of knowledge is going to convince me that Scheme has a syntax as conducive to maintainability as python and even C. I suppose Scheme is a step up from IA32 assembly but I'd still place it in between asm and C in terms of how easy it is to write maintainable code.

Well, that's my two cents anyway. Note I never said nothing could change my mind, its just I doubt anything will.


If you want to avoid Scheme, it's none of my business. I just don't like seeing someone tell beginners not to learn a certain language that they have never used because they don't like the syntax.

It's more fun to defend LISP without resorting to quoting Paul Graham, but some people might be interested in an essay of his called Beating the Averages.
Geminias




PostPosted: Sat Dec 08, 2007 9:30 pm   Post subject: RE:Ruby or Python?

Quote:
Do not mistake the complexity of an API (which is what Emacs LISP amounts to) for inherent complexity of the core language.


Yes this is always the truth. But I know I'm not the only one who gets lost in brackets.


Quote:
A Lisper frequently builds up the language to a point where it is more convenient to express the solution for the given program. You'll hear the term "domain specific languages" thrown around. Scheme and Lisp's syntax is highly flexible, lending it to this kind of customization.


This is the best point I've heard so far. Paul Butler raised some good points and so did a few others. I take back my advice about not learning Scheme. I find the syntax of Scheme disagreeable, but I cannot suggest a replacement language, therefore I'm forced to concede I gave bad advice. Thanks to all who helped change my mind Smile
MrHippo




PostPosted: Sun Dec 09, 2007 1:54 am   Post subject: Re: Ruby or Python?

Well thanks for the advice (though it did get a bit off-topic =P)

I decided to focus on Ruby for now simply because I want to be able to participate in the CCC and that doesn't give me much time to fiddle around with 3 (or even 2) languages at once.
Not sure if Ruby is the best choice, but it's better than sitting and thinking which one to choose hehehe...

Thanks again!

-MrHippo
McKenzie




PostPosted: Sun Dec 09, 2007 1:26 pm   Post subject: Re: Ruby or Python?

I know you've made your "final" decision, but if it is the CCC you are focused on, I would strongly suggest Python. It breaks a number of problems. A few quick reasons:
- eval
- list comprehensions
- basic functional programming
- translation tables
- automatic handling of "big" integers

I really don't know enough Ruby to judge how good it would be for CCC problems. Also keep in mind that CCC stage 2 only allows C/C++ and pascal.
wtd




PostPosted: Sun Dec 09, 2007 1:32 pm   Post subject: RE:Ruby or Python?

Assuming that "translation tables" means "associative arrays", then yes, Ruby does all of these things very well. It also takes functional programming seriously, whereas the Python leadership seems determined to remove it from future implementations.
MrHippo




PostPosted: Sun Dec 09, 2007 3:15 pm   Post subject: RE:Ruby or Python?

Hehe I'm really not worried about stage 2. I doubt I could get good enough to beat 2000 other people in 2 months... Don't even know if that's possible starting from no knowledge of computers (at a comp. sci. level)

Python and Ruby seem similar at a glance though..
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 3 of 4  [ 50 Posts ]
Goto page Previous  1, 2, 3, 4  Next
Jump to:   


Style:  
Search: