Jump to content

  • Log In with Google      Sign In   
  • Create Account

Logic (That's what programming is centered around right?)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
20 replies to this topic

Poll: Should Logic be a prerequisite to computer programming? (33 member(s) have cast votes)

Should Logic be a prerequisite to computer programming?

  1. No, it is not a must. (11 votes [33.33%] - View)

    Percentage of vote: 33.33%

  2. It depends... (6 votes [18.18%] - View)

    Percentage of vote: 18.18%

  3. Yes! It is a must! (16 votes [48.48%] - View)

    Percentage of vote: 48.48%

Vote Guests cannot vote

#1 Tutorial Doctor   Members   -  Reputation: 1630

Like
0Likes
Like

Posted 27 February 2014 - 08:53 PM

So, let's peak over at Wikipedia for a sec, to the article on "logic."

 

http://en.wikipedia.org/wiki/Logic

 

So, yeah, big topic. Lot's of research. Years and years of exhaustive toiling over the meaning of meanings....

 

Now you want to be a computer programmer. You see a few tutorials, play with a few languages. Write a few lines of code...

 

But how is your logic and reasoning?

 

Are you a problem solver? A good one?

 

I figured after watching an iTunes U course on Computer Science that logic is the main topic of a college level CS degree. 

 

How do we solve complex problems efficiently? 

 

Do you think that logic should be a prerequisite to computer programming?

 

If so, why don't we teach logic in grade school as a separate course? 

 

 


They call me the Tutorial Doctor.


Sponsor:

#2 Vortez   Crossbones+   -  Reputation: 2698

Like
0Likes
Like

Posted 27 February 2014 - 10:18 PM

I voted "It depend" because logic does play a role in programming, but it's not all that programming is all about (if it was electronics then ill say it's way more proeminent). 

True, a lot of ifs/switchs/comparaisons are used in most programs, but they also work with numbers (add/sub/mult/div ect...) so logic is only half of programming id say, the other half being computational task and IO stuffs.

 


Do you think that logic should be a prerequisite to computer programming?
If so, why don't we teach logic in grade school as a separate course?

 

Well, i belive most programming course should include a chapter or two on logic, i learned mine in my electrician course, and it was really easy for me (i didn't knew programming at that time very much).


Edited by Vortez, 27 February 2014 - 10:26 PM.


#3 BGB   Crossbones+   -  Reputation: 1554

Like
0Likes
Like

Posted 27 February 2014 - 11:27 PM

I voted "It depend" because logic does play a role in programming, but it's not all that programming is all about (if it was electronics then ill say it's way more proeminent). 

True, a lot of ifs/switchs/comparaisons are used in most programs, but they also work with numbers (add/sub/mult/div ect...) so logic is only half of programming id say, the other half being computational task and IO stuffs.

 

 

 


Do you think that logic should be a prerequisite to computer programming?
If so, why don't we teach logic in grade school as a separate course?

 

Well, i belive most programming course should include a chapter or two on logic, i learned mine in my electrician course, and it was really easy for me (i didn't knew programming at that time very much).

 

I am not sure how to best classify or describe programming (at a meta level).

 

I think probably just thinking things and writing out whatever they happen to be thinking at the moment (in code form) probably mixed with a fair bit of trial-and-error, are probably a pretty big part of the process as well.

 

well, and also sometimes the "feel" of engaging in a direct fiddle-and-feedback loop:

fiddle with code;

recompile and test;

fiddle a little more;

...

 

though, in terms of the experience, it seems like it should need to be very fast for this to work, it sort of works with a cycle time of potentially many minutes or more.

 

spending too long thinking without actually doing anything can make one feel irritable.

sometimes, it may get to be one acting out of habit, maybe doing a few cycles or building and testing things for "no reason in particular", it can become somehow oddly soothing/relaxing.

 

then again, apart from this sort of thing, my life is pretty empty sometimes...



#4 Aardvajk   Crossbones+   -  Reputation: 6010

Like
6Likes
Like

Posted 28 February 2014 - 02:00 AM

No. Formal logic is a prerequisite to electronics as has been said, and the start of any course in circuit design will almost certainly be a primer on boolean algebra, karnaugh maps etc. But taught in the context of logical gates. Context is everything in teaching and formal logic taught in isolation would seem meaningless and abstract, but put someone in front of a virtual circuit board designer so they can see how it relates to making a seven segment display output a number and you're golden.

 

Bitwise operations are increasingly "advanced" topics in programming these days and the higher level that beginners languages work in mean the kind of logic you need for programming is well divorced from formal logic and more in the realms of common sense - if/then, while, (logical) and, (logical) or are all concepts I'd expect people to understand without any formal training in logical analysis.

 

This is not the area which seems to be the barrier to beginners. Variables, control structures and normal maths seem to be. Drowning a beginner in formalized logical analysis would probably scare most people off as it would validate the misconception of programming as hard and complicated, as perpetuated by the Hollywood screenshots of dense, unreadable code in every hacker flick.


Edited by Aardvajk, 28 February 2014 - 02:03 AM.


#5 King Mir   Members   -  Reputation: 2002

Like
0Likes
Like

Posted 28 February 2014 - 04:31 AM

While formal logic has similarities to programming, it's really a separate field.

EDIT:
Re: Electronics.
Logic is not a prerequisite for electronics either. Boolean logic as used in electronics uses different symbols and terminology to formal logic, and is rather small subset of a logic course. Boolean algebra and karnaugh maps are better coupled with a math course or a circuits course than a straight logic course.

Edited by King Mir, 28 February 2014 - 04:42 AM.


#6 Olof Hedman   Crossbones+   -  Reputation: 2851

Like
0Likes
Like

Posted 28 February 2014 - 04:42 AM

Formal logic is probably a bit over the head for most children in grade school, even many first year students at university struggle with it.

 

So I don't think it's really needed in grade school, but for any higher technical or scientific education it should definitely be included, and I would be surprised if there wasn't at least some course in logic in any such program.

 

But a prerequisite? no... you can go a long way in programming without any knowledge of formal logic, just using your intuition.

 

It definitely helps knowing something about it though (in programming, and in life in general...) 



#7 Álvaro   Crossbones+   -  Reputation: 13368

Like
3Likes
Like

Posted 28 February 2014 - 09:33 AM

This is a bad question because "Logic" can mean many things. Primarily, it could be a branch of Philosophy or a branch of Mathematics. However, the answer is still "no". A smart kid can learn programming without any prerequisites whatsoever.

 

I started to program when I was 7. My dad taught me a few basic things about how his programmable calculator worked, and I played around with it until I figured it out. If instead of teaching me what "if" and "goto" do he had started by introducing Logic and whatever other things people think should be prerequisites for programming, I would have been overwhelmed and I wouldn't have learned anything.



#8 frob   Moderators   -  Reputation: 21475

Like
1Likes
Like

Posted 28 February 2014 - 11:55 AM

First I voted "it depends", then changed my answer to "no" because people are lazy when it comes to definitions.

In order to program you need to think logically, you need to be able to reason through problems. You need to be able to explain a problem in terms of equations.

However, the ability to reason is very different than the study of reason. Most people are able to logically reason their way through problems without formal study on the rules of logic, how implication works, playing reasoning mind-games, or, (since you likely meant computational logic rather than logic generally) study their way through formal languages of logic or proofs.

Also, due to lax definitions, I would say no to 'prerequisite', but yes to 'corequisite'. You need the material at the same time you are learning to program.

Logic is a big field. You can get advanced degrees in the study and expression of logic by itself. You don't need that as a prerequisite to beginning to program.

Finally, while I will agree that computer science can rely on formal logic, that is not the core. I would argue computer science is an application of general mathematics rather than logic. The machines are computational engines designed around mathematics, the values used in computation are a perfect fit within discrete mathematics, and when programmed the applications frequently align themselves around mathematics topics like linear algebra, trig, accounting and verifiability, cryptography, and more.



Do you need the ability to apply reason and the ability to break problems down, build problems up, and find equivalent solutions? Yes. All of these are areas of logic that you need while learning how to program.

Do you need formal study on logic, the history of logic, philosophy of logic, semantics of logic, logic in debate, logic in philosophy, logic in mathematics? No. While these can potentially be valuable in a career, and many people in computer science rely on them, they are not a prerequisite to programming.

Edited by frob, 28 February 2014 - 12:01 PM.

Check out my personal indie blog at bryanwagstaff.com.

#9 BGB   Crossbones+   -  Reputation: 1554

Like
0Likes
Like

Posted 28 February 2014 - 12:07 PM

This is a bad question because "Logic" can mean many things. Primarily, it could be a branch of Philosophy or a branch of Mathematics. However, the answer is still "no". A smart kid can learn programming without any prerequisites whatsoever.

 

I started to program when I was 7. My dad taught me a few basic things about how his programmable calculator worked, and I played around with it until I figured it out. If instead of teaching me what "if" and "goto" do he had started by introducing Logic and whatever other things people think should be prerequisites for programming, I would have been overwhelmed and I wouldn't have learned anything.

 

 

yeah. I mostly started out fiddling with QBasic and later Turbo C and DJGPP and similar back when I was in elementary school (mostly on my own).

at the time, I didn't even really know what the order of operations were or similar, but it didn't take long to learn them from observation.

 

I did ok in high-school level algebra, but basically sucked at everything else.

got to college, pretty much sucked at everything.

and, as well, suck at pretty much anything life-in-general related.

 

not particularly good with dealing with abstract thinking either.

...

 

still reasonably good at programming though at least.

 

like, in life, there are relatively few things that actually make sense. programming seems to be one of them.

I suspect in many ways, it may be a lot more fundamental than all of the "meta" and academic disciplines and similar that people seem to try to glue onto it.



#10 Tutorial Doctor   Members   -  Reputation: 1630

Like
0Likes
Like

Posted 28 February 2014 - 12:17 PM


However, the ability to reason is very different than the study of reason

 

Hmm. Good quote. Question though, do you think that taking a CS course in college teaches you to reason at a higher level? And when it comes to computer programming, don't  you think that a person should be able to reason at a higher level for that profession?

 

Sure, I can solve lots of problems, and I can reason through stuff, but there is no way I could write such complex algorithms as are out there to do complex tasks. It just feels like such reasoning/logic comes from college courses, and not from common sense. 

 

The main reason I am asking this question is to find out if I need to learn about logic in order to become a better programmer, or at least a faster problem solver. 


They call me the Tutorial Doctor.


#11 King Mir   Members   -  Reputation: 2002

Like
0Likes
Like

Posted 28 February 2014 - 12:32 PM

Learning to write algorithms would probably come from studying a lot of existing algorithms and software patterns. It about of being able to express a problem in a generic way, and knowing which pieces can go together for the bigger picture. It's also about being able to articulate how you go about solving a problem yourself.

A formal logic course won't teach you that.

#12 frob   Moderators   -  Reputation: 21475

Like
1Likes
Like

Posted 28 February 2014 - 12:54 PM

However, the ability to reason is very different than the study of reason

 
Hmm. Good quote. Question though, do you think that taking a CS course in college teaches you to reason at a higher level? And when it comes to computer programming, don't  you think that a person should be able to reason at a higher level for that profession?
 
Sure, I can solve lots of problems, and I can reason through stuff, but there is no way I could write such complex algorithms as are out there to do complex tasks. It just feels like such reasoning/logic comes from college courses, and not from common sense. 
We gain a certain amount of logic and reasoning through experience. They start out at a basic level (touching the stove is hot, falling down the stairs is painful, dirt tastes bad), where through experience we learn to reason about the world around us (touching something in the oven might also be hot, falling off a cliff might also be painful, mud probably also tastes bad). As we study in school and in life we gain more experience and more nuance.

Normally in a CS program the theory courses begin in the third year. During the first two years people are exposed to certain types of logic and reasoning, but they don't have any courses dedicated to it. Some students may ask questions about it, others will not. Also some students will drop out of the program and become arts or humanities majors. By the time you get into subjects like compiler theory, algorithmic theory and complexity theory, course where more formal logic is used, the instructors know they must generally teach a bit of formal reasoning skills to the students.

The main reason I am asking this question is to find out if I need to learn about logic in order to become a better programmer, or at least a faster problem solver.

I have only once heard someone seriously complain about having too much knowledge. It was because so many people kept coming to them asking for assistance that they were struggling to get their own work done.

Gaining more knowledge and experience in a field you find interesting is valuable in itself. If you want to increase your knowledge in a topic or field, that is reason enough to do it.
Check out my personal indie blog at bryanwagstaff.com.

#13 Tutorial Doctor   Members   -  Reputation: 1630

Like
0Likes
Like

Posted 28 February 2014 - 01:08 PM

So many points I would like to comment on on that post frob, good one. 

 

Your first paragraph gives me some ideas about AI in programming. Some type of Experience Algorithm, or inference. 

 

I like your last sentence also. I could increase my knowledge in a field, but if it is unnecessary to a goal I might not. 

 

I felt that learning about games and game mechanics and game theory, even if a little, would help me to understand them more. I saw that a lot of topics here were technical, and there weren't many discussions about game theory and such. I wanted to get the the core of what games are, and why people play them, and why people prefer one over another. I mean, if I am making a game I want to sell, I figure such information would be useful. 

 

Now I was wondering if when learning to program better, I should learn logic or study algorithms and such. 

 

Now, I can relate this to another venture I took, to learn chess

 

What I found is that chess is a fun game, but it becomes less fun when you are playing someone who has studied all the possible opening moves and middle game variations and end- game variations. It becomes less fun when you are playing against someone who can see 20 moves ahead. It is more fun when you play with someone of your equal. 

 

Also, if one understands the rules of chess, and the limitations and strengths of the pieces, one can naturally play a "best move" without study of chess theory. 

 

Why is it not fun to play with people who went deep? They beat you every time! 

 

I think there are two ways to go about logic. Understanding the building blocks of logic very well, and studying logic and reading endless books on logic. I prefer the former. 

 

Understanding the DO's and DON'Ts and the WHYs. 

 

I think I should apply this thinking to all new things I learn, to learn the basic building blocks so well that I can solve more complex problems with them. 

 

Variables to functions to classes etc. 


Edited by Tutorial Doctor, 28 February 2014 - 01:09 PM.

They call me the Tutorial Doctor.


#14 BGB   Crossbones+   -  Reputation: 1554

Like
1Likes
Like

Posted 28 February 2014 - 04:51 PM

Learning to write algorithms would probably come from studying a lot of existing algorithms and software patterns. It about of being able to express a problem in a generic way, and knowing which pieces can go together for the bigger picture. It's also about being able to articulate how you go about solving a problem yourself.

A formal logic course won't teach you that.

 

yes. a fair bit of programming is mostly rehashing things which already exist, or taking something that have been used in one context and applying it in a slightly different context, ...

 

probably having an ability to fit largish amounts of random stuff into their memory is on-par with having an ability to really understand or reason about it.

and, with memory, one can also benefit that others people have largely done most of the actual thinking and reasoning work, so to a large degree it becomes more a matter of remembering having seen a good or at least adequate solution which can be made to fit the current problem (or maybe remembering various solutions and ranking them according to some or another metric, ...).



#15 Tutorial Doctor   Members   -  Reputation: 1630

Like
0Likes
Like

Posted 01 March 2014 - 05:11 PM


so to a large degree it becomes more a matter of remembering having seen a good or at least adequate solution which can be made to fit the current problem

 

Nice way to put it! That is what I meant by the chess thing. I remember playing this one chess game that teaches you how to play chess. I think it was ChessMaster for PC. He didn't teach you all the different variations and such. He said the move you should play is "the best move."

 

So he taught you how the pieces move and how to best move the pieces. Then he gives you a scenario and says, "play the best move." Now, there were good moves on the board also, but I had to play the best move. He then explains why the move is the best move. Usually, when you move "with tempo" that is the best move. 

 

I wonder if there is some small basic principles of programming, that I could use as building blocks to solve more complex computational problems. There is probably a term out there that describes what I am talking about, I just haven't run across it yet. 


They call me the Tutorial Doctor.


#16 walsh06   Members   -  Reputation: 662

Like
0Likes
Like

Posted 01 March 2014 - 05:46 PM


I wonder if there is some small basic principles of programming, that I could use as building blocks to solve more complex computational problems. There is probably a term out there that describes what I am talking about, I just haven't run across it yet.

Thats pretty much what programming is in the end. No matter what happens youll still end up using a loop or using an if or whatever other part of programming.

 

 



#17 Bregma   Crossbones+   -  Reputation: 5182

Like
1Likes
Like

Posted 01 March 2014 - 06:11 PM

Premise 1: All reasoning requires logic.

 

Premise 2: Programming a computer requires reasoning.

 

Conclusion: Computer programming requires logic.

 

Of course, you can come to that conclusion through trial and error, perhaps by throwing darts at a dart board with random words taped to it, or hiring infinite monkeys with spell-correcting word processors.  There are approximately 2¹⁸ seconds in the expected lifetime of the universe, you can do it if you start now.


Stephen M. Webb
Professional Free Software Developer

#18 Paradigm Shifter   Crossbones+   -  Reputation: 5380

Like
0Likes
Like

Posted 01 March 2014 - 06:30 PM

If you really want

 

 

You must try though


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#19 Bacterius   Crossbones+   -  Reputation: 8945

Like
0Likes
Like

Posted 01 March 2014 - 10:16 PM


There are approximately 2¹⁸ seconds in the expected lifetime of the universe, you can do it if you start now.

 

TIL the universe ends in three days laugh.png


The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#20 Álvaro   Crossbones+   -  Reputation: 13368

Like
3Likes
Like

Posted 01 March 2014 - 11:25 PM

Premise 1: All reasoning requires logic.
 
Premise 2: Programming a computer requires reasoning.
 
Conclusion: Computer programming requires logic.


The problem is that premise 1 is false.

Logic is to reason as grammar is to language. And I wouldn't say studying grammar is a prerequisite for speaking.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS