ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Suggesting good programmers you know would never work on Python is bizarre and then saying maybe some good programmers here might use it is insulting.
I took that to mean his more-skilled colleagues were biased against it, thereby preventing him from knowing any python programmers with skill. As in a situational confine. No need for offense based on your own reading of the statement; that's pretentious.
Kevin Barry
Click here to see the post LQ members have rated as the most helpful post in this thread.
Python has dynamic typing and can easily be used in an object oriented way. A huge plus in my mind.
Obviously it depends on the programmer whether they think object wise or procedural.
Suggesting good programmers you know would never work on Python is bizarre and then saying maybe some good programmers here might use it is insulting.
That puts a very different spin on it than what I actually said.
Quote:
Any language can be hard to follow if not well written and well documented.
...
if you write Python code in a well structured way and comment it well, it will be as readable as any language.
Obviously I agree. I think my statements already implied most of that.
But I think the language design is a big factor, especially when the programmer has less skill and/or motivation for writing well structured code.
I still think the design of Python leads you toward badly structured code, in contrast to the design of Java, which leads you toward well structured code.
In support of that idea, I have both my own understanding of the language features of many languages, and a bunch of anecdotal evidence from correcting the work of many other programmers. One programmer, whose work I corrected a lot, worked in both Python and C++, preferred Python and knew it much better than C++. His C++ work was shoddy, but his Python work was so much worse (an unstructured disaster that he could never understand himself even a few weeks after finishing any section). Another programmer worked in Java and C++, preferred Java and knew it better than C++. Her C++ was a similar quality to the first programmer I mentioned, while her Java code was almost OK. I've seen a lot more samples in various languages from various programmers that each work mainly in one language. Those all also support my observation that bad programmers make a worse mess in Python than in other languages, but that is not only just anecdotal evidence, it also lacks any control for the relative skill of the various bad programmers.
I know enough about programmers in general and about the effects of language design in general, to conclude that some good programmers are writing good code in Python. I have never actually looked at any good Python code, but I can still assume it exists.
That puts a very different spin on it than what I actually said.
In which case, I apologise to you.
I've never done any Java (never interested me as it produces slower programs than native code for my money), so I can't comment on it. I certainly find that I've seen some of the worst written code in C and C++. You can obfuscate that so much.
I will respectfully disagree about writing neat code in Python though.
I think I have a need to learn a programming language or similar, but I'm at a loss to know which one fits my needs well. ...
Some of the choices depend on the format of the files you want to textually manipulate. If, for example, they are .pdf files then probably "forget it", if they are OOo files then it's going to be tricky ...
Last edited by catkin; 12-13-2009 at 01:36 PM.
Reason: Didn't like it; better now
Whatever language you pick, learn how to code in a way that can be understood. "You mean I can name this object/method/variable just about anything? cool, let's go for pizza, popcorn and hotdog." I am guilty of this, name it anything, but make that anything descriptive of what the thing does!
I'd go with Perl; it's very good with text, even foreign langs and widechar situations. Note that the inventor Larry Wall is actually has an English degree, not a CS one.
The regex engine built-in to Perl is very powerful, in fact it's used by some other langs (see pcre: perl compat regex).
You'll need the Llama book as above to get started, then I recommend the Perl Cookbook http://oreilly.com/catalog/9780596003135; worth it's weight in gold and the following docs/tutorials http://perldoc.perl.org/ http://www.perlmonks.org/?node=Tutorials
search.cpan.org for a massive library of pre-written modules you can use and do get the Mastering Regular Expressions book http://regex.info/, avail in several langs as you can see.
Perl is actually compiled-on-the fly, so its pretty swift. Not quite as fast as C, but much easier to write, & waay faster thnn shell.
Explanation http://www.perl.com/doc/FMTEYEWTK/comp-vs-interp.html if you really want to know the details.
As mentioned above though, learning to program properly/clearly is your key need, in any language.
At the end of the day, it's your choice; maybe you should do a little work in a few of the langs recommended and see if they gel for you.
I'd go with Perl; it's very good with text, even foreign langs and widechar situations. Note that the inventor Larry Wall is actually has an English degree, not a CS one.
The regex engine built-in to Perl is very powerful, in fact it's used by some other langs (see pcre: perl compat regex).
You'll need the Llama book as above to get started, then I recommend the Perl Cookbook http://oreilly.com/catalog/9780596003135; worth it's weight in gold and the following docs/tutorials http://perldoc.perl.org/ http://www.perlmonks.org/?node=Tutorials
search.cpan.org for a massive library of pre-written modules you can use and do get the Mastering Regular Expressions book http://regex.info/, avail in several langs as you can see.
Perl is actually compiled-on-the fly, so its pretty swift. Not quite as fast as C, but much easier to write, & waay faster thnn shell.
Explanation http://www.perl.com/doc/FMTEYEWTK/comp-vs-interp.html if you really want to know the details.
As mentioned above though, learning to program properly/clearly is your key need, in any language.
At the end of the day, it's your choice; maybe you should do a little work in a few of the langs recommended and see if they gel for you.
You may be right, I didn't check. I know a big deal is made of the effect the English degree has on the design of Perl.
In either case, a good lang and prob good for this OP.
I was thinking Shell when I first read his post - why can't he just use the Shell?
A worthy comment. I've been using BASH for the last 6 years. I guess I assumed that was a "crude" or "inefficient" way of doing things. My code is like: do this, then do that, then do that, then finish.
Recently, I took up the study of LaTeX. I was extremely skeptical at first about it, thinking it would just be inefficient and a waste of time. But, after studying LaTeX for just a few months, I've written many of my own macros and now my work is much more organized and I can assemble lengthy and complicated documents in a very short time. I've come to see word processors as "crude" and "inefficient" tools for most of my work.
My current job affords me much time, which I intend to use for educating myself before returning to school. I thought maybe it was time to advance beyond the shell, but since that is unknown territory for me, I have no idea what new tools I will find there. I don't see any books named, "Natural Language Processing for the Unix Shell" or "Linguistics for BASH", so I assume I need to find myself something a little more powerful.
Anyway, I'm exploring everyone's suggestions closely. I notice if I type 'python' I'm dropped into a sort of shell, where I can type in various commands. Is this a "safe" sandbox in which I can test things out? I mean...can I accidently delete files and stuff from inside this?
I don't see any books named, "Natural Language Processing for the Unix Shell" or "Linguistics for BASH", so I assume I need to find myself something a little more powerful.
natural language processing is more advanced. you can either find a toolkit with commands that you can execute on the shell, or modules that can be used with languages such as Python or Perl. You can search the net for "Python natural language processing" or "Perl natural language processing" to see if you can find anything you like.
Quote:
Anyway, I'm exploring everyone's suggestions closely. I notice if I type 'python' I'm dropped into a sort of shell, where I can type in various commands. Is this a "safe" sandbox in which I can test things out? I mean...can I accidently delete files and stuff from inside this?
Python has a shell, believe it or not, if you don't want to use bash shell as your normal shell, you can use Python shell, although i don't see many do that. example from my screen
Code:
>>> import os
>>> os.getcwd()
'/home/images'
>>> os.mkdir("test") <--- shell: mkdir
>>> os.chdir("test") <--- shell: cd
>>> f=open("file","w") <--- shell echo "test" > file
>>> f.write("test"+"\n")
>>> f.close()
>>> for line in open("file"): <<---- shell: cat file
... print line
...
test
>>> os.listdir(".") <---- shell: ls *
['file']
>>> os.remove("file") <---- shell :rm file
>>> if not os.path.exists("file"): <---- shell: [ ! -f "file" ]
... print "file does not exists"
...
file does not exists
>>>
so you can see, files won't get deleted , unless you tell it to. !
Last edited by ghostdog74; 12-15-2009 at 05:13 AM.
I still think the design of Python leads you toward badly structured code
I think the design of Python doesn't lead you to any structure. It's what makes Python great for those who want to learn how to code and those who already know how to code. There's a balance here, which may or may not appeal to you depending on preferences: the relative freedom Python gives can easily lead to a coding mess but its freedom makes it also easier to structure in advance (or refactor when insight progresses).
Python allows me to freely mix procedural, functional and OO programming aspects or use global variables. Python invites to sit down and start coding without thinking first. I don't see that as weaknesses but I recognize pitfalls for sloppy coding.
It's all about coding standards, having them and applying them. Python's not like an old interpreter BASIC that almost tried to work against you if you tried to structure your work. But still, software design and coding is something one has to learn.
Given the question of the OP, I'd say Python is a valid suggestion: easy to learn, easy to use a general programming education, capable, useful for prototyping solutions AND still understandable after 6 months.
Last edited by Caesar Tjalbo; 12-18-2009 at 01:48 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.