Do I have to know mathematics?

I want to be a web-developer and work with websites, to know Javascript and PHP. So I started to learn these programming languages, I passed only few lessons of PHP and JS, and found that JS is more difficult to learn than PHP. At college we study Pascal, and all the hometasks are to program lots of mathematical formulas. And the problem is that I am very weak in mathematics. My classmates alwas say “you won’t succeed in programming because you can’t program formulas in pascal and make calculations, which is the easiest part in programming”. So I want to ask you, professional web-programmers, I need your opinion, are my classmates right? If I am weak in mathematics, I must quit learning web-programming? When you work as a web-programmer, are there lots of mathematical calculations you have to program?

1 Like

Depends on the purposes of what you’re programming. Some is heavily entrenched in math, others aren’t. I will say that if you’re looking to deal with a lot of custom graphics, then a fundamental understanding of math would be helpful, but isn’t crucial.

1 Like

i am rubbish at maths. seriously bad at adding and subtracting numbers but for web programming it hasn’t been a problem for me. Most of what i do is logic not mathematics. Its mostly about if this happens then that happens but not if that happens etc.

If you were working with Shopping carts i guess it will be more maths but that will be mostly adding or subtracting or the occasional percentage. You won’t have to do the actual maths in your head, just write what you want it to do.

The most complicated thing i’ve come across is a query to use latitude/longitude to query other lat/longs in the table within a certain radius. But i didn’t actually have to write that as someone had already done the complicated bit i just had to know how to plug in my database and variables.

Weirdly for me it is more about language. I started learning Greek and i think having a programming language knowledge helped my brain remember how to construct the sentences etc as the syntax is important in both. You will learn to be more accurate with full stops and commas etc as if you get it wrong it won’t work.

hth

1 Like

Noppys post describes my situation. I’m terrible at math for the most part, and never took high level math.

so, how do you cope with it when your task includes math calculations?

Programming languages do have a lot of math functions.
It is amazing to see the work some have done using trigonometric, bitwise etc. functions.

I guess in some cases my code could be made less verbose if I used more advanced math functions, but so far I’ve only very rarely needed to use them.

Simple addition, subtraction, division and multiplication usually suffice.
Modulus and percent come in handy at times.

IMHO it is very important to understand the differences in various datatypes eg. precision errors, than it is to know the advanced math functions.

But as Dave pointed out, it depends on what code you’re writing. Some will need to use more than simple math is capable of doing.

Object Pascal (Delphi) is my first love. It was the first language that made any sense to me.

I also believe in where there is a will there is a way; never reinvent the wheel; you are not alone in this world; and Ed Emberley rocks!.

Oh, and I am dyscalculic. It’s a learning disability related to math.

  • Where there is a will, there is a way: calculators, cheat sheets, tricks you can learn, etc.
  • Never reinvent the wheel: Make use of code and libraries written by people with better math skills than you.
  • You are not alone in this world: You never have to do something all by yourself, in the real world. Being part of a team means you get to specialize in the stuff you are good at and leave the complicated math to the math geniuses on your team.
  • Ed Emberley rocks: He wrote a series of children’s drawing books that reduced everything into it’s simplest forms, teaching kids a whole new way to look at the world, and solve big problems by breaking them down into simpler, easier to solve parts. Circles and triangles are easier to draw than hearts, and you can build a heart from 2 circles and a triangle. Understanding his philosophy and how it applies to everything in life, can take you quite far.

While I probably would flunk all the math stuff you are struggling with in school, I don’t let my disability stop me or slow me down from doing what I want to do, what I have a passion for. And I have had a passion for software development, and building things, for most of my life.

Yes, it means I have to go over some things more, test more, think a bit more, draw more flow charts, but it can be done and done well, if you specialize in what you are good at, and don’t try to specialize in what you are not.

And two of the things you will learn in school is what kind of programming you are good at…and what kind you are not.

1 Like

Arithmetic is mostly what is required and virtually no mathematics is ever used but can come in handy when using PHP and JavaScript :slight_smile:

Edit:
Arithmetic vs Mathematics

Arithmetic is just one branch of mathematics, namely that involving
basic techniques of calculation with numbers. When you add, subtract,
multiply, divide, take square roots, and so on, you are doing
arithmetic. When you solve an equation you are doing algebra. When you
determine relations between shapes or find their area, you are doing
geometry (though the latter calculation will be done by applying
arithmetic to the geometric formulas). Most of what young children
learn in math is arithmetic.

What would you consider Binary, Octal, Decimal and Hexadecimal?

They seem to come into play quite often in my web dev and other coding experince.

True, online “converters” are easy enough to find, and I guess one doesn’t need to fully understand the differences to be able to use them But deciding which to use can make a world of difference in the code.

For example, if one wanted to sort IP addresses, - eg. 123.075.238.090

All classed as arithmetic with different bases.

For example, if one wanted to sort IP addresses, - eg. 123.075.238.090

I do not understand your example.

A while ago I was trying to write some code to sort IP addresses.

Normal sort functions didn’t work because they aren’t in decimal.

Similar to sort vs. natsort. Alpha, Charlie, bravo or when 2.jpg comes before 14.jpg

I did manage to get something thrown together that “worked” but then @Paul_Wilkins came up with a much more elegant solution.

My version was quite involved

function sort_by_ip($info_arr)
{
	$temp_ip_arr = $ip_seg_one = $ip_seg_two = $ip_seg_tri = $ip_seg_qua = array();

	$i = 0;
	foreach($info_arr as $ip_data)
	{
		$ip_segs = explode(".", $ip_data[0]);
	
		$temp_ip_arr[$i][0] = $ip_segs[0];
		$temp_ip_arr[$i][1] = $ip_segs[1];
		$temp_ip_arr[$i][2] = $ip_segs[2];
		$temp_ip_arr[$i][3] = $ip_segs[3];
		$i++;
	}
/* .... prepare to Sort array of IPs .... */
	foreach ($temp_ip_arr as $ip_key => $ip_row)
	{
		$ip_seg_one[$ip_key] = $ip_row[0];
		$ip_seg_two[$ip_key] = $ip_row[1];
		$ip_seg_tri[$ip_key] = $ip_row[2];
		$ip_seg_qua[$ip_key] = $ip_row[3];
	}
	array_multisort($ip_seg_one, SORT_ASC, $ip_seg_two, SORT_ASC, $ip_seg_tri, SORT_ASC, $ip_seg_qua, SORT_ASC, $info_arr);
	return $info_arr;
}

But Paul’s was a few lines because his code converted the 4 bytes to a single number.

Thanks @Mittineague - I can’t quite find that code now, but fear not, for the following code does the same job:

function ip4() {
    var ip = Array.prototype.slice.call(arguments, 0, 4);
    ip.toString = ip4.toString;
    ip.valueOf = ip4.valueOf;
    return ip;
}
ip4.toString = function() {
    return this.join('.');
};
ip4.valueOf = function() {
    return (this[0] << 24) | (this[1] << 16) | (this[2] << 8) | this[3];
};

var lan = [
    ["ADSL Router", ip4(192, 168, 0, 1)],
    ["Gary's Mac", ip4(192, 168, 0, 15)],
    ["Network Switch", ip4(192, 168, 0, 2)],
    ["Production Email", ip4(192, 168, 0, 60)]
];
lan.sort(function(a, b) {
    return a[1] - b[1];
});

Which all relies on the valueOf method to do the heavy lifting for us.

2 Likes

Can you supply an example of $info_arr and I will use the values in the following:

jb-sorted

$info_arr was an array of database results which I might still have somewhere but I’m not sure, it was a few years ago now.

But I did find this which is hopefully a big enough sample set and array-iffiable

ip-array.txt (2.6 KB)

jb-sorted Update

Unless I’m not seeing something, it looks like natcasesort does a fine job at it.
I don’t know how I could have missed that before.

1 Like

I am not sure how to classify using the contents of a “Black Box” function. Reminds me of trigonometry but could also be mathematical :slight_smile:

1 Like

In my experience there has not been much math involved with my career in web based software architecture and programming. Much of the low level stuff that would require extensive math knowledge has already been written. You just need to understand those things at a high level to achieve given business requirements.

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.