Better HN
topnewbestaskshowjobs
Log inSign up

usrbinbash

4,687 karma · joined Dec 4, 2021 (4y ago) · 1,693 submissions

Submissions

comment 4y ago · link · parent

> I'd hope it's a pretty non-controversial thing by now that software shouldn't silently fail without indicating something's wrong?

That depends whether the error condition is worth caring about, for a given application, in a given state.

eg. how often do programs check if `printf("something")` actually succeeded?

comment 4y ago · link · parent

> Why?

Because unless the caller of foo uses a catchall, it may not actually catch the exception raised by bar. Lets say bar opens a file, and callerOfFoo says `except FileNotFoundError:` ... what if bar opens a file that exists with insufficient Permissions? Then it's `PermissionError`, and callerOfFoo won't catch it.

Sure, its possible that callerOfFoo is prepared for that, but my point is, I don't know that unless I check its code.

comment 4y ago · link · parent

> Things can still panic in go.

Yes, but panics are intended to represent an actually exceptional situation, like dereferencing nil, or the machine running out of memory ... things that normally shouldn't happen, and from which the logic cannot easily recover.

> Error handling for an API etc usually make the most sense in a central location (

Which is doable:

    if err := couldFail(); err != nil {
        return err
    }
I can let errors bubble up the call stack as far as I want, I just have to be explicit about it.

comment 4y ago · link · parent

> are ignored error returns flagged/grumbled-about?

No, they are not.

    func couldFail() error { /*...*/ }
    func ohNoes() {
        couldFail()
    }
ohNoes() can call couldFail() and ignore the error return completely, without the compiler complaining.

This is intended. Error returns are not special; they are just another return value. Error handling by the caller includes "I don't care if there is an error". Yes, in some situations that's a bad code smell. In others, it really doesn't matter. Go puts the responsibility to decide which applies in the hands of the programmer.

To get the same effect in python, I'd have to wrap the call in

    try:
        couldFail()
    except:
        pass

comment 4y ago · link · parent

> are more about having a framework of allowing inner/library code to drop the ball and run away screaming, without making more of a mess.

It also allows the calling function to ignore the mess and hope that something further up the call-chain will deal with it.

Exceptions circumvent the normal control-flow of a program, and that makes code less obvious to follow. When I see foo calling bar() in go, I know where, and if, errors returned by the function are being handled, just by looking at foo.

When I see foo calling bar() in Python, and there is no try-except block in foo, I have no idea what happens to any errors that bar may return. I now have to check everyting that calls foo, which may be multiple other places, each of which could have a different Exception handling, or none, in which case I have to also check all the callers of that caller of foo, etc.

And even if there is a try-except, I have to check whether except catches the correct TYPE, so now I also need to be aware of the different types of Exceptions bar may raise ... which in turn depends on everything that bar calls, and how bar itself handles these calls, etc.

Yes, error handling in Go is verbose. Yes, it would be nice if it offeres a little syntactic sugar to improve that.

But error handling in Go is also obvious.

comment 4y ago · link · parent

> I never understood how people consider go an alternative to python.

I work in both Python and Go. I love both languages. Here are a few reasons why I chose Go over Python for a lot of things these days:

Alot faster, self-contained executables instead of virtualenv, scales natively, no GIL, linear code in goroutines instead of asyncio.

comment 4y ago · link · parent

Even if we had infinite renewable energy, or something like Fusion Power; there are still the problems of having to manufacture all these individual vehicles, gathering the resources to do so, maintaining them, storing them, and providing them with roads.

comment 4y ago · link · parent

I never account for schedules for public Transport in my city, the serving frequency is short enough that I just show up at the station whenever I please. Unless there is some sort of technical or logistical problem, I almost never have to wait for more than 3-5 minutes.

comment 4y ago · link · parent

> The only downside to car culture is environmental concerns that I really hope electric cars fix.

How are they supposed to fix it?

In many countries we still burn gas & coal for electricty.

The cars need to be produced, which is alot more resource intensive than building better public transports, since a train transports hundreds of individuals at once, and can serve the transportation needs of thousands over the course of a day, the amount of material and energy for fabrication per-passenger is far lower. And thats's not even taking into account total service-time and cost of recycling.

The cars need parking spots when not in use, which requires space that could otherwise be used for housing/parks/recreation/businesses. Public Transport systems have far fewer downtimes (even when I dont ride the train, someone else does). Plus, they are more space efficient to begin with.

And of course cars need roads. Lots of them, and no matter how many are built, there still seem to be traffic jams.

comment 4y ago · link · parent

Where I live, public transport is a breeze. Roomy, punctual, good serving frequencies, clean, constantly improving (more stations, modernizing vehicles). I don't have to concentrate on driving, I dont have to worry where to put the vehicle when its not in use, I have not been in a traffic-jam for year. And they cost less than owning a car.

comment 4y ago · link · parent

Question:

How many people would use cryptocurrencies without such platforms?

comment 4y ago · link · parent

Problem 1: The point where the two curves meet is almost always met sooner in a projects dev-cycle than expected.

Problem 2: Coding something is one thing. Version-Controlling it, intergrating it into a deployment chain, running it in different Environments, Reviewing it, scaling it are a collection of entirely different beasts.

Problem 3: As soon as the project hits a requirement where there is no lownocode solution (eg. integration with some custom monitoring system with no premade hooks available), the effort required goes through the roof, because now we have to interface the two worlds with each other, adding a layer of complexity that wouldn't exist if the entire thing had been code from the beginning.

comment 4y ago · link · parent

Docker going strong :-)

Unsurprising, really. The usefulness of it cannot be overstated.

Doesn't even matter if its used anywhere in the deployment chain; simply having the ability to pull up a replica of almost any *nix environment on my laptop in mere seconds, using it for tests, and then throwing it away resetting it again in mere seconds is beyond awesome, no matter if what I'm working on then goes into a huge complicated deployment chain, or is shoved onto some on-premises, zero-abstractions, baremetal server.

And how is it all configured? Plain text files. How is it controlled? Command Line. Meaning I can script it every way I want, using the tools I already have and use. Doesn't get in the way, doesn't demand that I work around it...it works with me and my tools in the same way they already work together.

Oh, and of course, good bye and good riddance to the days when I had to install and configure local RDMS for tests. Everything I use has an official image, so I just write some small setup script, a Dockerfile, knit everything together in a docker-compose.yml and presto, done: Application stack is up and running.

To me, Docker is as essential as my text editor these days.

comment 4y ago · link · parent

All the more reason to make said allocation easier to handle.

A unified system of land organisation, subdivision and addressing would make it easier to determine/refine/update which land is allocated how, similar to how unified systems of measurment made trade easier a long time ago.

Even for entities in conflict over what land belongs to whom, such a system would simplify the formulating and argueing of their respective claims.

comment 4y ago · link · parent

It's mind-boggling that we, as a species, can;

...on the one hand; send probes to outer space, people to the moon, research how to implement fusion-based power plants, do genetic engineering, reason about black holes, build the Large Hadron Collider, and connect billions of people to the largest repository of information available by means of battery-powered devices so tiny they fit in a pocket;

...but on the other hand don't implement a common baseline for how to organisationally subdivide and address areas of land.

comment 4y ago · link · parent

I'm using "What", "Why" and "How" here as defined in the article.

Problem with documenting in the code itself: The "Why" is further from the code than the "What", and the "How" is further away still.

Explaining "What" a function does is close to the code, I just put some comment lines before the function/type, etc. and maybe some into the definition. They are just to make the code better readable for the human.

But where do I put the "Why"? I could put it with the "What", but often the "Why" depends on somewhere completely different in my code (or someone elses code). eg. "Why am I using a map here instead of a list? Because the remote API expexts a JSON object and the map is easier to Marshal into that".

But what if the remote API changes? Okay, I change the code that deals with it, and update the comments for that code. Do I also change the comments everywhere else where this map is used? For that matter, is it explained anywhere else in the code why that is a map instead of a list? The "What" says "this code iterates through the maps values and appends an underscore to each", but is the "Why", which explains why that is a map there as well? In every function that works on that map?

My point is, not only is it difficult to explain everything in the code, it's also very very difficult to keep this documentation up to date, because the relationship between a comments location, and the code it belongs to, becomes more complicated the further up we go from the "What".

comment 4y ago · link · parent

Well, they are fairly transparent.

The problem is, they have a tendency to suddenly get horribly intransparent when they grow larger than maybe a few dozen lines.

comment 4y ago · link · parent

Free, simple, works in a terminal.

Best password manager I ever used.

comment 4y ago · link · parent

Doesn't even take until then before it fails for me...wysiwyg formats are traditionally a nightmare for version control systems. All my plaintext notes in Markdown and Asciidoc can be checked in without a problem :-)

comment 4y ago · link · parent

> That we're unable to learn from the silent majority of experts casts an unusual light upon online discussions.

This has been a problem with (and not just) online discussions since...well...ever. What is discussed the loudest or most frequent, isn't necessarily the most important topic in the field.

comment 4y ago · link · parent

> and therefore want to embed images (gasp!), tables, hyperlinks, and even file or sound embeds in my documents.

And exactly which one of them can't I do in asciidoc?

comment 4y ago · link · parent

IPv6 adoption isn't a matter of preference or price, it's an inevitability. We can do tricks like NAT all we want, fact of the matter is: Every day, more and more devices that require a public address, connect to The Internet.

Once the address space is exhausted, the only choices are: IPv6 or no new devices. Since the latter isn't an option, IPv6 is inevitable.

comment 4y ago · link · parent

If assume (please correct me if I'm wrong) by "conventional document format" you mean ones that do not play well with version control software like git (eg. because they may be/contain huge binary blobs), yes?

If so, at least in the projects I am involved in, all documentation that is checked into the repos remains in markdown (asciidoc is also used alot), and is only converted to non-plaintext formats for the purposes of release.

This is similar to how we build executables from our source code, but don't check in the resulting binary files into the repo.

comment 4y ago · link · parent

This "nothing" is valueable information nonetheless.

Science is just as much (often more) about ruling out hypotheses as it is about confirming them. Sometimes that means ruling out all existing hypotheses, meaning new ones have to be formulated to be tested in turn.

comment 4y ago · link · parent

Agile and Documentation-Driven-Development can not only easily go hand in hand, I think agile is perfectly suited to work like this.

We figure out what the software is supposed to do -> We write documentation describing that -> We build the implementation -> New Requirements -> Figure out how to incorporate them into the plan -> Update the documentation -> Build the changes.

It's an iterative process, perfectly suited to agile development.

1
343536
57