Jump to content

Recommended Posts

Posted

So I've decided to pickup coding, and I've decided to start with Python. I'll go ahead and say that I have zero experience. I've messed around with BASIC back in the 80's and QBASIC about 10 years ago, but never got to far. I have a year to kill in Afghanistan, so I might as well do something productive. I've been playing around with linux operating systems on and off for about 10 years as well. I'm thinking about going to school for something in the computer science / security field when my time in the Military is up.

Alright so anyways, I'm looking for some good literature for beginners. I downloaded "Dive into Python" but it's a little to fast for my taste and assumes you already know a good deal about programming. Downloadable (free) books is mostly what I'm after since mail takes about a month and sometimes it's difficult to get online out here.

Any help would be greatly appreciated! Thanks!

  • 2 weeks later...
Posted

Try this http://couch.it/K4SzyQ4k/. If you can manage to watch YouTube out there, the Richard Buckland videos are a really great way to learn the basics of the C programming language (upon which Python was based). Once you have a bit of an idea about C, learning other languages (like Python) from books should be easier. Richard Buckland is actually a really good teacher and several people I know have learned to program by watching his lectures.

If you're in a hurry or can't get YouTube, try http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python_2.6.

Posted

I hate reading books, but this one book was written by a father and young son duo to make it easy to read with pictures and stuff and exercises to do like program games, ect.. It was really easy to read for me, all in simple terms, I highly recommend it for anyone wanting to learn Python or getting into programming (and hate reading thick books with small words w/ a bunch of filler crap) it is here - http://www.amazon.com/Hello-World-Computer-Programming-Beginners/dp/1933988495 I also seen a ebook of it I think online one time maybe it was TPB or something, I bought mine though so I could read it at the beach or carry it around with me to read. It is really a awesome book to learn Python, you should check it out man.

Posted (edited)

Python is simple enough to learn. Only hard part of learning programming in NAY language is the syntax. Get down that "Grammar" and youll be fine

Edited by The Sorrow
Posted

Python is a great and powerful language. Reminds me of modula. Unfortunately, I can not get into the the tabbing (indenting) you have to do all the time. Drives me nuts. I guess I have become spoiled with free form languages. Cobol and Fortran were column conscious way, but have veered away from the structure. To be honest, I have been using a lot of freebasic to re-purpose a lot of qbasic code, I did years ago. It is a pain to set up, but once you do have it set up right, you can do so much including gui. The one thing I like about it most is how easy it is to interface with hardware without having to load special modules such as pyparallel and pyserial. Want to get into asm some too.

Posted

Python is a great and powerful language. Reminds me of modula. Unfortunately, I can not get into the the tabbing (indenting) you have to do all the time. Drives me nuts. I guess I have become spoiled with free form languages.

You don't indent code blocks in whatever language you're using? Indenting code blocks is a standard practice in all languages, even if just for readability.
To be honest, I have been using a lot of freebasic to re-purpose a lot of qbasic code, I did years ago. It is a pain to set up, but once you do have it set up right, you can do so much including gui. The one thing I like about it most is how easy it is to interface with hardware without having to load special modules such as pyparallel and pyserial.
Oh? On Linux you don't need to load any modules to access the serial or parallel port... but even still, is it really that hard to add an import line at the top of your file? How does freebasic do it?
Posted (edited)

Indenting is standard, but in python the tabs are used to show an end to a structure or loop. If you do not indent the code right your logic goes haywire. Hard to tell where things begin and end unless you are intimate with code. If you have done any maintenance programming you would understand why.

True you can easily add includes, but I find my code is more portable between systems. I.e. between Messywindoze and linux. It is so much easier, faster, and disk efficient to use compiled binaries on multiple linux systems. You do not have to have the libraries on all the machines. Even the C language you have to watch where the includes are: (i.e. sys/io.h vs asm/io.h)

Edited by inventoman
Posted

Indenting is standard, but in python the tabs are used to show an end to a structure or loop. If you do not indent the code right your logic goes haywire. Hard to tell where things begin and end unless you are intimate with code. If you have done any maintenance programming you would understand why.

This sound to me like a lack of a decent text editor. If you're using a text editor that displays whitespace (like Vim or Notepad++) and folds on indents you won't have any headaches about indentation or where blocks begin/end.

For Vim, just add this to your ~/.vimrc

set list listchars=tab:>-,trail:-
set foldmethod=indent

Also, to be clear, Python doesn't mandate the use of tabs. It requires that you indent, but you can use either tabs or spaces (and any number of spaces you like) as long as you are consistent within each block. By convention, most Python coders prefer four spaces.

True you can easily add includes, but I find my code is more portable between systems. I.e. between Messywindoze and linux. It is so much easier, faster, and disk efficient to use compiled binaries on multiple linux systems. You do not have to have the libraries on all the machines. Even the C language you have to watch where the includes are: (i.e. sys/io.h vs asm/io.h)

The standard libraries are standard. If you have the Python interpreter it's a safe bet you have the standard libraries as well. Most of the those libraries are portable across platforms as well (with obvious exceptions for OS-dependent features like Unix-permissions or forking). Your explanation doesn't make it clear to me how freebasic handles things any better than Python or C. If you want dependency-free code just compile it to a static binary.

BASIC, in nearly all of it's variants, is a syntactically and grammatically bankrupt language. I can't see why someone would choose to use it over alternatives unless they simply didn't know any better. If you have legacy code, write a shim or wrapper around it so you can make calls from more sophisticated languages.

Of course, learning BASIC is all well and good. I highly recommend it. However using it in production is generally ill-advised.

Posted (edited)

Generally with freebasic, I do not even have to use or remember what includes are required (not that I could not), so I just write the code, compile, and go. Besides it is real easy to tell where structures begin and end, so you are not having to gauge whitespace. Not sure that python does a true compile. Freebasic does(via C). If you know of a python compiler that does, Let me know.

Most of the systems I use are minimalistic in nature, so the closest I can get to compact disk usage then the better off I am. Once you compile code, it's all machine language anyway. Who cares what it is written in if it works. Elitist type elegant code does not impress me at all. Considering how bulky elitist code based gnome, mswindows, and the like are as they require insane amount of resources, they will economically bankrupt you, I will pass on them. Have done a lot of things in Basic that a lot of advanced programmers said were impossible. Do not get me wrong, One can code with whatever language they wish. I do frequently program in C among other high level languages,

Edited by inventoman
Posted (edited)

Generally with freebasic, I do not even have to use or remember what includes are required (not that I could not), so I just write the code, compile, and go.

You keep making this claim but not giving a clear explanation or showing demonstrative examples.

Besides it is real easy to tell where structures begin and end, so you are not having to gauge whitespace.

Again, you make it sound hard. It's not. The vast majority of developers are trained to indent whether the language cares or not.

This is like complaining that a language requires you to use text files instead of Word docs.

Not sure that python does a true compile. Freebasic does(via C). If you know of a python compiler that does, Let me know.

http://effbot.org/zone/python-compile.htm http://code.google.com/p/shedskin/

Of course, I'm not trying to argue that Python is "better" for creating native executables. But if that's your goal, there are still some better languages than BASIC available.

Most of the systems I use are minimalistic in nature, so the closest I can get to compact disk usage then the better off I am.

I'm not sure what you mean by this. See next post.

Once you compile code, it's all machine language anyway. Who cares what it is written in if it works.

It's not about what CPU sees, it's about the time and effort required to create and maintain the source code. Optimizing for the developers time, rather than the CPU time, because good compilers/assemblers will optimize for the CPU more efficiently than a human could.

Elitist type elegant code does not impress me at all. Considering how bulky elitist code based gnome, mswindows, and the like are as they require insane amount of resources, they will economically bankrupt you, I will pass on them.

I'm not sure what exactly you are referring to as 'elitist' here. I'm not advocating using Gnome or Windows. I never referenced them at all.

Have done a lot of things in Basic that a lot of advanced programmers said were impossible. Do not get me wrong, One can code with whatever language they wish. I do frequently program in C among other high level languages,

Impossible? Basic is Turing Complete so I have no doubt that it could do anything and everything that C can do. What's in question isn't whether or not it's possible but whether or not it's practical.

If you need native binaries there are, of course, C and C++... but also Objective-C, D, Go, Lisp (and family), Haskell, and Java (and a number of other JVM langs) via gcj.

Edited by Sitwon
Posted

Most of the systems I use are minimalistic in nature, so the closest I can get to compact disk usage then the better off I am.

So you use assembler a lot then?

because good compilers/assemblers will optimize for the CPU more efficiently than a human could.

I assume you meant "because good compilers will optimize for the CPU more efficiently than most humans could." There are still some times when a human with knowledge of the CPU/ machine architecture will be able to optimize a program for speed much better than a compiler. Of course this level of optimized code is not needed for most software, but for embedded systems can be critical.

Impossible? Basic is Turing Complete so I have no doubt that it could do anything and everything that C can do. What's in question isn't whether or not it's possible but whether or not it's practical.

This is a very good point that lots of people miss. The language you are using to write one sort of program may not be as suitable for a different type of program. I use Perl for data processing and quick prototyping. For writing a boot block I wouldn't use Perl though, I would use assembler (Probably FASM but that is just personal preference) as this would give me the level of control of the machine code produced that I would require.

Posted (edited)

I assume you meant "because good compilers will optimize for the CPU more efficiently than most humans could." There are still some times when a human with knowledge of the CPU/ machine architecture will be able to optimize a program for speed much better than a compiler. Of course this level of optimized code is not needed for most software, but for embedded systems can be critical.

Yes and no. Yes, it is possible for a person to create code that is more optimized than the compiler would have generated, but in the vast majority of cases they aren't more efficient at it. The difference in time and effort of optimizing and hand-tuning assembly code versus writing it in C and using the compiler's optimizations is staggering. It takes a very exceptional project to justify the added costs of all those man-hours.

Most of the systems I use are minimalistic in nature, so the closest I can get to compact disk usage then the better off I am.

After having some caffeine, reading Jason's post, and re-reading what you wrote I realized that I was parsing this sentence completely wrong before. (If everyone learned Lojban we wouldn't have these problems. :-P)

Ok, so you want to save on bits (at the expense of man-hours). Well I've pointed out that you have other options for compiling to native code. And I doubt you're getting smaller binaries from freebasic than you could get with 'gcc -Os'.

I'd still like to see some freebasic examples that demonstrate how it's easier than importing a module.

Edited by Sitwon
Posted

Yes and no. Yes, it is possible for a person to create code that is more optimized than the compiler would have generated, but in the vast majority of cases they aren't more efficient at it. The difference in time and effort of optimizing and hand-tuning assembly code versus writing it in C and using the compiler's optimizations is staggering. It takes a very exceptional project to justify the added costs of all those man-hours.

I can see where you are coming from now. I was reading it as "the compiler producing more efficient code" rather than "the compiler being more efficient at producing optimized code".

Having cleared that up, I agree :)

Posted

The best and or the fastest way to do anything is relative. Systems analysis should always be done before doing any programming. You do not need a jet to go down the street to the end of the block. A model "T" will do just fine.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...