Wikipedia:Reference desk/Archives/Computing/2008 March 24
{{#ifeq:{{PAGENAME}}|Special:Undelete| |{{#if:|
What programming languages to learn?
I am interested in learning some computer programming, but I'm not sure where to start. I can currently only write XHTML (not a programming language, I know). I'm thinking maybe I should start with easier, more web based markup languages such as JavaScript and CSS and move on to maybe BASIC or C? Well, any help would be appreciated, because I'm lost; I really have no idea what I'm doing! :P --Voyaging (talk) 01:09, 24 March 2008 (UTC)
:Start with something easy like php and powerful not like javascript. Actually Ruby is probably a great place to start.. it's a terrifyingly powerful and flexible scripting language with a rather large following. Try [http://tryruby.hobix.com/ the interactive tutorials].. the application is slick so check it out even if you don't care to try Ruby :D\=< (talk) 02:13, 24 March 2008 (UTC)
:There are enough programming languages out there to spend a lifetime learning. First ask yourself the question: what do I actually want to do? That said, I think something like Python is nice, on a readability level.--Fangz (talk) 02:18, 24 March 2008 (UTC)
::If you learn python you'll never return to the land of the sane :D\=< (talk) 04:43, 24 March 2008 (UTC)
::As far as what I want to do, I simply want to attain knowledge. I just want to have the knowledge of knowing different programming languages. I'm not sure of specifics because of my limited knowledge of the subject, but I'd like to be able to code a variety of programs, so nothing that is limited to a certain type of program would be ideal. In addition, something that could maybe build a foundation for learning other languages, or maybe lead up to learning them would be optimal. Thanks for the help so far! --Voyaging (talk) 05:03, 24 March 2008 (UTC)
::: IMO, you won't learn anything worth while unless you actually try to do it. So you need to set yourself a project (eg be the first person to produce a KenKen solver). Probably the easiest to learn, but of least use commercially, is non-visual Basic. Did you know that Excel includes a Basic as a macro language? I wrote my (yet another) sudoku solver in Excel VB. -- SGBailey (talk) 09:15, 24 March 2008 (UTC)
::::Aren't you talking about VBA?
::::I think Java is a good language to learn. -- Meni Rosenfeld (talk) 11:39, 24 March 2008 (UTC)
:::::VB and Java are both terrible languages to learn for a beginner. You think you're learning a low level language and then miss out entirely on pointers, which makes for absolute fail. Learn an easy, powerful, and slow scripting language first then go for hardcore C so you learn the full spectrum, then you can learn the wussie languages like VB and Java :) :D\=< (talk) 18:58, 24 March 2008 (UTC)
::::::Why would anyone learning VB or Java think he's learning a low level language? -- Meni Rosenfeld (talk) 23:14, 24 March 2008 (UTC)
:::::::Well, I mean like a "real" language. Java programmers are always like "I am a programmer" and everyone rolls their eyes at them. Nobody's even polite to the VB programmers. :D\=< (talk) 01:36, 27 March 2008 (UTC)
I'm of the opinion that if you learn any of the C-like languages (C, C++, C#, Java, Perl, PHP, Python, etc.), you can then very rapidly pick up any of the others. Me, I think Perl is a nice language for a beginner; C (or any of the other compiled languages) has a high "minimum required activation energy" for a rank beginner.
I'm also of the opinion that Visual Basic will destroy your mind, polluting it with many ridiculous ideas that will block you from leaning about how programming really works. (NB: I don't have any problems with people learning non-Visual BASIC, though. But BASIC is a language that's quite different from any of the C-like languages that dominate the business nowadays; it owes its basic forms to much older languages and now less-used like Fortran.)
Atlant (talk) 14:12, 24 March 2008 (UTC)
:We learnt Cobol and Pascal as starter languages, then moved onto C and C++. If you are learning purely for interest I would say you want to learn one that is logically structured rather than powerful. You want one that is easy to read rather than flexible. I recall having to spend about 30 minutes talking to an old non-IT based manager explaining how coding is like hand-writing - everyone does it slightly differently. There are 100s of ways to achieve the same goals in most languages, so your best bet is not to try get into understanding the syntax/language in depth but to get a basic understanding of programming as a structure. Things vary from language to language but a good basis in one of the early-years languages (I believe) would bode well for you ever having to learn a more advanced/current language. I still do a bit of programming in FOCUS, which is actually a remarkably easy language to understand (at least at the depth of detail I use it). ny156uk (talk) 14:20, 24 March 2008 (UTC)
:I think you're mad to suggest Perl Atlant :) It's extremely difficult to read example code until you're familiar with it and was written by a notorious obfuscater! I'd agree with Ruby for someone who has a professed interest in web technologies. Voyaging, you probably want to get up and running pretty quickly right? What kind of thing do you want to do? A game, a web-app, or do you want to start on the road to becoming a full-time programmer? BananaFiend (talk) 10:15, 26 March 2008 (UTC)
::Well, you can write shite in any language and you're correct: much of everything that's distributed on the web as "sample code" is shite. But when I write Perl, I try to write it with the same diligence I use when writing C so I'm careful to use appropriate, self-documenting names, lots of comments, and the like. I write it as though I'll have to maintain it for years (which actually is the case ;-) ). So I think you'd find that you can pick up my Perl code, read it, and learn from it. One proof point of this is that my wife, who's a web developer but not a programmer, has been able to pick up, use, and modify Perl that I've written for her web sites.
::And because Perl isn't typed and usually has a pretty good idea of what you actually mean to do, I find it's easy for beginners to use. Show them how to write and run "Hello, World!" and they're pretty much off and running.
::Atlant (talk) 16:44, 26 March 2008 (UTC)
::I don't really have specifics on what in particular I want to be able to code, but I think a game would be a fun starting point. It doesn't really matter, I just want to get started coding. --Voyaging (talk) 16:52, 26 March 2008 (UTC)
:::well, if you're interested in anything with serious graphics, you're going to be dealing with C or one of its derivatives, like C++ or C#. maybe look at some book on graphic programming for windows and start trying to much through that as soon as you can while doing introduction to C# or whatever at the same time, to get through the bottleneck. (just my opinion, my object-oriented language of choice is Excel)Gzuckier (talk) 17:32, 26 March 2008 (UTC)
If you are planning on doing things with the web in the future (and really, who ain't?), PHP is a great place to start—it's relatively powerful and you can get very satisfying results quickly, in part because you use HTML to build up your interfaces (you aren't stuck with just a console, like most of the other languages given, or building up an interface in a clunky IDE, as with VB and VB.NET). And in my opinion, when we're in the realm of self-teaching, quick, satisfying results are important, lest one find it too much trouble! (I tried to teach myself C++ years ago. After hours of playing with it I could make a console program that could do some basic math. I was not impressed with the result. Never went back.)
But as has been said, it doesn't matter so much which one you start with—what matters more is that you have a driving project. Trying to learn a programming language without setting out a goal is like trying to learn a spoken language by using just a dictionary. If you have a goal in mind and are having fun with it the learning will be quite easy and enjoyable. PHP has the added benefit of being widely used on the web so there are LOTS of sites of sample code, examples, other people's implementations, etc., to benefit from. --Captain Ref Desk (talk) 14:22, 24 March 2008 (UTC)
Python or Ruby. The interactive interpreters are great for beginners experimenting. The way most of us learnt programming went something like Statements --> Routines --> Classes and I still think this is the best way. Python and Ruby will let you write a program that does something without defining a class, but will continue to support you as you write something more structured. Good luck.
:I learnt C as my first (programming) language and never felt it was hard or something.. Going Visual might be harder, but that's why world is full of guides and documentation. Though I must admit I'm just a * person-with-no-life, so I haven't bothered to find out what kind of heaven there is behind those Pythons and Perls. If you are planning to learn "just to learn", not to get something done right now, then I would recommend C/C++. --82.141.93.96 (talk) 15:10, 24 March 2008 (UTC)
Thanks so much for all the help! After reading all your responses, I think I'm going to start with C, then move on to some other languages. From what I've read, many of the current popular languages are based off of C (Perl, PHP, C++) so I think that'd be a good starting place. Now my next question. What resources would you recommend to me for learning the language? Thanks again! --Voyaging (talk) 15:54, 24 March 2008 (UTC)
:They're loosely based on C (if in Perl's case you consider the Kuiper belt to be merely "loose" around the Sun's waist) but C's a tough nut to crack.. if you have windows I strongly advise you to download Visual C++ 2008 (NOT c#) and use that IDE, it's much more beginner friendly than console compilers like ming or gcc. Or just learn php and ruby and use notepad and your web browser. Seriously you're going to be very disappointed with your progress in C, scripting languages are far more powerful and you can do some actually useful things even while learning :D\=< (talk) 19:03, 24 March 2008 (UTC)
K&R is a good one. Would definitely recommend something printed anyway. Google is indispensible but it really helps to be following a printed course as well.
You also need a project. How about: Write a program to decipher text that has been encoded by a Caesar cipher. The program should use frequency analysis to decode the text (ie without any clues from the user).
:but, note that C is a very "special" kind of language, not for everybody or everything.. if i had had to get through C first, i'd never have gotten past it. like learning assembler in the old days. Depends what you want to program. Heck, you might find programming in SQL to be your path to greatness. Gzuckier (talk) 19:05, 24 March 2008 (UTC)
You want to see the weirdish wikibooks:C Programming/Using a Compiler to get quickly started. That Crimson Editor isn't necessary, I have survived for a long time with just MS Notepad. Otherways Wikibooks isn't (probably) the optimal thing to read. As a general tip I would say you should just dig around and try many guides/tutorials to find the one that suits you best. --212.149.216.233 (talk) 19:18, 24 March 2008 (UTC)
I'd recommend focusing on learning programming rather than on learning a particular language. Once you know how to program, learning a new language won't be that hard. But just learning a language doesn't automatically mean learning how to program. Learning the language means jumping through the hoops the language puts in your way. Learning to program means being able to see the relationship between the program code and what it does (a relationship that works both ways -- "why is this code doing what it's doing" and "what code would do what I want"). As for choice of language to start with -- I'd say, find a teacher, or text, or whatever, that you're comfortable learning from, and use whatever language they use. (Even if it's a "useless" language -- because (a) it's about learning to program, not just about learning that one language; and (b) you might be surprised what turns out to be "useful;" one obscure language, that I considered even leaving out of my resume, is used extensively where I work now) If you were learning from me, I'd choose C, because that's what I'm most comfortable with. Also, it's a good idea to learn more than one language. Not only because you'd then have one more tool available to you, but because you learn different things from each one. (Many years ago, I "sort of" knew C. Then I tried to learn x86 assembly language. I mostly failed... but at the end I understood "C" a lot better.) -- Why Not A Duck 23:41, 24 March 2008 (UTC)
:This is one of those questions that cannot be answered credibly or reliably over a largely anonymous forum like this. Why Not A Duck states the point quite clearly, so there's not much to add except this.
:Most programming languages exist because someone thought they could "fix" an annoying aspect of another language they were already using. From this, you can learn a few things:
- 1) there is no such thing as a "perfect" programming language to learn;
- 2) a good sign of "knowing" a programming language is when you understand its limitations relative to other languages, and relative to what it was supposed to "fix";
- 3) many people either do not realize or disagree with points 1 & 2 above;
- 4) because of 3), many people stop learning new languages, and become "entrenched";
- 5) because of 4), this question cannot be answered credibly over an anonymous forum like this;
- 6) because of 5) you can ignore this post and this thread. NoClutter (talk) 13:12, 25 March 2008 (UTC)
::::Don't waste your time with intermediate steps, if your target language is say C++, begin with C++. That's the best advice I can give from my personal experience. --Taraborn (talk) 16:55, 25 March 2008 (UTC)
:If you don't have a project in mind, Python (a non-visual, "high-level" language) is considered pretty versatile, easy for beginners, and teaches good habits. There are a couple beginners' programming books (I wish I could remember titles) available that use Python. Many programmers have started in C and C++, but these are sufficiently "low-level" to get a new user into trouble, especially if that user is self-taught.
:I agree with the above-repeated dictum to avoid "visual" languages; these bind you to one company's way of doing things, and Gawd help you if that company is Microsoft. I learned in QBasic (circa 1990), in which it was easy to pick up simple modular structure concepts (loops and such), which was a decent foundation for when I needed to use application scripting languages in WordPerfect 5.1 and FoxPro 2.5, and Unix shell scripting. Grain of salt notice: I never became a "real" programmer (don't wanna), and I've not seen Ruby (recommended elsewhere in this thread) but have heard good things about it. / edg ☺ ☭ 17:37, 26 March 2008 (UTC)
A word of warning about both PHP and JavaScript: there is a lot of bad example code out there. These two languages, perhaps because they are easy to pick up and get results with quickly, tend to attract more than their fair share of bad voodoo programmers. That's not to say there aren't good programmers as well, or that the languages have anything wrong with them, but as a complete beginner you may not be able to differentiate between good and bad examples and will easily pick up a lot of bad habits. 81.187.153.189 (talk) 01:23, 27 March 2008 (UTC)
:This is very good advice. Most of my PHP is just terrible; it's such an inefficent language that there's really no point in trying to optimize (except your db connections/queries) and except for the largest applications it's unlikely that you'll ever work with someone else on the same code. Combine that with how easy it is to read through to tell what it does and how short scripts usually are, and you have a recipe for commentless, sloppy disaster! :D\=< (talk) 01:34, 27 March 2008 (UTC)
= What about game programming ? =
Thanks so much to everyone for the help! Hmm, how about this. Say my end goal was to be able to code a game (and not just an Atari game, one that at least has a bit of depth). I know that's not an easy goal by any means, but say that was my ultimate goal. What would be the best way to start? Thanks again for all the help! --Voyaging (talk) 01:54, 27 March 2008 (UTC)
:You might want to look at alice [http://www.alice.org/]. It's gaining some attention and publicity according to O'Reilly publishing which tracks that kind of thing in order to know what books to sell. NoClutter (talk) 03:21, 27 March 2008 (UTC)
Sound Problems
I'm on an HP Compaq tc4400 laptop computer (well, tablet pc). All of a sudden when I try to play a video from the internet or a song from iTunes, I hear the video/song for 4 seconds and then silence from then on. Can someone tell me what's causing this problem, and what I can do to fix it? Thanks in advance. ~EdGl 02:07, 24 March 2008 (UTC)
Just to make things clear, is it the Windows XP tablet edition Windows XP Tablet PC Edition? Kushal 11:54, 24 March 2008 (UTC) Kushal 12:55, 24 March 2008 (UTC)
:Sorry, forgot to mention it's using windows vista, I believe enterprise edition. ~EdGl 13:08, 24 March 2008 (UTC)
:Yay, it seems to be working now! Weird, as I didn't do anyting, not even restart. Well, sorry for taking up RD space.. carry on.. ~EdGl 13:37, 24 March 2008 (UTC)
Don't worry about it. I wonder what went wrong in the first place. Glad it is working. Kushal 19:17, 24 March 2008 (UTC)
Periodic patterns in bittorrent download rates
I'm not sure if it happens in general as well, but I notice that often, the download speed curve of a bittorrent transfer shows a strong periodic pattern. The download rate goes down, and then comes back up, and then goes down again, with a period of about 30 seconds.
Is there any explanation for this behaviour? Or is it just me?--Fangz (talk) 02:21, 24 March 2008 (UTC)
:What client do you use? I use Azureus, and I see that a lot. I'd would guess it's a swarm behavior—one client disconnects from me (down), a new one connects optimistically uploading (up), then decides I don't deserve that rate (down again)—but I notice my upload rate often changes in the same way, matching my download rate for the entire cycle. Can't imagine one most likely cause. Might be just the way the client calculates rates. / edg ☺ ☭ 03:25, 24 March 2008 (UTC)
:This happens when the following two conditions are met:
:# the torrent has only one seeder
:# the seeder uses superseeding
:See Super-seeding for a basic explanation. Morana (talk) 08:27, 24 March 2008 (UTC)
::I can definitely confirm that this is happening when there is more than one seed.--84.71.41.235 (talk) 14:50, 24 March 2008 (UTC)
:::You're probably not making enough connections.. I typically connect to 50 or so peers per torrent, and don't get most of my pieces from any one peer in particular so except for fascinating swarm-wide fluctuations due to weird seeder behavior or something which is always possible I guess, I have mostly stable down speeds. Make more connections and make sure something upstream isn't load balancing you :D\=< (talk) 18:55, 24 March 2008 (UTC)
javascript help
I don't know Javascript but would like to do something very simple.
I want to present a block of text with some words in red, and when you click a red word you can change it with a dialog that pops up. At the end you submit the whole thing via post.
Is this possible? could I get some help writing it? Thank you.79.122.35.198 (talk) 14:49, 24 March 2008 (UTC)
:Here's a very simple implementation of such a thing:
function get_word(id) {
var existing = document.getElementById("word"+id).innerHTML;
var newword = prompt('Replace "'+existing+'" with:');
if(newword.length>0) {
document.getElementById("word"+id).innerHTML = newword;
var nextword = document.getElementById("word"+(id+1));
if(nextword != null) get_word(id+1);
}
}
function submit_text() {
document.submit_form.submit_data.value = ReplaceTags(document.getElementById("text_to_submit").innerHTML);
document.submit_form.submit();
}
var regExp = /<\/?[^>]+>/gi;
function ReplaceTags(xStr){
xStr = xStr.replace(regExp,"");
return xStr;
}