Live data from Hacker News

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

news.ycombinator.com

31–40 of 112 posts

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

#33
Hi from Tent :-) https://cphuntington97.cupcake.is

If you're uninterested, please ignore, but here is something I want that might make an educational project:

A list of English words and/or phrases that are "phonetically contained" within Spanish words and/or phrases (and vice versa). For example, the English words 'cone,' 'tea,' and 'go' are phonetically contained within the Spanish word 'contigo.' (I'm trying to write songs in both languages that converge at key points). You might be able to do it with a https://www.wiktionary.org dump.

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

#34
There are a lot of good answers here. What launched me into development when I didn't even know to program (so one step behind you) was that I found a problem I had personally had and looked for a way that could solved it. It turned out it was programming. The reason this was so effective was I was already passionate about the problem before I even knew what programming was. Then I discovered programming was the right approach, so I learned the tools to get the job done, then iterated.

That _passion_ was a HUGE motivator, in fact i didn't even like programming really was when I solved the problem, but I liked the result. I realized later how many problems could be solved that programming was the tool for the job so I eventually learned to program. But that came after I found the problems I was passionate about.

I find later that this approach was very fulfilling and now I am reading heavy textbooks and doing jobs I thought I would NEVER do because I really like solving problems. But I never could have seen myself doing this 10 years ago.

Now you're follow up question might be, how do I find my passion for this tool I have. Doesn't that now feel like an awkward question? I have a tool, I don't know why I have it, but I want to use it on something. There must have been some reason why you learned how to use this tool. What made you say "wow, how was this done?", or "I wish I could just do X" Try to recreate whatever it was that made you first look up "how to learn javascript programming" in google. If you are still stuck, then you might take to some of these other answers. Browse github, visualize something that could exist and work backwards, read other peoples code etc... but where all of them will fall short and where I suggest you take with yourself is that nothing will kick you on the curb harder then doing something that you're not passionate about.

The number of times I quit a program half way through because I lost the passion was A LOT! I felt miserable about programming for years. I thought I didn't have what it takes and beat myself up about it a lot. I was admittedly ambitious. Some things that could have helped:

* Smaller problems. Something you may not be able to control.

* Breaking your goals up into smaller chunks so you get rewards often.

* Working with someone else. Think of it like a running buddy, or a workout buddy.

* Being forced to do it. Get a job in programming, if someone realizes on you, and you feel that heat under your butt you'll probably end up doing it even if you loose the passion temporarily, though you should stop if you never get the passion back, but give it some time.

* Teach someone. You learn very quickly if you try to teach someone else. Especially if you try to force your brain to think of ways to find your passion. It's a good chance it will spark some passion into yourself as well.

Good luck, I hope something I said helped spark something in you and I hope you can find your passion! Or learn that this passion isn't for you. Someone once said that programming is 90% frustration and 10% elation. That gets you through that 90% my argument here is your passion to solve the issue. If you have no passion that 90% is going to be hell. But stick with it because it will take time! Good Luck!

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

#35
If you want a process that takes you from problem to product I recommend one I have used in developing several real world solutions, described by Freeman & Pryce in the book "Growing Object-Oriented Software - Guided by Tests". Allthough the book uses an object oriented paradigm and Java (none of which I particularly recommend) the process described in the book's first few chapters is solid and makes quality software development more predictable - and less of an art. (For those of you in the know, but who haven't read the book, this is about TDD, London style, (outside-in) with a high level of automation (continuous delivery).)

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

#36

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.

Outside academia it is all about conformance to requirements -- i.e. you get paid to solve a problem for somebody somewhere.

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

#37
When I went to grad school, my career had been programming, and I'd done a lot of it for some years. Two applied math profs were starting a computer science course and asked me what good lessons I'd learned, and I answered. The answer remains current:

A programmer stands between a real problem and a computer.

The computer does only what operations it is carefully instructed to do and no more understands the real problem than the chef's knife of a good cook understands cooking.

So, the work of the programmer is to take the real problem and see how to use the computer to solve it.

For this work, as a first step, if only to make the work easier for the programmer, get a first list of the data inputs for the problem and the data outputs. Yes the code for a Web page is a special case of this first step.

Then outline how the program will take the inputs and generate the outputs.

Here likely will need to define storage for the inputs, say, some or all of variables, arrays, data structures, instances of object-oriented classes, database tables, etc.

Then move on to the work manipulating the input data to get the desired output data. In the case of a Web page or any software with a graphical user interface (GUI), also will want to outline what the output will look like on the user's screen.

Then for the manipulations of the data, use the old strategy of divide and conquer, that is, break the work down into largely or entirely independent pieces of work. People have been doing work of wide variety this way for centuries, likely back to the pyramids and the first boats that could cross an ocean. For each such piece, have in the software a section of code, subroutine, or function. The work of such a piece may be further subdivided.

In the end, want each such piece of code, section, subroutine, ..., to be small, to have a purpose that is easy to explain briefly, that is fairly easy to debug, by desk-checking (that is, careful critical reading), running test cases, etc., and with logic that is fairly easy to create, explain, and follow.

This division of the work should be, at least intuitively, robust to small changes in the real world problem to be solved. That is, the division should be for a problem a little more general and complicated than the one actually given; how much more is a matter of judgment, but a small change in the problem statement should still be a small change in the software!

Next, in the division, exploit the scope of names rules in the programming language to help the software pieces be independent.

Next, remember that at least one human needs to be able to understand the source code and that "When a program is written, it is understood only by the programmer and God. Six months later, only God." So, humans need to be able to understand the code, for small projects, just by reading the source code and not needing additional documentation outside the source code.

Next, remember that humans communicate in natural languages, e.g., English, hopefully with sentences, paragraphs, etc. Remember that, no matter how much we might wish and intend otherwise, the source code of software is not in a natural language. Yes we can use mnemonic spelling for the various names we choose and use, and such mnemonic naming does help someone trying to read and understand the code, but such mnemonic names are still a long way from English. Bluntly, as information for a human reader, the code doesn't really mean anything or is likely a puzzle problem to solve to guess the meaning.

So, net, have to document the code, that is, explain the code to a human, explain with English, essentially with sentences, paragraphs, etc.

Here is an example of a technique in source code documentation: My project now is a new Web site; the source code for the Web pages is in Microsoft's Visual Basic .NET making use of the .NET Framework (collection of object-oriented class), SQL Server, ASP.NET, and IIS. For this work, I have 5000+ Web pages of documentation, nearly all from Microsoft's Web site MSDN.

So, my code makes use of a lot of classes, functions, etc. from those 5000+ pages of documentation, and some of those classes, etc. do a lot and need some good documentation. So, in my source code, when I use one of those classes, functions, etc., I insert in my source code a comment with the title of an appropriate Web page of documentation along with a tree name of the Web page on a hard disk on my computer. So, when reading such source code, one keystroke in my favorite text editor (which is what I use to write code) will display the Web page so that I can confirm that my source code is doing what I intend.

Since the code is awash in symbols, good examples of how to explain code are in good texts in subjects based heavily on symbols. So, can explain code much like a good freshman physics text explains Newton's second law or Coulomb's law or how a good freshman calculus text explains conic sections or differentiation. E.g., for English readers, mathematics is still written in English; then the symbols are names, that is nouns.

In large projects, the documentation may be hundreds of pages. But essentially always there is documentation as source code comments in the source code.

Then, six months later God, the programmer, and others will all be able to understand the code!

My view is that currently the biggest bottleneck in practical computing is poor documentation. Sorry 'bout that. YMMV!

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

#38
For this, you don't need to ask yourself how you solve problems with code, you need to ask yourself how you can solve problems with products.

Coding is not the hard part, it is rather a means to an end. Figuring out for whom you are solving that particular problem and how your product will actually solve that problem is the hard part.

For every problem that there is to be solved, there are 1,000 ways to execute the product that is supposed to solve that problem. However, only 4 or 5 out of these 1,000 ways actually do solve the problem that the product is intented to solve.

So, now you need to

1. Find a problem that is worth solving and that interests you

2. Find out if this is actually a problem. The more people have the problem, the better

3. Figure out how to build a product that is built in such a way that is solves that problem that you are intending to solve

All in all, as you are just starting out, you should probably start writing little scripts that solve your own problem. However, your questions is basically how do I build products that people want to use or how do I start a startup. I would recommend you to start with this essay. http://www.paulgraham.com/start.html.

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

#39
Great question.

Problems are solved by tools. Powerful tools can be built with code.

So try first to think about what kind of tool would be helpful for you. How could a computer help you accomplish something that you couldn't do yourself on pen+paper.

One example I like was I was making designs for various sports teams, and I liked the idea of word clouds, but it seems like too much work. So I built a javascript app that counted words in wikipedia articles and built wordclouds form that.

It's a cool project, but the original seed didn't comde form thinking 'what problem can I solve with code' it came from trying to do something new, then thinking if that specific problem could be done with code.

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

#40
The computer is an automation tool. When you write code, it is serving the purpose of automating a specified and designed process. The things you write in the program to make the automation happen only have to be as complex as is actually necessary for that task.

First, have a good problem to solve. This is your design - developing your sensibility for it is somewhat independent of your coding skill. For your own project designs you should always prioritize your own motivations first, because there is nobody you are directly obligated to finish for. If you don't do this finishing will become very hard. Find problems people have already solved and reinvent their wheels so that you learn more about the problem domain. (e.g. if you want to learn how Facebook works, clone parts of Facebook - if you want to learn how operating systems work, build a toy OS, etc.) Or, find clients who seem to know what they want(nobody really knows - the design will change) and build things for them, on their terms, in a way which will get you paid so that you have the obligation to finish.

A good problem should be either obvious and a bit boring on the surface(an everyday thing made easier, more available, more accessible), or scary(a technical problem that you are not immediately sure how to solve, or are not sure how long it will take to solve). Usually projects start out looking like the former and then develop parts of the latter as you go along, forcing you to "plateau" on new features as you build out the infrastructure. You can also slice up a project into defined versions with incrementally larger sets of features so that your expectations for "done" are managed - if you don't get to some things, you still have a practically useful program.

Then, start working on it in small steps. Maybe you aren't sure how to envision the whole problem. In that case, you can simplify it by reducing the problem into a bunch of facades that are intentionally incomplete. Maybe you want to render a page that shows tables of data, for example. You can start by building up a facade for the presentation layer and see what kinds of data will have to be passed in to make the presentation work. Then you can mirror this at the other end and only solve the problem of "how to store and process the data." Then you figure out a protocol for making the two parts communicate. If you design each part so that it is simple to rewrite, the code will be maintainable regardless of your techniques or technologies, because then you can rewrite your way out of any corner you get painted into.

Post reply on HN