Live data from Hacker News

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

news.ycombinator.com

11–20 of 112 posts

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

#11
Pick a small, simple project that will force you to learn new things and put pieces together. My favorite starter server project is building a super simple URL shortener. You just need to render a page with a form, accept a POST from that form submission with the URL to shorten, hash the URL, store it in a database, return the hash, and set up a GET that maps your hashes to your URLs by looking up against the database.

The most important thing with beginner projects is scope. Pick MVP versions of things you want to make and build out.

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

#12
I've often felt the same way. I've found things just by spending time brainstorming, and keeping it in the back of my mind as I go about my week. You can actually come up with a lot of ideas just by practicing observation of daily tasks you have.

I'd also recommend attending a Startup Weekend or hackathon of some kind and just joining up with a group working on something interesting. Being around the creativity at these can the wheels turning even afterwards

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

#13
Excellent question for a Friday. Coding is like welding, how do you find two pieces of metal that need to be joined? Generally the answer is visualize something that could exist, but does not exist, and then fill in the parts that need to be there for it to exist.

What you need at this point are a series of assignments which are self-contained problems with known solutions. The assignment 'create a web server that displays "Hello World"' is an example of one.

Here are some more:

Create a web site that allows a person to identify what would be an 'affordable' mortgage. (or flip it, shows them how much they need to save each month in order to retire). These are both applications of the compound interest / annuity calculation, but built in such a way that you can pick different parameters to see the results. Pick an interest rate, or pick a home value or retirement amount.

The goal of that assignment is to have you create a web site which has a built in formula (logic) which can be manipulated by user entered data.

Next assignment, build a web site that collects data about a particular commodity that changes day to day (could be a stock price, could be oil, unemployment, could be Eve online credits, what ever), then plots that data on a graph. Allow the user to annotate the graph by date with specific events. You will find the d3 library helpful here. Once annotated allow the annotated graph to be shared by URI.

The goal of that assignment is to get you to store data over time, use third party APIs, and provide a way of getting to a particular state based on arguments in a URI.

Now for third assignment, create a market site for three commodities, we'll call them 'stone', 'wood', and 'sheep'. Have a system random number generator periodically generate one or more units of one or more commodities. Simultaneously create a Sudoko board such that the first player to solve the puzzle gets the commodities. In the Market people can buy and sell commodities, the market creates a currency for recording those transactions. Players with a specific quantity of individual commodities can produce a 'product' and that product adds to their 'production' score. Rank all players by the quantity of currency in their account and their production score.

The goal of that assignment is to create a fun market simulation game that echoes some of Settlers of Catan and gives you something fun to put into a Show HN posting.

Bottom line, practice problems. Then when you, or someone you know says, I'm trying to do this ... you can tell them you can do it or not.

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

#16
based on what you wrote, i would say the next goal is to write a twitter clone.

write something that takes user input, stores in a database, and represents it later on.

CRUD (create read update destroy)

many webapps could be categorized as a CRUD app, or start as a CRUD app. if you've only gotten as far as "hello world" then i'd consider this a worthy "next target"

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

#17
Remember, programming languages are a tool and problem solving is a skill. Learn data structures and algorithms. There are plenty of good books and websites out there on those topics. Once you have a basic understanding of those you can learn to apply your language of choice to implement solutions to problems. Next, find problem and solve. Also, some languages lend themselves to solving certain problems better than others. Don't limit yourself to one language. Once you have the knowledge of one language you are only a different syntax away from the next. Logic does not change, problems do.

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

#18
Read Programming Pearls to begin flexing your mind in the right direction. It's a somewhat older book in terms of the actual practicalities, but in terms of getting you thinking about how code is applied to situations, it's timeless.

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

#19
I learn it backwards. Take something slightly complicated (so much so that you find it challenging to read) that solves a problem that you understand.

Then think of a feature or modification that you think would be useful. Try and implement it.

It's incredibly painful but I find this works better than trying to build something from 'hello world'. Before you know it, you can understand why stuff was implemented that way and what not.

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

#20
That is exactly why I made this collection of problems: https://github.com/karan/Projects

> A list of practical projects that anyone can solve in any programming language. These projects are divided in multiple categories, and each category has its own folder.

Feel free to also look at other people's solutions (many in JS): https://github.com/thekarangoel/Projects-Solutions

Post reply on HN