News for hackers. Stuff that matters.
Re:SQL is 43 years old – Here’s why we still use it today by dllthomas on Tuesday May 02, 2017 @11:04AM (#14246922)
You and the parent are not using quite the same definition of "types", I think.
Re:SQL is 43 years old – Here’s why we still use it today by kbenson on Tuesday May 02, 2017 @01:14PM (#14248306)
I think we are, if you look at it from a high level. C has some well known types most people are familiar with. Perl has a few types too, scalar, array and hash (and a few more lesser known or used ones). This makes Perl very easy to use initially, because you can just treat strings as string and numbers as numbers, and Perl will mostly do what you want based on the operators involved. You create complex data structures by just creating them (ad-hoc) or by actually defining a class, which actually gives you a new type.

As you create any non-trivial program, you'll likely create some types, whether in C or Perl (as classes). What was initially a benefit in Perl, since you didn't have many typed to keep track of, becomes a liability, as there are more types but still no formal way to ensure they are being used in the correct locations and as expected arguments without runtime checking (and manual checking at that, unless you use a good module to handle a lot of that for you).

That some languages keep types fairly low level (C, with typed relating fairly closely to machine representation) and some are high level (Perl, with each type being a higher level container) is really irrelevant. In the end, they are just labels that codify behavior (size, acceptable methods of use).

In SQL and NoSQL systems, you have the same trade-offs. Do I define everything up-front so I know (presumably) when there's a problem, or do I create the structure ad-hoc as needed and enforce the structure through the function of the application that creates the data?

Re:SQL is 43 years old – Here’s why we still use it today by fnord123 on Tuesday May 02, 2017 @01:50PM (#14248715)
Yes, we're talking about the same thing. But in Perl, do we make classes or hashes with keys as the field names? :)
Re:SQL is 43 years old – Here’s why we still use it today by kbenson on Tuesday May 02, 2017 @02:04PM (#14248880)
Such is the eternal question in Perl. :)

Also, sometimes we make classes out of scalars, arrays and globs as well. It was interesting the first time I looked into the source of IO::Handle (and IO).

Hmm, I bet there's a module to create classes that uses pack and unpack to store byte level representations in a scalar as the blessed type of a class.

Re:SQL is 43 years old – Here’s why we still use it today by dllthomas on Tuesday May 02, 2017 @07:31PM (#14251672)
Heh, then I think I read you as saying something more interesting than you'd intended :-P
Re:SQL is 43 years old – Here’s why we still use it today by fnord123 on Wednesday May 03, 2017 @08:49AM (#14255182)
What did you think I was talking about?

I guess there could be a few senses of types for a programming practitioner:

1. integral types (int, float, etc) 2. product types (structs, objects) 4. sum types (enums) 5. containers (vec, dict, list, etc).

Typeless types would be dicts of lists of dicts. i.e. shitty product types. e.g. `x = dict(y=1, dict(z=[1,2,dict(u='good data')]))`. Passing this to functions that want to get 'good data' out of the structure basically end up treating this as a type, if that makes sense.

If I understand kbenson's point, it's that sometimes this is better than a tower of babel of type hierarchies that you may have confronted in Java or C++ and you end up needing to ponder how to convert your IWiggleWoggleSupplierProvider into an IWoggleWiggleProviderSupplier even though they do almost the same thing and have the same data but somehow they have different inheritance hierarchies.

Re:SQL is 43 years old – Here’s why we still use it today by dllthomas on Wednesday May 03, 2017 @02:22PM (#14258593)
There's a sense of types of "anything (computable?) you can statically say about your terms". Representation is just a part of this, and often not a very important one. "How can I use this?" is usually much more interesting.

From that perspective, "treating the shape of your dicts as its type" certainly makes sense - it determines how you can use it correctly. It's incidental that you're not encoding this information in the "type system" your language provides (and that may or may not be a good idea, depending - there are always tradeoffs and we've left an awful lot of context unspecified).

From the same perspective, if you can use your IWWSProvider and your IWWSSupplier identically, we can say that they're arguably not different types and only being treated so because someone has given the Java or C++ "type system" an incorrect specification.