Live data from Hacker News

One Way to Improve Your Coding

changelog.com

51–60 of 121 posts

Re: One Way to Improve Your Coding

#51

A lot of people will recommend reading great code -- well known open-source libraries etc. That's good, but one thing I think is useful is to read your dependencies. Then you can get a better picture of what "regular" code is like. Most popular libraries are not great to read because they are often very abstract, or they use so much helper code that it's hard to see what's actually going on. But fairly small librarie…

I certainly agree with this sentiment (and the author's words "Read code that you can actually grok"). As a younger programmer, I tried to get into reading the source code for Flask and learned pretty much nothing.

The thing that has seemed to have the most effect for me (of course, this may not necessarily be effective for everyone) is refactoring or even completely rewriting my side projects after/near finishing them. It's a little bit maddening, since I would rather move forward and build new features or start a new project, but the exercise is really helpful. It forces me to take a step back, look at everything I've done, and figure out where I could have done something better. Then, hopefully at least, when I'm in a similar spot in the future I'll be able to think ahead better. In fact, "thinking ahead" might be the most valuable skill for a programmer to have, and I don't really see how reading code can help with that. All of their design decisions have been made by the time you read the code, and it's really difficult, especially for a junior developer, to actually consider how and why those decisions were made.

Re: One Way to Improve Your Coding

#52

Can anyone recommend good tools for reading code? I find github.com to be very klunky for this purpose, and even emacs/vim make the task much more troublesome than it could be. Is there such a thing as a "read-only IDE" anywhere out there? (Ideally features would include click-to-definition, navigate back and forth, add bookmarks and annotations.)

Why is vim more troublesome than it could be? With Nerdtree and Fzf/Ag plugins (or ctrl-P) I can't imagine how much easier it could get.

Re: One Way to Improve Your Coding

#53
post #40

Earlier quoted context omitted.

I've been a UX designer for 10 years and I can tell you why. (Or at least why from point of view.) It's a deprecated design practice to make font rendering looks smoother in a world where retina screens were not ubiquitous. Back in the old days (so like 3 years ago) before the majority of screens were 'retina' (aka you can't see the pixels at normal viewing distances) fonts always rendered with jagged edges. Turning…

That's an interesting point of view! As a UX designer veteran, you must know these numbers better than most of us here, do you know how ubiquitous retina screen are? On desktop, the Firefox Hardware report [1] tends to show that they the most common resolutions are 1366 * 768 and 1920 * 1080, this unfortunately doesn't tell us if those are retina screens or not, but from [2] it seems that we're talking about at most…

And I've lost track of the web UIs that pretend that everyone has and will game the web page 1920 pixels of width (while writing this, I'm glaring at JIRA in 1200x1920, portrait mode.)

Re: One Way to Improve Your Coding

#54

I'm going to be "that guy" in the comments section this time, largely because I feel like I've been seeing this more recently and I've had to fix it myself: I don't really get why it seems to be a "thing" recently for websites to have low-contrast text colors. This is at least the second time in a week I've seen light gray text on white background, and to not strain my eyes I went into the CSS for the website and fix…

I've been a UX designer for 10 years and I can tell you why. (Or at least why from point of view.) It's a deprecated design practice to make font rendering looks smoother in a world where retina screens were not ubiquitous. Back in the old days (so like 3 years ago) before the majority of screens were 'retina' (aka you can't see the pixels at normal viewing distances) fonts always rendered with jagged edges. Turning…

There's indication that 00/FF contrast can be problematic, especially for dyslexics [1].

The ridiculous part is the amount the contrast is often toned down as a result. No one benefits from a sea of grey on grey bordering on unusable.

[1] http://www.bdadyslexia.org.uk/dyslexic/eyes-and-dyslexia

Re: One Way to Improve Your Coding

#55
post #38

The most obvious way to improve your coding is to write more code. This is a bit too simple: writing more of the same, in the same style, usually won't cut it and unfortunately I've seen people being stuck like that for years: always producing more code, without any improvement whatsoever and instead just repeating the same mistakes. Once those mistakes become a habit they are extra hard to get rid of. So actually wr…

Depends what you are wanting to achieve, to be honest. Writing the same code can help make you faster at writing that code. This can be annoying to people who are higher level coders, but the reality is that intrinsic quality of code is easy to complain about, but hard to model the importance of. In large because its importance is quite low.

That is, if what they are writing works, despite having what could be seen as mistakes to a more disciplined practitioner, then what is the problem?

Consider, someone that has put together Ikea cabinets every week for the past year is probably hella fast at it by now. Can they replace a carpenter? Doubt it. Are they bad at what they do? Doubt it.

Re: One Way to Improve Your Coding

#56
post #15

Can anyone recommend good tools for reading code? I find github.com to be very klunky for this purpose, and even emacs/vim make the task much more troublesome than it could be. Is there such a thing as a "read-only IDE" anywhere out there? (Ideally features would include click-to-definition, navigate back and forth, add bookmarks and annotations.)

This is a great idea, if it doesn't already exist. Edit: On a little further reflection, it would be really fun to build. I can imagine a site called something like readgithub.org, which is a dedicated site for reading the code hosted in github repositories. You could start focusing on projects in one language only.

I recently came across something like that for opensource Java code, called `grepcode`:

http://grepcode.com/file/repository.grepcode.com/java/root/j...

It supports quite a big number of Java code repositories it seems.

Edit: Also sourcegraph (linked in a link in a sibling post) does something similar:

https://sourcegraph.com/github.com/gorilla/websocket/-/blob/...

Re: One Way to Improve Your Coding

#57
post #39
post #32

Earlier quoted context omitted.

> Perhaps this seems a bit lazy, but I think of reading code as similar to reading books or articles: not everything is worth the same level of investment. The point of reading code is to understand it. How to read code efficiently depends also on language and coding style. Which would require full blown IDEs just for proper code navigation. And honestly: If setting up an IDE for the language you want to read is too…

> The point of reading code is to understand it. There are varying levels of understanding (or desires to understand something). I use Python a lot. For a lot of the language and libraries my understanding is superficial; dicts have key/values, lists are ordered and mutable. As I use it more I'll dig more into specific parts as needed; how do lookups happen for a dict, how are lists allocated? If I downloaded cPython…

[deliberately responding out of order]

> Your argument here sounds like it would be against having syntax highlighting

No, but syntax highlighting is just something that helps parsing a single page. I'm talking about "show documentation for function/var/whatever under cursor", "jump to definition", etc...

> There are varying levels of understanding (or desires to understand something). I use Python a lot. For a lot of the language and libraries my understanding is superficial; dicts have key/values, lists are ordered and mutable. As I use it more I'll dig ....

That "digging" is what I am talking about. Code is rarely read sequentially; it's reading docs for functions/classes/vars, jumping to definitions and finding call-sites. To do this, you need a very good understanding of the target language by the "viewer"-tool. Thus: You need an IDE for proper code reading. And probably still a good grasp on /usr/bin/find for those things your IDE cannot help you with.

Re: One Way to Improve Your Coding

#58
post #38

The most obvious way to improve your coding is to write more code. This is a bit too simple: writing more of the same, in the same style, usually won't cut it and unfortunately I've seen people being stuck like that for years: always producing more code, without any improvement whatsoever and instead just repeating the same mistakes. Once those mistakes become a habit they are extra hard to get rid of. So actually wr…

This is a good reason why becoming a "polyglot" probably does more good than harm. Many languages are often better suited to different programming styles or paradigms or problem sets or environments than other languages; learning a new language can help better understand a new concept, thus improving one's ability in general across all languages.

Re: One Way to Improve Your Coding

#59
post #38

The most obvious way to improve your coding is to write more code. This is a bit too simple: writing more of the same, in the same style, usually won't cut it and unfortunately I've seen people being stuck like that for years: always producing more code, without any improvement whatsoever and instead just repeating the same mistakes. Once those mistakes become a habit they are extra hard to get rid of. So actually wr…

Write more and reflect on what you've written. I've come to have a dev diary where I reflect on what I did the past day/week, and note things I ran across that did/didn't work out so well, and why.

That said, if all you're doing is greenfield development I don't think it's actually possible to improve without third party input. A major goal of good code is maintainability, and that can only actually be known in hindsight.

Re: One Way to Improve Your Coding

#60
post #38

The most obvious way to improve your coding is to write more code. This is a bit too simple: writing more of the same, in the same style, usually won't cut it and unfortunately I've seen people being stuck like that for years: always producing more code, without any improvement whatsoever and instead just repeating the same mistakes. Once those mistakes become a habit they are extra hard to get rid of. So actually wr…

Note that the author didn't claim that it was the best way, or that it might not have drawbacks, just that it's the most obvious.
Post reply on HN