Hacker News new | ask | show | jobs
by still_grokking 1242 days ago
> You're confusing several things here.

I think the problem is that the parent tries to look at quite advanced topics without understanding anything about the foundations.

I'm not sure repeating already stated facts will change much therefore.

He was given already quite good sources to learn more. Now it's on him to understand those things.

(Of course things would be simpler if he would asks questions instead of insisting on his misunderstandings.)

> > use a single solitary type that represents the larger universe of all possible values everywhere that a type is used?

LOL, the all mighty uni-type! :-D

But I see here more people that confuse mere runtime values with types…

I fear too much exposition to "dynamic" languages (or maybe also static languages with "type values") causes some severe damage to future understanding of PLT concepts and confuses people.

I think some PLT / functional programming needs to be thought early in school as part of the math education. This would likely prevent some of damage form being exposed to imperative programming and/or dynamic languages later on.

Just my 2ct.

1 comments

consilient/still_grokking -- this is my response to both of you:

You have the Natural Numbers, N.

You have the Integers, Z.

You have the Rational Numbers, Q.

You have the Real Numbers, R.

You have the Complex Numbers, C.

(https://en.wikipedia.org/wiki/Number#Classification)

My question to (both of) you -- is simply this:

Are those designations, N,Z,Q,R,C -- TYPES?

Or are they not TYPES?

Answer me that with a yes/no answer -- before we proceed.

Are the domains for numbers in Mathematics TYPES?

Or are they not TYPES?

?

The answer(s) to this question depend(s) on which foundation of number theory you like to use.

The classical foundation of number theory is set theory. (No types there!)

But you could actually base number theory also on type theory… (No clue whether someone did this actually).

The result may differ than, I think.

Is a subset of a set -- a TYPE?

?

Dude…

No.

Have you tried google?

Maybe even ChatGPT "knows" enough to help you.

Question:

Why are types -- used at all?

In Computer Programming or in Mathematics?

Surely types -- must have some purpose -- otherwise, WHY are they used at all?

?

I'll give a quick surface-level answer to this...

In computer programming languages, consider Integers and consider Floats (Floating point numbers, i.e., numbers with decimal points, i.e., Float, Double, Long Double, etc).

OK, so let's suppose we define an Integer variable (in whatever language)...

int MyInt = 100;

And now, let's suppose that we want to divide it (using non-integer division!) by 3...

MyInt = MyInt / 3;

Well, now we have a bit of a problem!

You see, even though the answer should be 33.33333 (repeating) -- MyInt can only hold an Integer value!

It can only hold 33!

Some languages will permit this operation -- and the result of the operation will be 33 -- which is the wrong answer.

Some languages will prohibit this operation.

But the point is, is that true division, not explicitly integer division -- is an operation.

Some operations/operators -- make sense to perform on data that is of a specific type -- and some do not!

It's perfectly OK to perform true divison on a floating point type (well, ignoring division by zero, which creates problems no matter what!) and put that value back into that floating point type -- but it doesn't make sense to perform true divison on an integer -- and put that value (now wrong!) back into the integer!

At least not without an explicit typecast -- which tells the compiler "I am OK performing this non-standard operation on this type -- I am OK with the side-effects..."

So that's one example.

Another example is adding an integer value -- to a string.

Another example is concatenating, or performing another string operation -- to an integer...

Basic understanding is this -- types prevent operations on data -- where it doesn't make sense to perform the operation on the given data type!

A type determines a subset -- of the set of all operations (which are basically functions!) possible that "make sense" to be applied to them!

So types are in fact subsets!

Subsets of possibilities, subsets of various amounts of bits and bytes, subsets of operations/functions which make sense to be permitted on those types!

That is WHY they exist!

So N,Z,Q,R,C -- are not subsets of the set of all possible numbers?

?

Also...

Does there exist at least one subset of all of the sets in existence -- which is a type?

?