A CS 101 Memo
4 人贊了文章
The author typically does not write on this topic. The reason is two-fold: 1) these are factual knowledge that has little insights into the design and implementation of real-world computer systems. 2) lots of the content mentioned here can be found from the Internet. However, seeing the need of many fresh CS students who the emergent needs of improving their learning experience. I wrote this memo to offer my 6 cents which hopefully you the reader will find helpful.
The languages
If you want to do Machine Learning, learn Python, Java and Matlab. If you are interested in front-end development. Learn HTML, CSS and Javascript. If you are a system level developer. C and C++. C++ is just high-level C, so you are probably writing systems in C++ based on what you do on C based on what you do on Assembly (if youve good luck.) Good luck.
Turns out C++ is based on C. Java is just C++ plus HelloWorld helloWorld = new HelloWorld() which is made with C++, Javascript copies Java. Python finally ditched the braces but its still C++ in the core. Conclusion? C is the best language in the world Learn C and C++ to start, at least, because everything is somewhat related to it, and they are the building blocks of modern computing.
Notes for CS students: Personally I feel that mastery of those are not necessary any longer. The same theory goes for Turing Machine and Von Neumann Model getting grandfathered in the next 50 years. Our cost model will not be based on the processor/memory layout of our hardware, but something more higher level. (I am not the one who makes this claim) AND SORRY CE GUYS, THIS IS NOT (YET) TRUE FOR YOU!
And, at least one of the functional programming languages as your intro language. Choose by your own preference either from the ML family, Lisp family or Haskell. If your school only teaches Python and your school is not MIT, do follow this piece of advice.
The rules of thumb for whether to learn a new language are: 1. whether you somehow must use that language. For example, the author recently learned Scala and Go because he needs to do his homework. 2. Whether this new language inspires you do program in a new way. The author prepares to learn Rust when he is free, probably as an escape plan from C++ (逃(literally
Learn yourself a UNIX for greater good. (Learn the tools)
By now, most of you are probably familiar with the basic components of programming: variables, control flow; better: higher order functions, mutability/immutability, modularity. Before you learned all the concepts, you are climbing the curve. But once you move those text book examples to the real world, your confidence plummets. You want to give up but you cant because mid-terms or finals are coming. What should you do next then?
The first things you need to do is to move out from your comfort zone of using the IDLE. Nobody uses the IDLE in real life. Actually no one even uses the term IDLE. We call it the REPL (Read-Eval-Print-Loop), learn yourself that word, and how you can invoke your REPL from the Command line (yeah thats some terminology you should familiarize yourself with, its also called the Terminal). Learn to use it. A good resource that I will recommend is CMUs GPI link Its a very short course on everything you need to know about the command line. Learn to use it as it will accompany you for the rest of your career. If you need a more fast-food crash course on using the terminal, check this out. Also check out the labs on using command line real-life scenarios. (Yes, youre watching a jihad between the two writers, an Illini and an Andrew.) "But dad, I love my GUI." "cd ~." Also acknowledge that various systems may behave differently, so get to know how you can ssh your Colleges supercomputer to do your homework instead of banging your head against the weird shell on your Windows laptop. After the course, you also need to know how to set up your computer so they dont behave weirdly. TL/DR? Once you master CLI, youll never head back.
Recently many of my friends have been asking me about bugs that they cannot resolve. I helped along, explaining the rationale behind those niche tiny details. It turns out its not the computers problems, its THEIRS: They dont know what the problem is about, they dont know why that occurs, and they dont know they are actually totally definitely able to solve it with the tools on hand. So start trying and stop 喝熱水 hoping your problem will disappear. Some specific examples may include why your are running a wrong version of Python from the command line. If that is the case for you, Google the term "PATH" you will find your answer.
There will the the historical moment when you will have to choose YOUR EDITOR. (After that you will have to choose whether you are using tabs or spaces.) You must learn either Emacs or Vim if you are serious about programming. They are the only two terminal editors that allow decent programming. For arguments and war go to this link. I use Emacs, but for beginners I actually recommend two other options which are Atom and Sublime Text. Choose the one that your are more comfortable with. You can also ask me privately if you are interested in how to optimize your workflow.
By the way, in case you need to install some software for development. A good way to do that on Mac is to use homebrew, on Linux you have either apt-get or yum depending on whether you are using Ubuntu or Debian. If you have no idea why you should use this, no worries just hear my advice and after some time you will realize why. (I have no idea what you can use on Windows. I just assume that students learning to program dont use Windows, do they?)
Yes, I heard your screaming: "but I have my finals, and problem sets and ...". The author hopes to find a shorter path for you too but he simply does not think it is possible for him to teach you what cd, ls are in a shorter way. These are facts and facts are best learned from written stuff arent they? The sooner you learn how these things work, the sooner it will start to save you tons of time trying to debug some weird configuration errors.
PS. For those wanting to learn Emacs, I recently found a very good intro article from UChicago. If you are tired of configuring Emacs yourself, check out Spacemacs PPS. once you have some ideas of how to use the Terminal, you may want to check out zsh, in particular Oh-my-zsh. You will find it a breeze..
Software engineering practice for writing homework
When doing our work on Yechuans danmaku, the Andrew author hacked together the website from scratch to nearly production in 5 hours, ended up getting both saluted to and laughed at by the Illini author until the next Yechuan came and the system was completely reworked. (Disclaimer: The Illini author is an engineer.) (Added by the Andrew author: he did all the refactoring because he wants to pass on the project to someone else.)
If you wanna write r n=take(n+1)$iterate(a->zipWith(+)(0:a)$a++[0])[1], sure, but please avoid that until you expert the language and can tell me what that does in three seconds. Reason being simple: Its not easy to maintain. You can hack together such a code piece for solving ONE problem, but you wont 1) edit it to do something else 2) edit it to port it somewhere else and 3) edit it to solve a mishap. So enjoy the time being a fast hacker, but also acknowledge there are times you need to get serious, slow and precise, and produce an engineered masterpiece.
Learning to write Makefiles, using version control system like Git will help you manage your homework/projects with more ease. Be sure to write unit tests to test your problem. It helps you to track down your bugs and make good assertions about the correctness of your algorithms. For example if I were to have a C homework. I will have three files: 1) a Makefile for compiling other C files to the executable. 2) the main.c which includes the main problem. 3) the test.c file which will drive the tests for my main.c.
For people interested in Machine learning, the way of testing your ML algorithm is quite different from the traditional approach. I will leave this as the topic for another post dedicated to ML. Nevertheless, I will just hint here that you may want to have learning curves or statistical tests to assert correctness.
Some techniques that can help you debug your problem, test your solutions can be found here written by David Anderson from CMU.
The real business
Once you move on from your homework, its time that you find a project that really interests you and DO it! I will just note a few projects that other people did which I recently find interesting.
- (How to Write a (Lisp) Interpreter (in Python))
- The Super Tiny Compiler
- A Spam filter using Naive Bayes (More on this next time)
- A web scrapper (most peoples first Python project is to write a scrapper!)
- Flappy bird with Reinforcement learning?
- Web server (a fork-based solution? async one based on IO-multiplexing maybe?)
If you are interested in what the author is doing right now. Well, he is figuring out the mechanics of the RDDs behind Apache Spark, hopefully useful for his goal to finding a good framework for implementing Distributed Artificial Intelligence. The author has become an enthusiast in functional programming (particularly in OCaml). The author hope to figure our what EM (Expectation Maximization) is by the end of this month. Some other projects are under NDA so I cannot disclose.
The author enjoys his life as a CS student. A LOT. If you like CS as much as the author does, feel free to email him at ethanluoyc [at] gmail dot com
Acknowledgement is given to Jimmy who offered his Illini opinion. By the way, the author is from Imperial, not Andrew
推薦閱讀:
※零基礎編程入門(01)——前言
※linux Shell(腳本)編程入門 實例講解詳解
※v2ex帖子 教小朋友學c++問答整理
※黃哥Python:從一個小題目看學習編程思路的重要性
※《C++ Primer》從入門到放棄