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

Username:   Password: 
 RegisterRegister   
 A few things you should know going in...
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
wtd




PostPosted: Thu Jan 08, 2009 3:31 am   Post subject: A few things you should know going in...

So you want to learn to program? Well, there are a few things you should know about first, and if you don't, that doesn't mean you should just give up on programming. Instead it just means you have a bit of catch up work to do.


  • File systems - you need to understand a few things about files.

    • Extensions - understand how extensions work, particularly the ways that Windows can hide extensions from you. Be aware of at least several common file extensions.
    • Directories - understand how directories can be created and navigated. Understand how copying and pasting directories around in a GUI shell works.
    • Filepaths - understand absolute and relative filepaths.
    • Hidden files - understand what that leading dot in a file name indicates on a great many systems, and how to see hidden files.
    • . and .. - understand what these represent and how they are useful for navigation.
    • Permissions - understand at least Unix-style read/write/execute and owner/group/world permissions.

  • Command-lines - you need to know about the command-line.

    • Navigation - understand the basics of filesystem navigation in a command-line, including listing directory contents, changing directory and printing the current directory.
    • How to call programs - understand how to call programs, how to pass arguments and options to them.
    • Variables - understand how to define variables in a command-line shell, and how to use them later on.

Sponsor
Sponsor
Sponsor
sponsor
Roman




PostPosted: Tue Jan 13, 2009 4:22 pm   Post subject: RE:A few things you should know going in...

I've recently started exploring the command line, and I'm curious: what advantages does using the command line hold over using a GUI? I know it's a valuable skill to learn, and in a sense that is enough. However, are there any practical reasons as well?

Note: I'm not claiming it's useless or impractical. I'm curious as to what those practical uses may be.

-RZ
Unforgiven




PostPosted: Tue Jan 13, 2009 4:35 pm   Post subject: Re: RE:A few things you should know going in...

Roman @ Tue Jan 13, 2009 4:22 pm wrote:
I've recently started exploring the command line, and I'm curious: what advantages does using the command line hold over using a GUI? I know it's a valuable skill to learn, and in a sense that is enough. However, are there any practical reasons as well?

Note: I'm not claiming it's useless or impractical. I'm curious as to what those practical uses may be.

-RZ


Power. You can do things on the command line, especially in terms of automation, you can't do with any GUI without it getting unreasonably complex. Also, some very useful programs just don't have a GUI, and when you add one, they lose flexibility. When you start working at a shell like Bash or any other decent one, you can start piping together commands, and from very simple pieces make very flexible and useful things that you just can't do with a GUI.
DemonWasp




PostPosted: Tue Jan 13, 2009 4:39 pm   Post subject: RE:A few things you should know going in...

There are many, many ways that CLI's triumph over GUIs. Certainly, a GUI is more intuitive and easier for new users, but CLIs are more useful for a lot of advanced tasks.

Automation is a huge benefit to the CLI. Let's assume you want to do something to every file in a directory. With a GUI, depending on how it's set up, you may have to do the same thing manually, over and over, for every file in the directory. With the CLI, you can just tell it to do that to /some/directory/* , and it'll go off and do that while you get some more coffee.

The command-line is very well-defined in what it does, whereas GUIs are not. While you can be reasonably assured that a given control will do more or less what you expect, you often find that someone has decided the button would work better if only it would do a lot of other random stuff. With CLI programs, there's generally a help message to tell you exactly what's going on (try command -h or man command depending on the OS).

In the command-line, if you don't feel like typing a super-long command, you can just alias it to "whatever". Then, when you next type "whatever", the system automatically substitutes the long-command.

In general, anything the GUI can do, the CLI can do to. The reverse is not true - there's a lot you can do through the CLI that there's simply no GUI for.
Unforgiven




PostPosted: Tue Jan 13, 2009 4:40 pm   Post subject: RE:A few things you should know going in...

One minor thing to add to the first point on the original list, about extensions - also know that really, extensions are meaningless. Calling a text file file.png doesn't magically make it an image, and as far as I know, Windows is the only OS dumb enough to assume it is based on the last three letters of the name. File extensions are just a convenient way to sort of make a note about the contents (after all, for example, your source code is plain text, but you don't save it as a filename.txt, do you?).
Roman




PostPosted: Tue Jan 13, 2009 10:39 pm   Post subject: RE:A few things you should know going in...

Ooh I sort-of understand. Well... theoretically anyways. I guess overtime as I use it more I'll discover the usefulness of such features. Right now I'm mainly using...
cd
ls
cat (ocassionaly)


Does this CLI(CLI?) vs. GUI have anything to do with why people say Linux is better than Windows?
wtd




PostPosted: Tue Jan 13, 2009 10:53 pm   Post subject: RE:A few things you should know going in...

Well, the command-line on Windows is largely an afterthought, which makes a programmer's job harder.

Does that make Linux better than Windows? Depends on how useful you find the CLI.
DemonWasp




PostPosted: Wed Jan 14, 2009 9:08 am   Post subject: RE:A few things you should know going in...

The CLI is one of Linux's great strengths over Windows...and also one of its failings. The reason for this is that if you know what you're doing, the CLI (command-line-interface, as opposed to graphical user-interface) is very useful and powerful. If you're new to the machine, you have no idea how to use a CLI, but a GUI is generally much easier to learn, which is why relying on the CLI for configuration and installation in Linux tends to be daunting to users used to point-and-click mechanics.

As wtd says, the CLI on Windows is a trimmed-down set of commands from the days of DOS, and it's sorta-emulated now. It lacks the power, versatility, and documentation of the CLI found in Linux, BSD and other UNIX derivations.
Sponsor
Sponsor
Sponsor
sponsor
chrisbrown




PostPosted: Wed Jan 14, 2009 9:39 am   Post subject: RE:A few things you should know going in...

Use of the command line is much like writing your own programs. There are probably graphical tools out there that perform the task you are trying to solve, but it will inevitably be bundled with a bunch of crap you'll never need. On the other hand, (in Linux, at least), a few well-thought out commands at the terminal can usually accomplish the same task- in much less time than would take to find and install the graphical version.

Quick example: say you have a shared media folder and want to move mp3's to a Music folder and .mpg's to Video: Instead of cut and paste, (or any mouse interaction whatsoever), you need only enter
code:

mv *.mp3 Music
mv *.mpg Video

What's more, you could easily save that as a script called, say, organize, and then reuse it when the media folder gets messy again by entering
code:

organize

for the same effect.
Insectoid




PostPosted: Wed Jan 14, 2009 1:19 pm   Post subject: RE:A few things you should know going in...

That's definitely going to be useful for organizing my code, methodoxx. Just out of curiosity, how do I set a script to execute via the command line, other than just adding #/usr/whatever to the top?

Must I adjust the you/group/world read/write/execute properties? Or is there a simple way? (I'm on mac, but as it's *nix, it should work the same)
DemonWasp




PostPosted: Wed Jan 14, 2009 2:39 pm   Post subject: RE:A few things you should know going in...

You need to have this line at the top of the file:

#!/bin/sh

it may be different on a Mac, but probably shouldn't be. If you have bash, change it to

#!/bin/bash

Then you need to set the execute flag for your user (at the very least, maybe for everyone depending on your needs). Assuming it's just you, use:

chmod u+x somefile
Tony




PostPosted: Wed Jan 14, 2009 5:37 pm   Post subject: RE:A few things you should know going in...

alternatively you can execute a script specifying the interpreter yourself
code:

/bin/whatever ./filename

(if your PATH is set properly, you wouldn't need /bin/ part)

Your user needs to have proper rights, but if those are not set, you could throw in a sudo
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: