r/AskComputerScience • • 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?

37 Upvotes

23 comments sorted by

View all comments

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:

  1. 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/

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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/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.