Hacker News new | past | comments | ask | show | jobs | submit | tidwall's comments login


Hi HN. I’m the author of this hash. It’s just something I whipped up last night. It’s really not much different than the other hashes out there. I wanted to see if I could make a simple quality hash that easy to cut & paste, under 80 chars lines, and self contained.

Otherwise just an experiment.


PRs cannot be disabled.


...without archiving the repo.

Archived repos however have that ugly yellow warning.


Can you still push to the repo? Perhaps via --force?


A working example in Go. https://github.com/tidwall/btree


Also it is possible to start multiple Neco schedulers in different threads, there’s an example in the readme.


yeah i like this model. then you can use whatever synchronization junk you prefer to share state between the threads, if you have any.

your library looks well written and clean. thanks for sharing.

if anyone else wants to go coroutine spelunking, these were interesting to me:

https://github.com/higan-emu/libco/tree/master

https://github.com/Tencent/libco

https://github.com/hnes/libaco

https://kernel.googlesource.com/pub/scm/virt/kvm/qemu-kvm/+/...

https://tia.mat.br/posts/2012/09/29/asynchronous_i_o_in_c_wi...

https://www.cs.uml.edu/~bill/cs516/context_paper_rse-pmt.pdf


Japan is geographically larger than Germany.

https://en.wikipedia.org/wiki/List_of_countries_and_dependen...


Germany is part of the European Union, which is 10x larger than Japan and a sixth of world GDP.


Why sixth? EU's GDP is #2 (nominal) lagging very slightly to US [1], or #3 by PPP.

Germany's GDP is #3 (nominal) or #5 (PPP) [2].

[1] https://www.imf.org/external/datamapper/PPPSH@WEO/EU/CHN/USA

[2] https://en.wikipedia.org/wiki/Economy_of_Germany

UPDATE: fixed the statement, previous was about world trade share.


Not #6 but "a sixth" as in 1/6 of the total GDP of the world.


Not quite sure what you're getting at, but that claim is not true. The US economy was roughly comparable in size to the EU's 15 years ago but is now nearly 1/3 larger than the EU + UK, or about 1/2 larger than the EU without the UK: https://www.ft.com/content/80ace07f-3acb-40cb-9960-8bb4a44fd...


Seems like the difference is in PPP vs Nominal. Numbers are hard. Matching the numbers:

                 US   / EU   / Europe:
    Nominal [1]: 27.0 / 18.4 / 25
    PPP     [2]: 15.5 / 14.6 / 21
My point was that EU is higher than #6, as well as Germany, whatever the metric.

But, as I was corrected below, they meant "sixth" as share, not as rank.

[1] https://www.imf.org/external/datamapper/NGDPD@WEO/USA/EU/EUQ

[2] https://www.imf.org/external/datamapper/PPPSH@WEO/USA/EU/EUQ


>EU's GDP is #2, greatly surpassing US

Your link [1] shows that the EU surpasses US in international trade, not in GDP.


Yep, fixed (you're too fast! :).

Although the statement still holds, but it's "slightly" not "greatly" now.


A lot of Japan's landmass is basically uninhabitable mountains, though. Not much arable land, for instance.


Yeah but it's mostly mountain. 11% arable (33% in Germany).


TG isn't spherical and wasn't designed to be. It's 2D and projection agnostic. Crossing the antimeridian is a user problem to solve. I recommend following the GeoJSON rule of antimeridian cutting [1].

As I said in the README. My goals are fast point-in-polygon, geometry intersections, and low memory footprint. Those are my bread-and-butter.

From what I know about S2, it has different goals. Such as being spherical and using discrete cells for distributed spatial indexes. Those are great things of course, but not really what I need.

This is the second comment that recommends using Shewchuk’s methods. And while yes I agree that that may be a superior way to go, and always on the table for the future, I'm still able to achieve my goals without those methods. At least for now.

[1] https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.9


Yeah we're spherical mostly because working in spherical coordinates let's you not have to worry about the projection. S2Cells are really just nodes in a quadtree, the difference being our quad tree is implicit, you can (and we do) store them in a linear array in memory.


I can't stop precision loss in all cases, but I do my darnedest to avoid loss when it causes false positives, especially for stuff like intersect detection code. For example the collinear [1] function looks really big for a seemingly simple operation, but there are extra checks built in for precision loss and in the cases of compiler associate math issues (like a user borking a build with -ffast-math).

I'm sure it's not all perfect but I feel pretty good about it overall. It certainly helps that much of the logic derived from the Tile38 [2] project, which has 8 years of use in production. I ported many of the tests too, which make me warm and fuzzy every time they pass.

[1] https://github.com/tidwall/tg/blob/v0.1.0/tg.c#L389

[2] https://github.com/tidwall/tile38


You might consider Shewchuk’s methods for robust geometric computations: https://www.cs.cmu.edu/~quake/robust.html

There are more modern implementations available on GitHub, but I’ve found it to be fairly easy to integrate into C-family projects without much modification.


I have strict safety rules for this project, one of which requires that all geometries are thread-safe pointers. So in the example you show, it would not be safe to share the tg_geom pointer with other threads because it belongs on the stack instead of the heap.

Yet I do see the need for avoiding allocations when working with lots of simple geometries like points and rects, and for my use I made functions like tg_geom_intersects_xy and tg_geom_intersects_rect to perform relation operations directly on point and rectangle values.


It’s a new structure I came up with as described in the docs/POLYGON_INDEXING.md document. https://github.com/tidwall/tg/blob/main/docs/POLYGON_INDEXIN...


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: