LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 09-25-2006, 09:52 AM   #16
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 718

Rep: Reputation: 72

Hi.

You may wish to view the site 99 bottles, which has a solution to a single problem done in more than 1000 languages. Although I first noticed this today, it has been mentioned on LQ occasionally over the past few years; the number of languages has increased from those references.

The few I looked at seemed to be valid. Often each language has several variant solutions. Comments are often posted from friends and others ... cheers, makyo

http://www.99-bottles-of-beer.net/
 
Old 09-25-2006, 11:00 AM   #17
pankaj99
Member
 
Registered: Mar 2006
Location: India
Distribution: Fedora
Posts: 47

Rep: Reputation: 15
Quote:
Originally Posted by bulliver
5 minutes... here is a great introduction to Python for those who know how to program:
http://linux.duke.edu/~mstenner/free.../html/toc.html

The question is how long will it take you to unlearn all that C/C++ damage
There is nothing like C/C++
 
Old 09-25-2006, 12:00 PM   #18
vargadanis
Member
 
Registered: Sep 2006
Posts: 248

Original Poster
Rep: Reputation: 30
mayo chk this out:
http://www.99-bottles-of-beer.net/la...-perl-737.html

You will laugh...
Perl probably is not the best choice tough it is quite powerful for those who can solve 1 problem in 299 ways. I hope Perl6 will change this and introduce something new, something OOP and etc...
Somebody said that learning C and Python is not the same effort. Why not? I understan C but I do not know anything about Python. Is there any point in learning python if I can write the same program in C that is faster and maybe more secure?
Ok... I might change my mind if you list me some very important project fully written in python/perl/ruby.
I can give you some examples for C/C++:
Linux, Linux, Linux and Linux
 
Old 09-25-2006, 04:31 PM   #19
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 718

Rep: Reputation: 72
Hi, vargadanis.

Yes, and now you know why the set of rules for copying, etc. perl, is called the Artistic License

As for languages, as in other things -- the right tool for the right job. Even though there are many, many languages, you might not find the right one. That's one reason why Jon Bentley (among others) wrote about little languages in his book More Programming Pearls -- those languages that you create yourself for a restricted domain.
Quote:
Originally Posted by bulliver
And as for speed, don't get caught up in premature optimization.
Wise words, I think. It is inexpensive to throw hardware at problems these days. However, the real speedup for many problems is in the algorithm. Jon Bentley, in a different book, Programming Pearls 2nd, compared a TRS-180 running interpreted Basic to an Alpha 21164A running compiled C to solve a problem of a sum of a sub-sequence of integers. As you might expect, the Alpha running one obvious algorithm trashed (pun intended) the TRS-80 running a different algorithm -- or did it? At a problem size just above 1K, the TRS-80 started pulling ahead. At a size of 1M, the TRS-80 took 5.4 hours. The Alpha never finished, because an estimate was that it would take a touch over 19 years to complete ... cheers, makyo
 
Old 09-25-2006, 04:54 PM   #20
slantoflight
Member
 
Registered: Aug 2005
Distribution: Smoothwall
Posts: 283
Blog Entries: 3

Rep: Reputation: 35
Smile

Quote:
Originally Posted by vargadanis
Ok... I might change my mind if you list me some very important project fully written in python/perl/ruby.
omg! are you even really asking that question?!

I'll give you a hint.. its a protocol. Created/maintained by a python programmer. Accounts for 1/3 of internet traffic.

The best to thing to happen to the internet, since this very popular search engine thats uses python extensively.

Which happens to use a a certain modified commercial linux distro..
%30 of which is python.


You remind of me a fellow C programmer who says to me, "Well I have'nt ever seen python do anything useful."

It was all I could do to keep my jaw from dropping to the floor. I was considering him fairly knowledgable about computers. Until he said that ofcourse.

And perl...

Well you can barely visit a site anymore without getting smacked in the face by perl. You couldn't even really consider yourself a web programmer without knowing atleast a little bit of perl. Almost as bad as not knowing html.
 
Old 09-25-2006, 05:09 PM   #21
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86; Gentoo PPC; Gentoo Sparc64; FreeBSD; OS X; Solaris
Posts: 3,731
Blog Entries: 4

Rep: Reputation: 64
Quote:
Is there any point in learning python if I can write the same program in C that is faster and maybe more secure?
But one of the points of Python and other 'scripting' languages is the savings in human time, rather than machine time, of which human time is orders of magnitude more valuable. Computers are so fast these days that wasting days writing something in C that will save you only microseconds on the computer is just silly. You can write a functional app in Python in the same time it would take to write the function/class protoytpes in C++...

And I doubt your assertion that C is more secure. Seems to me that since C is way more low-level that it would afford you way more opportunities to write bad code, while Python/Ruby and Perl run in the relative safety of a VM.

And as for 'important projects' that is just daft. There are thousands. Start at python.org and click on 'who uses python'.
 
Old 09-26-2006, 10:45 AM   #22
vargadanis
Member
 
Registered: Sep 2006
Posts: 248

Original Poster
Rep: Reputation: 30
Ok... I agree now. I just really did not want to learn python. I do not know why I do not really like this language so far. But maybe you are right. I should not write everything in C. There is no point in...
 
Old 09-26-2006, 05:29 PM   #23
slantoflight
Member
 
Registered: Aug 2005
Distribution: Smoothwall
Posts: 283
Blog Entries: 3

Rep: Reputation: 35
Quote:
Originally Posted by vargadanis
I should not write everything in C. There is no point in...
You're right about that. You certainly wouldn't want to write everything in C, but make no mistake. Its still a very useful language to learn. Even if only for the purpose of extending higher level languages.
 
Old 09-26-2006, 05:34 PM   #24
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86; Gentoo PPC; Gentoo Sparc64; FreeBSD; OS X; Solaris
Posts: 3,731
Blog Entries: 4

Rep: Reputation: 64
Agreed. I did not want to give the impression that C/C++ is not worth learning, as it is, but generally these days it is not needed. Obviously it is one of the only choices when it comes to systems programming. For regular applications, you can prototype the app in Python or whatever, and if there are noticeable bottlenecks, you can rewrite that little bit in C and plug it into your original Python app.
 
Old 10-19-2006, 10:59 AM   #25
vargadanis
Member
 
Registered: Sep 2006
Posts: 248

Original Poster
Rep: Reputation: 30
Ok guy... I tought I inform you about my not important decision.
I decided to learn Perl. I tryied Python at first, but it seemed to be so unusual that I couldn't suceed with it. I am used to {} signes and things like that and Python seemed to be even harder to read and it is slower too.
I love Perl now, I have created my first gtk2-perl app and it is fast. Surprisingly fast. I wrote the same program in C to check the speed difference and I could hardly feel it. That is good.
There are 1mill libraries for perl so I can decide which to use so I am using the OO versions even thoug they are not std. I am trying to get myself used to OO so that I can learn C++ easier later. ^_^

Dani
 
Old 10-19-2006, 07:31 PM   #26
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5
Posts: 16,086

Rep: Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995
Yep, C => Perl transition is easy: almost the same syntax, nearly as fast (as mentioned above it's usually an algorithm prob if it's too slow), and easier to make secure because things like string handling are done for you.
The massive library at search.cpan.org is very useful.
You might find http://www.perlmonks.com/ useful if the qns get too obscure.
As has been mentioned many times in threads here, 'clean programming' is a matter of the programmer being disciplined, not the language. You can write unmaintainable/unreadable code in any lang (and i've seen a fair bit!)
 
Old 10-19-2006, 11:13 PM   #27
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 239Reputation: 239Reputation: 239
Quote:
Originally Posted by chrism01
As has been mentioned many times in threads here, 'clean programming' is a matter of the programmer being disciplined, not the language. You can write unmaintainable/unreadable code in any lang (and i've seen a fair bit!)
There are many "undisciplined" programmers too, how many i do not know, but there will be somehow..so if a programmer is "undisciplined", code may be hard to read too..many languages does not "enforce" discipline that much, but Python , in a way, does because it "forces" the programmer to indent properly with their spaces/tabs...if not , the whole script will not compile properly.

Just my $0.02
 
Old 10-20-2006, 12:01 AM   #28
vargadanis
Member
 
Registered: Sep 2006
Posts: 248

Original Poster
Rep: Reputation: 30
Ahha... I dunno.. I like massy code. Usually I am keen on finishing my work or I want to advance my knowledge so I do not pay that much attention on the source code itself. I have just now coded 450 lines of PHP and I am pretty sure nobody else will understand what and how but I do. I guess eveybody can understand their own scripts and what they wrote.
 
Old 10-20-2006, 01:40 AM   #29
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5
Posts: 16,086

Rep: Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995
Try looking at it again after 6 mths; you'll find it's (almost) as bad as having been written by another programmer.
If this is just for home/personal use, it's your choice.
If it's for anybody else, please layout properly... it might be me having to maintain it(!)
 
Old 10-20-2006, 02:12 AM   #30
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 239Reputation: 239Reputation: 239
Quote:
Originally Posted by vargadanis
Ahha... I dunno.. I like massy code. Usually I am keen on finishing my work or I want to advance my knowledge so I do not pay that much attention on the source code itself. I have just now coded 450 lines of PHP and I am pretty sure nobody else will understand what and how but I do. I guess eveybody can understand their own scripts and what they wrote.
like what chrism01 says, make sure the one maintaining your code knows what you are doing...I happen to maintain some perl,java codes when i took over the job, they were so messy i had a hard time reading , even though i know perl and java. I have since converted them to python, because 6 mths later, i don't want to refer to my books to know what some of those symbols means..
well..just my preferences...
 
  


Reply

Tags
language


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python or Perl drdroid Programming 29 12-22-2006 09:54 AM
perl vs python yenonn Programming 6 08-01-2006 05:44 AM
Perl or Python JJX Programming 4 04-17-2006 02:42 PM
Python or Perl? Boby Programming 2 06-12-2005 10:54 AM
Perl or Python JJX Programming 6 10-27-2004 03:58 AM


All times are GMT -5. The time now is 02:52 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration