Computer Programming

Post here if you need help with the forum, getting files to work or have questions/tips about popular software (Photoshop, bit torrent, media players, etc.)

Moderators: The Dream, devious_sos, SOStmohs, YukiPwns00

Computer Programming

Postby ~Spark~ » Sun Mar 11, 2012 12:59 am

print "Hello Word!" (<- First thing most people learn with Python)

So yeah, I've been learning Python lately.
I thought it'd be nice to have a topic to discuss computer programming since I have seen a few people here that know about it. :desho:

I'm currently still a major noob, I only started learning how to interact with file this week XD

So to get the ball rolling, which language do you use/prefer?
ImageImage
Standard activities on-board the Stealth-Ship
Credit to Johnxfire & Saywhat? for sigs
User avatar
~Spark~
Stealth Ship Crew Member
 
Posts: 4482
Joined: Sun Aug 01, 2010 6:42 am
Location: Canada

Re: Computer Programming

Postby kFYatek » Sun Mar 11, 2012 1:14 am

I generally prefer C++, because it's a powerful language that allows you to use many advanced paradigms that save time once you get used to them, and for the speed of program execution. I wouldn't recommend it to any kind of beginner, though, because it requires you to know exactly what you are doing, or fail miserably.

When it is preferable to deliver acceptable quality while minimizing time and frustration (well, in practice - it's usually like that) Java is what I would suggest. It is nowhere near powerful as C++ (or other languages like Lisp or Ruby, which are also very powerful in different ways), but being simple and clean is exactly what is its strength - less features mean less things to learn, and less ways to fail. It also guards you against some of the common mistakes.

As you can guess, I'm a big proponent of statically typed languages, which is not too popular opinion, but that's how it is. I believe that static typing not only executes faster, but also helps discover (and fix) bugs earlier.
Image
User avatar
kFYatek
SOS Brigade Leader
 
Posts: 1131
Joined: Sun Jan 08, 2012 12:58 pm
Location: Kraków, Poland

Re: Computer Programming

Postby ~Spark~ » Sun Mar 11, 2012 6:38 am

When I was picking language to learn I almost picked C++ as my primary since I heard a lot of god stuff about it, and if I remember correctly, lots of Windows is written with it.
I think I might learn it later on when I have hopefully advanced.
I don't really know much about the difference between static and non-static(No sure that's the right term) languages.
I'm guessing one changes as it does stuff and the other does not? :huh:

BTW, how does Python compare to C++?
ImageImage
Standard activities on-board the Stealth-Ship
Credit to Johnxfire & Saywhat? for sigs
User avatar
~Spark~
Stealth Ship Crew Member
 
Posts: 4482
Joined: Sun Aug 01, 2010 6:42 am
Location: Canada

Re: Computer Programming

Postby Veganzombie » Sun Mar 11, 2012 4:18 pm

Im going to do a course or try to do it this coming September that does programming ^^ it only covers java and HTML but i hope to do programming in university so who knows what they do there! i hope its C++ but that would be a nightmare! :lol: oh well i like challenges!
Image
User avatar
Veganzombie
SOS Brigade Lieutenant
 
Posts: 255
Joined: Fri Jan 20, 2012 9:25 pm
Location: Synapse

Re: Computer Programming

Postby develoore » Sun Mar 11, 2012 4:37 pm

I work as a PHP programmer now so it pretty much defines what language I'm good at. I loved doing C++ before, we also learned C# back in secondary school.
I need to start learning Java as soon as possible, because my next job is entirely in Java. :lol:
On a side note when we had Pascal in our school I was only there on the first and last lesson, but did a perfect mark, and I learned BASIC in like... 20 minutes?
Image
User avatar
develoore
SOS Brigade Consultant
 
Posts: 141
Joined: Wed Jan 18, 2012 1:24 am
Location: Somewhere in the EU

Re: Computer Programming

Postby kFYatek » Sun Mar 11, 2012 5:44 pm

~Spark~ wrote:I don't really know much about the difference between static and non-static(No sure that's the right term) languages.

Dynamic typing is when you can assign anything to any variable. Like, you have some variable called, for example, a, and you can write (I hope this is correct Python syntax):
Code: Select all
a = 10
a = "some text"
a = 3.14
a = [5, 1, 8]

Here, a is first an integer, then a string, then a floating-point value, and finally a list. And it is the same variable all the time.

With static typing, you cannot do that, as every variable (and function/method argument, and so on) has a strictly specified type. So, when you declare a as a string, you cannot assign a number to it (or, in some cases, it will automatically get converted to a string.

~Spark~ wrote:BTW, how does Python compare to C++?

Python is a dynamically typed language, while C++ is statically typed. Also, C++ is much more low-level, which means that you can write code that does really bad things and it is harder to find bugs in them. But it also executes faster. Python's dynamic typing also mean that some of C++'s features would be meaningless in it, like templates or conversion operators.

Also, C++ is a so-called curly bracket programming language. In Python, blocks of code are specified by indentation, and statements are separated from each other with a newline. In C++ (and C, Java, C#, Perl, PHP and many other languages), indentation and newlines are purely aesthetic, and statements are terminated with semicolons, and grouped in blocks using curly brackets {}. For example:

Python:
Code: Select all
if i == 10:
    print("Hooray!")
    print("i equals 10")
else:
    print("i does not equal 10 :(")


C++:
Code: Select all
if (i == 10) {
    puts("Hooray!");
    puts("i equals 10");
} else
    puts("i does not equal 10 :(");

The same code can be written on a single line like:
Code: Select all
if (i == 10) { puts("Hooray!"); puts("i equals 10"); } else puts("i does not equal 10 :(");

The else block doesn't need to be put in curly brackets because it's just a single statement. But remember, it is almost always a good practice to consistently indent your code, regardless of whether the language enforces it or not.

develoore wrote:I loved doing C++ before, we also learned C# back in secondary school.
I need to start learning Java as soon as possible, because my next job is entirely in Java.

If you learned C# before, you'll feel at home. The syntax is almost identical in those two languages, AFAIK the APIs are also somewhat similar. You'll just have to learn the naming conventions and so on.
Image
User avatar
kFYatek
SOS Brigade Leader
 
Posts: 1131
Joined: Sun Jan 08, 2012 12:58 pm
Location: Kraków, Poland

Re: Computer Programming

Postby johnxfire » Sun Mar 11, 2012 5:58 pm

Just a suggestion, try learning C first. It's a really really really good base for everything else.
Image
La tristesse durera toujours.
User avatar
johnxfire
Melancholic
 
Posts: 9402
Joined: Mon Jan 24, 2011 2:40 pm
Location: Dreaming.

Re: Computer Programming

Postby kFYatek » Sun Mar 11, 2012 6:24 pm

I'm going to be a traditionalist and suggest learning Pascal before C or C++. It is a language rarely used for anything else than teaching programming nowadays, but it is easier to learn than C/C++, protects the programmer from more common errors (eg. have checked arrays, no pointer arithmetic and no default conversions), enforces more good practices, while still being fairly low-level and allowing to grasp the principles.
Image
User avatar
kFYatek
SOS Brigade Leader
 
Posts: 1131
Joined: Sun Jan 08, 2012 12:58 pm
Location: Kraków, Poland

Re: Computer Programming

Postby ~Spark~ » Wed Mar 14, 2012 1:19 am

:shock: So many languages to learn.
I guess I'll get around to learning Pascal sometime soon...

Meanwhile, I was finally able to make another advance in Python today :cheer:
I've been able to rename files with this:
Code: Select all
import os
os.rename ("Example.jpg", "nope.jpg")

But I haven't been able to actually open them normally just to look at XD
Until today
Code: Select all
import os
os.chdir (r'C:\Documents\morefilepath')
os.startfile ("Example.jpg")

:cheer3:
Not sure if that is the best way to do it, but it worked. It also seems to work in opening folder in explorer.
So I wrote this program to test:
Code: Select all
password = raw_input ("Password: ")
if password == "testing123":
    loop=1
    choice=0
    while loop==1:
      print "Hello, where would you like to go?"
      print "Your choices are:"
      print " "
      print "1) Python folder"
      print "2) End"

      choice=input ("I Choose: ")
      if choice==1:
          import os
          os.startfile ("C:\Documents and Settings\Administrator\My Documents\Python")
      elif choice==2:
              loop=0

else:
    print ("Try again")
    password = raw_input ("Password: ")

Some advise/constructive criticism would be great ^^
ImageImage
Standard activities on-board the Stealth-Ship
Credit to Johnxfire & Saywhat? for sigs
User avatar
~Spark~
Stealth Ship Crew Member
 
Posts: 4482
Joined: Sun Aug 01, 2010 6:42 am
Location: Canada

Re: Computer Programming

Postby kFYatek » Wed Mar 14, 2012 1:43 am

You shouldn't really do things like import os in the middle of program. You should do it at the beginning of the program.
Image
User avatar
kFYatek
SOS Brigade Leader
 
Posts: 1131
Joined: Sun Jan 08, 2012 12:58 pm
Location: Kraków, Poland

Next

Return to Computer Club Corner

Who is online

Users browsing this forum: No registered users and 1 guest

cron