r/AskComputerScience • u/[deleted] • Sep 14 '19
What are some basic Computer Science concepts every self-taught person should know?
I have been a frontend developer for almost two years now. I am self-taught so I didn't study Computer Science at the university, which means there is a considerable amount of holes in my knowledge. That's why I would like to ask what are some basic concepts that every self-taught developer should study in order to have a better understanding of the tools they are working with.
I have always have a natural curiosity and am still very much learning a lot about programming and computers in general, but as I try to learn more and more about tools, languages and technologies (JavaScript, Blockchain, Mobile Development...) I come across basic concepts and ideas I am not familiar with. For example, I don't really understand what a Turing machine is or what we talk about when we say procedural programming.
When I ask the which of these concepts to learn to have a better general understanding of how computers work, people often say it depends on your career goals. But in my case, I don't really have a defined career goal, and it's in part due to my lack of understanding of what else I could be doing with the tools available out there. I work as a frontend developer for a blockchain development studio, which I love and hope to get deeper into, but at the same time, I feel like I will never become a better developer as long as I lack some basic computer science knowledge. I am currently learning C, as most serious developers I've talked to have explained to me the importance of understanding C. What are some other concepts, books, design patterns, technologies... you would recommend to learn to someone without a CS degree?
24
u/hayk92 Sep 14 '19
Completely agree with xaillisx's answer. Data structures, algorithms and memory management are key in programming.
Here is my add-on: some concepts that most CS students learn in college. You might not necessarily use them all for your line of work though:
Number systems: Binary numbers, Hex numbers, number conversion from binary-decimal, decimal-hex etc.
Binary arithmetic: Add, subtract numbers in binary form (this is basically how computers work)
Boolean algebra and logic: Logic gates (AND, OR, NOT, XOR etc)
Discrete Math
Range of Datatypes: Min and Max values different datatypes can have, and what happens when you exceed these values
DATABASES: since you are a front-end dev, I am assuming you haven't done much with databases. They are extremely important!!!
Pointers: You will learn them in C
Structs and classes
Networks and internet: how data gets sent over internet
Compilers: what they are, and how they work
Lots of other stuff...
9
u/IAmNotNathaniel Sep 14 '19
100% this post.
You don't have to get into the details, and you don't need to be an expert on all the items. In fact half of it might not ever be directly used.
But it's ALL important to have floating around in your head, because when you start hitting StackOverflow for answers, you need to know what the hell people are saying and not have to do 10 more google searches to see if the answer you found is relevant to you or not.
(Also, it's the more you know about how computers work generally, the more fun and easy it is to come up with solutions)
10
u/calinet6 Sep 14 '19 edited Sep 14 '19
After 10 years, here are the ones I can think of off the top of my head because they're still pretty relevant in my day-to-day:
Algorithmic complexity. Big-O notation is actually a really good intuitive rule-of-thumb for thinking about writing efficient programs, and it's one of the things I see self-taught folks miss most often probably. If you're writing a program that loops over a loop of loops over a data structure, it could reach O(n³) complexity, or time proportional to the size of the input cubed—and it might make sense to do break it up if possible or try to optimize. As that data scales it's going to make a real difference in how fast your program runs. Big deal. Here's a good beginner's guide: https://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/
Recursion. It's remarkably useful in the right conditions. It can be confusing and get you into trouble, but if you learn to integrate it gracefully into your programs, it can make things that otherwise would have been hairy messes of loops and repetition into simple, straightforward functions. Recognize when to use it: when your data or problem is recursive in nature; when it's a tree or a nested structure, then your algorithm to process it should match the same concept. That's one way to think about elegance, in fact: when the form of your solution matches the form of the problem—recursion is definitely one of those I see people without CS experience skip over and get tangled in trying to fit a square peg into a round hole.
First-class functions and how to think functionally. I learned this in Scheme/Lisp, which is very function-y, but it's also one of the reasons I love JavaScript so much (shhh, don't tell anyone). Passing functions around as data is supremely powerful and useful and lets you make abstractions you otherwise couldn't. Like, without 'em you might make a list method that iterates in a certain way, but you need to make a new one each time you want to do a slightly different thing with the data. With first-class functions, you might allow the caller to decide how to treat small parts of the execution, giving you the opportunity to make things more generic. Thinking in functions—not necessarily all the way to FP/Functional Programming comprehensiveness, but just the practical application of functions-as-data—is an excellent tool to have in you belt.
Abstraction. Just the concept of abstraction. It was the thing my 2nd year professor drilled into us: software engineering is about abstraction. It's turtles all the way down. It sounds like a meaningless word at first, but the idea is sound: you want to think in levels, and you want to solve problems and write code at the right level to make other problems easier. If you're using libraries that hide underlying complexity—for example an HTTP library that makes it so you don't have to worry about network calls—then you're already doing this; but it's even more important to think that way about designing your own programs. How can you break down and architect your program into the right pieces at the right levels, so that your final solution is a readable single-page set of calls that assemble lower levels that are each on their own focused solutions to lower level problems? I don't think I'm overstating when I say this is likely the most important single skill in programming. When I see engineers who can think in levels and navigate them expertly and design solutions with that in mind, I'm always impressed, because it's very rare.
Compilers and assembly are more important than you think. Speaking of abstraction, this is something that's been totally abstracted away from modern software engineering, and that's a wonderful thing overall—it helps us focus on the abstraction level where we're actually doing the work. But people with experience in compilers and assembly languages tend to have a great instinct for what their programs are really doing, and that's great context for writing at higher levels. It helps you really internalize concretely what an O(2ⁿ) function is actually doing, or what it really means to store incredibly large data structures in memory, and just having a respect for what the compiler is doing for you to optimize certain things—and maybe more importantly, what it can't do for you. I'm not saying you should optimize every instruction and function call, but it does change the way you think subtly.
Provability. This one is probably my biggest practical frustration with non-computer-science programmers I run into. Frustration because it has a real impact in outcomes, and usually in a negative way. When you have knowledge about how programs work through and through—from the high level all the way down to how it runs on the chip—you can't avoid the fact that computer programs are deterministic. You can prove whether your program will do what you want it to do, or not. This is a real sea change in how one thinks about writing software. I see some people look at bugs or issues with the problem with the attitude of, "ah, the computer is so dumb! It's making a mistake!" In reality, a computer always does exactly what you tell it to do. Of course, there are a lot of fallible humans in between your program and the computer, but in many cases you can control everything you need to control to design reliable programs that you can essentially prove will work as intended. It always baffles me a bit when people are surprised at how their programs run. At the same time, I don't fault them for not knowing—it takes a lot of context, knowledge, and experience to arrive at this epiphany about how computers work, and it's their lucky day if they get to start learning that.
That's all I can think of for now. The other answers are great as well, but I think they're generally more like skills that can be learned than ways of thinking. The biggest difference I see in formally trained CS folks is in the way they think, and I think that does make all the difference.
P.S.: Not having a goal is a fantastic start for this kind of learning. The whole point of core CS knowledge is to learn the foundational concepts of computing without a real goal or objective. The idea is that having this foundation will help you in ways you wouldn't have been able to predict in advance. I have certainly found that to be true.
1
u/beeskness420 Sep 14 '19
What do you mean by a looping over a loops of loops being exponential?
2
u/IAmNotNathaniel Sep 14 '19
It means that if you loop over an array of n items, then within that loop you do another loop over some other list of m items, you are now doing n*m loops.
Now add another loop of p items. you have n*m* p iterations.
Which is fine when the numbers are small, but if any of the indexes increase in size - or worse, if your logic is such that n and m are related (i.e. increase of n results in an increase of m and p) and with a list of only 1000 items you can easily be doing 1000*1000*1000 = 10003 or a billion iterations.
It's usually easy to avoid, but for newcomers it's easy to forget about. Or sometimes you might decide to use a library function in a loop and not realize it loops inside as well, etc.
1
u/mcherm Sep 15 '19
That's "cubic" not "exponential". They are different. Cubic can result in very bad performance. Exponential is far, far worse. You know how cubic is way worse than quadratic (a loop of loops) which is way worse than linear? Well, exponential performance gets that much worse each time your input size goes up by some fixed amount.
1
u/beeskness420 Sep 14 '19
This doesn’t describe exponential behaviour.
Number of loops is independent of complexity, all that matters is total number of steps.
It’s only in simple special cases you can compose loops by multiplying them together.
If you want an exponential algorithm why not just loop over all binary numbers of length n?
A freshman is more likely to say the above example is cubic rather than hinting at anything exponential. But you really can’t say anything just based on number of loops.
2
u/calinet6 Sep 14 '19
It's been a long, long time since I was a freshman, and the real world is very different from university CS (I tend to lazy-load memories from CS classes as needed). But, this is AskComputerScience and not AskSoftwareEngineering, so I stand corrected.
It still could be quite bad, though, and that's the point—and it's one of the things I see junior software engineers (or even more experienced folks without formal CS experience) gloss over and run into issues because of it. Maybe not accidentally writing exponential time algorithms (though I have definitely seen it), but definitely some gnarly polynomials that really could be broken up or optimized. It happens often, and that's the thing to remember.
1
u/calinet6 Sep 14 '19
It's O(n³), you are correct. Thank you for the detail observation.
But that's not the important part—the important part is to understand the concept.
-1
u/beeskness420 Sep 14 '19
Again three loops doesn’t necessarily imply cubic runtimes. The concept is important but I think a bad example is worse than no example.
2
u/calinet6 Sep 14 '19
I've fixed it and clarified that it's an upper bound. Thank you for the help.
-1
u/beeskness420 Sep 14 '19
It still seems to be implying that number of loops relates to complexity. You can easily go over cubic time with a triple nested loop.
2
u/calinet6 Sep 14 '19
Of course. I hope that my paragraph is but the beginning of being curious about this concept.
2
u/lunareffect Sep 14 '19
Software design patterns. They really help to create good programs and are essential when discussing your programs with other developers. https://en.m.wikipedia.org/wiki/Software_design_pattern
2
Sep 14 '19
cs 50 ! i am in your shoe and i've summed up some opinions that lead to cs 50, i ll be down to have a partner to learn with, dm me if this interests you !
5
u/respeckKnuckles Sep 14 '19
You should probably explain what "cs 50" is, since the course numbering system is not the same for different universities.
1
Sep 14 '19
sorry about that, because its just famous, its a harvard free course, u just type cs 50 and u ll find it
1
u/antonivs Sep 14 '19
He's probably referring to Harvard's online CS50 course, which is a free, self-paced, online, entry-level course delivered via edX. If you want a certificate out of it there's a fee of $90.
4
u/tstenick Sep 14 '19
For clarity. Harvard offers their class called CS50 free online through edx.org and I think they have a lot of stuff on YouTube as well. They occasionally do streams for specific topics as well.
Edit: and it's awesome.
1
u/gammison Sep 14 '19
I think having some ideas on how to reason about computability theory is very useful, extra so if you ever work on a compiler. Knowing what a formal language is, some knowledge of automata can be very useful,and not covered by self taught people very often.
1
u/qxnt Sep 14 '19
The ACM publishes a CS curriculum. It forms the basis of most top degree programs. You could self-learn the fundamentals of a standard CS degree by following this curriculum. Use the textbooks used by top schools.
1
u/samsmith453 Sep 20 '19
I think that the basic workings of hardware, how a cpu actually works, is very often overlooked, and yet so useful for building the right mental models !!
This is the approach that I took and it has accelerated both my learning and my career !!
There are plenty of good resources for starting on this. I have just begun a YouTube series on this topic which may or may not be useful:
https://www.youtube.com/playlist?list=PLH4a1-PgdkBTKkSSNx63uVkQG1Qs6GmYv
29
u/xaillisx Sep 14 '19
You should look into learning data structures, algorithms, and memory management. Languages aren't a bad direction but you'll learn more going towards theoretical information and then you can apply that theory with any language. This site is the bomb https://www.geeksforgeeks.org/