1

A wise man told me that to learn how a syntax works does not mean your a good programmer, but rather to grasp programming constructs like iterators and conditionals, thus, meaning you can pick up any syntax easier. How would one go about learning these constructs??

Spencer Hire
  • 735
  • 3
  • 14
  • 32
  • Have a look for books on design patterns. – Ash Burlaczenko Mar 03 '12 at 08:55
  • Well, conditionals are supported by nearly all languages but iterators only appear in the newer ones with abstract collections. For comparative syntax, you should look at http://hyperpolyglot.org/ . – Dan D. Mar 03 '12 at 08:59
  • The wise man said wisely. Here's an [analogy](http://stackoverflow.com/a/10057916/307454) that provides perspective on constructs. – lifebalance Nov 12 '15 at 02:42

2 Answers2

2

The easiest construct you mention is a conditional. The basic pattern of a conditional is:

if <some-condition> then
    <do-action>
else
    <do-other-action>
end if

This basic pattern is expressed in many different ways according to the language of choice, but is the basic decision-making building block of any program.

An iterator is a construct which abstracts the physical layout of a data structure, allowing you to iterate (pass through) it without worrying about where in memory each element in the data structure is.

So, for example, you can define a data structure such as any of Array, Vector, Deque, Linked List, etc.

When you go to iterate, or pass through the data structure one element at a time, the iterator presents you with an interface in which each element in the data structure follows sequentially, allowing you to loop through with a basic for loop structure:

for <element> in <data-structure>
    <do-action>
end loop

As for other constructs, take a look at some books on Data Structures and Algorithms (usually a 2nd-year level computer science course).

ose
  • 4,065
  • 2
  • 24
  • 40
0

Syntax is only a technical form of expressing your solution. The way you implement and the concepts you use in your solution are the ones who makes the different between a beginner and an experienced developer. Programming languages are the means not the wits !

giorashc
  • 13,691
  • 3
  • 35
  • 71