Better HN
topnewbestaskshowjobs
Log inSign up

randomdata

8,634 karma · joined Jun 23, 2011 (15y ago) · 7,679 submissions

Submissions

comment 2y ago · link · parent

The SQL is preferable in this overly simple, cherry-picked case, but now do composition.

comment 2y ago · link · parent

Yes, QUEL is a language for querying relational databases. Relations are fundamentally unordered.

I suppose if your example is using a NoSQL (meaning non-relational) database, that is ironically queried using SQL, then you might need something else. But my understanding is that we're back on the relational kick these days.

comment 2y ago · link · parent

Use QUEL?

    range of c is cars
      retrieve (avg(c.price) where c.brand = 'BMW' by c.year)

comment 2y ago · link · parent

> You create interfaces purely for testing

The interface cost is real, but I'm not yet convinced the other solutions for simulating errors while under test are not even more costly. testcontainers is a complete non-starter. I'm not, for example, going to physically crash my hard drive to get the appropriate errors out of it.

If you are not documenting your failure cases in your tests, you may as well not write any code at all. The failure states are the most important part of your application.

comment 2y ago · link · parent

Doesn't that suggest that the working-class is collapsing rather than the-middle class?

comment 2y ago · link · parent

> I provided a JS try-catch example above; is there something wrong with it?

Yes, it suffers all the same problems. And then doesn't even help you with the errors once you get them! You then have to resort to this kind of craziness to do something with the error:

    try {
        doSomething()
    } catch(error) {
        if (error instanceof FooError) {
            console.log('foo')
        } else if (error instanceof BarError) {
            console.log('bar')
        } else if (error instanceof BazError) {
            console.log('baz')
        } else {
            console.log('unknown')
        }
    }
Which leaves you wondering why you didn't just write:

    err := doSomething()
    switch {
    case errors.Is(err, ErrFoo):
        fmt.Println("foo")
    case errors.Is(err, ErrBar):
        fmt.Println("bar")
    case errors.Is(err, ErrBaz):
        fmt.Println("baz")
    default:
        fmt.Println("unknown")
    }
At least Java gives you multiple catch blocks to make things slightly more sane.

But I get the impression that those who find benefit in passing errors using exception handlers don't handle errors. If you don't have to worry about errors in the code you write, then I think there is a good case to be made that errors as exceptions is a better approach.

That is, after all, the difference between scripts and systems. Scripts can simply fail, leaving the user to try again. Errors as exceptions, or something in the same vein, make sense as the predominant mechanism in scripting languages. Systems, on the other, have to deal with failure. You don't get to just bubble it up and let the user deal with it. This is where errors as exceptions becomes a nightmare. Go is unabashedly a systems language. It is not meant to be a scripting language.

Different tools for different jobs.

comment 2y ago · link · parent

> Also you can't scope it to just part of the function.

Why not?

    func outer() {
        func() {
            defer catch() {
                if r := recover(); r != nil {
                    fmt.Println("Recovered from doSomething:", r)
                }
            }()
            doSomething() // Can panic
        }()
        func() {
            defer catch() {
                if r := recover(); r != nil {
                    fmt.Println("Recovered from doSomethingElse:", r)
                }
            }()
            doSomethingElse() // Can also panic
        }()
    }

I don't get why we keep getting these "expert" comments from people who have never used Go before.

Hell, if you long for try/catch for some reason, you can even get creative:

    func try(fn func(), catch func(any)) {
        defer func() {
            if r := recover(); r != nil {
                catch(r)
            }
        }()
        fn()
    }

    func outer() {
        try(func() {
            doSomething()
        }, func(r any) {
            fmt.Println(r)
        })
        try(func() {
            doSomethingElse()
        }, func(r any) {
            fmt.Println(r)
        })
    }
But then you soon start to realize how awful try/catch actually is, so...

comment 2y ago · link · parent

There was no indication that it was an active choice. I'm speaking to where it was clearly incorrect behaviour, not where one honestly wanted to ignore the condition. I'm assuming these programmers would write out the boilerplate (perhaps even automatically by some IDE feature) and then forgot to return to it to fill in the logic.

And fair enough. It would be just as easy to forget to do that as it would be to forget to handle errors in any other language. There is no silver bullet here.

comment 2y ago · link · parent

I've read a lot of code in my life. I see that exception handlers are sometimes used to carry errors, virtually always exceptions, but almost never anything else. Who is it that you are think are passing around email addresses and geocooreinates using exception handlers?

But even assuming it is done sometimes, is the developer going to actually handle it? I don't know how many times I've come across "catch" blocks that are empty or something equally inappropriate. Nothing was gained. It turns out that programmers will still forget no matter how hard you try to hold their hand.

I'm not sure there is any other solution than to test it, and once you get into testing, entire blocks of logic missing are going to stick out like a sore thumb. Forgetting an entire branch is not exactly a subtle bug. At that point it really doesn't matter what language constructs you do or don't have available.

comment 2y ago · link · parent

Same as all of those other languages mentioned. What gives you the impression that Go is somehow magically different? Or have I misinterpreted you?

comment 2y ago · link · parent

> My problem with errors in Go are that they are too easy to ignore accidentally

This is a problem for values of all types, not just errors. One I'm not sure we've figured out how to solve[1]. There are a few languages out there that force variable assignment to try and address the problem, but even then there is really nothing to say that you haven't accidentally ignored the variable assigned.

> It's also _very_ hard to convince a team that they've been doing things incorrectly by ignoring errors.

To be fair, if you are able to completely leave out entire blocks of logic without anyone noticing even under the most cursory of testing, perhaps it wasn't actually needed? Forgetting entire code branches isn't exactly a subtle bug.

[1] Short of going all the way to formal proofs.

comment 2y ago · link · parent

The language doesn't impose this upon you. You can use the exception handling system to pass values around, just like you might in the aforementioned languages. Even Go's standard library does it. Read the encoding/json source sometime.

You might impose it upon yourself when you start to understand the pitfalls of using exceptional handlers for anything other than exceptions, but such is engineering. Everything comes with tradeoffs.

comment 2y ago · link · parent

There is nothing to be confused about. The syntax may be slightly different to other languages, but there is no meaningful difference in the design. If you understand exceptions and exception handlers in those other languages, you understand them in Go. There is no exactly a lot you can do with exceptions to see them differ in any big way.

Why is it that Go attract so many "experts" who have clearly never used the language even just once?

comment 2y ago · link · parent

> panic is Go's term for an exception

No. An exception is a datatype. Not completely unlike an error type in concept, but intended for erroneous conditions that could have theoretically been caught at compile time (i.e. the programmer screwed up), as opposed to conditions that are not decidable at compile time (i.e. something happened in the outside world).

In Go, panic creates an exception, which may be the source of your confusion. The exception contains any metadata you passed to panic along with other data, like a stack trace. This is not panic in and of itself, though.

> but when writing idiomatic Go one would prefer error types over using panic

Not really. Idiomatic Go says that errors are in no way special and is faulty to think of them as being special. They are just values like any other. Go exceptions allow attaching any value as metadata.

The official line is that panic stack traversal should not cross package boundaries, but internal use is perfectly acceptable. Even the Go standard library does it.

comment 2y ago · link · parent

Go has exceptions. Always has.

comment 2y ago · link · parent

> it’s an emergent feature of the system

It is an emergent feature of trade. Realistically, there is always going to be someone who has something you want more than what they want from you, creating an imbalance. Trade and capitalism are not synonymous, though.

Consider the most primitive type of trade humans engage in: Sex. There is little question that the most sexually attractive "at the top" have way more power than those "at the bottom". People will fall over themselves for a chance to please the "hot girl" all while the "homely guy" doesn't even get the time of day. This is the same type of hierarchy that is featured in the larger discussion taking place here...

...Yet is not capitalism. If you do think that kind of sexual hierarchy is capitalism or a product of capitalism, you are not using a definition that aligns with any common usage. Sex appeal is not traditionally considered capital. Capitalism wasn't even invented when these human sexual dynamics came into existence.

> No I didn’t have trade in mind, listen to my words.

Your words are poorly chosen. I do my best to infer, but there is only so much to work with.

comment 2y ago · link · parent

There have been no comparisons made, so it is not clear what you are trying to say. The idea that capitalism is compulsory is equally unclear.

Capitalism allows private ownership of capital, just as (to introduce a comparison) you are allowed to have a birthday party, but you in no way have to participate. You can choose to forgo capital ownership entirely, you can hold public ownership with other people who wish to share in the ownership (e.g. co-ops), you can do just about anything you want. Even within the USA, you can find people doing all of those things.

What you probably cannot avoid is trade. I expect that this is what you really have in mind – it is oft confused with capitalism for some reason. Indeed, a human surviving in complete isolation from other humans without being able to share is an incredibly challenging feat, and, frankly, isn't realistic for anything more than a short period of time. Trade is not a feature of capitalism, though. Trade is something else, and is much more fundamental.

comment 2y ago · link · parent

Dotenv is an okay hack, but the root problem is that the operating systems we run these applications in don't have a fully conceived environment variable system.

I think you have a fair point that dotenvx doesn't get the implementation right, but it does at least seem to recognize where the problem lies and is trying to fix it from that angle. You have to start somewhere. Almost never do we get solutions right the first time. It takes iteration and experimentation and perhaps this (and others like it) can pave the way towards a better solution.

comment 2y ago · link · parent

> Servers have always had savvy, and started unionizing in the late 1800s

The union leaders no doubt had savvy. Those who needed to lean on those who had savvy are not demonstrative of the sort. After all, that's the whole reason people join unions: To outsource savviness to those who have it, improving one's unsavvy standing within some kind of community.

> This didn't require a college degree.

Well, of course. Some jobs require licensing, but the "degree required" you see on job advertisements is just that: An advertisement. It communicates the idea of "You might like this job if you have an interest in this type of scholastic program." It has nothing to do with any kind of literal requirements.

> How do colleges measure "savvy"?

They try to measure sexual attractiveness. That is what college sells, after all: A community of people in their sexual prime that are prepared to regularly mingle.

It requires savvy to make oneself sexually attractive, though. While anyone can be attractive to someone, savvy is necessary to make oneself attractive to a reasonably wide audience. Being attractive to only one other person isn't typically going to get you admittance (of course, no measure of the nature is ever 100% perfect).

> If someone is admitted for being a good football, water polo, or lacross player, does that automatically make them more savvy than being a good Pokémon player?

Automatically, no. Statistically, those sports players do tend to be more sexually attractive to a wide audience.

> I may have done well on my SAT and got good grades (which is enough for many colleges), but that did not make me savvy in any sort of business sense that would apply to a waitstaff position.

I look forward to receiving your application. Someone with savvy, but not the right kind of savvy, would be the perfect hire.

comment 2y ago · link · parent

Yup, in theory, capitalism shouldn't even have hierarchies, but in practice people hate managing capital so hierarchies emerge anyway. We're reminded of that in another discussion that came up on HN[1]. Life is much, much, much easier and more enjoyable when capital is someone else's problem – when all you have to do is show up and give some time.

You'll notice that the capitalism detractors never advocate for greater capital management abilities. It is always to take away such ability so that they can feel less guilty about their choice in not wanting to manage capital. Can't really blame them. Managing capital truly does suck. But it is interesting nevertheless.

[1] https://news.ycombinator.com/item?id=40787255

comment 2y ago · link · parent

As do birthday parties.

comment 2y ago · link · parent

> For one, the server has no ability to set a price and has to accept whatever he's offered, even if it's zero.

Nonsense. In most jurisdictions the server is given full reign over the sale of alcohol. They are well and truly free to reject your request for a drink and there is nothing the venue can do about it. If you are not willing to pay their price, they most definitely can halt service.

It is the cultural norm to assume that the customer will pay up in good faith, typically a percentage of the venue's take. Indeed, if you don't pay up they're probably not going to hunt you down. If most people stopped acting in good faith you might see things change, though. There is no obligation for the server to honour your alcoholic drink request.

That is not so much the case for other items. You are right there. The very same server rejecting the sale of a perfectly good meal because you won't pay them would be grounds for them being ejected from the venue, but not so is the case for alcohol. Servers are considered independent operators when alcohol is involved. Which is why an independent operator fee, known as a tip, is paid.

Hence why tipping originated around the sale of alcohol. Although you're right that would also apply to some medical doctor situations as they have the same right to reject service (although that may violate their ethics commitment, which does muddy the waters). The modern adaptation of throwing a bonus at the jug of oil you bought down at the auto shop, which may be your source of confusion, is something quite different. That's not really tipping, at least not in the historical sense.

comment 2y ago · link · parent

Perhaps you mean corporatism? Capitalism does not define a hierarchical system.

comment 2y ago · link · parent

But will it free Hat?

comment 2y ago · link · parent

> Are they savvy enough to figure out you wouldn't give them a large enough mass raise, but would raise the suggested tip levels and pass the issue on to the customers?

They're likely savvy enough to know that if I can cashflow what would have been the tip, it works in my favour. There is good reason the workers (and, quite often, customers!) prefer to keep it a separate transaction. Sucks for me, but what can you do? You don't have a business without staff (and customers). They hold all the power.

> Are they savvy enough to rig things to get a higher tip, even though the overall effect is worse for the restaurant?

No doubt to the extent that it is to their favour. They most certainly aren't there for my benefit.

> Are they savvy enough to avoid getting a "worthless, over priced college degree", as richrichie suggests is the fundamental issue?

Perhaps, but pursuant of a degree is always done for the feel good emotions, not rational decision making. Not even the savviest person alive is able to keep all emotions at bay. Sometimes you just gotta spend money to get laid.

> Is this request for higher suggested tip rates because they "now are "highly educated" with expectations"?

Well, if we look to the historical record it does not appear that servers always had savvy, but that the rise of savvy people taking serving positions has raised the bar (although that could be the result of not having good data rather than some actual change).

What we do know is that colleges flat out won't allow anyone without savvy into their halls, going to great lengths to banish anyone who might try, so as a result there is a strong correlation between having savvy and having college debt. Did savvy people start taking serving jobs because they had to in order to service the debt? It is quite possible.

> That is, everything you say can be true, but not at all support richrichie's (deservedly, IMO) downvoted comment.

Okay....? That's fine. I couldn't care less about what richrichie had to say, and I care even less about someone pressing an arbitrary button that does nothing.

> Your response also sounds like I am correct

Let's hope. As long as it isn't me that's correct. I can think of nothing more defeating than spending all that time writing comments, and then not being able to learn anything from it because I was already correct.

comment 2y ago · link · parent

Where is the "extra on top" coming into play?

Imagine I'm your server at a restaurant. You agree to pay the restaurant $20 for the service it rendered and, separately, me $3 for the service I rendered, the latter of which oft called a tip. I now have $3 in hand. What more am I going to get "on top"? I've never heard of such a thing.

Are you somehow confused in thinking that the restaurant is taking $23? That might be reasonably described as "on top", but doesn't happen, so would be nonsensical to discuss.

comment 2y ago · link · parent

> Instead of pushing the external, side-effecting thing down the stack, I put it up the stack and call the logic that generates the data for it from there.

I've never seen Go code that does anything else. That's not to say it doesn't exist, but it's seemingly not the norm amongst Go developers (probably exactly for the reasons you describe). That doesn't address what the parent is talking about, though. You have the exact same problem spoken of no matter where in the stack you put it.

1
373839
256