Maker Pro
Maker Pro

how to build programming logic?

shivajikobardan

Oct 21, 2021
39
Joined
Oct 21, 2021
Messages
39
I am computer engineering student(Our curriculum is 80% similar to electronics engineering in our country so you can call me electronics engineering student as well tbh). But this thing is relevant to electronics engineering as well so I am asking it here. I still don't know how to program. I of course can code very tiny tiny programs like prime number etc etc...But I am nowhere near the level of building big programs like using frameworks to make stuffs and so on.

I learnt c, c++ and python and bit of javascript. But all of them were useless. I learnt programming languages and not programming.

I know assebly language coding in 8085 and 8086 microprocessor. I didn't learn 8051 quite well though.

I think this question is relevant to electronics engineering students in my country(Nepal) as most electronics engineering students pursue career in coding like web development. Any way, coding is essential part of electronics engineering, we all know about that.


I am currently learning python. I learnt syntax of python. And I am currently solving codewars problems. I read other person's solutions as well and try to understand at least 5 different solutions to a problem. My logic has improved a bit in programming but I consciously want to know how to improve my logic in programming? What else can I do to improve my logic in programming? Any guidance will be extremely valuable.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
12,615
Joined
Nov 17, 2011
Messages
12,615
Studying code others have written is imho a good start for improving your code skills. This is the reverse: have your code studies and discussed by others. You could create a group of fellow students where you solve coding problems, then study, compare and discuss your solutions. In these discussions you will learn a lot by listening to your peers and why they chose a specific coding solution.
It will also help to study code that has been published e.g. on Github.


As often in life there is more than one way to solve a problem aka write code for solving a problem. When discussing different solutions to a coding problem, you will have to consider the quality attributes of the code:
  • Is the programming language appropriate for this kind of problem? Many programming languages are specifically well suited to deal with one kind of problem but utterly clumsy when applied to other problems.
    Take for example assembler versus C++: While assembler is useful for programming near to the hardware, with little memory usage and at high execution speed, it would be a chore to program a visual interface (GUI) in assembler. And vice versa.
  • Is the code well readable /maintainable (these two go imho hand in hand)?
  • is the code efficient in terms of memory usage and/or runtime?
  • is the code testable ( a requisite for ensuring almost correct code - unless the code is absolutely simple there will always be errors that need to be found)?
  • is the code fault tolerant, i.e. does it recover from minor errors such as e.g. unexpected user input?
Optimizing one of these quality attributes often comes at the expense of others. You may have to find a balance.

But I am nowhere near the level of building big programs like using frameworks to make stuffs and so on.
That will come with time. When you start to learn how to drive a car, you cant jump into a race competition without lots of training.
I learnt c, c++ and python and bit of javascript. But all of them were useless.
I doubt your effort was useless. You may not be able to apply your newly acquired knowledge immediately, but knowing more than one programming language and their paradigms will greatly help you in choosing a suitable language when you need to tackle your next problem. Not all programming languages are equally well suited to solve a problem. We're now back to the above mentioned quality attributes. If you know only one programming language, then you will have to solve all programming tasks with this one language, your "Golden Hammer".

You may also study literature on programming. One well written series is "The art of computer programming" by Donald Knuth. This book series was started in the 1960, the last volume was released in 2015. In this book series Donald Knuth explains how to solve problems by programming. He uses his own programming language to abstract the logical reasoning from issues with real programming languages. In my opinion this book series is invaluable in spite of being a Methusalem (when thinking in computer engineers' terms of time).
Go to your university's library and see which books on programming they have to offer. Don't just read these books, try to follow along by coding your own examples (many books come with "tests" and solutions for you to follow).
 

hevans1944

Hop - AC8NS
Jun 21, 2012
4,739
Joined
Jun 21, 2012
Messages
4,739
Learning how to program (computers) is much like learning how to teach a very young child... a two or three year old, for example. If the child is innately of superior intelligence, the learning goes quickly. But, unless you are working with a very sophisticated computer that has already been programmed to behave as an artificial intelligence or AI, it is very difficult to "get inside" the computer to tell it what you want it to do.

Unless you are trying to program a computer built with "fuzzy logic," computers will always do what you tell them to do, not necessarily what you want them to do. Part of the "joy" of programming is figuring out why your program doesn't cause your computer to do what you want it to do. Different programming "languages" approach this problem in different ways, and as @Harald Kapp noted, you don't want to use machine-level assembly "language" to create a Graphical User Interface. You might need to insert some low-level code to improve performance (ray-trace rendering, for one example) but the entire GUI application will be written in an appropriate "high-level language" that allows abstraction of the GUI components.

Computers today can be programmed to "understand" a spoken language to a very limited extent. Once the art of programming, and the hardware on which to run the programming, has advanced sufficiently, anyone will be able to "program" by simply stating what the computer should do and then allowing the computer to "figure out" how to do it. We can then gather up all of that and place it in a mobile, anthropomorphic, chassis and... voila! We have invented a humanoid robot. Make sure you have, at the very least, built in Isaac Asimov's Three Laws to prevent the thing from running amok after you turn it on. It would help to also have a remote switch to turn in off. We want to build robots, now and in the future, that act only as compliant servants, not rulers of our human species, no matter how "intelligent" they may become.

If you are studying engineering, you should also take a few beginning courses in Computer Science. I did this just so I would be able to "supervise" what a programmer was doing, but later I learned to trust their code after observing how well it worked after extensive testing trying to "break" it. This example was ancient FORTRAN of course, but the same principles apply to any computer programming "language" such as C++, Java, Javascript, PHP, Python, R, SQL Here is a website that you might find useful. Good luck on your engineering journey! The world needs good engineers now more than ever.
 
Top