Question about learning programming

TGV320
Messages
40
Reaction score
25
TL;DR Summary
Need advice about learning intermediate subjects of programming
Hello,

I am currently learning Python as a basis for further studies in programming. The course that I took at college was quite basic, teaching us the basic concepts required for programming, and some web oriented concepts like data scraping, APIs, automated tasks using bots. As I delved deeper into programming, I noticed that the course didn't teach us much about algorithms. That part of programming seemed like a really important one, since I found out that when I try to program from scratch, I really didn't have much idea about how to do anything, like the deeper logic control loops or data structures.

Therefore, I am now contemplating studying some computer programming textbooks about algorithms and data structures.

The question is : should I study it as mentionned and do you think doing so might really help me understand the deeper logic involved in programming?

Thanks a lot,
Regards
 
Technology news on Phys.org
I think you should study some important algorithms and especially data structures. Those are important topics in programming.
 
  • Like
Likes harborsparrow and DeBangis21
"THE ART OF COMPUTER PROGRAMMING" by Donald E. Knuth

(volumes 1, 2, 3 are the ones I remember and I think there are also 4 and 4A, and possibly 5.) Well worth the time and effort!
 
Last edited by a moderator:
  • Like
Likes bhobba and FactChecker
Tom.G said:
"THE ART OF COMPUTER PROGRAMMING" by Donald E. Knuth
The first three volumes are classic. But it is a very heavy amount of work to study them. I'm not sure that the OP is asking for that kind of commitment.
 
  • Like
Likes bhobba, glappkaeft, phinds and 1 other person
TGV320 said:
Therefore, I am now contemplating studying some computer programming textbooks about algorithms and data structures.

The question is : should I study it as mentionned and do you think doing so might really help me understand the deeper logic involved in programming?
No.

You have tagged this post "Python"; this already implements standard algorithms and data structures (as do other high level languages) so you don't need to know how to write them.

Programming does not involve any "deeper logic", what it consists of is breaking down a problem into smaller parts and writing code for each part using the logic you already know. In order to do this successfully you need to practice. If you don't already have problems to practice on try www.codewars.com.
 
  • Like
  • Informative
Likes bhobba, harborsparrow, PeterDonis and 3 others
Hello,

Thanks for the advice. It is true that I don't practice enough on programming. What I frequently read on the internet is that beginner programmers just use a lot of Stackoverflow and such for solving programming problems, often being caricaturized as "copy and paste".

Thanks for answering,
Regards
 
TGV320 said:
What I frequently read on the internet is that beginner programmers just use a lot of Stackoverflow and such for solving programming problems, often being caricaturized as "copy and paste".
If you want to actually learn how to program, that's not a good approach.
 
  • Like
Likes TGV320 and Vanadium 50
Hello,
Very well, I think I'll get to work then.
 
It is nice to have some general knowledge of the algorithms that are being used by a utility library. That does not have to be very detailed unless you are really going to work on those algorithms. Other than that, if you have a field of application that you are interested in, IMO, you are wise to start getting familiar with the groups (internet?, university?, publications?) who work in that field and the computer techniques that they use.

PS. Some libraries have good documentation on their algorithms that should be good enough for general knowledge. MATLAB has good documentation and the old IBM FORTRAN Scientific Subroutine Package was also very well documented.
 
Last edited:
  • #10
Hello,

For the moment I really don't have much of an application focus, I'm just trying to strenghten my general knowledge of computer programming overall, building a good basis for the future. I have found out that having robust theoretical knowledge does help with its future applications.

I am now leaning towards taking an university introductory course on data structures and algorithms.

Thanks,
Regards
 
  • Like
Likes harborsparrow, FactChecker, DeBangis21 and 2 others
  • #11
Hello,

I've started taking an introductory internet course on "Data structures and algorithms" from Bejing University. Only now do I realize what I would have missed had I not decided to take that course.

Thanks,
Regards
 
  • Like
Likes .Scott, jtbell, FactChecker and 1 other person
  • #12
TGV320 said:
I've started taking an introductory internet course on "Data structures and algorithms" from Bejing University. Only now do I realize what I would have missed had I not decided to take that course.
Excellent! If you like that, you might be a programmer at heart. You might have found your niche.
 
  • #13
Programming is not an exact science like for instance math. There are languages designed for different problems. Procedural, functional, object oriented as well as pure geekish fun. In my opinion “learning how to program” is a little like a mix of understanding algebra (what are those letters doing in my equations?) and selecting the right tool for the job.
 
  • Like
Likes TGV320 and FactChecker
  • #15
TGV320 said:
I noticed that the course didn't teach us much about algorithms. That part of programming seemed like a really important one, since I found out that when I try to program from scratch, I really didn't have much idea about how to do anything, like the deeper logic control loops or data structures.
Most learn algorithms through application, but it is useful to view them in pseudocode to get the structure.

https://archive.org/details/introduction-to-algorithms-third-edition-2009

Not a terrible guide for when you are starting out.
 
  • #16
Death Metal said:
it is useful to view them in pseudocode to get the structure
Python is often said to be "executable pseudocode". It doesn't 100% achieve that goal, no programming language can, but the idea behind it is a useful one: a programming language should let you just write the logical structure of the program, not as "pseudocode", but as actual code that can just run.
 
  • Like
Likes bhobba, symbolipoint and Death Metal
  • #17
PeterDonis said:
Python is often said to be "executable pseudocode". It doesn't 100% achieve that goal, no programming language can, but the idea behind it is a useful one: a programming language should let you just write the logical structure of the program, not as "pseudocode", but as actual code that can just run.
IMO, this goal is in conflict with another Python principle of "only one way". There can be different ways to express pseudocode and only one will work in Python. This was displayed when the Python version changed and the old "one way" was changed to a new "one way" and old code had to be modified.
 
  • Informative
Likes symbolipoint
  • #18
FactChecker said:
another Python principle of "only one way".
The actual principle was that there should be only one obvious way to do it. (Although the way might not be obvious unless you're Dutch. 😉)

It's true that the Python 2 to Python 3 changed the "one obvious way" in many cases--which IMO was a highly mismanaged change and shouldn't have happened that way, but that's long since water under the bridge now. Minor version changes in Python 3 (at least since 3.3 or so) haven't broken old code, although they have sometimes introduced new syntax (such as the await keyword, and more recently the match keyword) that gives new "obvious ways" to do things that were done differently before.

FactChecker said:
There can be different ways to express pseudocode and only one will work in Python.
Even given the above, I don't think this is true, or if it is, it's very rare. Only one way might be obvious in Python, but Python almost always gives you multiple ways to express the same general coding concept. For example, writing out procedural if clauses vs. using generator expressions or comprehensions. The latter is usually faster, but the former is usually easier for newbies to understand. Python lets you do both.
 
  • Like
Likes Death Metal
  • #19
Most of the newer languages are in part designed to fix bad habits of programmers. I truly do not believe that there can ever be "only one right way" but I think "one obvious way" is good for script-style languages. Anyone remember HyperCard?
 
  • #21
PeterDonis said:
The actual principle was that there should be only one obvious way to do it. (Although the way might not be obvious unless you're Dutch. 😉)
I have seen Python scripts written by good programmers, that, IMHO, implemented simple scripting tasks in tedious ways. The consequence was they were not obvious and adding simple error checking was additional work. I greatly preferred Perl for those tasks because it was designed for scripting.

Here is a small example of the type of script that seems clear to me in Perl but I think it would be relatively messy in Python.
Perl:
# A small script to look for a gvim task and kill it if the used desires.

$tasks = `tasklist`; # Run tasklist and store the printed output in the string $tasks
# Find the pid of a vim editing task
# If none are found, die and print a notice
$tasks =~ /gvim.exe + (\d+)/ or die "ABORT. Can't find a gvim task\n";
$pid=$1;   # Store the found pid in the string variable $pid
print "$pid is one gvim task\n Want to kill it? (y or n)\n"; # Print the pid to the terminal
$answer = <STDIN>;
if( $answer =~ /y/i ){
   `taskkill /F /pid $pid` or warn "Can't kill pid $pid\n"; # kill the task with that PID
}
 
  • #22
FactChecker said:
I greatly preferred Perl for those tasks because it was designed for scripting.
More precisely, it's designed for scripting similar to what you would do in a shell script language like Bash, where you want to be able to do things like capture terminal input and run external programs and capture their output as concisely as possible, because that's most of what a typical shell script does. Your example illustrates that: yes, it would look quite a bit more verbose in Python, because in Python there is no shortcut syntax for running a program and capturing its output. The syntax for reading input from the terminal isn't too bad in Python, but it's still somewhat more verbose than the Perl you show.

The difference is that Python, though it is often called a "scripting" language, is not one in the same way that shell script or Perl is. It is not optimized for doing the sorts of things most shell scripts, and probably the majority of Perl scripts, do. It's designed for much more general programming tasks, for which shell script, if it's usable at all, is intractable, and Perl, while it might support the task, will give you code that looks more like line noise than anything else. In Python, such programs, IMO, are much more readable and easier to reason about. That's been my experience, anyway.
 
  • Like
Likes Mark44, pbuk and FactChecker
  • #23
PeterDonis said:
More precisely, it's designed for scripting similar to what you would do in a shell script language like Bash, where you want to be able to do things like capture terminal input and run external programs and capture their output as concisely as possible, because that's most of what a typical shell script does. Your example illustrates that: yes, it would look quite a bit more verbose in Python, because in Python there is no shortcut syntax for running a program and capturing its output. The syntax for reading input from the terminal isn't too bad in Python, but it's still somewhat more verbose than the Perl you show.
Exactly. The confusion is unfortunate. I kept running into Python scripts that should have been shell scripts or Perl scripts. If I had to do significant work with them, it was usually easier to convert them than to keep it in Python.
PeterDonis said:
The difference is that Python, though it is often called a "scripting" language, is not one in the same way that shell script or Perl is. It is not optimized for doing the sorts of things most shell scripts, and probably the majority of Perl scripts, do. It's designed for much more general programming tasks, for which shell script, if it's usable at all, is intractable, and Perl, while it might support the task, will give you code that looks more like line noise than anything else. In Python, such programs, IMO, are much more readable and easier to reason about. That's been my experience, anyway.
I agree. Although I have no experience comparing Python with typical general purpose languages like C, C++, Ada, etc. I certainly wouldn't advise using Perl for those applications.

That being said, a lot of my programs involved a top-level shell script (usually Perl) that would control a sequence of programs written in general purpose languages or utility programs. This was very beneficial if the entire workflow was complicated, tedious, tricky, or required a lot of parsing of outputs.
 
  • #24
FactChecker said:
I have no experience comparing Python with typical general purpose languages like C, C++, Ada, etc.
I've used both Python and C for general purpose applications. In terms of capability (leaving out things like ease of use), they're technically the same--the reference version of Python is implemented in C, so anything you can do in Python you can do in C (and there are also things like C y t h o n -- I had to type that with spaces because there seems to be some stupid auto-correct thing that changes it to "Python" if I type it as a single word -- that take code in Python, or at least a subset of Python, and translate it into C). But I find Python much, much, much easier to program in.
 
  • Like
Likes FactChecker
  • #25
PeterDonis said:
I've used both Python and C for general purpose applications. In terms of capability (leaving out things like ease of use), they're technically the same--the reference version of Python is implemented in C, so anything you can do in Python you can do in C (and there are also things like C y t h o n -- I had to type that with spaces because there seems to be some stupid auto-correct thing that changes it to "Python" if I type it as a single word -- that take code in Python, or at least a subset of Python, and translate it into C). But I find Python much, much, much easier to program in.
I have minimal experience with Python programming. One thing that worried me about Python was the fundamental reliance on indentation levels. So much of my work involved cutting and pasting code from my old programs into a new program. It seemed that the Python indentation levels would make that difficult any time the "cut" code came from a different level than where it was pasted.
 
  • Like
Likes 256bits and TensorCalculus
  • #26
I mean he is still starting out with programming right? In which case learning a ton of languages is probably not the way to go. Learning about data structures &algorithms in a way that doesn't rely on a specific language (e.g. learning graph theory in maths) might be a better option. And then python is a really good starter language for implementing these kind of things and learning to apply the algorithms and structures you learn about as well as developing the sort of thinking needed to tackle programming problems (assuming that this is something you are interested in doing). Since python is easy to understand (though I get the indentation problems...) and also really intuitive and straightforward as well as quite versatile. Then once you have a good idea of these things, move to other languages - it'll be easier to learn them after you get a really good grasp of what programming is.
Not that I am a super advanced programmer myself, just a student so maybe take this all with a pinch of salt.
 
  • Like
Likes FactChecker
  • #27
TensorCalculus said:
python is a really good starter language for implementing these kind of things and learning to apply the algorithms and structures you learn about as well as developing the sort of thinking needed to tackle programming problems (assuming that this is something you are interested in doing).
Absolutely. Python has a very large and enthusiastic user base that can really help. Many of the YouTube tutorials that I see for learning things like AI image recognition are done in Python. I think that it is the best choice for learning.
On the other hand, a person seeking employment might prefer learning C or C++ since there is such a large amount of existing C/C++ code in business applications.
 
  • Like
Likes TensorCalculus
  • #28
FactChecker said:
Absolutely. Python has a very large and enthusiastic user base that can really help. Many of the YouTube tutorials that I see for learning things like AI image recognition are done in Python. I think that it is the best choice for learning.
On the other hand, a person seeking employment might prefer learning C or C++ since there is such a large amount of existing C/C++ code in business applications.
Ah yes fair enough. As I said I'm a student so I have no idea how coding for employment works :)
 
  • Like
Likes FactChecker
  • #29
TGV320 said:
Hello,

Thanks for the advice. It is true that I don't practice enough on programming. What I frequently read on the internet is that beginner programmers just use a lot of Stackoverflow and such for solving programming problems, often being caricaturized as "copy and paste".

Thanks for answering,
Regards
There is nothing wrong with assembling an application with "cut and paste" - so long as you understand precisely how and why it works. That process will drive you through tons on possible solutions and programming styles. It is a good way to learn.

Deducing algorithms comes in a few parts:
First, you need to know what tools are provided in your development environment. As an easy example, you don't normally want to rewrite a sort - but make sure you know how flexible those existing sorts are.

Second, you need to have a lot of exposure to algorithms - mostly those written by others. That "Data Structures and Algorithms" sounds very on-target. If it doesn't get into data normalization, you may want to check that out as well.

Third, develop your algorithm skills by writing and testing them yourself. Exactly what this looks like is hugely dependent on your own particular mental assets - memory, eye sight, language skills. But in all cases, you will need to be able to collect system requirements. When an algorithm is not obvious to me, I will pose the problem to myself - how would I do it without a computer. Then work through a few case-in-points and "get practical" because often a good engineering solution is far from mathematically elegant or optimal.
 
  • Like
Likes FactChecker
  • #30
Indeed, copy/paste is the backbone of programming. If someone already solved the problem for you reinventing the wheel is just stupid. If you can tell if it's worth copying that is. :cool:
 
  • Agree
Likes TensorCalculus
  • #31
sbrothy said:
Indeed, copy/paste is the backbone of programming. If someone already solved the problem for you reinventing the wheel is just stupid. If you can tell if it's worth copying that is. :cool:
stack overflow and geeks for geeks literally carry me... copy paste off those two is something I do way too often...

BUT please please do NOT try to learn by getting AI to generate code for you... it is not the same as copy pasting! When you copy paste sections of code... you have already broken things down and considered each step in solving the problem/building the software... however when you get AI to do it for you, there is no critical thinking involved whatsoever. You will not improve just by prompting an AI - using it to plan, to brainstorm, to compile... that's fine. But when you're learning - don't ask it to code. Sometimes you are getting it to do jobs you would benefit from doing without even realising.

By the way, a really fun programming challenge that comes out every year is Advent of Code (I am personally a huge huge HUGE fan...) - https://adventofcode.com/. Give it a shot when December rolls round. Or do the past year problems as practice!
 
  • #32
Been programming nearly all my life, and I am now 70. I did it professionally for over 30 years.

Python is the best language to learn first.

But if you want to learn more, you need a language closer to systems programming. I do not like systems programming (to put it mildly). I am an application programmer through and through; for that, Python is excellent. But there is no getting around the fact that knowing more about systems programming will significantly enhance your computing knowledge.

I suggest learning the new system's language on the block, Zig. C and C++ have been the systems programming languages of choice for many years, but everything points to Zig as their modern replacement. Zig can compile both C and C++ (no kidding). It does this by translating it to C as an intermediate step and feeding the C into a C compiler or LLVM. It is a program optimiser that accepts several languages and spits machine code out or gives an optimised translation to another language.

It is gaining a foothold as the language to integrate with Python:
https://www.infoworld.com/article/3831676/how-to-boost-python-program-performance-with-zig.html

Thanks
Bill
 
Last edited:
  • #33
I'd recommend starting with assembler and coding your own operating system as you do as part of a proper CS education. Having a high level language handle your garbage collection may get you started quickly, but if you encounter a pointer or having to grasp the concept of a stack, learning Python doesn't prepare you for any of that.

EDIT: Then again I'm a retired dinosaur.
EDIT2: Assembler may be a little bit too low a starting point but you get my drift.
EDIT3: If you just want to learn programming go ahead with a high level language, but if you want to learn it in depth, I'd recommend starting from scratch.
 
  • #34
Posts #32, #33.
I tried to learn Python on my own many years ago and made NO progress. I have been only ever able to handle two different forms of BASIC. Initially, BASIC was most of the few little amount of Programming learning I had in school. I can not more than just guess that if Python was the main language to learn when I was a student then today I could have become familiar with and made progress with Python.
 
  • #35
Python is such a popular language that nowadays there is so much infrastructure for learning it and getting good at it, and from what I've heard (from large communities of young coders), it seems the go-to language for beginners.
My advice is stick with python until you encounter something that is such an annoyance to make in python that you're better off writing it in another language...
 
Back
Top