Coding For Dummies - WAS: Coding Competition...I Like It


10 LET x=x+1
Its also important to remember that in programming, variables can be given helpful names:e.g. 

Code:
sheep = sheep+1
if  (sheep==10){
    print("There are ten sheep")
}
Some of my first programs used nothing but single-letter variables - agurgh!
Yes, but if those were used on one of the old 8bit BASICs, then there were very good reasons for using single letters - firstly that some BASICs only allowed one letter, secondly that longer names took up more bytes in memory (yes, we really were that tight for RAM back then) and thirdly each time a variable is accessed in an interpreted BASIC it has to be looked up[1], and string-compares are far faster on one-byte strings than they are on longer strings!
I thought we were discussing the relative merits of programming languages in the context of modern computers described using GHz and GB?
 
Last edited by a moderator:
10 LET x=x+1
Its also important to remember that in programming, variables can be given helpful names:e.g. 

sheep = sheep+1
if (sheep==10){
print("There are ten sheep")
}Some of my first programs used nothing but single-letter variables - agurgh!
Yes, but if those were used on one of the old 8bit BASICs, then there were very good reasons for using single letters - firstly that some BASICs only allowed one letter, secondly that longer names took up more bytes in memory (yes, we really were that tight for RAM back then) and thirdly each time a variable is accessed in an interpreted BASIC it has to be looked up[1], and string-compares are far faster on one-byte strings than they are on longer strings!
I thought we were discussing the relative merits of programming languages in the context of modern computers described using GHz and GB?
We are. I gave an example of a line of code which opened my eyes back in the very early 80s; I wrote it exactly as it was when I learnt it. You then informed me that we could have longer names now, I replied with the reasons we didn't use longer names back then.

Do keep up :)

D.
 
I first took on PHP because I was intrigued by complex web content. Then I learned that PHP wasn't too different from C, but I still have problems with the latter, it's difficult for me trying to read "advanced" code. I see that there are some ways to do things "nicer" and more efficient which I have yet to understand. And I haven't tackled more complex functionality in PHP either, likely I would face similar problems there. Anyway, C and PHP are, if you can call it that, mathematical programming lingos, as opposed to ones that are more like spoken word, at least that is how I perceived Visual Basic at school. This is very subjective of course.

Why do I still try and work on C/C++? Because it promises to be more useful in the long run. 

"For dummies" books aren't bad a bad choice. There is an abundance of literature out there that helps you get going and there's programming forums for your questions. Not trying to talk you out of the college idea, it's an alternative.

You might go ahead and have a look at COBOL if you feel adventurous and are interested how programming worked using punchcards in the olden days.
 
We are. I gave an example of a line of code which opened my eyes back in the very early 80s; I wrote it exactly as it was when I learnt it. You then informed me that we could have longer names now, I replied with the reasons we didn't use longer names back then.

D.
s'pose that makes sense...
 
No. Do not try COBOL. Don't ever try COBOL. Just Don't Do It.
 
Indeed, I can clearly remember the day when I learnt the code:


10 LET x=x+1
 

Which, if written in C/C++:


x=x+1


Actually seems simpler to me? Basic languages too have for/while loops and their syntax isn't that much better than C/C++ in my opinion. I think the basic I used had something like:

10 FOR n = 1 TO 5 STEP 1


20 REM Do something with n...


30 NEXT n

Which compares to:


for ( int n = 1; n < 5; n = n + 1 )
{
// Do something with n
}

I mean you could argue one is easier than the other, but in reality I don't see why it would take anyone too much time to get the basic concept in either language.

Now, if you then want to move on to displaying a sprite on the screen (which is probably the first thing everyone wants to do?) it would depend which basic you are using, certainly the ZX Spectrum 128k basic I started with didn't facilitate displaying a custom sprite very easily. I've also used Dark Basic and Blitz Basic - didn't get on with Dark Basic at all, but found Blitz nice to work with. Made a couple of games with that (including a Pang clone). To me it felt like a nice way to code as the language was straight forwards (similar to C/C++ too I felt) and it had built in support for displaying sprites, playing audio, taking input and so on. But then you can provide a C/C++ API that gives all the same support (with the same function names if you like) at which point the code looks very similar when you compare C/C++ with Blitz (mainly with C/C++ having ; to delimit line ends and braces {} to delimit scoping).
 
Indeed, I can clearly remember the day when I learnt the code:

10 LET x=x+1
Which, if written in C/C++:

x=x+1 Actually seems simpler to me? Basic languages too have for/while loops and their syntax isn't that much better than C/C++ in my opinion. I think the basic I used had something like:

10 FOR n = 1 TO 5 STEP 1

20 REM Do something with n...

30 NEXT n
Which compares to:

for ( int n = 1; n < 5; n = n + 1 )
{
// Do something with n
} I mean you could argue one is easier than the other, but in reality I don't see why it would take anyone too much time to get the basic concept in either language.
....No, sorry. Your C syntax is impenetrable to a beginner. Whereas FOR starts and denotes a loop, you start with "int n" - what does int do? Why the semicolons? FOR n=1 TO 5 is much easier to look at and understand, with the C equivalent you have to manually deconstruct it in your head.

Your problem is that you don't think like a beginner. You think that C is easy because you find it easy, not because it is easy.

Now, if you then want to move on to displaying a sprite on the screen (which is probably the first thing everyone wants to do?) it would depend which basic you are using, certainly the ZX Spectrum 128k basic I started with didn't facilitate displaying a custom sprite very easily. I've also used Dark Basic and Blitz Basic - didn't get on with Dark Basic at all, but found Blitz nice to work with. Made a couple of games with that (including a Pang clone). To me it felt like a nice way to code as the language was straight forwards (similar to C/C++ too I felt) and it had built in support for displaying sprites, playing audio, taking input and so on. But then you can provide a C/C++ API that gives all the same support (with the same function names if you like) at which point the code looks very similar when you compare C/C++ with Blitz (mainly with C/C++ having ; to delimit line ends and braces {} to delimit scoping).
Blitz being hard to learn was one of the reasons I wrote SpecBAS - my son was wanting to learn to code, and had decided on learning Blitz. He found it horrible to learn and really struggled. He had messed around in BASIC on the Spectrum and wanted something that was more modern but just as simple. Hence I wrote SpecBAS, which gave him the leg up he needed. He codes in C++ and .Net now.

Again, people who recommend C as a starting absolute-beginner language are usually so well used to reading and working with it that they no longer see how unbelievably bad the syntax is to understand - if it wasn't, then languages like BASIC and Python wouldn't be so popular with beginners.

D.
 
In this thread now:

Now not only is OP completely put off programming but it's devolved into which language is better.

More important is learning programming concepts - which you can basically do in any language. 

Anything you learn in one language can be applied to another and if you get reasonably skilled in one language moving to another language is a piece of pie as your mind is orientated into that "do this, then do that" logical concepts. 
 
No. Do not try COBOL. Don't ever try COBOL. Just Don't Do It.
ha ha ha... there is a blast from the past. back in uni the engineers were taught FORTRAN and a friend doing a commercial course was taught COBOL . ugh..

last thing i remember programming was turbo pascal4 a long time ago......
 
In this thread now:

Now not only is OP completely put off programming but it's devolved into which language is better.

More important is learning programming concepts - which you can basically do in any language. 

Anything you learn in one language can be applied to another and if you get reasonably skilled in one language moving to another language is a piece of pie as your mind is orientated into that "do this, then do that" logical concepts. 
that's what I'm saying from the start... I don't care whether you say "10 LET x=x+1" or "x++" the only important thing is "how do you count the sheep"...
 
Well, yes...

We might argue that anything that can be written in one language can be written in another (since every modern language is Turingcomplete, yadda yadda), and thus that any language is as good as another. I'd argue that that isn't true, too, but even without that, "What we might express" in a language isn't the same as "What is easy to express". And even more so, it is not the same as "How apparent is the translation between what we want to express and how to express it". Language used in learning programming does matter. I work with these things daily, and I can link you a bunch of articles (proper science, research stuff) on the matter if you like, or else just trust me :D

Yes, we do express the same things by writing


FOR i = 1 TO 5  ... NEXT i


Code:
for (int i=1; i<=5; i++) {...}


Code:
for i in (1, 2, 3, 4, 5)
    ...


and as experienced programmers, we have a model of what we want to do, we have a model of the machine and the state of it and the flow of the code. As a beginner, you haven't. For a beginner, the words TO and NEXT (which we more experienced types see as unnecessary syntactic sugar) are a godsend in helping to construct that model. The Python verbosity of explicitly listing the list of values to traverse, combined with the word "in", is also helpful. It looks like english, it is even almost readable out loud. Also, it presumes no other particular knowledge. For the C version, you need to understand about numeric types first, or take them on good faith. You have to memorize the order of the arguments - assignment, test, update - or look them up, whereas in both other languages, it is apparent from the context. There are several kinds of brackets around with different meaning. It is the same thing (although arguably less of a problem) as Javas "public static void main(str[] args)" thingie that means that to write the simplest possible program, you must understand void return types, array notation, visibility classes and classes with static methods - or you just have to take it on faith. 

This is less of a problem in a formal teaching setting, where you have experienced TAs or lecturers who you can trust in making these delineations - "Don't worry about that bit, it just is supposed to be like that. You should only deal with these lines here" - but for self-paced, selfdirected learning it is disastrous. Where do you look when something goes wrong? How do you know which parts of your code to trust? The more things you have to take "on faith", the less in control you are when you need to find an error. 

The same goes for other parts of the environment. Having a big IDE with completion, libraries, GUI construction tools, project management and the like is more or less a given for someone with experience, but for a beginner, the multitude of options are a hindrance, rather than a help. I pressed the play button thingie and my program doesn't work - Why? Is there something wrong in my code? Was it the wrong play button thingie? Am I having the right window on top? What does "missing library" mean? Why is my program a "project" with what seems to be several directories and files? Where's the exit?

All these things are of course surmountable. It is possible to learn to program from nothing, using C++ in Visual studio. It takes a lot more effort, but it is possible. Which means yes, it is possible to learn in any language. Just as it is possible to learn to ride a bike on a highly geared velodrome rig with fastening shoes and so on - It'll just mean that you fall over and hurt yourself a lot more, and you'll have to figure out a lot of complicated things on your own, at once. Indeed, there are those whose personality makes it the better choice - "I will overcome this! That which does not kill me..." and so on. But the rest of us are probably better served by balloon tyres and traning wheels, at least until we've found our balance.

tl;dr: I am strongly opposed to "You can learn programming as easy in any language". It is quite simply not true. 
 
Last edited by a moderator:
...and yes, if I wrote python code for myself, then I'd use an xrange(). For a beginner, though, I'd write it out as above.
 
I guess a lot depends on whether you consider syntactic sugar / redundant built-in constructs to make a language "simpler" (because it makes it look more like English) or "more complicated" (because it introduces extra keywords to be learned).

Another classic point is that of strongly typed vs weakly typed vs untyped language. Again you could argue both ways: strongly typed languages make it easier to avoid type errors and force you to think about types (which can be a good thing), while weakly typed or untyped language make it easier to write programs (you don't have to declare any types) and don't force you to think about types.

Another issue is: should you start with an imperative language or with a declarative one? Again there are arguments both ways.

Finally, should you start with a very high level language and work your way down to the low level from that, or should you start with a very low level language and work your way up from that, or should you start somewhere in the middle?

Should you even start with a Turing complete language?

I guess there are lots of didactic approaches that could be defended; in my opinion, the important bit to is start somewhere (it doesn't really matter that much where), and try to get sufficiently fluent in a programming language so that you can "think" in that language. Then try to learn about as many other paradigms as you can before you get too committed to one specific paradigm. E.g. it will be very hard for someone who has only programmed in BASIC for 20 years to learn to think in Prolog or LISP (and the other way around).
 
Disagree. People prefer what they're used to. 

Hence why in every arguement you see C++ coders go "the syntax gives me closure" and more script orientated people say "C++ looks gross".

If you start to learn in one language (funnily enough) you'll prefer it. And there is enough great material out there on C++ (Binkys youtube series springs to mind) to self learn and take baby steps. www.reddit.com/r/learnprogramming is a great place to post really beginner code and get immediate feedback

+1 for C++
 
Last edited by a moderator:
In this thread now:

Now not only is OP completely put off programming but it's devolved into which language is better.

More important is learning programming concepts - which you can basically do in any language. 

Anything you learn in one language can be applied to another and if you get reasonably skilled in one language moving to another language is a piece of pie as your mind is orientated into that "do this, then do that" logical concepts. 
Thank you.

I was really beginning to get overwhelmed with the "Mine's bigger than yours" competition I seem to see developing here in this thread.

All these code snips and what not...jesus, it puts me off because it all looks Greek and complicated.  OOP was never something I liked anyway, it always freaked me outbecause it is SO DIFFERENT from the way I learned...way back in the 1980's.

And then I see this sort of stuff and feel totally hopeles, like I could never learn it.

Can we stick to possibly the merits of self-taught, versus one-on-one hand-holding versus a college course?

Because I truly WOULD like to learn.  but this stuff IS off-putting.

Maybe, without code-snips and without any "mine's bigger than yours" back-and-forth, we could talk about the relative merits of which language might be best for me to try to learn, in terms of leaqrnability and functionality.
 
Every language has it strengths and weaknesses as a first language to learn. When I look at computer science curricula, there are quite a lot of different choices for the first language: Java, C, Scheme, Python, Pascal, to just name a few.

The best way to self-learn any language is probably to start with a tutorial text to get to know the basic concepts, then read a lot of example programs (well-written ones), try to make some changes to those programs to see what happens, etc. Basically just like a human language: you don't start by reading a book on grammar and a dictionary, and then start writing a novel. To learn a programming language, you don't start by reading the language specification (syntax and semantics) and then immediately write a huge complicated program.
 
I'd say: Go to Udacity. Take their cs101 online course. It goes through the basic programming constructs, using Python, in a well-designed course sequence with available help, frequent feedback, and a good community around it. Python will be useful for you later - It runs straight off on your pandora, right now - and is close enough to the C-like languages (C, C++, C#, Java, ...) that you will have no problem transfering the concepts later.

EDIT: And, forgot to add - It is free of charge, and has some seriously big names on the list of teachers (Peter Norvig does one of the later courses, for instance). It is very much distance education done right.
 
Last edited by a moderator:
Back
Top