Live data from Hacker News

What was the last breakthrough in computer programming? (2019)

quora.com

151–160 of 226 posts

Re: What was the last breakthrough in computer programming? (2019)

#151
post #25

Earlier quoted context omitted.

It's nice to read a positive comment like yours occasionally, because the vast majority of the time, I'm just disappointed in how bad our programming tools (including languages) are. It's become a meme in my office that I'm the guy constantly bitching about how stupid our languages are. This week I was back on my soap box about the fact that almost zero mainstream (statically typed) programming languages can even let…

You're looking for refinement-types? Scala to the rescue: https://github.com/fthomas/refined And a new one: https://github.com/Iltotore/iron/ The latter will be zero overhead once a compiler ticket is closed. Both solutions will yield compile time checks where possible, and fall back to runtime checks when the data isn't statically known.

Yeah, pretty much. I know such things exist on the periphery, but I think it's extremely disappointing that we keep churning out "new" languages that are basically "Here's C again, but with one interesting feature from the 70s!"

I worked on a Scala once several years ago and I really didn't "get it". The more I use Kotlin, the more I wish it were Scala.

Re: What was the last breakthrough in computer programming? (2019)

#152
post #25

Earlier quoted context omitted.

It's nice to read a positive comment like yours occasionally, because the vast majority of the time, I'm just disappointed in how bad our programming tools (including languages) are. It's become a meme in my office that I'm the guy constantly bitching about how stupid our languages are. This week I was back on my soap box about the fact that almost zero mainstream (statically typed) programming languages can even let…

> almost zero mainstream (statically typed) programming languages can even let you write down that you want a non-empty string. Today D will fulfill your dreams! struct MyString { private string s = "error"; alias s this; this(string s) { assert(s.length); this.s = s; } } void main() { MyString ms = "hello"; test(ms); MyString mserror = ""; // runtime assert fail } void test(string s) { }

I love that! So it's the `alias s this` that's the magic here, I assume? It's making the `this` pointer actually point to the stored field? That's awesome!

Re: What was the last breakthrough in computer programming? (2019)

#153
post #48
post #34

Earlier quoted context omitted.

The original comment said nothing about C-style languages. That must be something you read into their comment. Learning J is like learning Perl or regular expressions. Nobody really wants to engage in such an activity, but people do what they need to do. Depending on their level of experience, a person who understands imperative and declarative paradigms along with the language's execution model can absolutely learn…

"This is at least part of the reason that reasonably strong engineers can learn a new programming language in under a day. The paradigms just aren’t that different." This literally says "the paradigms aren't that different." So if you accept that C and J are different paradigms, then because the paradigms aren't that different, a C programmer could pick up J in a day. What it doesn't say is that truly different parad…

>To a J programmer, that's not just clear, it's obvious.

Is the argument that J just has really weird syntax? It feels trivial to me to make a mess of syntax that makes learning a language obtuse, unless there's something more fundamentally different about J, this is the first I'm hearing of it.

Re: What was the last breakthrough in computer programming? (2019)

#154
post #76
post #59

Earlier quoted context omitted.

Let me ask you this, though. If your strings that come from user inputs are optional, doesn't that mean they could also just not be present (as in null)? Why do you need or want two different ways to express "nothing"? Are all of the text fields just funneled right into the database without checking/validating any of them? I've written a number of RESTy/CRUDy APIs and I can't count the number of "check that username…

The argument for disallowing nulls is much stronger than the argument for demanding a compiler-enforced non-empty string. I definitely support the ability to declare variables, including strings, as non-nullable. An empty string is simply analogous to the number 0. It doesn't really overlap in meaning with null. It's true it would be useful to occasionally disallow the number 0, but only very occasionally. The obviou…

> The argument for disallowing nulls is much stronger than the argument for demanding a compiler-enforced non-empty string. I definitely support the ability to declare variables, including strings, as non-nullable. An empty string is simply analogous to the number 0. It doesn't really overlap in meaning with null. It's true it would be useful to occasionally disallow the number 0, but only very occasionally. The obvious example is division, but having a representation of +/- infinity alleviates some cases.

Well, of course you should be able to declare something non-null. What do I look like, someone who likes Java? :p My point wasn't that I WANT to use null instead of an empty collection/string, it was that our languages give us multiple mechanisms by which we can pass in "nothing" for strings/collections, but they give us zero ways to ask for a non-empty string/collection. That's super frustrating! Yes, of course "null" and "empty set" are technically and semantically different. But they're close enough that you could actually deal with having only non-empty strings + nulls and be able to mostly express what you want. That's not the case if I actually want a non-empty string in many of today's languages. Not if I want it to be usable with other APIs and the standard libraries, that is.

> Paraphrasing: "I've written the same kind of method over and over throughout my career and have been unable to (or made no attempt to) abstract it away." I love strong type systems, but it doesn't sound like the type system is your problem here. The problem is that you're constantly re-implementing the same business logic.

Eh, no. I haven't worked in the same language or on the same project for my whole career. So, yeah, I've noticed that I'm pretty much always either defining a bunch of boilerplate types up front or I regret not doing it when a 0 hits the database because someone wasn't careful with their math or had an off-by-one error.

Maybe I should publish a book a la Gang of Four and call it "Static Type Patterns". ;)

So, yeah. Believe it or not, I HAVE implemented stuff like PositiveInt and NonEmptyString a bunch of times in a bunch of languages. And it's better than not having it, but it still sucks because in several of those languages, it means that I have all kinds of noise converting to and from, e.g., the native string type. And that's because most of the above languages have no concept of "newtypes" and have no intention of letting programmers define or refine "primitives".

It's not really about "business logic". It's about "I know how to describe the shape of this data, but my statically typed language won't let me."

Re: What was the last breakthrough in computer programming? (2019)

#155

Earlier quoted context omitted.

> Why not a type for even numbers? Odd, prime, not-prime, etc? Those are not mathematical entities in the same way as are the sets W (whole numbers) or N (natural numbers, indices). It is reasonable to specify your domain closely, otherwise you end up with sqlite. "Why not a type for datetimes or complex numbers?" would be a better question, as those are different kinds of things but not quite so frequently used in p…

I would question that primes are not mathematical entities. Same for other sets like "not-primes", or the odd numbers. Sets can be nicely approximated with types. (Some people say even that types correspond directly to sets).

OT: It's funny how primes are given this property of 'primeness' and not-primes are those that don't have the property, when it's actually the opposite. The not-primes have the property of being composite (a product) and the primes are the negative space of numbers excluding composite numbers.

Re: What was the last breakthrough in computer programming? (2019)

#156
post #48

Earlier quoted context omitted.

"This is at least part of the reason that reasonably strong engineers can learn a new programming language in under a day. The paradigms just aren’t that different." This literally says "the paradigms aren't that different." So if you accept that C and J are different paradigms, then because the paradigms aren't that different, a C programmer could pick up J in a day. What it doesn't say is that truly different parad…

>To a J programmer, that's not just clear, it's obvious. Is the argument that J just has really weird syntax? It feels trivial to me to make a mess of syntax that makes learning a language obtuse, unless there's something more fundamentally different about J, this is the first I'm hearing of it.

Their argument would be that J works differently, and once you internalize how it works, many hard problems become tractable. Their slogan is something like, "understand the problem, and it's done" -- meaning that once you understand the problem, the second step of translating the solution into code is near-trivial.

I would argue that's at least partially because J programmers are in general incredibly smart. (I don't count myself as a J programmer.)

Re: What was the last breakthrough in computer programming? (2019)

#157
post #59

Earlier quoted context omitted.

Let me ask you this, though. If your strings that come from user inputs are optional, doesn't that mean they could also just not be present (as in null)? Why do you need or want two different ways to express "nothing"? Are all of the text fields just funneled right into the database without checking/validating any of them? I've written a number of RESTy/CRUDy APIs and I can't count the number of "check that username…

> I've written a number of RESTy/CRUDy APIs and I can't count the number of "check that username isn't empty" checks I've written over the years. But you do it only once, thereafter you have hopefully some "Username" type of object which is guarantied to contain a valid username.

Correct.

But, the reason I'm bitching about it is because, in most languages, you then cannot use your Username type in place of a "native" string, where some third-party or standard library function just expects a string. So now you have to convert back and forth.

And if this is a language like pre-record Java, fucking forget it. Define the class, implement equals(), implement hashCode(), write a getter for the wrapped string so that you can pass its guts to functions that expect strings, write the constructor. Speaking of the constructor, do you let the constructor throw an exception? Do you make the constructor private and write a factory function? Does that factory throw an exception or return a failure value? Checked exception or unchecked exception?

Now do that everywhere that you want a "newtype".

Is it possible? Absolutely. I've done it. Is the amount of effort for such a simple concept reasonable? No.

And my other point is that I actually want a non-empty string MUCH more often than I want a potentially-empty string.

I think that programmers are especially prone to just internalizing bullshit and papercuts. We like "solving puzzles" and we're pretty smart and adaptable. So when we encounter something that's actually kind of insane, but we eventually figure out a workaround, we completely forget that it was ever insane in the first place (see: Gang of Four patterns).

Re: What was the last breakthrough in computer programming? (2019)

#158
post #68
post #63

Earlier quoted context omitted.

I'm using "C-style language" as a metaphor for "imperative procedural language". I'm not the first to do so.

Clearly, C is not a functional, array language. Nobody said it is. What is your point?

And I didn't say C is a functional, array language either, so we're agreed on that. I'm lost about what your objection is at this point, so I'm happy to drop this.

Re: What was the last breakthrough in computer programming? (2019)

#159
post #25

Earlier quoted context omitted.

It's nice to read a positive comment like yours occasionally, because the vast majority of the time, I'm just disappointed in how bad our programming tools (including languages) are. It's become a meme in my office that I'm the guy constantly bitching about how stupid our languages are. This week I was back on my soap box about the fact that almost zero mainstream (statically typed) programming languages can even let…

Have you tried Ada? Its type system is the closest I could think of to your use case?

I haven't, but I've done a fair amount of reading about it and that is the kind of thing I'm talking about.

Re: What was the last breakthrough in computer programming? (2019)

#160
post #67
post #25

Earlier quoted context omitted.

It's nice to read a positive comment like yours occasionally, because the vast majority of the time, I'm just disappointed in how bad our programming tools (including languages) are. It's become a meme in my office that I'm the guy constantly bitching about how stupid our languages are. This week I was back on my soap box about the fact that almost zero mainstream (statically typed) programming languages can even let…

I'm not so sure that I sympathize with your example. Why not a type for even numbers? Odd, prime, not-prime, etc? You really are asking for a type that is "valid data." Commendable, but not a static property of data. As a fun example, what is a valid email address? Once established as valid, how long will it stay that way? If invalid, how long until it can become valid? Do I think better typing can be a boon? Absolut…

> You really are asking for a type that is "valid data."

Enumerations come to mind.

Post reply on HN