HN user

ainar-g

3,708 karma
Posts48
Comments620
View on HN
www.iso.org 2y ago

C23 is cancelled due to missing the publication deadline

ainar-g
7pts4
foo.zone 2y ago

Kiss High-Availability with OpenBSD

ainar-g
15pts3
dnsviz.net 2y ago

Russian TLD .RU fails DNSSEC validation

ainar-g
71pts22
status.snapcraft.io 3y ago

Snapcraft: Multiple Major Outages

ainar-g
2pts0
kristerw.blogspot.com 4y ago

Useful GCC warning options not enabled by -Wall -Wextra (2017)

ainar-g
2pts0
ctrl-c.us 4y ago

Cross-arch Go tests with QEMU

ainar-g
1pts0
www.reddit.com 5y ago

Ongoing incident with compromised mod accounts

ainar-g
11pts0
www.crockford.com 5y ago

Base 32 (2002)

ainar-g
1pts0
go.googlesource.com 6y ago

Design Draft: First Class Fuzzing for Go

ainar-g
1pts0
go.googlesource.com 6y ago

File System Interfaces for Go – Draft Design

ainar-g
4pts1
rakyll.org 6y ago

Few Things on Generics

ainar-g
2pts0
blog.golang.org 6y ago

The Next Step for Generics

ainar-g
673pts664
blog.golang.org 6y ago

Pkg.go.dev Is Open Source

ainar-g
7pts0
en.wikipedia.org 6y ago

UTF-Ebcdic

ainar-g
2pts0
blog.golang.org 6y ago

Go Developer Survey 2019 Results

ainar-g
171pts122
www.youtube.com 6y ago

The Dot-Com Bubble – 5 Minute History Lesson – By the Plain Bagel

ainar-g
1pts0
en.wikipedia.org 6y ago

Gwoyeu Romatzyh

ainar-g
2pts0
dave.cheney.net 6y ago

Go Compiler Intrinsics

ainar-g
3pts0
blog.golang.org 6y ago

Experiment, Simplify, Ship – The Go Blog

ainar-g
5pts0
github.com 7y ago

Go Code Analyzer Staticcheck: 2019.2 Released

ainar-g
1pts0
github.com 7y ago

Proposal: Go 2 Number Literal Changes

ainar-g
2pts0
en.wikipedia.org 7y ago

Planck star

ainar-g
4pts0
unix.stackexchange.com 7y ago

Difference Between Login Shell and Non-Login Shell

ainar-g
1pts0
www.saturdayeveningpost.com 7y ago

A Cat Meme Photographer from a Century Ago

ainar-g
122pts53
docs.google.com 7y ago

Analysis API: modular static analysis for Go

ainar-g
2pts0
words.steveklabnik.com 7y ago

The Language Strangeness Budget (2015)

ainar-g
2pts0
medium.com 7y ago

How Am I Not Burned Out?

ainar-g
1pts0
www.sqlstyle.guide 7y ago

SQL Style Guide

ainar-g
59pts16
science.raphael.poss.name 7y ago

Measuring errors vs. exceptions in Go and C++

ainar-g
2pts0
www.openwall.com 7y ago

Musl 1.1.20 released

ainar-g
2pts0

Thank you, rsc, for all your work. Development in Go has become much more enjoyable in these 12 years: race detector, standardized error wrapping, modules, generics, toolchain updates, and so on. And while there are still things to be desired (sum types, better enum/range types, immutability, and non-nilness in my personal wishlist), Go is still the most enjoyable ecosystem I've ever developed in.

While the compiled programs stayed the same, we no longer get a warning (even with -Wall), even though both compilers can easily work out statically (e.g. via constant folding) that a division by zero occurs [4].

Are there any reasons why that is so? Do compilers not reuse the information they gather during compilation for diagnostics? Or is it a deliberate decision?

That could be true, but I've done a few optimizations of allocations in Go code, and I don't recall pointers to stack values ever being optimized (unless the entire branch is removed, of course). If anyone could provide an example of the code that does pointer operations yet doesn't cause allocations, I'd appreciate it!

Whenever you do:

  v := interfaceType(concreteTypeValue)
in Go, what you're actually doing on a lower level is:
  dataPtr := &concreteTypeValue
  typePtr := typeData[concreteType]()
  v := interfaceData{
          data: dataPtr,
          typ: typePtr,
  }
The first line here is the allocation, since (at least, the way I recall the rule) in Go pointers never point to values on the stack, so concreteTypeValue must be allocated on the heap. The rule about pointers not pointing to the stack is there to make it easier for goroutine stacks to grow dynamically.

See https://go.dev/doc/faq#stack_or_heap.

Privilege separation[1], most likely. If your system needs to do three things, it could either just do all of them using a single executable requiring all three permissions (thus also theoretically allowing an attacker to use it to do all three things as well) or split your system into three executables, each only having the permission to do one thing (thus reducing the amount of potential damage).

[1] https://en.wikipedia.org/wiki/Privilege_separation

This makes me thing of the stories I've heard stories from those who lived in communal apartments back in the U.S.S.R. days. Couples who had a creaking bed and wanted to go at it at night would just do it on the floor instead of on the bed. Which in turn makes me think if those beds are just some kind of kickback scheme, because I can't be the only one who thinks of suck obvious solution, can I?

Edit: Seems to be fake news: https://www.snopes.com/fact-check/anti-sex-beds-2020-olympic....

On a related note, have there ever been extensions for PosgreSQL/SQLite/any other FOSS DBMS that would allow using Tutorial D[1] (the Third-Manifesto one, not to be confused with Walter Bright's D language) to define and query data? In particular, I feel like PostgreSQL's CREATE TYPE[2] feature would allow for easier bridging between SQL and Tutorial D.

Unfortunately, searches for “PostgreSQL Tutorial D” don't issue useful results for obvious reasons.

[1] https://www.dcs.warwick.ac.uk/~hugh/TTM/index.html

[2] https://www.postgresql.org/docs/current/sql-createtype.html

A feature that combines well with range and enum types are typed indexes of arrays:

  TYPE
   TWeekday = (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,
    Sunday);
  VAR
   WeekdayNameIndex : ARRAY [TWeekday] OF ShortString = ('Mon', 'Tue',
    'Wed', 'Thu', 'Fri', 'Sat', 'Sun');
Now `WeekdayNameIndex` is a properly type- and range-checked look-up table.

It's really sad that these simple joys of Pascal are still lacking from a lot of mainstream languages.

Re. the shape of the code, it's probably a matter of habit, as I have the complete opposite experience reading code in languages with exceptions. That is, I find that there is too much happening within a few lines, wondering which line can explode and in which ways, heh.

Funny you mention Go, because it's my main language these days. And I have to be honest, I don't have the issues you're mentioning. 99 % of loops in the code I review is the plain for-range type, and whenever it's something more complex, I usually am/recommending splitting away the body. Also helps with complexity metrics (and having at least a maximum cyclomatic complexity checker for your code is a must, imo). And if your error handling is repetitive, there is a high chance you're not adding the important context to errors and/or not checking if the context is added in the reviewed code.

A thing I've discovered that helps me a lot that don't see mentioned at all is to always review code by checking it out on your machine and using your editor to inspect it. Maybe it's just me, but there is something about seeing the code in your own environment as well as having all of your tools to e.g. see where a method is used helps massively.

I think one of the reasons might have something to do with the fact that with more experience—and thus, often, a higher position—comes the responsibility of reading more code. Often, you come to a point where you are reading more code than you are writing, i.e. when conducting code reviews or investigating an issue. And while the code in more complex languages can still obviously be readable, simple languages force the code to be at least somewhat readable even at its worst.

I've looked up some JSSS code examples, and it seems like it's pretty much the only type of code where the "with" keyword makes sense:

  <style type="text/javascript">
  tags.H1.color = "red";
  tags.p.fontSize = "20pt";

  with (tags.H3) {
    color = "green";
  }
  with (tags.H2) {
    color = "red";
    fontSize = "16pt";
    marginTop = "4cm";
  }
  </style>
jq 1.7 3 years ago

Depending on whether or not the resulting YAML is supposed to be human-readable[1], you can just produce JSON output, since YAML 1.2 is a superset of JSON. I did that at one of the places I worked in at the time, and it worked very well.

[1]: I personally think that JSON is plenty readable, but a lot of people seem to disagree.

jq 1.7 3 years ago

What are you using yq for? Unless you use YAML-only features (e.g. integers, arrays, and objects as object keys), it seems like it would be easier to just pipe-convert your YAML to JSON and process it with jq.