6 ms·
> Did you ever learn how to read code at university? Were you shown loads of different code, in different languages and different styles, and then asked to expl
by dexen 14y ago
> Did you ever learn how to read code at university? Were you shown loads of different code, in different languages and different styles, and then asked to explain what the code did? I don’t think code comprehension is a normal part of the curriculum for computing science classes. We’re taught how to write, not how to read. Maybe that’s a mistake.
Dear lazyweb,
I want to bridge that gap in my education. Where do I go to read loads of code in different styles? With the emphasis on plurality of styles.
- indiecore 14y agoGithub?
- robertfw 14y agoI would recommend the above, along with chapters from http://www.aosabook.org/en/pypy.html http://www.aosabook.org/en/pypy.html as a guide
- dalke 14y agoI'll augment indiecore's answer. What kind of code are you interested in? Suppose you are, like me, interested in cheminformatics software. Find a few different packages (Open Babel, RDKit, Indigo, and others), download them, and compare how they implement a given task, like SMILES parsing or fingerprint generation. If you're interested in text compression, then download a few compression toolkits and see how they work. Also read a few articles on the topic. Regular expression engines? Dozens are available. Interested in networking? Take a look at ZeroMQ and other networking packages. Databases? That's a big topic, but you don't need to understand the entire package. Pick some aspect which interests you and see if you can figure out how SQLite, PostgreSQL, and MySQL handle it. Here's an easy one to start off with - how do Lua, Python, and C++ implement hash table-like data structures?
- aidenn0 14y agoReading code without a purpose can cause your brain to tune out. You think you're learning but you aren't. I would rather suggest you find an open-source project and fix a bug in it. You will have to read lots of code in order to do so, and, so long as there is a repeatable test-case, fixing the bug shouldn't be too hard.
- crandles 14y agoRosetta Code is a great resource (http://rosettacode.org/wiki/Rosetta_Code http://rosettacode.org/wiki/Rosetta_Code). Examples from many languages are provided per a given topic (e.g. http://rosettacode.org/wiki/Sieve_of_Eratosthenes http://rosettacode.org/wiki/Sieve_of_Eratosthenes)
- beatgammit 14y agoI would read code on codereview.stackexchange.com. If you're not familiar, it's a site where you can get help making your code more readable and more idiomatic. I'd browse the questions for questions you're interested in and look at the suggestions for improvement. Personally, I don't like traditional OOP, so for me, Go and D are interesting to me (read the standard libraries if interested). Go tries to restrict you to their "idiomatic" style, and D tries to let you program in whatever style is appropriate for the problem. My best advice is to solve a real problem in a new language. Try to make that solution as idiomatic as possible for that language. Trying a functional language like Haskell or Racket will also do you a lot of good.