Starting programming

Talk about computers, hardware, applications, and consumer electronics.
dreams slip through our fingers like hott slut sexxx
Posts: 3896
Joined: 2009.01.14 (15:41)
NUMA Profile: http://nmaps.net/user/Tunco123
MBTI Type: INTJ
Location: Istanbul

Postby Tunco » 2009.07.07 (19:35)

MattyMc13 wrote:
EdoI wrote:I was working with Game Maker.
If you are interested in game programming, then I suggest flash, as that would be a good start. There is these video tutorials somebody found for me and they make it easier to learn it. I also agree with you about Game Maker.
Flash? You mean Adobe Flash CS4 Professional?

That's too much starters. And personally I wouldn't give 699.99$ to Fl CS4 Pro. if I was a starter in programming.
spoiler

Image


User avatar
Albany, New York
Posts: 521
Joined: 2008.09.28 (02:00)
MBTI Type: INTJ
Location: Inner SE Portland, OR
Contact:

Postby jean-luc » 2009.07.16 (04:14)

You might look in to Python. it's not going to do anything as perhaps exciting as Game Maker, but it's fairly easy to learn, it's useful for all kinds of things, and it's similar to so many other programming languages.
Some people are uncomfortable with whitespace-sensitivity (where indentation is actually part of the programing language), and it's rare. Python is whitespace-sensitive, so you might consider another language that isn't. PHP is very similar to C, and thus very similar to other languages that are very similar to C (C and it's variants, Perl), and quite easy to learn. Get the command-line interpreter, so you don't need to deal with the web side of things.

If you're really new to programming, a lot of people recommend fooling around with something like Scratch (scratch.mit.edu) that will introduce you to programming logic without you having to worry too much about syntax.
-- I might be stupid, but that's a risk we're going to have to take. --
Image
Website! Photography! Robots! Facebook!
The latest computers from Japan can also perform magical operations.

User avatar
Retrofuturist
Posts: 3131
Joined: 2008.09.19 (06:55)
MBTI Type: ENTP
Location: California, USA
Contact:

Postby t̷s͢uk̕a͡t͜ư » 2009.07.16 (07:11)

jean-luc wrote:Some people are uncomfortable with whitespace-sensitivity
And these people are retards. That's such a trivial thing to condemn a language for, for starters. It makes your code look cleaner, prevents you from writing code that reads like a Perl hack, and I think is an excellent way of building good code formatting habits for beginners. And what does it take away, exactly? A greater freedom to write functional Python poetry, the ability to outsmart yourself, and the job security of being the only person who can debug your own code?
[spoiler="you know i always joked that it would be scary as hell to run into DMX in a dark ally, but secretly when i say 'DMX' i really mean 'Tsukatu'." -kai]"... and when i say 'scary as hell' i really mean 'tight pink shirt'." -kai[/spoiler][/i]
spoiler

Image


User avatar
Bayking
Posts: 315
Joined: 2008.10.01 (20:26)
NUMA Profile: http://nmaps.net/user/exuberance
Location: Guelph, Ontario, Canada

Postby Exüberance » 2009.07.16 (13:46)

EdoI wrote:Obviously, I'll need Notepad for this.
Might I recommend jEdit? You can tab or un-tab multiple lines, have multiple files open in different tabs, choose your own syntax highlighting for probably hundreds of languages, and the very usefull bracket matching feature. That will be usefull when coding in Python or C... or any language that doesn't come with it's own IDE.

I got started into programming with Game Maker (which I still use sometimes. That thing was pure awesomeness), which introduced me to programming logic and a very very very very basic idea of object oriented programming.

Then I moved onto Flash Actionscript 2.0 in which I learned about object-oriented programming. Since I was teaching myself Flash by reading the documentation, it took me a while to figure out pointers, but when I realized what was happening, it made arrays make a lot more sense... and I could do things I couldn't before!

After that I learned Scheme, a functional language, in my first term of University which was completely different than any other langauge I'd seen.

Then I moved onto C++ (again in University. Not on my own) where Flash`s NaN is replaced with the even more infuriating segfault. Fun fun... Well that tought me about memory management and efficiency. It also lets me write doom applications which would probably destroy early versions of Windows. Heheheh.

You could also throw the bit of Java I learned in highschool somewhere in there along with Flash but... highschool programming really didn`t teach me anything except the idea of inheritance, which I would`ve figured out in Flash anyways.

I have yet to try Python.... I`ll get around to it... sometiSEGMENTATION FAULT
ExüberNewsFeed: Exuberance is mostly <AFF> (Away From Forums) for a while, though I may still participate in epic contests/threads. When I return, I shall bring several comic updates (enough to finish season 1) and hopefully 1 or 2 games- at least one of which is N-related
Comic Activity-O-Meter: (how often I'm updating my comic)
(Click here to see what each level and half-level means in terms of updates per time period)

NOTE: If I just add a bunch of comics in one day, but plan on going back to normal after that, I probably won't update the status.
+ Dead: Canceled. Done. Maybe you'll get a random comic like once a year, but it's pretty much done.
- Zombie (Dead/Comatose): The comic is probably done regular updates forever, but I'll probably still add something once in a blue moon. It's still POSSIBLE, that I'll raise the status up, but not very likely. Maybe I'll have a comicplosion for like a week, then go back to being dead
+ Comatose: Complete stand-by. No (or very few) updates for some amount of time, but the comic's far from being over
- <AFK> (Comatose/Loitering): Stand-by, but you might possibly count on a few updates once and a while. Again, this is temporary
+ Loitering: Like comatose, but for short amount of times.
- Turtling (Loitering/Semi-Active): Really slooooww updates
+ Semi-Active: One every 2 weeks...ish?
- Quasi-Active (Semi-Active/Active): Averaging about 2 comics every 3 weeks
+ Active: Loosely defined status, but about a weekly update
- Over-Active (Active/Power-leveling): About 2 comics a week
+ Power-leveling: About 3 comics a week. Possible a schedule, possibly not
- Über-Epic (Power-leveling/COMICPLOSION!!): In some cases, this may actually be mean updates more frequently than COMICPLOSION!!, but I'm defining this level as a non-organized comic rush, kind of like a few days after my comic started
+ COMICPLOSION!!: Daily updates for a minimum of 5 days (since the daily updates started. It remains at this status until the 5, 7, whatever days are done)

Image
"Science without religion is lame. Religion without science is blind." ~Albert Einstein
My N+ Vector Sprite Sheet ::: My Caption Contest ::: My Comic :::Puzzles of the Exuberant ::: DEFEND YOUR NINJA: THE FLASH GAME (Release Date TBA)
Image
Exüberance on WoW
Image
Maps in the Fernat Epic (so far): (meh, let's put this in a spoiler too. My sig's gettin too big. I'm such a packrat :p)

Nmaps.netNmaps.net


User avatar
Retrofuturist
Posts: 3131
Joined: 2008.09.19 (06:55)
MBTI Type: ENTP
Location: California, USA
Contact:

Postby t̷s͢uk̕a͡t͜ư » 2009.07.16 (21:01)

Exuberance: I'm flirting with Haskell. You should try it. It's "fun".
[spoiler="you know i always joked that it would be scary as hell to run into DMX in a dark ally, but secretly when i say 'DMX' i really mean 'Tsukatu'." -kai]"... and when i say 'scary as hell' i really mean 'tight pink shirt'." -kai[/spoiler][/i]
spoiler

Image


User avatar
Albany, New York
Posts: 521
Joined: 2008.09.28 (02:00)
MBTI Type: INTJ
Location: Inner SE Portland, OR
Contact:

Postby jean-luc » 2009.07.18 (19:27)

Tsukatu wrote:
jean-luc wrote:Some people are uncomfortable with whitespace-sensitivity
And these people are retards. That's such a trivial thing to condemn a language for, for starters. It makes your code look cleaner, prevents you from writing code that reads like a Perl hack, and I think is an excellent way of building good code formatting habits for beginners. And what does it take away, exactly? A greater freedom to write functional Python poetry, the ability to outsmart yourself, and the job security of being the only person who can debug your own code?
Although my wording did not portray this, my point was more that Python is dissimilar to most languages in that respect. So, if you want to develop a general programming skill, it might be better to start with a language like PHP that is syntactically similar to many languages (since a huge number of languages are also C-style, and PHP uses the whitespace-insensitive explicit blocking that you'll find in the vast majority of languages).
-- I might be stupid, but that's a risk we're going to have to take. --
Image
Website! Photography! Robots! Facebook!
The latest computers from Japan can also perform magical operations.

User avatar
Retrofuturist
Posts: 3131
Joined: 2008.09.19 (06:55)
MBTI Type: ENTP
Location: California, USA
Contact:

Postby t̷s͢uk̕a͡t͜ư » 2009.07.18 (23:27)

jean-luc wrote:
Tsukatu wrote:
jean-luc wrote:Some people are uncomfortable with whitespace-sensitivity
And these people are retards. That's such a trivial thing to condemn a language for, for starters. It makes your code look cleaner, prevents you from writing code that reads like a Perl hack, and I think is an excellent way of building good code formatting habits for beginners. And what does it take away, exactly? A greater freedom to write functional Python poetry, the ability to outsmart yourself, and the job security of being the only person who can debug your own code?
Although my wording did not portray this, my point was more that Python is dissimilar to most languages in that respect. So, if you want to develop a general programming skill, it might be better to start with a language like PHP that is syntactically similar to many languages (since a huge number of languages are also C-style, and PHP uses the whitespace-insensitive explicit blocking that you'll find in the vast majority of languages).
PHP is the great Satan. I'm heavily against beginners getting used to the amateur bullshit PHP encourages you to do.
[spoiler="you know i always joked that it would be scary as hell to run into DMX in a dark ally, but secretly when i say 'DMX' i really mean 'Tsukatu'." -kai]"... and when i say 'scary as hell' i really mean 'tight pink shirt'." -kai[/spoiler][/i]
spoiler

Image


User avatar
Albany, New York
Posts: 521
Joined: 2008.09.28 (02:00)
MBTI Type: INTJ
Location: Inner SE Portland, OR
Contact:

Postby jean-luc » 2009.07.19 (05:57)

Tsukatu wrote:
jean-luc wrote:
Tsukatu wrote: And these people are retards. That's such a trivial thing to condemn a language for, for starters. It makes your code look cleaner, prevents you from writing code that reads like a Perl hack, and I think is an excellent way of building good code formatting habits for beginners. And what does it take away, exactly? A greater freedom to write functional Python poetry, the ability to outsmart yourself, and the job security of being the only person who can debug your own code?
Although my wording did not portray this, my point was more that Python is dissimilar to most languages in that respect. So, if you want to develop a general programming skill, it might be better to start with a language like PHP that is syntactically similar to many languages (since a huge number of languages are also C-style, and PHP uses the whitespace-insensitive explicit blocking that you'll find in the vast majority of languages).
PHP is the great Satan. I'm heavily against beginners getting used to the amateur bullshit PHP encourages you to do.
I find myself highly skeptical of the idea that PHP encourages bad style and technique. PHP is very freeform, and I think it allows you to do things wrong more than many other languages, but good behavior is also made easier.
I think PHP is definitely the easiest C-style language. it's interpreted, and it's not the sheer hell that Perl is. PHP's typeless variables and high willingness to convert implicitly mean that data types are largely not a concern. Although this behavior does make it easy to work with, it does make it easier to screw up in certain ways (implicit narrowing conversions!).
PHP is widely used in the web arena, but if you want to do any desktop programming you'll eventually want to learn a language like C# (for Windows applications), Objective-C (for OS X applications), or the horrid C++ (for Linux applications). These languages are syntactically pretty similar to any C-Style language, so if you learn something like PHP you'll find the structure of these languages familiar. All three languages do add quite a bit of complexity (particularly C++), though, so look forward to a learning curve.
If you're looking to learn desktop development straight up, Visual Basic .NET (VB.NET) is easier to learn that C#, but no less powerful. You can get a basic VB.NET compiler and IDE (VB.NET Express Edition) for free from Microsoft.
There are those that are vehemently opposed to any and all BASIC-style languages, but VB.NET is, in many ways, more similar to a basic C-style language than a BASIC language.
-- I might be stupid, but that's a risk we're going to have to take. --
Image
Website! Photography! Robots! Facebook!
The latest computers from Japan can also perform magical operations.

User avatar
Retrofuturist
Posts: 3131
Joined: 2008.09.19 (06:55)
MBTI Type: ENTP
Location: California, USA
Contact:

Postby t̷s͢uk̕a͡t͜ư » 2009.07.19 (23:01)

jean-luc wrote:I find myself highly skeptical of the idea that PHP encourages bad style and technique. PHP is very freeform, and I think it allows you to do things wrong more than many other languages, but good behavior is also made easier.
"Variable-variables" are an intentionally built-in feature of the language. 'Nuff said. I damned near lost my lunch when I learned that PHP had those.
jean-luc wrote:PHP is widely used in the web arena, but if you want to do any desktop programming you'll eventually want to learn a language like C# (for Windows applications), Objective-C (for OS X applications), or the horrid C++ (for Linux applications).
Huh? A huge variety of languages can be used to make a functional desktop application for any of those platforms, and regularly are. I'm actually curious about the number of people who actually use C++ anymore for third-party desktop applications, because I doubt that it's very high.
[spoiler="you know i always joked that it would be scary as hell to run into DMX in a dark ally, but secretly when i say 'DMX' i really mean 'Tsukatu'." -kai]"... and when i say 'scary as hell' i really mean 'tight pink shirt'." -kai[/spoiler][/i]
spoiler

Image


User avatar
Ego Lancer
Posts: 303
Joined: 2008.09.26 (06:13)
NUMA Profile: http://nmaps.net/user/PsychoSnail
MBTI Type: ISTP
Location: The Gaming subforum

Postby PsychoSnail » 2009.08.03 (22:43)

I learned Java as my first programming language, and I quite like it, though I haven't tried Python yet (I'm starting to learn C++ now (EDIT: Speaking of which, do any of you have any recommendations on good C++ compilers for Windows?)).
spoiler

Image
Opera innovates, Firefox emulates.
Last updated: September 27th, 2009


User avatar
Semimember
Posts: 22
Joined: 2008.09.28 (14:06)

Postby ZZ9 » 2009.08.04 (09:55)

MinGW is fairly decent.

User avatar
Retrofuturist
Posts: 3131
Joined: 2008.09.19 (06:55)
MBTI Type: ENTP
Location: California, USA
Contact:

Postby t̷s͢uk̕a͡t͜ư » 2009.08.04 (17:14)

PsychoSnail wrote:Speaking of which, do any of you have any recommendations on good C++ compilers for Windows?
I have a Cygwin installation on any Windows machine I use, so usually I just use gcc.
If you want an IDE, I've also had an overall positive experience with Dev C++. As far as IDE's go, it's pretty straight-forward and uncomplicated.
Otherwise, as a computer science student, I have a free license for Microsoft Visual Studio 2005, which I've been using for toying around in C#. I'm not really much of a fan, though, and mostly use it for the GUI builder.


Two things:
1) If you know a lot of Java, you should find that you pick up C++ pretty quickly.
2) You'll probably pick up Python pretty quickly, regardless of programming experience.
[spoiler="you know i always joked that it would be scary as hell to run into DMX in a dark ally, but secretly when i say 'DMX' i really mean 'Tsukatu'." -kai]"... and when i say 'scary as hell' i really mean 'tight pink shirt'." -kai[/spoiler][/i]
spoiler

Image


Why Was Six Afraid of Seven? Because...
Posts: 789
Joined: 2008.10.30 (19:35)
NUMA Profile: http://www.nmaps.net/user/999_Springs
Location: In the toilet, flushing down springs, one by one.

Postby 999_Springs » 2009.08.04 (18:49)

I was reading through the discussions in this thread a few days ago, and it sort of inspired me to try programming for the first time. So I downloaded Python (with original intention to run NHigh on it, but used it as a programming tool as well) and looked up a few of those tutorials on the Internet.

Now I had just created this program using Python to find the smallest nontrivial factor of a positive integer, and here it is:

Code: Select all

def bleurgh(n):
	for x in range (2, n^(1/2)):
		if n % x = 0:
			print n, "=", x, "*", n/x
	else:
		print n, "BLEURGH"
and I tested it first for a few small numbers and it worked fine, giving instantaneous responses. So i decided to take it up a level and get it to factorise this nine-digit composite number:

Code: Select all

bleurgh(157519381)
and what followed was the most hideous scene that I have ever experienced on my computer since actively watching the destruction of my NReality highscore *0ths by Unreality back in April.

Firstly, I pressed Enter, and - nothing happened initially. It later transpired that the computer seemed to be calculating bleurgh(157519381) and taking an unusually long time. However, I soon realised that the computer's hard drive was making the most grotesque noises that I had ever heard, and it had slowed the computer down right to a snail's pace such that even the TheRealN Forums homepage was taking a minute to refresh itself and kept giving the "Not Responding" message temporarily whenever I clicked on anything. I tried to get Python to close to kill the program off, but that itself took three minutes and a failed attempt to load Task Manager, and the noises did not stop. Finally Task Manager opened, showing that there were no other programs running than those which I had intended to run, so I closed it again and opened Python again in the hope that things would soon get back to normal.

That was certainly not the case. The unbearable noises continued to invade my ears, and the computer's speed was not showing any signs of improving. Finally Python opened. I pasted the program back onto the screen and tested it for some more small numbers, for which it did work. But suddenly a window appeared on the screen which was nothing like I had ever seen before in the five years of my using the computer. It stated that "Virtual Memory is too low" followed by some other ridiculous rubbish. Python closed itself. I was so alarmed that I shut down the computer completely.

At that point I was not sure whether such a bizarre problem was a cause of Python or of something else. So I turned the computer on again, loaded up Python, put the program into it, tested it for some small numbers, and typed in bleurgh(157519381) again. The same thing happened with the unresponsiveness and the grinding noises emanating from the hard drive. I shut down the computer before the situation got any worse.

I have absolutely no idea what went wrong there. I had previously tested a similar program to find the smallest nontrivial prime factor of eleven-digit numbers and it worked very smoothly indeed. Is it the program itself, or is it something to do with the way that Python is handled by my computer? How do I solve it?
Achievements:

Completed N and NReality.
106 N v1.4 highscores.
I used to maintain 1000 NReality Level Top20 Highscores - Ranked 0th
Former Owner of Episode 169, way back when.
I've taken 10 Metanet 0ths. 6 of them lasted <2 days. I don't have any of them anymore. >:(
Third Place in BLUR 4 highscore.
Not highscoring anymore until v2.

EddyMataGallos is an alien.


User avatar
Retrofuturist
Posts: 3131
Joined: 2008.09.19 (06:55)
MBTI Type: ENTP
Location: California, USA
Contact:

Postby t̷s͢uk̕a͡t͜ư » 2009.08.04 (21:30)

999_Springs:

I'm surprised your code even worked for small numbers.
  • The caret operator is not exponentiation in Python. Try some simple ones in the interpreter, and you'll see things like 2^3 = 1. The exponentiation operator in Python is two asterisks. 2 ** 3 = 8.
  • (1/2) is integer division, so it results in an integer (it's rounded down). When (1/2) is evaluated, you get 0. So if you exponentiate anything by (1/2), you're going to get 1. If you really want to express one-half as a quotient, make either or both of the numbers a float, e.g. (1.0 / 2), (1 / 2.0), or (1.0 / 2.0). Below, I simply use 0.5.
  • You'll get deprecation warnings for using a float in the range() function, so you should convert that upper bound to an int. Add 1 to correct for the error in that conversion.
  • The test for equality is two equal signs, not one (in your if statement).
  • Consider removing the else statement if you're going to give it large numbers. For large numbers, there are going to be a heck of a lot of non-factors smaller than it, so you'll get three and a half assloads of "BLEURGH" filling your screen.
Here's the code I used to test that massive number:

Code: Select all

def bleurgh(n):
   for x in range (2, int(n ** 0.5) + 1):
      if n % x == 0:
         print n, "=", x, "*", n/x
   # else:
      # print n, "BLEURGH"
The results, after a fraction of a second:

Code: Select all

157519381 = 7507 * 20983

EDIT:
The side of me that gave into Perl just couldn't resist. Here's a one-liner that returns a list of all whole factors of the given number:

Code: Select all

bleurgh = lambda n: [x for x in range(2,int(n**.5)+1) if n % x == 0]
Call it the same way you do your bleurgh().
[spoiler="you know i always joked that it would be scary as hell to run into DMX in a dark ally, but secretly when i say 'DMX' i really mean 'Tsukatu'." -kai]"... and when i say 'scary as hell' i really mean 'tight pink shirt'." -kai[/spoiler][/i]
spoiler

Image


Plus (Size) Member
Posts: 42
Joined: 2008.09.27 (02:56)

Postby taaveti » 2009.08.05 (02:52)

Incindentally, if you're using python below 3.0, you should probably use xrange instead of range for such large ranges. In 2.x, range creates a list consisting of all the specified values (in the case of "range(157519381)", that's a structure which takes close to 2GB of memory, which is probably the source of all your hard drive activity), whereas xrange creates an iterator object which will traverse the specified values. In 3.x, the old-style range was ditched and xrange was renamed to range.

User avatar
Retrofuturist
Posts: 3131
Joined: 2008.09.19 (06:55)
MBTI Type: ENTP
Location: California, USA
Contact:

Postby t̷s͢uk̕a͡t͜ư » 2009.08.05 (04:07)

taaveti wrote:Incindentally, if you're using python below 3.0, you should probably use xrange instead of range for such large ranges. In 2.x, range creates a list consisting of all the specified values (in the case of "range(157519381)", that's a structure which takes close to 2GB of memory, which is probably the source of all your hard drive activity), whereas xrange creates an iterator object which will traverse the specified values. In 3.x, the old-style range was ditched and xrange was renamed to range.
I thought that that change was made back in the 2.3ish days.
I mean, I just did that, and my RAM usage didn't skyrocket (and it'd only go upwards of 600 MB, incidentally).
[spoiler="you know i always joked that it would be scary as hell to run into DMX in a dark ally, but secretly when i say 'DMX' i really mean 'Tsukatu'." -kai]"... and when i say 'scary as hell' i really mean 'tight pink shirt'." -kai[/spoiler][/i]
spoiler

Image


User avatar
Ego Lancer
Posts: 303
Joined: 2008.09.26 (06:13)
NUMA Profile: http://nmaps.net/user/PsychoSnail
MBTI Type: ISTP
Location: The Gaming subforum

Postby PsychoSnail » 2009.08.05 (05:01)

ZZ9 wrote:MinGW is fairly decent.
Thanks, I'm trying MinGW now, and it's working pretty nicely. I just have one issue with it - when I use the standard library, such as iostream, MinGW generates really large executable files (over 400kb for a simple Hello World program), even after stripping the executable of debug info. Is there any workaround to this?
spoiler

Image
Opera innovates, Firefox emulates.
Last updated: September 27th, 2009


User avatar
Beyond a Perfect Math Score
Posts: 834
Joined: 2008.09.30 (06:37)
NUMA Profile: http://nmaps.net/user/Nexx
MBTI Type: INTJ
Location: California, USA

Postby Nexx » 2009.08.05 (07:35)

PsychoSnail wrote:Thanks, I'm trying MinGW now, and it's working pretty nicely. I just have one issue with it - when I use the standard library, such as iostream, MinGW generates really large executable files (over 400kb for a simple Hello World program), even after stripping the executable of debug info. Is there any workaround to this?
I just found this thread, and I was actually going to back up Tsukatu's recommendation of Dev C++ because I've used it to make a few programs. But now your comment makes me want to try MinGW. *puts it on his to-do list*

User avatar
La historia me absolverá
La historia me absolverá
Posts: 2228
Joined: 2008.09.19 (14:27)
NUMA Profile: http://nmaps.net/user/maestro
MBTI Type: INTP
Location: Beijing
Contact:

Postby 乳头的早餐谷物 » 2009.08.05 (08:26)

Avarin wrote:
PsychoSnail wrote:Thanks, I'm trying MinGW now, and it's working pretty nicely. I just have one issue with it - when I use the standard library, such as iostream, MinGW generates really large executable files (over 400kb for a simple Hello World program), even after stripping the executable of debug info. Is there any workaround to this?
I just found this thread, and I was actually going to back up Tsukatu's recommendation of Dev C++ because I've used it to make a few programs. But now your comment makes me want to try MinGW. *puts it on his to-do list*
I think Dev-C++ (I'll third the recommendation) uses the MinGW compiler.
M E A T N E T 1 9 9 2

Image


Who is online

Users browsing this forum: No registered users and 12 guests