Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: How to learn CS and programming on your own?
8 points by curious16 on Feb 19, 2023 | hide | past | favorite | 15 comments
As someone from a STEM field (non-CS/math) how do you learn programming and fundamentals of CS on your own by the side?

Is there any particular order of subjects you can follow?

Books or courses that were particularly helpful to you when you were in a similar situation?



For me the most productive method has been to have a project, pick a language, get a introductory book for that language and dig in. Start working through the book and doing the exercises and immediately apply what I learn to that project. Making progress on my project how ever small or poorly executed it may be helps greatly in advancing and as I progress I find it gives a much more clear understanding of the more advanced ideas since I see them in context of a real application and not just as idealized text book examples.

I supplement this with reading a more advanced book which I understand little of and do not worry about understanding or applying, I find it helps keeps my mind engaged while working through banal exercises.

I have also found putting in the time to understand the long pedantic conversations/arguments some people have in various online forums to be quite valuable, they tend to be about nuances/minutiae of the language and this is something which books and the like fail to teach. This is actually what brought me to HN, when it comes to long seemingly pointless pedantry about code I have found no where better and I have learned a great deal from it.


What book and project did you start with?


I guess what got me started was bash, the bash man page, and limited options. I had no internet, my wifi card died right after reinstalling the system (money was too tight at that time for a new card) so I had no way to install anything beyond the basic stuff which came with slackware. I wanted to make music so I started to experiment with using bash scripts and SOX to make music. The results were not great but I learned a good deal and it got me interested in the possibilities so I got a copy of 'Programming: Principles and Practice Using C++' since most audio applications seemed to use C++ and there would be a great deal of code to learn from. During that time I also learned a few audio DSLs, enough of a handful of languages that I could hack code I found to make it do what I wanted it to and can sort of figure out most modern languages. Most importantly I learned how to learn, or at least how I learn. Now I am onto lisp, have a rather complex program I want to build and am reading 'Practical Common Lisp,' 'On Lisp,' and 'Lisp in Small Pieces.'

Probably the most valuable aspect of having a project to work on as you learn is it allows you to ask much more useful questions. When you ask a text book question you get text book answers by people who want the upvote, when you ask a question about an issue with the program you are writing you get dozens of varied answers and the people who respond are more likely to actually engage with you and help you learn/complete your project.


I personally think Harvard's CS50 courses can get you pretty far.

CS50: Introduction to Programming with Python - https://cs50.harvard.edu/python/2022/

CS50: Introduction to Computer Science - https://cs50.harvard.edu/x/2023/

Projectbook: 100+ Project Ideas - https://projectbook.code.brettchalupa.com/


CS and programming describe different fields with only some intersection. Think physicist vs. engineer, or biologist vs. physician.

You learn any complex subject (CS) or skill (programming) with deliberate study and practice. Good teachers and mentors can help a lot.

You seem to express a bias to how schools work, conflating formal education with learning. You can easily start programming today with all of the free open source languages, tools, resources, and people available online.


Yes, I came here to write the same answer.

Learning programming is relatively easy. Pick a language, get a book or three, watch some videos and you're off and running. As with most skills your expertise will improve with doing and stretching yourself, rather than just repeating, will improve more.

At one point I read the language reference, slowly digesting one command at a time, building it into an example and so on. Like a human language, your fluency goes up in line with vocabulary - learning the new commands will make you better.

The language you pick won't matter overmuch to begin with. It's just a start. Ideally you'll want to spend time with an object language (c#, java), an interpreted language (JavaScript) and, for bonus points, some exposure to a functional language (lisp).

[hint - most programmers don't do s functional language, there's a reason for that, so feel free to skip that part].

Computer science is a much harder proposition. Here you need done idea of "cariculum" - ie what to actually study. This part is a lot more science than programming - and there are innumerable branches to follow. Concepts here tend to be language agnostic, and deal with the nature of data, algorithms, hardware and so on.

A programmer is asked to "sort this data". A computer scientist would investigate what you mean by "sort" (can you sort text written in say pictographs rather than an alphabet?), what sorting algorithms exist, and what are their constraints, does it work in Order(n), order(log n), order (n^2) time/space etc.

In some respect think of the computer scientist as the one who develops the algorithm, and the programmer as the one who implements it.


Start with the basics, Understand conditions, loop, functions, classes and data structures. They are basically same in all the languages.

Once you get the feel that you can build a lets say a calculator in any language of your choice then advance further.

Once you start feeling comfortable go to next level and try to make a software or application for a dummy company like a library system or a hotel. At this point you have to ask yourself if you want to stay in the backend or frontend and then that's another discussion for later


This is a well-written book that is accessible to beginners. If I started over I would want to start here: https://eloquentjavascript.net

I started with Logo Writer (in 1st grade, didn't even realize I was learning programming). One of my ideas is to create Logo Writer for VR/MR. Both as a learning tool and to aid in creation of VR environments/experiences.


Taught myself programming at 12 years old... long story short, I wanted to build games. Visual Basic 3 was what I had. I tried and tried... would just move object-oriented things on the platform. Had no clue what else to do. Went to sleep one night... had a dream about coding... woke up... and I've been a coder ever since. Of course, I did eventually read up on it, but it made so much more sense after that dream.


I am a computer scientist and a computer engineer. I recommend that you learn to code first. After that, the motivation behind the computer science is a lot more clear and you will learn it much more easily.

Learning to code means:

* Absolutely learn to type correctly and without looking; if you are not willing to do this, then do not bother with this field.

* Learn one editor really well; most people who are serious use gnu emacs or vi (vim?); I use gnu emacs.

* Learn a revision control system; these days, everyone will expect you to know git; get a github account, which is really cheap, and put all of your projects there; it makes it easy to collaborate with others; learn the correct way to write git commit messages.

* Start with the C programming language and the build tool gnu make; have someone show you how to write a simple makefile to build your projects.

* Have someone show you how to compile using, say, gcc so that the compiler outputs the assembly files (.s) annotated with the C input: https://stackoverflow.com/questions/137038/how-do-you-get-as...

* Write lots of little C programs and compile them and look at the assembly langauge with the C input interleaved with it.

* Maintain all of that in a github repository named, say, c-examples; write regression tests and run them every time you change anything.

* For any code repo you have called, say, foo, make another github repo called foo-notes; maintain a todo list in that repo, possibly in mulitple files; also maintain a list of relevant notes related to the project; also maintain another file or files of proposed changes or future work; doing this makes it easy to coordinate with others; DO NOT PRETEND TO KEEP EVERYTHING IN YOUR HEAD.

* Go through a book on C, say, The C Programming Language, and for every feature they mention, write a little program using it and a test for that.

* Learn to write C and read assembly before going on to any other language.

* After getting fairly competent at C, get a data-structures book and implement all of the primary data structures, such as linked lists, hashtables, red-black trees, etc.

* Build something you want, such as a tool to process your logs; you might want to use flex to process the input; write documentation for your project; if you put it in a file Readme.asciidoc in your repo, then github will run asciidoc on it and display it on the main screen of the repo.

Doing all of that, including learning all the idiomatic folk ways of doing things, like how to type without looking, how to write makefiles idiomatically, writing regression tests for everything you do, writing down EVERYTHING in the foo-notes repo, checking it off when done, etc. is a LOT of work; if you are not willing to do all of that, then pick a different field.

After you have built a few things, you might consider learning how the machine structures work, such as the memory hierarchy; learning this will help you write faster code. You might also want to study asymptotic analysis of algorithms which will help in picking the right data structure for a problem.


Hm. I've been doing quite well in this field for 30 years, and other than knowing git and having a github account, exactly zero of this applies to me. I'm not saying it doesn't apply to your corner of the industry, and I'm not saying that none of it is ever true, but it is far from universal advice, and definitely not a case of "if you are not willing to do all of that, then pick a different field."


> exactly zero of this applies to me

You do not use a tool for managing the build of your program? You do not use a revision control system? You keep everything in your head? Really?


>Have someone show you how to compile using, say, gcc so that the compiler outputs the assembly files (.s) annotated with the C input:

Never knew you could do this, not a single programming book that I have read has mentioned it. This is great and really helpful, thanks.


You are welcome. Learning C is pretty straightforward when you know what it is doing: mysterious bugs are no longer mysterious. I think this notion of "information hiding" being helpful to people is ridiculous. Learn what the machine is doing at the bottom and then build up your understanding in layers.


This is an exemple of an experience to learn programming specifically, although i was a teen when i applied these steps ( blindly ):

- Get the basics of programming from written ( no videos ) tutorials available online. Many are good quality and you skim through at your own pace.

- Pick a "difficult" compiled language, like C++. You'll also get insight on how interpreters for languages such as js or python work as well, and the low level stuff will make the high level concepts trivial to understand further down the line.

- Pick one or more simple and fun projects to do alone: a console text-based adventure, a glitchy platformer with SDL or SFML, a web scrapper with python, a tool to automate a task you find annoying in Batch script.

- Once you're there, reach out to programming communities. I used to go to irc channels. I'm not a big fan otherwise, but now some discord servers are full of people you can get insight from now and well-meaning people, who would be happy to show you some strings if you ask nicely.

- If you are in trouble, remember to make a minimal reproducible example of your issue with as few code as you can, more often than not this can lead to you finding the solution by yourself.

- If this doesn't work and you struggle with something, don't be afraid of recognising your ignorance: this stuff is not simple, no one guesses it all alone, ask for help while showing you did try other available solutions given your current knowledge.

- Be patient and learn to read code from other projects as well as documentations, this will provide incredible insight about expected/standard approaches for common problems.

- Rest, having pauses up to 1-2 weeks during the early process will help you integrate this complex stuff naturally, no need to burn yourself out. You may occasionally think about it during a walk or a shower and that's where the familirity builds up.

- Pick-up some boring books such as Bjarnes Stroutrup's one and read it without thinking too much. This can serve as reference without needing a network connection and that's invaluable. I can recommend other books for this purpose to read mindlessly if you're interested.

- Recognize your improvments, especially in the early stages the learning curve is incredibly rewarding, feel good about having a little square moving in your window, show it to your friends !

- Get into more serious maths, a good way to do that is to get the hang of linear algebra through parametric equation, solving 1 or 2 degree equations, vector and matrix, in the context of computer graphics. Graphics helps having satisfying feedback, identify issues intuitively, while exploring the basics of these concepts.

- Find a more serious project to work on, maybe you already have an idea, have fun and keep digging :)

[Edited: typos and formating]




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: