Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Someone is interested in learning to program. What language paradigm should I recomend him - imperative or declarative? And what programming language should he start with?

I think that declarative because it is closer to math. And I would say that Prolog might be the best start because it is based on logic and programs are short. On the other hand at school we started learning from imperative languages and I am not sure whether there is a benefit to start with them instead of declarive ones.

Thanks. :)

share|improve this question
2  
Prolog is based on logic, but departs from very quickly (cut symbol, etc.). Its syntax and semantics are very far from any other language, which is bad for beginners when they encounter "a real language". –  maaartinus Aug 3 '11 at 21:50
1  
Do you include functional as a subset of declarative, or as a separate paradigm? This could make a big difference to answers. –  Steve314 Aug 3 '11 at 22:05
add comment

7 Answers

up vote 8 down vote accepted

I used to teach Prolog as a first language to freshmen (followed by Scheme and Java in the next semesters) . It was great for some of them, and apparently completely impenetrable for many others. Logic programming may be very close to mathematical logic, but many people are not, in fact very good at formal logic - it's very different from the kind of reasoning (largely informal or even unconscious) that people actually use day-to-day.

On the other hand, I have also taught Java first, with much the same ratio of success! These days I believe that it depends way to much on the individual learner to make a blanket suggestion. I still think that starting with near-machine-level languages (to understand what is actually happening in the computer) and then progressing towards more abstract languages was the right way for me personally, but experience has convinced me that this is not the kind of recommendation that can be generalized.

share|improve this answer
    
+1 for experience. So it seems it depends on student and teacher rather than language. –  user712092 Aug 4 '11 at 9:15
add comment

I wouldn't start with a language like PROLOG. When you're a beginner programmer, you really want to be explicit. PROLOG is not particularly explicit with anything. I would teach a language with simple, obvious execution.

share|improve this answer
    
+1 - I think I agree, but not with the wording. Any language is explicit about the things its explicit about ;-) Prolog is explicit about the logic statements that specify a problem but not the algorithms used to resolve that problem, whereas C would be the other way around. –  Steve314 Aug 3 '11 at 22:18
1  
So imperative language instead so they would grasp algorithms? –  user712092 Aug 4 '11 at 9:14
add comment

I like your idea of teaching Prolog as a first language, but ambitious young programmers want to make something. I taught programming to kids many years ago and we did a lot of VB6 - before everyone cringes, VB6 was very easy to get into, and the progams we worked on were usually games or something graphical, which was also very easy to set up and start in VB6. The students got to see immediate results of changing their code, they had a great time and many often moved on to some of the more advanced courses in C++ and Java, with very little transition problems.

I guess it depends on the first-time programmer you'r working with, but I would stick with imperative simply because there's many more tools and libraries available to "make cool stuff" - unless you know of something cool for Prolog, in which case I'd like to hear about it.

share|improve this answer
    
I have no right to cringe. I started with Commodore Basic. At least your variable names had more than two significant characters. –  Steve314 Aug 3 '11 at 22:06
1  
+1 for Immediate feedback. I guess Evaldraw with immediate feedback would be good too. It has C-like imperative language. –  user712092 Aug 4 '11 at 9:12
add comment

I think that a multi-paradigm language, such as Python or Scala would be best. These wouldn't constrain you to a single paradigm, but allow you to teach procedural, functional, and object-oriented languages without the barrier of learning a new syntax. These are also the major paradigms used in the "real world" of software development, at least for now.

Going along with the point that FrustratedWithFormsDesigner made, these languages also satisfy the urge to build something - it's fairly easy to develop applications that involve input and output (and even graphical user interfaces) quickly, so you can actively see and use what you're building.

share|improve this answer
    
+1 good insight for multi-paradigm. –  user712092 Aug 4 '11 at 12:45
add comment

Declarative may be more math-like, but in real life we much more frequently use imperative statements to convey instructions. For example, the imperative way:

Go potty, then wash your hands, brush your teeth, and go to bed.

vs the declarative way.

Bed time is at 8 o'clock. Going potty is always done before bed. Washing your hands is always done after going potty. Brushing your teeth is always done before bed. The current time is 8 o'clock.

Then, of course, your kid tries to wash his hands after going to bed, or does something gross like brushing his teeth concurrently while using the toilet, and you have to make even more declarations to cover those conditions. (And any parent knows kids are uncannily skilled at finding those loopholes.)

Basically, unless you're teaching a group of people whose immediate primary application for computers is going to be describing the relationships between things, like mathematicians or scientists or statisticians, you're better off starting with imperative languages.

share|improve this answer
    
+1 good insight. I can make up these declarative statements as I remember them, so I describe the problem to computer and expect solution (TLDR order does not matter). I know that human would forget or mess up. In Imperative I solve it. –  user712092 Aug 4 '11 at 9:23
add comment

I taught myself Commodore Structured Bsic, then learned Waterloo Structured Basic and Fortran in high school, and found it so easy. Then I taught myself Prolog, and while I hated the debugging and learning curve (after being taught purely imperative methods), I eventually learned it and to this day, it remains my favourite language. Not that I get hardly any chances to use it, but it teaches you to really think about the application at hand, and break down the work, as opposed to sloppily diving in and nibbling away at the task procedurally.

Nowadays I use various imperative languages, and miss Prolog's elegance, but the lessons I learned were never lost. Anyone can pick up imperative languages, but learning them first makes it harder to learn declarative languages afterwards. Learning declarative languages first teaches good concepts for life, and saves grief trying to get your head around it after learning imperative languages.

If you will only ever write simple scripts or apps with highly deliberate routines that you can easily figure out, then you may as well skip declarative languages, but if you may ever tackle something far too big for any single human brain, you will bless the days you learned the techniques in attacking a project using a declarative language. And why limit yourself from day one to simple coding that one day will surely be done by an app or offshored for a fraction of your price? I say it's truly worth the short 'pain'.

So I vote for learning a declarative language in school, then a more popular imperative language, which is the best way to instill good planning behaviour while minimizing the learning curve.

share|improve this answer
add comment

I cannot emphasize enough that it depends on the person.

Assuming that they want to learn in the first place, a given student may do extremely well with a declarative language, or may need an imperative language to get a conceptual foothold. They may happily leap into messing with abstract concepts and pure math, or they may become completely lost without friendly, visual feedback. They may get a kick out of crafting elegant loops and recursive functions, or they may lose interest if they can't go straight into manipulating things on the screen. They may connect with the flow of a functional language, or they may appreciate the concrete representation of an object-oriented one.

My introduction to the programming world was a little bit of TI-83 BASIC during geometry, a high-school Java class, a college "intro to computing" course that used VB.NET, and a summer doing an Access application in VBA for an internship. And this summer, I did a project using the Spring framework.

The point being, I sort of picked up stuff all over the place, and any one of those (except Spring) could have been my primary introduction to programming. But for someone else, they might be better off with Haskell or Prolog or C or even JavaScript. And for plenty of people, it almost doesn't matter what you throw at them -- they'll learn it anyway. So it comes down to your ability to figure out what, if anything, they need to be able to learn effectively, and choose your tools appropriately.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.