11

I have just learned HTML/CSS and I practice everything I read to make it more understandable to me and I really enjoy it. My goal is to be a Modern Web Developer both front and back-end, so I won't stop learning. I'm planing to jump on JavaScript now but what I would like to know is how important is math to being a Web Developer.

  1. Do I need to know math?
  2. If so, what kind of math should I know and understand?
4
  • 1
    Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.
    – gnat
    Commented Jul 17, 2013 at 22:55
  • 1
    The trouble with these questions is the answer is either trivially yes or no depending on what you consider math to be. e.g. if logic is math then, yes you obviously need math. on the other side some people seem to actually define math to be stuff they don't need to know, so obviously they don't need 'math'. Personally i'm in the programming == math category but will admit that a formal math education is not necessary, it is possible to discover the math you need on your own, the question then becomes is this the most efficient way to learn?
    – jk.
    Commented Jul 18, 2013 at 7:00
  • 1
    see programmers.stackexchange.com/questions/199793/…
    – jk.
    Commented Jul 18, 2013 at 7:03
  • also relevant steve-yegge.blogspot.co.uk/2006/03/math-for-programmers.html
    – jk.
    Commented Jul 18, 2013 at 7:23

6 Answers 6

21

I am a poor mathematician - numerical methods (Computer Science 412) was a class I took several times, and please don't ask me to do an integral calculus problem. When I was done with it, I thought I'd never touch such a math problem again.

A number of years later, I wanted to make an image of an animated braid in RGB as an avatar.

Animated braid in rgb

I did that. While the math to get the three sine waves was easy (highschool math), the question of when does one stand overlap another took some thought and turned out to require a small bit of numerical methods (that CS 412 class I took - the derivative of a function, quite easy... but I still had to recognize it and solve it).

Its a trivial example, but one you may come across. It wasn't the math that was the hard part, it was the recognizing the class of the problem.

A recent example from Programmers.SE: What class of problem is this, and what math do I need to know to solve it?

How does one calculate this? It reminds me of solving matrices in high school. Is this something that can be done with matrices? What is this problem called? What do I need to know to solve it?

This as pointed out in the answer is linear programming. Again, it isn't about solving the problem, it is about recognizing the class of the problem and being able to find out how to solve the problem.

At my previous place of employment, there was a person working on a computer program to optimally cut carpets. Optimal Carpet Cutting shows how this can be done. It involves some math (frankly that is a bit above what I can understand with a glance). And yes, this was being done for a webapp (there is even more fun in that of trying to figure out how to send it from the back end to the client - do you json it up and rerender it? how would you store that? Or maybe just generate an image on the back end?).

An optimal carpet.

I was working on a point of sales system and working on getting the correct numerical formats in a number of places and tracking down missing pennies in receipts that were thousands of dollars (coupons and promotions and packages oh my!). Tracking through this code required some advanced algebra and the recognition of the implications of doing certain operations in different orders. Identifying and simplifying things such as Math.pow(10,foo) / Math.pow(10,bar) to Math.pow(10,(foo - bar)) made some of the code run a little bit cleaner.

Another problem that was being tackled was reducing the complexity of the spline of a person's signature without changing the shape. (The following image is not what I was working on, but serves to illustrate the problem)

enter image description here

Which of those points are the least significant ones that can be removed (to fit in some other antiquated system that has a limit to the number of points in a signature)?

Continuing on this, and especially applicable to a front end web person you may often find yourself working with splines in web animations. Look at w3 on SVG animations and the inkscape wiki. You may find yourself wanting to do a chord diagram (glance at circos for some 'wow' visualizations of this nature)

And one last bit, being a backend tools person, I often found myself doing reports against my tools. This often touched into stats (standard deviations, mean, median, mode, outliners, statistical significance, best fit lines, identifying the proper graph to present the data, etc..)

The point I am trying to make is that there are many places - both on the front end and the back end - that make use of some higher math. You may find yourself in careers that don't make use of this at all. It is quite possible. However, you will more than likely find yourself needing some advanced math at some time.

As a programmer, any math you can get your hands on and head around will likely be useful in the future. I can't say if you will find simple numerical methods the limit of where your career will take you, or if you will find yourself trying to determine the optimal cutting of carpet, or trying to explain to a client why it is not a good idea to represent all the possible ways to arrange 7 items on a single web page.

4
  • Interesting stuff! Im currently doing basic crud so I'm somewhat envious... Oh well, at least I get to make fancy UIs.
    – Max
    Commented Jul 18, 2013 at 8:54
  • @Max Don't underestimate the amount of math that you can put into fancy UIs. Designing visualizations on the web of the reports from crud can lead to a number of interesting problems to solve.
    – user40980
    Commented Jul 18, 2013 at 14:06
  • This is like saying "Study quantum mechanics, you might write a scientific program someday! Study basket weaving, you might write a weaving program someday!". Just because you might, maybe, possibly end up in a job that sorta uses stuff you learned in class doesn't mean you should torture yourself to learn about the subject
    – TheLQ
    Commented Jul 21, 2013 at 7:34
  • @TheLQ unless one is attempting to limit themselves to just dealing with crud and never doing anything more (even having other people do the analysis of the data that you collect), one should study math. Not having enough math to recognize what problem domain exists in really limits yourself - even as a web programmer. As to QM, I do have the layman's understanding of it (ha!) and one recreational program I've been trying to tackle for years might be best approached by using simulated quantum annealing.
    – user40980
    Commented Jul 21, 2013 at 16:49
19

You don't need to know more than perhaps trigonometry in order to develop web pages. But you should know the following if you want to be optimal:

Set Theory: This helps with more things that I can count in programming. You learn how to weed out duplicates more efficiently.

Graph Theory: If you want to understand networks at a fundamental level, this is helpful. It's also good for breaking down certain kinds of problems more easily.

Linear Algebra: This is huge if you want to do anything with 3D graphics like HTML5 Canvas.

Statistics: This is even bigger since you'll want to be able to understand things like web analytics and machine learning in order to fully optimize your website's features.

Understanding mathematics is also useful from the standpoint that it will generally improve your problem solving skills. You'll be able to draw analogies between difficult real world problems and mathematical models with known (often not easy) solutions.

5

If you're using CSS to do any kind of non-trivial layouts, especially if you're going the whole Responsive design/fluid grid/best practices/whiz-bang-pow route, you're going to be crunching a lot of numbers.

For example, say you have a 960px wide page, and you need to put 5 boxes on it, flush against the sides, with gutters in between:

Diagram showing 5 evenly spaced boxes in a 960px wide area

Lets assume we'd like to try for 20px wide gutters, and hope the math works out. That's leaves us with a bit of algebra:

5x + 4(20) = 960

So solving for X tells us that are boxes are each 176px wide. However, we're working with a responsive fluid grid so pixels won't cut it. We need that as a percentage so we pull out our responsive equation (from the book):

(target/context)*100 = percentage

But wait! It turns out we'll need multiple rows, and so can't just use :first-child or :last-child to cancel out the extra margin. We could use nth-child(5n) (look! Math!), but we want legacy browser support, so we'll wrap the boxes in a container that's 20px wider than the 960px and give it a negative right margin.

  • So the container width is: (980px/960px)*100 = 102.083%
  • And the container's right margin is: (-20px/960px)*100 = 9.375%
  • And the boxes' widths are: (176px/980px)*100 = 17.959%
  • And the boxes' right margins are: (20px/980px)*100 = 2.041%

And then lets assume we want each box to be the same height as 6 lines of text, and that we're using the default font size of 16px, with our line height set to 1.5 (16px*1.5 = 24px), and we're using ems for our vertical units, which are factors of the current font size.

That means the height of one box is (6*24px)/16px = 9em.

And if we want a 20px margin between the rows, the boxes need a bottom margin of 20px/16px = 1.25em


So yes, I find math very important when writing CSS, and often javascript. At the very least, knowing when you'll need a certain piece of algebra, geometry, or even trigonometry will come in very, very handy.

Even with modern pre-processors, the computer can only crunch the numbers, you need to figure out which numbers to crunch.

4

FWIW, in a generic sense (i.e. programming, irrespective of language), the most valuable proof in terms of math for programming is algebra. You don't use it directly, but it trains you in the kind of logical processes necessary to be successful as a programmer. A lot of programming is math-orientated, too, but the algebra is best in teaching you how to think in order to solve problems you might encounter.

That said, if I were to teach an "Intro to Programming" course, I'd do an algebra pre-test that's heavy on logical process (word problems, solve for x, and so on) and then highly suggest anyone that washes out on that test to think very hard about finding another class because their chances of success would be slim.

And yes, this is opinion, but opinion based on several of my personal experiences, too.

2
  • 1
    +1 for algebra being the minimum. If you can't handle algebra (I'd say algebra 2) you're not going to get/like programming which, like algebra, is very much about separating the answer from the question so you can give yourself a useful question. Commented Jul 17, 2013 at 23:28
  • That said, many have realized they were actually decent at math through programming. Lots of graphic designers moving to web design and then full-blown front end dev realized algebra was no big thing when they could understand it in their own terms. Commented Jul 17, 2013 at 23:38
0

I am a web developer with over six years of professional experience; primarily on the server-side but with a decent amount of client-side work as well.

When I went to high school, the school had implemented a controversial math program called College Preparatory Math. I was in the program for the first three years, then, the last year, I took a standard pre-calc class - and got a D.

Having always had an interest in computers and programming, I wanted to go to college and get a Computer Science degree. So the first year there, realizing the standard-level math classes might be too tough for me, I again took a pre-calculus class that wouldn't count towards the major. Not that that would have mattered; I got a D again. Dejected, and worried I wouldn't be able to graduate in time, I made one of the worst choices of my life and switched to an English Lit degree.

So, long story short, I have neither a CS degree nor much experience in college-level mathematics. But I'm doing okay as a web developer.

For this kind of work, more than high-level math, I think it's helpful to have a grasp of three particular things; logic, databases, and text processing. An understanding of logic is universal in development, of course, and databases are also seen in other development fields, but keen knowledge of text processing is a bit distinct; the same way that, say, a game developer will probably rarely have a need for regular expressions but need to implement trig and calc functions almost daily, a good web developer should know how to write a regex pattern in their sleep, but can probably go a lifetime without implementing the Pythagorean theorem.

That being said, it will certainly do you no harm if you can bear with it and learn higher-level math if you have the chance. As I said, I regret not sticking with it in college. Who knows; maybe you'll decide that you enjoy that stuff, and more than web development, you have a knack for graphics processing or game development.

-1

I think that we have tried our best to most cleverly sway from the problem at hand. To kindly circle back to the facts. As anyone programmer will tell you we are self taught. I think it would be a great disservice to yourself to not start coding because you feel like you could sleep through a trigonometry class as I know I would. I would never say math would not hinder me as a programmer. But math never stopped me from trying to learn anything to do with programming. It is a fact that it is not worth waiting to learn javascript because of mathematics. You will have many phases of learning to conquerer before you will be coding a clever man walking towards your last click.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.