<blockquote>
  <p>We've learned so many things but nothing is related to the CS or SE.</p>
</blockquote>

<p>Beyond any shadow of doubt, <strong>logic is the core skill of any programmer</strong>.</p>

<p>Since you're studying BSE, I'll use an example that is common to the field of enterprise software (as opposed to e.g. hardware drivers). For reference, this is a fairly common problem and by no means a fringe case.</p>

<p>I have two date ranges (i.e. each range has a start date and an end date). I want to know if they overlap in any way. Please write the code necessary to evaluate if these two ranges overlap.<br>
<em>If you want a problem situation: You're making an application for hotel reservations and you need to make sure that you don't double book a room. No two reservations can exist for the same room on the same day.</em></p>

<p>There is no way to not use logic to answer the question. Because you need to account for many different situations. An overlap is created if:</p>

<ul>
<li>range1 is fully in range2 </li>
<li><strong>or</strong> range2 is fully in range1 </li>
<li><strong>or</strong> range1 is before but partially overlaps range2 </li>
<li><strong>or</strong> range2 is before but partially overlaps range1.</li>
</ul>

<p><a href="https://i.sstatic.net/AIBUV.png" rel="nofollow noreferrer">This is a diagram of all possibilities you need to account for</a> (ignore case 5).</p>

<p>As a coder, you will work out the logic needed for each of the four cases, and then <strong>or</strong> their results to see if any of them are true. That's the basic approach to checking if one of many conditions is true.</p>

<p>But if you worked it out and knew how to reduce the logic (remove duplicates, negate the logic, or remove things that are invariably proven by an already existing check), you would see that it's much simpler than that:</p>

<pre><code>bool thereIsOverlap = !(range1.end &lt; range2.start || date2.end &lt; range2.start);
</code></pre>

<p>And that is a whole lot simpler than fully writing out all of those checks.</p>

<hr>

<blockquote>
  <p>It's all about gates and related to Electrical Engineer.</p>
</blockquote>

<p>As I mentioned before, logical gates are essential to programming.</p>

<p>The reason you're seeing this in the context of electrical engineering is because that is a very simple context in which to see its practical applicability. </p>

<ul>
<li>I want this lamp to turn on while I press the button. </li>
<li>I want this lamp to turn off when I press the button. </li>
<li>I want a buzzer to go off when the this button is pressed and another one is not. </li>
<li>...</li>
</ul>

<p>Consider electrical engineering as the example scenario, rather than the ultimate goal of the lesson. Because you're not learning about electricity (which is obviously a major part of electrical engineering), you're only learning about logic and how to apply it.<br>
Electrical engineers and programmers both use logical gates, and the principle of understanding them is exactly the same, even if their practical application is for different purposes.</p>

CC BY-SA 4.0
2020-06-24T23:45:11.173Z
"logic is the core skill of any programmer" Logic, but not "digital logic" ie gates.
philipxy
CC BY-SA 4.0
2019-05-17T12:34:00.063Z
2019-05-17T12:39:33.517Z
2019-05-17T12:39:33.517Z
Flater
<p>The implementation of any realistic software system is based on electronic elements.  Those elements use electricity, generate heat, take up volume, and require propagation time to operate and interconnect.</p>

<p>The more a CS student learns a feel for this physical electronic basis, the less likely they might be to waste time and energy (and thus money) when implementing some software solution.  (CO2 emissions and all that for the "politically correct" valuation of a programming solution.)</p>

CC BY-SA 4.0
2019-05-17T03:27:38.853Z
2019-05-17T03:27:38.853Z
hotpaw2
<p>You don't say if this is a full course in digital logic or just a part of another course. My own preference would be to make it a part of a course unless the entire program is heavy on engineering. </p>

<p>But, I find a short introduction to digital logic, along with some practice exercises to be useful, provided that the students take away the right lesson. </p>

<p>The lesson that I aim for in teaching Programming Languages and Computers Systems is that a complex system can be properly designed as a series of levels (a stack) in which each level has two properties. The first is that the current level is completely built on just the level below and nothing else. The level below was sufficient in every way to define the current level. </p>

<p>More important, for something like programming languages, is that each level is conceptually complete and completely consistent. Complete means that in order to program you can think at any given level and don't need to consider other things - even the lower levels. Consistent means that you won't find contradictory things at any level. </p>

<p>This means that you can, as a Java programmer, write any conceivable program without thinking about how Java was implemented. </p>

<p>Digital logic is usually taken as the lowest level in this stack - gates. From that we can build more complex things - adders. Adding a bit of physics to that we can build actual machines that act the way the math says the gates should behave. The next level up (perhaps) is machine language (actually microcode these days, but that is just another level). Above that is assembler language, then, perhaps something like C. But each level is complete and consistent. You don't need to think about gates as a C programmer. Nor do you need to know how the Java tools were constructed and whether they are expressed in Java, or C, or assembler. </p>

<p>Each level gives you a mental model that you can work with and the model won't desert you. It is complete and consistent. </p>

<p>The other big idea is that as you go up the stack, the ability to express new abstractions increases. Gates and machine language have no abstraction facilities. Assembler language gives abstractions of simple operations, but little else. Once you reach high level languages you get abstractions for things like functions and objects. You get to define and name complex things and program in terms of those complex things rather than gates. </p>

<p>But some study of digital logic and gates gives you a base on which this is built. It isn't "turtles all the way down". </p>

CC BY-SA 4.0
2023-02-12T05:57:58.980Z
Your answer keeps reminding me Gödel's incompleteness theorems. lol
Qiulang 邱朗
CC BY-SA 4.0
2019-05-02T19:32:06.147Z
2019-05-02T19:32:06.147Z
Buffy
<p>Logic is used <strong>A lot</strong> in programming. </p>

<p>There is little difference between hardware and software. It is just an implementation detail. The choice of what goes where is a balance between cost and speed, but where ever it goes it is just logic: if you implement it in Python, C♯, assembler, HTML, electronics, or mechanical. </p>

CC BY-SA 4.0
2019-05-20T20:33:21.650Z
Nailed it with "...just an implementation detail." As a developer I could not care less about gates themselves (heck I probably couldn't even draw most of them without a reference at this point), however I do care a great deal about how I set up all of my conditional statements. I've even drawn out truth tables for some of the more complex stuff.
Broots Waymb
CC BY-SA 4.0
2019-05-02T21:58:32.167Z
2019-05-02T21:58:32.167Z
ctrl-alt-delor
<p>Well, you would be amazed at the number of times I have reviewed code with a complex condition or nested-if statements where some condition got missed that I flagged by drawing a simple truth table.</p>

<p>However, the big problem is that without a digital logic course you likely won't understand "state machines" and that's a <strong>REALLY</strong> big deal.  And state machines pervade quite a lot of programming.</p>

<p>If you hear the word "protocol", there is a state machine underneath somewhere.  If you have "concurrency", there is a state machine.  "Parser" or "regular expression"--ayup, state machine.  "Agent" or "behavior"--also probably a state machine.</p>

<p>Now, you can design state machines implicitly without knowing that you did.  State machines are kinda common sense.  But, it's often a lot easier to deal with state machines when you know what you built, can name it, communicate about it, and use tools specifically built to deal with it.</p>

CC BY-SA 4.0
2023-02-12T05:48:06.333Z
But I see people can understand SM easily without knowing much of DC.
Qiulang 邱朗
CC BY-SA 4.0
2019-05-14T21:24:51.653Z
2019-05-14T21:24:51.653Z
Andrew Lentvorski
<p>It is really useful to understand the low level operation of the machine when programming in languages like C. Understanding how the digital circuits actually do the work aids understanding of one and two's complement arithmetic, and the relative speeds of integer and floating point operations. Having a sound understanding of the fetch/decode/execute cycle is also useful if you want to develop microcode or assembler.</p>

<p>It is often the case that problems at a software level can only be understood with a knowledge of the digital systems. For example, read through some of this post :- </p>

<p><a href="https://stackoverflow.com/questions/11227809/why-is-it-faster-to-process-a-sorted-array-than-an-unsorted-array">https://stackoverflow.com/questions/11227809/why-is-it-faster-to-process-a-sorted-array-than-an-unsorted-array</a></p>

<p>You might also need to program embedded systems, GPU cards, and control any number of low level devices later in your career. Gaining the understanding for this will depend on knowing the digital design basics.</p>

<p>Most important of all I would say that without this knowledge it is not possible to really understand how a computer works. There would always be a mystery for you regarding exactly how the computer operates. </p>

<p>Hope this motivates a little :)</p>

CC BY-SA 4.0
2019-05-09T20:40:23.390Z
2019-05-09T20:40:23.390Z
Jon Guiton
<p>I hope your course is teaching you skills which will be relevant if you decide to pick up whatever new technology comes along in 10 years time. Some courses might look to be aimed at people who can turn out generic code using whichever language was hot 5 years ago, and it may well be that the digital logic module is unchanged since the 1980's - but that doesn't mean it is irrelevant.</p>

<p>Assuming your course is generic, there are a wide range of career choices that follow the course. <a href="https://insights.stackoverflow.com/survey/2019" rel="nofollow noreferrer">Developer - Full Stack</a> might be hot in 2019, but there are plenty of other fields which need a different focus, are not electronics or standard cell design, but benefit from closer understanding of the hardware. You might be working in a cross functional team, and need to speak to hardware folks (or worse, trying to interpret a slightly incomplete specification). You might be making a trade-off between doing work on a CPU, GPU, NN, or FPGA. You might be testing CPU designs. I guess you're unlikely to end up implementing CPU architectures, but other people on your course might.</p>

<p>The course developer doesn't usually know in advance what field you will want to work in, and will usually be trying to avoid closing down your future options (unless the course is tightly focused on training a specific work task).</p>

CC BY-SA 4.0
2019-05-17T12:35:25.290Z
DLD does not prepare a student for electrical engineering. This does not entail the physical properties of electricity, but only the ways in which logic can be used to achieved certain outcomes in certain conditions (which is commonly done using electricity, but irrelevant to a programmer).
Flater
CC BY-SA 4.0
2019-05-17T15:45:46.320Z
You're misreading what I wrote. I am suggesting a wider background will help someone work better in a cross-functional team.
Sean Houlihane
CC BY-SA 4.0
2019-05-10T12:13:52.417Z
2019-05-10T12:13:52.417Z
Sean Houlihane
<p>Is there any relationship between a computer science student and DLD course? I am studying for a Bachelors of Science and Engineering degree, and we are studying DLD (Digital Logic Design) in my second semester.</p>
<p>We've learned so many things about DLD but nothing is related to the CS or SE. It's all about gates and related to Electrical Engineer.
Is there any need of DLD in Software Engineering? While the main thing which is concern for us is Programming Languages and Computers System?</p>

CC BY-SA 4.0
2019-05-02T21:54:24.807Z
There are a lot of abrivs in this question. Can you edit, so that we all know what you are saying.
ctrl-alt-delor
CC BY-SA 4.0
2019-05-03T01:27:10.340Z
How in the world could you assert that logic gates have nothing to do with Computer Science or Software Engineering?  It's like saying, "I want to learn medicine, but they're making me take a class about cells."
Ben I.
<programming>
Why Computer Science students learn Digital Logic Design?
# Why Computer Science students learn Digital Logic Design?

(Asked by: username_0 on 2019-05-02)

Is there any relationship between a computer science student and DLD course? I am studying for a Bachelors of Science and Engineering degree, and we are studying DLD (Digital Logic Design) in my second semester.

We've learned so many things about DLD but nothing is related to the CS or SE. It's all about gates and related to Electrical Engineer.
Is there any need of DLD in Software Engineering? While the main thing which is concern for us is Programming Languages and Computers System?

**Tags:** programming

> **Comments:**
> **username_1**: There are a lot of abrivs in this question. Can you edit, so that we all know what you are saying.  
> **username_2**: How in the world could you assert that logic gates have nothing to do with Computer Science or Software Engineering?  It's like saying, "I want to learn medicine, but they're making me take a class about cells."  

---

## 7 answers

### Answer by username_6 on 2019-05-02. Score: 6

You don't say if this is a full course in digital logic or just a part of another course. My own preference would be to make it a part of a course unless the entire program is heavy on engineering.

But, I find a short introduction to digital logic, along with some practice exercises to be useful, provided that the students take away the right lesson.

The lesson that I aim for in teaching Programming Languages and Computers Systems is that a complex system can be properly designed as a series of levels (a stack) in which each level has two properties. The first is that the current level is completely built on just the level below and nothing else. The level below was sufficient in every way to define the current level.

More important, for something like programming languages, is that each level is conceptually complete and completely consistent. Complete means that in order to program you can think at any given level and don't need to consider other things - even the lower levels. Consistent means that you won't find contradictory things at any level.

This means that you can, as a Java programmer, write any conceivable program without thinking about how Java was implemented.

Digital logic is usually taken as the lowest level in this stack - gates. From that we can build more complex things - adders. Adding a bit of physics to that we can build actual machines that act the way the math says the gates should behave. The next level up (perhaps) is machine language (actually microcode these days, but that is just another level). Above that is assembler language, then, perhaps something like C. But each level is complete and consistent. You don't need to think about gates as a C programmer. Nor do you need to know how the Java tools were constructed and whether they are expressed in Java, or C, or assembler.

Each level gives you a mental model that you can work with and the model won't desert you. It is complete and consistent.

The other big idea is that as you go up the stack, the ability to express new abstractions increases. Gates and machine language have no abstraction facilities. Assembler language gives abstractions of simple operations, but little else. Once you reach high level languages you get abstractions for things like functions and objects. You get to define and name complex things and program in terms of those complex things rather than gates.

But some study of digital logic and gates gives you a base on which this is built. It isn't "turtles all the way down".

> **Comments:**
> **username_7**: Your answer keeps reminding me Gödel's incompleteness theorems. lol  

---

### Answer by username_1 on 2019-05-02. Score: 4

Logic is used **A lot** in programming.

There is little difference between hardware and software. It is just an implementation detail. The choice of what goes where is a balance between cost and speed, but where ever it goes it is just logic: if you implement it in Python, C♯, assembler, HTML, electronics, or mechanical.

> **Comments:**
> **username_8**: Nailed it with "...just an implementation detail." As a developer I could not care less about gates themselves (heck I probably couldn't even draw most of them without a reference at this point), however I do care a great deal about how I set up all of my conditional statements. I've even drawn out truth tables for some of the more complex stuff.  

---

### Answer by username_9 on 2019-05-14. Score: 3

Well, you would be amazed at the number of times I have reviewed code with a complex condition or nested-if statements where some condition got missed that I flagged by drawing a simple truth table.

However, the big problem is that without a digital logic course you likely won't understand "state machines" and that's a **REALLY** big deal. And state machines pervade quite a lot of programming.

If you hear the word "protocol", there is a state machine underneath somewhere. If you have "concurrency", there is a state machine. "Parser" or "regular expression"--ayup, state machine. "Agent" or "behavior"--also probably a state machine.

Now, you can design state machines implicitly without knowing that you did. State machines are kinda common sense. But, it's often a lot easier to deal with state machines when you know what you built, can name it, communicate about it, and use tools specifically built to deal with it.

> **Comments:**
> **username_7**: But I see people can understand SM easily without knowing much of DC.  

---

### Answer by username_10 on 2019-05-09. Score: 2

It is really useful to understand the low level operation of the machine when programming in languages like C. Understanding how the digital circuits actually do the work aids understanding of one and two's complement arithmetic, and the relative speeds of integer and floating point operations. Having a sound understanding of the fetch/decode/execute cycle is also useful if you want to develop microcode or assembler.

It is often the case that problems at a software level can only be understood with a knowledge of the digital systems. For example, read through some of this post :-

<https://stackoverflow.com/questions/11227809/why-is-it-faster-to-process-a-sorted-array-than-an-unsorted-array>

You might also need to program embedded systems, GPU cards, and control any number of low level devices later in your career. Gaining the understanding for this will depend on knowing the digital design basics.

Most important of all I would say that without this knowledge it is not possible to really understand how a computer works. There would always be a mystery for you regarding exactly how the computer operates.

Hope this motivates a little :)


---

### Answer by username_11 on 2019-05-10. Score: 2

I hope your course is teaching you skills which will be relevant if you decide to pick up whatever new technology comes along in 10 years time. Some courses might look to be aimed at people who can turn out generic code using whichever language was hot 5 years ago, and it may well be that the digital logic module is unchanged since the 1980's - but that doesn't mean it is irrelevant.

Assuming your course is generic, there are a wide range of career choices that follow the course. [Developer - Full Stack](https://insights.stackoverflow.com/survey/2019) might be hot in 2019, but there are plenty of other fields which need a different focus, are not electronics or standard cell design, but benefit from closer understanding of the hardware. You might be working in a cross functional team, and need to speak to hardware folks (or worse, trying to interpret a slightly incomplete specification). You might be making a trade-off between doing work on a CPU, GPU, NN, or FPGA. You might be testing CPU designs. I guess you're unlikely to end up implementing CPU architectures, but other people on your course might.

The course developer doesn't usually know in advance what field you will want to work in, and will usually be trying to avoid closing down your future options (unless the course is tightly focused on training a specific work task).

> **Comments:**
> **username_3**: DLD does not prepare a student for electrical engineering. This does not entail the physical properties of electricity, but only the ways in which logic can be used to achieved certain outcomes in certain conditions (which is commonly done using electricity, but irrelevant to a programmer).  
> **username_11**: You're misreading what I wrote. I am suggesting a wider background will help someone work better in a cross-functional team.  

---

### Answer by username_3 on 2019-05-17. Score: 1

We've learned so many things but nothing is related to the CS or SE.

Beyond any shadow of doubt, logic is the core skill of any programmer.
Since you're studying BSE, I'll use an example that is common to the field of enterprise software (as opposed to e.g. hardware drivers). For reference, this is a fairly common problem and by no means a fringe case.
I have two date ranges (i.e. each range has a start date and an end date). I want to know if they overlap in any way. Please write the code necessary to evaluate if these two ranges overlap.
If you want a problem situation: You're making an application for hotel reservations and you need to make sure that you don't double book a room. No two reservations can exist for the same room on the same day.
There is no way to not use logic to answer the question. Because you need to account for many different situations. An overlap is created if:

range1 is fully in range2 
or range2 is fully in range1 
or range1 is before but partially overlaps range2 
or range2 is before but partially overlaps range1.

This is a diagram of all possibilities you need to account for (ignore case 5).
As a coder, you will work out the logic needed for each of the four cases, and then or their results to see if any of them are true. That's the basic approach to checking if one of many conditions is true.
But if you worked it out and knew how to reduce the logic (remove duplicates, negate the logic, or remove things that are invariably proven by an already existing check), you would see that it's much simpler than that:
bool thereIsOverlap = !(range1.end < range2.start || date2.end < range2.start);

And that is a whole lot simpler than fully writing out all of those checks.


It's all about gates and related to Electrical Engineer.

As I mentioned before, logical gates are essential to programming.
The reason you're seeing this in the context of electrical engineering is because that is a very simple context in which to see its practical applicability. 

I want this lamp to turn on while I press the button. 
I want this lamp to turn off when I press the button. 
I want a buzzer to go off when the this button is pressed and another one is not. 
...

Consider electrical engineering as the example scenario, rather than the ultimate goal of the lesson. Because you're not learning about electricity (which is obviously a major part of electrical engineering), you're only learning about logic and how to apply it.
Electrical engineers and programmers both use logical gates, and the principle of understanding them is exactly the same, even if their practical application is for different purposes.

> **Comments:**
> **username_4**: "logic is the core skill of any programmer" Logic, but not "digital logic" ie gates.  

---

### Answer by username_5 on 2019-05-17. Score: 0

The implementation of any realistic software system is based on electronic elements. Those elements use electricity, generate heat, take up volume, and require propagation time to operate and interconnect.

The more a CS student learns a feel for this physical electronic basis, the less likely they might be to waste time and energy (and thus money) when implementing some software solution. (CO2 emissions and all that for the "politically correct" valuation of a programming solution.)


---

