Live data from Hacker News

Ask HN: I've learned a programming language – how do I solve problems with code?

news.ycombinator.com

21–30 of 112 posts

Re: Ask HN: I've learned a programming language – how do I solve problems with code?

#21
What have you done that's more advanced than 'Hello World'?

I'm assuming you don't literally mean you've written 'Hello, World!' a thousand times, and I assume you've tried more complicated projects, so where do you keep getting stuck?

Logic and structure doesn't leap, fully formed, from the head of an architect like some prophecy. It starts with some notions that are carefully honed into a working implementation.

Re: Ask HN: I've learned a programming language – how do I solve problems with code?

#22
Try make something that interests you, see how you would go around implementing it. If you're stuck with a feature, google it. Then see how you did against the "proper" way of doing something, and maybe adapt your code to use the "proper" method. By proper, I mean that it's a more efficient way to do something than to hack it together and have it just about work.

You've learnt the language and the syntax, but it's the experience of just doing something that counts is where it's at! Good luck :)

Re: Ask HN: I've learned a programming language – how do I solve problems with code?

#23
Don't start by trying to solve a problem. That way lies madness.

(The problem is that your mind, your approach, needs to change, and that change comes with practice and time. And practice always starts with the simple, the controlled, the repeatable, not the full fury of all skills brought together in a high pressure win-or-lose moment.)

Computers are nothing more than repetition machines. Start by writing code to do things that you yourself now do multiple times per unit time.

Start small. Simple things. Let the computer handle the repetition for you, no matter how simplistic and rude and hacky your solution.

Then notice how program A and program B, written to repeat different procedures, have similar processes or structures.

Generalize A and B to make a C that does both.

Do this again for other processes. Over time, your approach will shift. You will notice patterns: Patterns of process, patterns of structure, patterns of relation.

Then you will start solving problems. Only afterwards will you realize you have done so.

(I started coding shell scripts for anything I had to do more than twice - or anything that required "too many characters". I got tired of typing "ls -alt *|head" so I wrote nwst to do it for me. Then I added a numeric option to nwst to control how much head wrote. I got tired of writing "find . -iname" so I wrote fndi. Etc. Etc.)

Re: Ask HN: I've learned a programming language – how do I solve problems with code?

#24

  1) Go to Github
  2) Browse the Javascript projects
  3)  Look for projects which are active with many follows/forks
  4) Click on the Issues tab
  5) See what open issues there are
  6) See if the maintainer is active and applies pull requests
  7) Pick an issue you can fix, fix it, write a patch
  8) Send a pull request
  9) See if the maintainer has any comments 
  10) Go back to step 1

See - you're solving problems. This is the kind of stuff you'd have to deal with on the job, and is the kind of stuff you'll deal with with your own projects as you or your users discover problems.

I know exactly a problem you can solve right now with Javascript.

   * Go to this website - http://maps.huge.info/zip.htm 
   * Move around the map so you can see where various San Francisco zip codes are.
   * Now try to do this on your phone
I'd love for this to be a mobile-friendly website, but it isn't. It's a useful tool, it looks like it's just a mashup of Google Maps and ZCTA's. A perfect project and problem to solve.

Re: Ask HN: I've learned a programming language – how do I solve problems with code?

#25
The answer will be 'write code'.

This will teach you a lot of things... I can try to come up with a short list of what I've observed of my own development as a programmer.

You will recurrently come up with particular patterns, you start to identify which approaches will work, which will be dead ends and so on.

Try to separate your understanding and model of a problem to at least data, model and view domains. You will have certain data - you should keep this as simple as can be for the problem you are solving. There will be the model - how is the data mutated, which rules will guide it - and there will be a one or more view to this model and data. Note, that as a pattern the view encompasses both the possibility of an API to your system, as well as the actual display of data.

Try to keep you code as simple as can be. Don't go for the more complex solution unless you know you really need it.

'Pragmatic programmer' and 'code complete 2' are pretty good books about software development in general.

I would suggest you figure out what interests you and then try to implement simple programs in that domain. If something feels too complex, then first try a simplified version... more simplified etc. until you understand how to solve it.

One of the best knacks to learn is how to approach something from a direction which makes the problem easier to solve. There are usually an infinite amount of ways to write something and the challenge is not to just start writing code but actually figuring out which solution method leads to the most understandable and easy solution.

I would suggest you familiarize yourself with the practically important datastructures: the list, the binary tree, the map and the graph, etc. "Algorithm design manual" is a pretty good book for this. Aho's foundations of computer science is a pretty solid and free reference: http://infolab.stanford.edu/~ullman/focs.html

It's probably most motivating to mix the computer science with practical exercises unless you find you get a great kick out of it.

Good luck!

Re: Ask HN: I've learned a programming language – how do I solve problems with code?

#26
Your best project ideas are going to come to you in day-to-day life, like the time my roommates started complaining that the laundry machine in our basement was always being used. A couple days later, a simple web app was hacked together that displays the washing machine status, and let's anyone "claim" the machine. I did that project when I was in college, and I probably knew way less about web servers and Node than you. I just Googled the first thing I wanted to do "make a website", struggled for a bit figuring out DNS and hosting for the first time, and then put up a test page. Seeing a page show up on the internet at yourwebsite.com for the first time is a pretty magical thing, and the rest was history.

In general, what you need is activation energy - that initial bump to get the project or idea started. After that, you need to practice maintaining the motivation to complete the project you started.

Asking the HN community was an excellent way to start. Good luck!

Re: Ask HN: I've learned a programming language – how do I solve problems with code?

#27

Don't start by trying to solve a problem. That way lies madness. (The problem is that your mind, your approach, needs to change, and that change comes with practice and time. And practice always starts with the simple, the controlled, the repeatable, not the full fury of all skills brought together in a high pressure win-or-lose moment.) Computers are nothing more than repetition machines. Start by writing code to do…

I don't know why this got downvoted, it is very intelligent and I completely agree. Especially for kids, the most effective way to learn coding is to have complete visibility over all the underlying components.

Re: Ask HN: I've learned a programming language – how do I solve problems with code?

#28
before i learned to program, i knew what i wanted to create. that was 13 years ago when i was too busy playing an online video game (nba live 2000) and i wanted to create an association league out of it, just like nba.com. first thing i knew i needed was a website, somehow picked php and after heavy amount of trial and error, just under 4 months or so i had a website going with my own forum, standings, team management system, player/team statistics, etc ... little did i know, that was all it took to set me off on a career path i've never have imagined otherwise and i love every day of it. :)

Re: Ask HN: I've learned a programming language – how do I solve problems with code?

#30
Most people have already given you a very good advice.

I can tell you what I did many years ago. When I learned my first programming language, I decided to create my own CMS. I was still in high school, around 15-16 years old so it was just a fun project for me.

Imagine a simple version of a Wordpress. An admin area where you can add new posts and tag them. And an index page where the posts are displayed in a descending order with a pagination.

This will teach you basic ideas about how to store data in a database, how to work with forms etc, how to retrieve the data from the database and display them in a structured way (templates).

Ok, let's make it little bit more challenging. users can click on individual posts and add comments. Once I got my hands dirty and created something simple, I started adding more functionality to satisfy my newly acquired thirst for knowledge.

Each new problem I solved, no matter how trivial, motivated me to go t a next level and learn more.

Let's say users have to register in order to post comments. This will learn you how to create a basic authentication system, how sessions and cookies work, how to safely store passwords in the database, maybe add your own custom catcha element on top of it.

Next, I moved on to a new feature. I wanted to be able to upload pictures from the admin area and be able to insert them inside posts. Images should also be resized into multiple sizes (thumbnail, full size etc).

You can see that what started as a very simple project can actually grow more and more complex and you can learn a lot.

After I finished my CMS, I went on to a new project, I wanted to created my own text editor and a simple image editor (imagine MS Paint). Did both of those and again learned a lot.

After that, I went even deeper and created a fairly complex social network from scratch. Although this was the first piece of code in my life I got actually paid for so it probably doesn't count.

What I am trying to say is that you should go and get your hands dirty. It might seem like reinventing the wheel (because it is reinventing the wheel) but it is perfect for learning how to actually do something useful with code. It teaches you about data structures and algorithms.

You will probably laugh at your first creations in couple of years but they will be very important in making you an actual software engineer down the line.

Post reply on HN