Forum Settings
       
« Previous 1 2
Reply To Thread

ProgrammingFollow

#1 Feb 11 2012 at 11:52 AM Rating: Good
Drunken English Bastard
*****
15,268 posts
So next year as part of my degree one of the core modules is programming. I know nothing about programming, and I know a bunch of you guys do.

Could you give me a few tips and things? I'd like to learn some basics before going into the classroom and making myself look like a complete noob.


Or if you know of any good online resources, those could help too.


Thanks!
____________________________
My Movember page
Solrain wrote:
WARs can use semi-colons however we want. I once killed a guy with a semi-colon.

LordFaramir wrote:
ODESNT MATTER CAUSE I HAVE ALCHOLOL IN MY VEINGS BETCH ;3
#2 Feb 11 2012 at 12:04 PM Rating: Excellent
http://www.sthurlow.com/python/

Good low friction scripting language + beginner tutorial to get you started.
#3 Feb 11 2012 at 12:14 PM Rating: Excellent
Meat Popsicle
*****
13,666 posts
BrownDuck wrote:

Good low friction scripting language + beginner tutorial to get you started.


I'll second that. A lot of the scripts we use around the lab are in python. It's simple enough that even us non-programmer types can interact with it without too much difficulty.
____________________________
That monster in the mirror, he just might be you. -Grover
#4 Feb 11 2012 at 12:54 PM Rating: Excellent
*****
13,251 posts
What language is the programming in, Nil? In the engineering program I was enrolled in, we did a lot of MATLAB programming, with the use of Maple's toolbox.
#5 Feb 11 2012 at 1:27 PM Rating: Good
Drunken English Bastard
*****
15,268 posts
BrownDuck wrote:
http://www.sthurlow.com/python/

Good low friction scripting language + beginner tutorial to get you started.

Brilliant, thanks!


Sir Spoonless wrote:
What language is the programming in, Nil? In the engineering program I was enrolled in, we did a lot of MATLAB programming, with the use of Maple's toolbox.

My computer engineer friends use MATLAB. I'm not entirely sure what the Physics department use. I'll take a look.

Thanks, rate ups for everyone!
____________________________
My Movember page
Solrain wrote:
WARs can use semi-colons however we want. I once killed a guy with a semi-colon.

LordFaramir wrote:
ODESNT MATTER CAUSE I HAVE ALCHOLOL IN MY VEINGS BETCH ;3
#6 Feb 11 2012 at 1:30 PM Rating: Excellent
The All Knowing
Avatar
*****
10,265 posts
Good Tips for Programming:

1. Give your variables descriptive names: Instead of "x", use "current_balance". In small programs, "x" is sufficient, however, in larger programs, you'll quickly forget what "x","y" and "z" are. I learned that the hard way.

2. Use Comments! Everything makes sense while you're typing away, but don't be surprised when you come back and ask yourself "WTF is this?". Not only does it make it easier for you to remember, it helps your professor know what you're doing or attempting to do.

3. I don't think people actually use flow charts, but don't hesitant to think critically first with a pencil and paper. People program differently. Some like to "freestyle" and think and program at the same time. Others like to think first, write pseudo code first, then program. Find what works best for you and do that.

4. Keep your work! You never know when you might have to refer to something again.

5. Don't reinvent the wheel! There are often already defined methods/classes/ etc. out there. Before you attempt to define it yourself, check to see if one already exists. If you do, ensure that it works the way you intend it to work.

6. For some people, it is more efficient to program in blocks and/or sections. Instead of trying to solve the entire problem at once, break the problem into smaller problems.

7. Test by bits. Make sure you test your code in sections. In coding, if you have an error on line 2, the error might show up on line 40 based on a mistake on line 2. Testing in sections take extra time while coding, but it can save much more time at the end if you're looking for the problem
#7 Feb 11 2012 at 2:47 PM Rating: Excellent
Avatar
******
29,919 posts
If you are programming in any C derived language, It's always the ******* semicolon!
____________________________
Arch Duke Kaolian Drachensborn, lvl 95 Ranger, Unrest Server
Tech support forum | FAQ (Support) | Mobile Zam: http://m.zam.com (Premium only)
Forum Rules
#8 Feb 11 2012 at 2:50 PM Rating: Excellent
If your language has built in testing, then test as you go along.

I <3 you JUnit test. Smiley: inlove

As my Java prof said, writing up test code is annoying. But debugging code without the test code is infuriating.
#9 Feb 11 2012 at 3:02 PM Rating: Good
The All Knowing
Avatar
*****
10,265 posts
Dread Lörd Kaolian wrote:
If you are programming in any C derived language, It's always the @#%^ing semicolon!


This... and to clarify (if my memory serves me correctly), semicolons end statements. Even if you separate statements with spaces, without a semi colon, it will be read as one. Doing so, will more than likely cause an error.
#10 Feb 11 2012 at 3:08 PM Rating: Good
Also, thisIsCalledCamelCase.

youWillLearnToReadItEasily
#11 Feb 11 2012 at 3:16 PM Rating: Good
The All Knowing
Avatar
*****
10,265 posts
catwho wrote:
Also, thisIsCalledCamelCase.

youWillLearnToReadItEasily


I_Prefer_to_use_Underscores. However, you are correct, there are many variables that are written that way.

Your first program will probably be "Hello World".

http://en.wikipedia.org/wiki/Hello_World

#12 Feb 11 2012 at 5:21 PM Rating: Good
*
67 posts
Quote:
2. Use Comments! Everything makes sense while you're typing away, but don't be surprised when you come back and ask yourself "WTF is this?". Not only does it make it easier for you to remember, it helps your professor know what you're doing or attempting to do.


Quote:
5. Don't reinvent the wheel! There are often already defined methods/classes/ etc. out there. Before you attempt to define it yourself, check to see if one already exists. If you do, ensure that it works the way you intend it to work.


This is very good advice. Especially in classes, use both of these and a lot of coding time will be saved. The semi-colon in C languages are elusive beasts though.
#13 Feb 11 2012 at 5:35 PM Rating: Good
Keeper of the Shroud
*****
13,632 posts
It's been years since I did any real programming, so I'll just offer this as more of a warning than actual advice.

As someone around here put it rather well a while back, programming is like math with grammar. It's tedious and time consuming, but you can do some neat stuff if you know what you're doing.

Edited, Feb 11th 2012 6:41pm by Turin
#14 Feb 11 2012 at 6:10 PM Rating: Excellent
Avatar
******
29,919 posts
These are all good suggestions so far. Make note of them. A few more of my own.

1. Try programming. If you find it interesting though frustrating, stick with it. if you find it annoying or boring, it won't ever get better and get out of it as soon as you can. You either like programming, or you hate it, and it really depends on the structure of your brain and how you look at the world as to which type of person you are.

2. Figure out which program language you are going to be working with, and then look for a good editor. For example, the free micosoft visual studio express editions are a very good place to start. http://www.microsoft.com/express

Some people find that better tools help them program, others claim they like a basic text editor and any color coding or code tree management features distract them. I find that those latter people are idiots personally, so find the best tool you can get and start playing with it.

3. Do read up on the tutorials and the structure and "hello world" programs as you start and with your class, but also take a look at program samples. Do a search for whatever language you are working with, and look for code snippets and how people implemented things. you may not follow it all right away, and not all that you find will even be correct so you need to take them with a grain of salt, but I always found that was the best way to get an initial idea of how everything meshes together, and more importantly "why" some of these things that seem useless initially that they are trying to teach you are important later on.

4. writing comments in code isn't just to help you. Its also to help the person 10 years down the line who ends up updating your code figure out exactly what your thought process was.

5. structure is key. the more things you can make identical (column spacing, line spacing, variable capitolization, etc) the easier your job will be.

It really is always the ******* semicolon though
____________________________
Arch Duke Kaolian Drachensborn, lvl 95 Ranger, Unrest Server
Tech support forum | FAQ (Support) | Mobile Zam: http://m.zam.com (Premium only)
Forum Rules
#15 Feb 11 2012 at 6:52 PM Rating: Good
Dread Lörd Kaolian wrote:
4. writing comments in code isn't just to help you. Its also to help the person 10 years down the line who ends up updating your code figure out exactly what your thought process was.


However, those comments are completely useless if all they do is tell you the operations being performed. Code comments should never really explain the "how" (unless you're using some highly specialized algorithm that isn't easily comprehended), but should instead attempt to explain the "why".

Also, code comments should cover an entire block of code. For the love of God, NEVER comment each and every line of your code. NEVER.


Edited, Feb 11th 2012 7:06pm by BrownDuck
#16 Feb 11 2012 at 8:42 PM Rating: Excellent
BrownDuck wrote:
Dread Lörd Kaolian wrote:
4. writing comments in code isn't just to help you. Its also to help the person 10 years down the line who ends up updating your code figure out exactly what your thought process was.


However, those comments are completely useless if all they do is tell you the operations being performed. Code comments should never really explain the "how" (unless you're using some highly specialized algorithm that isn't easily comprehended), but should instead attempt to explain the "why".

Also, code comments should cover an entire block of code. For the love of God, NEVER comment each and every line of your code. NEVER.


An anecdote related to this.

For a long time, we used a modified version of EQDKP in my Dynamis group, that one of our members tweaked and turned into FFDKP. FFDKP served us well for four years, until suddenly in 2010, it totally stopped working.

Another person poked around the PHP code and found the following bit:

The inner guts of EQDKP wrote:
Error: (some PHP code crap here) Year must be equal to 2010 or less.
/**Ambitious, aren't we?*/


Considering EQDKP was put together in 1999, then yes. Ambitious it was.

Edited, Feb 11th 2012 9:42pm by catwho
#17 Feb 12 2012 at 12:57 AM Rating: Good
Muggle@#%^er
******
20,024 posts
I enjoyed programming--haven't done any since AP Comp Sci in high school though, and that was only Java.
____________________________
IDrownFish wrote:
Anyways, you all are horrible, @#%^ed up people

lolgaxe wrote:
Never underestimate the healing power of a massive dong.
#18 Feb 12 2012 at 2:06 AM Rating: Excellent
*****
15,512 posts
Jesus fuck, keep track of all of your curly braces.

I hate curly braces so much
#19 Feb 12 2012 at 3:19 AM Rating: Excellent
****
4,901 posts
Programming is great fun. I started with BASIC on a TI-99 when I was 10 and have been hacking away ever since. Now people throw money at me to do it. It can be quite satisfying.

Anyway, I would think that you'll most likely be using Java or C# for your first language. They're good languages for getting your feet wet. You shouldn't have any problems finding tutorials and general tips like those mentioned above on the web.

But if you want a nickel's worth of free advice:

  • It may not seem like it at first, but getting the code to compile is the easy part. Just because it has compiled, doesn't mean that it's correct. Test your code early and test often.
  • Comment your code. This is paramount if you are going to go beyond intro to programming.
  • Incorporate units into your variable names if you're doing calculations: mass_kg, sampling_rate_mhz, elapsed_time_ms, etc. This implicitly comments your code and can help with debugging.
  • Debug assertions are the greatest programming tool ever.
  • Don't assume anything. The computer is incredibly stupid and only does what you tell it to do.
  • Pay attention to compiler warnings. In general (with default warning levels) they are usually pointing to a problem that will cause your program to not run correctly. (See previous item)
  • Learn to use the debugger for your environment. You can use it to step through execution of your code line-by-line and see the values of your variables and data as each instruction is executed. Familiarize yourself with breakpoints, watches, and the stack trace.
  • Be grateful you have a language with automatic garbage collection. You kids have it easy today.
____________________________
Love,
PunkFloyd
#20 Feb 12 2012 at 6:04 AM Rating: Good
Drunken English Bastard
*****
15,268 posts
Awesome. Thanks guys!

Bookmarking this thread, I'm going to get cracking soon. Hopefully I'll be a little ahead of the curve by next year. That being said, many of the guys in my class are about 5 years younger than me, and as I understand it they're taught basic programming at 15-16 in schools now.
____________________________
My Movember page
Solrain wrote:
WARs can use semi-colons however we want. I once killed a guy with a semi-colon.

LordFaramir wrote:
ODESNT MATTER CAUSE I HAVE ALCHOLOL IN MY VEINGS BETCH ;3
#21 Feb 12 2012 at 8:17 AM Rating: Excellent
Liberal Conspiracy
*******
TILT
The "?" sign can be used to mean PRINT

True story.
____________________________
Belkira wrote:
Wow. Regular ol' Joph fan club in here.
#22 Feb 12 2012 at 10:24 AM Rating: Excellent
Will swallow your soul
******
29,360 posts
Quote:
Learn to use the debugger for your environment. You can use it to step through execution of your code line-by-line and see the values of your variables and data as each instruction is executed. Familiarize yourself with breakpoints, watches, and the stack trace.


To expand on this just a bit:

Not all errors will be due to the raw code itself. I don't want to think about all the times I've sat with a developer watching him step through the code, having it complete flawlessly, only to have it fail in the real environment. This is where assertions and debugging messages can be incredibly useful.

Be aware of user environment variables for your more complicated, memory-intensive functions. If you need to choke back on the amount of resources your code can use at any given time, there are ways to do that. Certainly be aware of memory buffers (maybe not such an issue with more modern operating systems, but I wouldn't bet the farm on it).
____________________________
In a time of universal deceit, telling the truth is a revolutionary act.

#23 Feb 12 2012 at 6:05 PM Rating: Good
Lunatic
******
30,086 posts

However, those comments are completely useless if all they do is tell you the operations being performed. Code comments should never really explain the "how" (unless you're using some highly specialized algorithm that isn't easily comprehended), but should instead attempt to explain the "why".


No, the "how" is useful too. So is your sate of mind, what you ate for breakfast, what kind of garbage collection you think is "built in" to COBOL...anything really that helps "the next" guy unwind your fucking nightmare spaghetti nest of broken logic, pointers to nothing, and 1000 recursive loops that stand if for delays.

____________________________
Disclaimer:

To make a long story short, I don't take any responsibility for anything I post here. It's not news, it's not truth, it's not serious. It's parody. It's satire. It's bitter. It's angsty. Your mother's a *****. You like to jack off dogs. That's right, you heard me. You like to grab that dog by the bone and rub it like a ski pole. Your dad? Gay. Your priest? Straight. **** off and let me post. It's not true, it's all in good fun. Now go away.

#24 Feb 12 2012 at 9:16 PM Rating: Excellent
IDE's are nice and all, but I think everyone should start with a text editor and the command line/terminal.

Edited, Feb 12th 2012 9:18pm by Wint
#25 Feb 12 2012 at 9:19 PM Rating: Good
Wint wrote:
IDE's are nice and all, but I think everyone should start with a text editor and the command line.


Agreed, which is why I initially recommended python. A single script file is all that's required - no compilation or anything - so it's much more beginner friendly.
#26 Feb 12 2012 at 9:23 PM Rating: Excellent
*****
10,601 posts
Ruby. If you're going to learn a scripting language learn ruby. <3 irb.
____________________________
01001001 00100000 01001100 01001001 01001011 01000101 00100000 01000011 01000001 01001011 01000101
You'll always be stupid, you'll just be stupid with more information in your brain
Forum FAQ
« Previous 1 2
Reply To Thread

Colors Smileys Quote OriginalQuote Checked Help

 

Recent Visitors: 317 All times are in CST
Anonymous Guests (317)