Learning to program

CrazzyassCrazzyass Regular
edited February 2011 in Tech & Games
I have been interested in programming for a very long time and I feel like it would compliment my mechanical/electrical projects nicely, not to mention open up a whole new field to me.

I am currently a complete noob, more or less, when it comes to the field and so I was wondering if T&T had any recommendations for starting out and teaching yourself how to program.

Thank you!

Comments

  • duuudeduuude Regular
    edited January 2011
    What are you interested in doing?

    If your interested in web development HTML and JavaScript aren't hard to learn at all. I don't know PHP myself, but it doesn't look like it would be very challenging either.

    If your wanting to write applications and get jobs.. learning C++, Java, and Visual Basic would all be necessary.

    I've never used or tried to learn Ruby or Python myself, but I've constantly read about how user friendly they are and how easy they are to learn.

    You might want to start by researching and few languages and figuring out what you want to learn first.. then start checking for forums, tutorials, source code, etc. There aren't many coders here but I'm sure there are plenty of people who can share links or point you in the right direction.
  • thewandererthewanderer Regular
    edited January 2011
    There are tutorials for several different languages here
    http://www.w3schools.com/default.asp
  • CrazzyassCrazzyass Regular
    edited January 2011
    Serious thanks to both of you.

    To duuude: I somewhat want some general knowledge. Website design would be a great skill and designing my own apps would also be great, so I suppose both sides of that coin. Mostly I would like to be able to work with programmable machines and robots.
  • edited January 2011
    If you're looking to start web design and development then I can help you out. I know HTML, CSS and some basic PHP, alongside some MySQL for databases and whatnot. If you have some questions regarding this then feel free to ask.
  • CrazzyassCrazzyass Regular
    edited January 2011
    trx100 wrote: »
    If you're looking to start web design and development then I can help you out. I know HTML, CSS and some basic PHP, alongside some MySQL for databases and whatnot. If you have some questions regarding this then feel free to ask.

    I'd definitely be interested in learning a web design language or two.
  • edited January 2011
    Well, get started by learning some HTML. Then learn some CSS too which will help you style your HTML pages :)

    There are some fantastic tutorials on the following websites...

    http://www.w3schools.com/
    http://www.tizag.com/

    For anything else, give me a shout and I'll see what I can do.
  • CrazzyassCrazzyass Regular
    edited January 2011
    Thanks a ton, dude. Bookmarked. I'll start some learning.

    This should be a good introduction.
  • JBvenom777JBvenom777 New Arrival
    edited January 2011
    "Why's (poignant) Guide to Ruby"
    http://mislav.uniqpath.com/poignant-guide/book/chapter-1.html
    If you are interested in learning ruby, this is the book to read.
    This book also is a great place to start, as it helps you start thinking like a programmer. :)
  • KatzenklavierKatzenklavier Regular
    edited January 2011
    I recommend learning how to program an arduino. It's a c environment so it's easily adaptable to other c things, and that's a plus. You can also use it to control stuff irl, like a drunk santa doll. That's a plus too.

    Here's something I programmed a while back. It's a robot with an ultrasound eye, it turns when it's <15cm away from something.
    #include <[COLOR="DarkOrange"]Servo[/COLOR].h> [COLOR="Gray"]// include servo commands[/COLOR]
    
    [COLOR="Gray"]//variables and shit -----------------------------------------
    [/COLOR]
    [COLOR="DarkOrange"]Servo[/COLOR] rightwheel; [COLOR="Gray"]// make "rightwheel" a servo[/COLOR]
    [COLOR="DarkOrange"]Servo[/COLOR] leftwheel; [COLOR="Gray"]// make "leftwheel" a servo
    [/COLOR]
    const [COLOR="DarkOrange"]int[/COLOR] distance = 15; [COLOR="Gray"]// the robot's gonna turn if it's <15 cm from something [/COLOR]
    const [COLOR="DarkOrange"]int[/COLOR] pingPin = 11; [COLOR="Gray"]// set data pin[/COLOR]
    [COLOR="DarkOrange"]long[/COLOR] centimeters; [COLOR="Gray"]// initialize a variable [/COLOR]
     
    [COLOR="Gray"]//setup -----------------------------------------------------[/COLOR]
     
    [COLOR="DarkOrange"]void setup() [/COLOR]
    {
      rightwheel.[COLOR="DarkOrange"]attach[/COLOR](13); [COLOR="Gray"]// pin 13 is the right servo [/COLOR]
      leftwheel.[COLOR="DarkOrange"]attach[/COLOR](12); [COLOR="Gray"]// pin 12 is the left servo[/COLOR]
    }
    
    [COLOR="Gray"]//main loop ------------------------------------------------[/COLOR]
    [COLOR="DarkOrange"]
    void loop()[/COLOR]
    {
      getdistance(); [COLOR="Gray"]// get the distance from the ultrasound (subprogram)[/COLOR]
      [COLOR="DarkOrange"]if [/COLOR](centimeters < distance)[COLOR="Gray"] // is the distance < 15cm? [/COLOR]
      { [COLOR="Gray"]// if <15cm[/COLOR]
        [COLOR="DarkOrange"]if[/COLOR] ([COLOR="DarkOrange"]random[/COLOR](2) == 1) [COLOR="Gray"]// flip a coin[/COLOR]
        { [COLOR="Gray"]// if heads [/COLOR]
          pivotright(); [COLOR="Gray"]// turn right (subprogram)[/COLOR]
        }
        [COLOR="DarkOrange"]else[/COLOR] [COLOR="Gray"]//if tails[/COLOR]
        {
          pivotleft(); [COLOR="Gray"]// turn left (subprogram)[/COLOR]
        }
      } 
      [COLOR="DarkOrange"]else[/COLOR] [COLOR="Gray"]// if >15cm[/COLOR]
      {
        goforward(); [COLOR="Gray"]// go straight (subprogram)[/COLOR]
      }
    }
    
    [COLOR="Gray"]//subprograms--------------------------------------------------------------------------------------[/COLOR]
    
    [COLOR="DarkOrange"]void[/COLOR] goforward() 
    {
      leftwheel.[COLOR="DarkOrange"]write[/COLOR](180); 
      rightwheel.[COLOR="DarkOrange"]write[/COLOR](0); 
    }
    
    [COLOR="Gray"]//-------------------------------------------------------------------------------------------------[/COLOR]
    [COLOR="DarkOrange"]void[/COLOR] pivotright()
    {
      [COLOR="DarkOrange"]do[/COLOR] [COLOR="Gray"]// this until...[/COLOR]
      {
        getdistance();
        leftwheel.[COLOR="DarkOrange"]write[/COLOR](180); 
        rightwheel.[COLOR="DarkOrange"]write[/COLOR](180);
      } [COLOR="DarkOrange"]while[/COLOR] (centimeters < distance); [COLOR="Gray"]//...until measured distance > 15cm[/COLOR]
    }
    
    [COLOR="Gray"]//--------------------------------------------------------------------------------------------------[/COLOR]
    [COLOR="DarkOrange"]void [/COLOR]pivotleft() 
    {
      [COLOR="DarkOrange"]do[/COLOR] [COLOR="Gray"]// this until...[/COLOR]
      {
        getdistance();
        leftwheel.[COLOR="DarkOrange"]write[/COLOR](0);
        rightwheel.[COLOR="DarkOrange"]write[/COLOR](0);
      } [COLOR="DarkOrange"]while [/COLOR](centimeters < distance); [COLOR="Gray"]//...until measured distance > 15cm[/COLOR]
    }
    
    [COLOR="Gray"]//-------------------------------------------------------------------------------------------------[/COLOR]
    [COLOR="DarkOrange"]void [/COLOR]getdistance() [COLOR="Gray"]//gets the distance from ultrasound[/COLOR]
    {
      [COLOR="DarkOrange"]pinMode[/COLOR](pingPin, [COLOR="DarkSlateBlue"]OUTPUT[/COLOR]); [COLOR="Gray"]// set data pin to output[/COLOR]
      [COLOR="DarkOrange"]digitalWrite[/COLOR](pingPin, [COLOR="DarkSlateBlue"]LOW[/COLOR]); [COLOR="Gray"]// send 0 to the ultrasound[/COLOR]
      [COLOR="DarkOrange"]delayMicroseconds[/COLOR](2);
      [COLOR="DarkOrange"]digitalWrite[/COLOR](pingPin, [COLOR="DarkSlateBlue"]HIGH[/COLOR]); [COLOR="Gray"]// send a 1 to the ultrasound[/COLOR]
      [COLOR="DarkOrange"]delayMicroseconds[/COLOR](5);
      [COLOR="DarkOrange"]digitalWrite[/COLOR](pingPin, [COLOR="DarkSlateBlue"]LOW[/COLOR]); [COLOR="Gray"]// send a 0 to the ultrasound[/COLOR]
      [COLOR="DarkOrange"]pinMode[/COLOR](pingPin, [COLOR="DarkSlateBlue"]INPUT[/COLOR]); [COLOR="Gray"]// set data pin to input[/COLOR]
      centimeters = [COLOR="DarkOrange"]pulseIn[/COLOR](pingPin, HIGH); [COLOR="Gray"]// measure time it takes to get a 1 back from the sensor, (time it takes to echo)[/COLOR]
      centimeters = ((centimeters/ 29) / 2); [COLOR="Gray"]// convert that time to centimeters via math[/COLOR]
    }
    

    Best friend. http://www.arduino.cc/en/Reference/HomePage
  • edited January 2011
    When starting with web-development and design (yes, they are actually two different things) you should look at getting yourself some web-server software, which makes the whole thing a shit load easier.

    If you're running Windows, download and install Wampserver. It's an Apache webserver with PHP and MySQL installed already.

    If you're on Linux, then check out my tutorial on setting up a webserver.

    Also, you're going to want a decent program in which you can write your code. Forget all that Dreamweaver bullshit and download Notepad++. It's an open source text editor which supports many different programming languages, and should help you out a lot.

    Good luck!
  • LSA KingLSA King Regular
    edited January 2011
    trx100 wrote: »
    If you're looking to start web design and development then I can help you out. I know HTML, CSS and some basic PHP, alongside some MySQL for databases and whatnot. If you have some questions regarding this then feel free to ask.


    From my experience I think this is the way to start if you're a complete n00b like me. I started out doing HTML 10 years ago when the net was still young, fresh, and easy. Moved quickly into Javascript and CSS because you quickly realize how limited HTML is (lol) that you have to. PHP was still kind of new, a little confusing but not as bad as JS it seemed so I never got into it and I'm now trying to pick up some SQL/Database programming since that will probably benefit me the most in my career. I've forgot a lot of shit I once knew though, that's the problem with programming in general. If you don't use it you will lose it over time and in large chunks.

    I've tried a half dozen beginner Java, C#, C, C++ books and it seems to move from very basic and detailed as to what's happening, then out of nowhere shit just goes in directions you can't keep up with or at least in my case. I wish I was a kid where I had the time, energy, and will to sit around and play with shit but as an adult time is critical and I find it very hard to keep up trying to learn it all now. Maybe someone can offer me tips as well as to how they fully picked up programming, routes taken, etc.
  • edited January 2011
    I've forgot a lot of shit I once knew though, that's the problem with programming in general. If you don't use it you will lose it over time and in large chunks.

    Oh god man, fucking this.

    I go through phases of wanting to code and not wanting to code. This happens over large periods of time, so I'll often stop for a few months and then come back to it later on. I end up forgetting a whole load of it, although it's easier to pick up again second time around.

    Keep it up, especially if you're new to it. Otherwise you'll forget it all.
  • duuudeduuude Regular
    edited February 2011
    Speaking of which, I might start reading a Python guide.
  • SlartibartfastSlartibartfast Global Moderator -__-
    edited February 2011
    For a total beginner I always tell people to "muck about with bash/batch scripts" and glue things together.

    It's a scripting 'language' so no compiling and you get instant results.
  • edited February 2011
    duuude wrote: »
    Speaking of which, I might start reading a Python guide.

    I never managed to get my head around python. Well, I started up using it and thought something like "this is retarded" and just gave up there and then.
  • CrazzyassCrazzyass Regular
    edited February 2011
    trx100 wrote: »
    When starting with web-development and design (yes, they are actually two different things) you should look at getting yourself some web-server software, which makes the whole thing a shit load easier.

    If you're running Windows, download and install Wampserver. It's an Apache webserver with PHP and MySQL installed already.

    If you're on Linux, then check out my tutorial on setting up a webserver.

    Also, you're going to want a decent program in which you can write your code. Forget all that Dreamweaver bullshit and download Notepad++. It's an open source text editor which supports many different programming languages, and should help you out a lot.

    Good luck!

    Thanks man. I downloaded the stuff you recommended. I'm hoping I'll be able to look over some of this stuff tonight sometime.
  • edited February 2011
    Oh yeah, and one more thing! If you want to share your website with your friends then you should look into port-forwarding your HTTP port (port 80) on your router. This will allow people to view your website if you send them your IP address. If you're not going to do that then just leave the port closed - Wampserver will run just fine, but locally.
  • CrazzyassCrazzyass Regular
    edited February 2011
    trx100 wrote: »
    Oh yeah, and one more thing! If you want to share your website with your friends then you should look into port-forwarding your HTTP port (port 80) on your router. This will allow people to view your website if you send them your IP address. If you're not going to do that then just leave the port closed - Wampserver will run just fine, but locally.

    Good to know. I'm a little ways off from that, haha, but I will remember that when I get there.

    I'm just now getting the hang of html. :facepalm:
  • edited February 2011
    Awesome. If you need any help at all then give me a shout or post in this thread - there are a few people on &T who know this sorta stuff.
Sign In or Register to comment.