Better HN
topnewbestaskshowjobs
Log inSign up

hackandtrip

243 karma · joined Oct 4, 2017 (9y ago) · 160 submissions

Backend Python/C++, occasionally devops with Terraform
Submissions

comment 4y ago · link · parent

Well, the most basic pro is to avoid indentation and have pure function which are clear and have less assumption to take into account; if I know that my pipes always return me a result such as the one I want, and the "bad path" is discarded automatically, code is way cleaner.

Imagine a code without `if result is not None` basically!

comment 4y ago · link · parent

Who knows if a potentially well-made and viral show will put the light on the amount of money that VCs are investing in startups, and new regulations (good or bad) may appear

33.

The Dropout – The Story of Elizabeth Holmes(youtube.com ↗)

1 points · by hackandtrip · 4y ago · 1 comment

comment 4y ago · link · parent

Can't you 'compose' together the various errors inside the `Failure` and inspect it at the end of the pipe?

comment 4y ago · link · parent

Good luck checking for `None` equality and indent your code like 5 times... a sort of railway programming[0] avoids the awkward checks for values, making functions work with higher order types.

0: https://www.greenbird.com/news/railway-oriented-programming-....

comment 4y ago · link · parent

A similar "framework", very robust and used in production systems, is dry-python's one[0][1].

The approach taken is a bit different I think, since they rely heavily on `mypy` plugins to reach type safety and functional constructs otherwise impossible to get, without runtime inspections.

0: https://github.com/dry-python 1: https://github.com/dry-python/returns

comment 4y ago · link · parent

+1.

As software engineers I think we should explore more the part of our skills that can create things that are not useful per-se, but creative and funny, such as the best gifts (at least for me) are

comment 4y ago · link · parent

Love FastAPI for lot of concepts that it helped to make mainstream, such as typing-based-validation, but its documentation is lacking.

I love the tutorials, but an API reference is just as important; I may not want to check out long tutorials about things I already read, but check a detailed description of each function would be super helpful - other frameworks such as Sanic have it.

I think it's in the roadmap, kudos for that, and hope that it will get a few more maintainers to speed up the process

comment 4y ago · link · parent

Are those alternatives faster according to benchmark?

In my experience, the bottleneck is either: - JSON parsing and dumping; the solution for me is ORJSON, fantastic wrapper to use fast JSON serialisation for most common fields, and also datetime. - Validation - if you choose to validate your data, pydantic can indeed be slow... But it's not Pydantic the problem, but the validation that you apply to your data.

comment 4y ago · link · parent

Well, I strongly believe in testing all the queries/transactions (for example the repository pattern is super helpful to separate concerns and allow you to test only what concern your queries and the DB); but those are tested separately from the workflow of your service, if we are talking about unit tests. Why? Because otherwise either you write a gaziliion of tests, or they are unreliable. As an example, if you have in the service you wanna test various code paths, and your queries have paths of their own (what happens if you don't retrieve any object? if some property is null? and so on), I just think it gets messy quickly.

My solution is to test things separately, at least in unit tests. Obviously, this has pitfalls (it's easy and fun to write green tests, so not always tests respect the interface of the components and they don't get red even if something is wrong); but that's where integration testing come into play.

Have a few code paths where you touch multiple external services, and you want to test that everything actually works? Create integration tests that use either a fake or the actual service in a `staging` environment, take 10x time to run, but test the path that is most important for your logic. Obviously, if you many unit tests, you will have way less integration tests, but they serve different scopes, and one cannot substitute the other!

comment 4y ago · link · parent

Great article, not the first time I read this argument against the usage of mocks; I never understood though how to solve the problem of the explosion of the path that must be tested (usually exponential).

As an example, consider a single API that uses ~3 services, and these 3 services have underneath from 1 to 5 other internal or external dependencies (such as time, an external API service, a DB repository, and so on). How can I test this API, the 3 services, and their underneath dependencies without exponential paths to test - I want to be able to cover all the paths of my code, and ensure that my test only tests a single thing (either the API, the service, or the dependency interface); otherwise, it is not an unit test.

I always felt like that these type of tests without mocks works super-nice in nice situations without any external, or even complex but internal, dependency; otherwise, it becomes very very hard to test ONLY what I want, and not all the dependencies underneath.

Mocks allow me to stub the behaviour of a service/dependency that I can test in a separate fashion, covering all the paths, and ensuring that each unit test covers a single unit of my code, and not the integration of all my components.

comment 4y ago · link · parent

Note that Uvicorn still recommends to use Gunicorn for production use, with the Uvicorn worker class implemented for Gunicorn.

https://www.uvicorn.org/#running-with-gunicorn

comment 4y ago · link · parent

I may be an average corporate backend dev, but if anyone I work with would react in this way after any kind of mistake I did, I would report the situation / leave immediately.

Honest feedback is surely key to keep quality, innovation, and skills high - the thread has indeed a few lines of honest feedback (don't break user-space, wrong error) and the rest are just insults. I am pretty sure it goes against the Code of Conduct [1]

1: https://www.kernel.org/doc/html/latest/process/code-of-condu...

EDIT: Just saw 2012, I guess CoC was not in place back then

44.

Ask HN: Any New Years' Resolutions?

1 points · by hackandtrip · 4y ago · discuss

comment 4y ago · link · parent

Very interesting, thanks for the clear answer!

Love the fact that you make it easier for the customer to get a refund through your process, than through the refund one; I do not work in this space and offering free refunds for my product could be very destructive, but it makes 100% sense here.

comment 4y ago · link · parent

Kudos for the donation to charity!

I wonder how the other for-profit in this space keep their business running, considering the amount of disputes that must come from users.

For example, I know that Stripe is very strict on the disputes percent[1]...

1 - https://stripe.com/docs/disputes/measuring#:~:text=Dispute%2....

comment 4y ago · link · parent

After ~2y of professional experience, I don't think that there is huge hard skill gap between non-professional and professional devs.

The biggest thing is understanding that you may work on a single tool in ~10/100 people, so you must develop and work with other people in mind. So, modularity, enforcing code clarity and writing good tests, understanding product decisions and so on... Personally, I learnt this stuff on the job pretty fast - still newbie, but can autonomously solve medium/complex projects without senior help, which should be a base goal.

Larger-scale technologies is mostly larger-scale organization - just apply to one of those and I am sure you'll catch up fast

comment 5y ago · link · parent

Any thoughts from HN about gadgets that made their life (either work or social) significantly better in 2021?

comment 5y ago · link · parent

I find Changelog podcasts (https://changelog.com/podcasts) very high quality.

Some examples:

- Richard Hipp (SQLite creator) (https://changelog.com/podcast/454)

- Co-founder of Cockroach Labs (Massive scale and ultra-resilience)

comment 5y ago · link · parent

100% agree on this and that's my point.

Was that code merged without any review? If so, that is a recipe for disaster. Why no unit tests, integration tests, QA? What was the speed at which the outage was resolved? If a sane deployment strategy is in place, I'd hope that no big damage was actually done; if the error budget was burning fast, there should be some manual/automatic rollback.

tl;dr they may have been a key factor in the outage, but it seems like it is a symptom of a deeper hole in the process.

comment 5y ago · link · parent

The fact that an individual can bring production down is 1000% a problem in the process; outages should not attributed to single commits but to a series of problems in the process. Just saying this since the number of times someone being production down should not be cause of shame or firing

comment 5y ago · link · parent

Did not know it existed, extremely cool indeed! By skimming it I still think Pulumi might have a better Dev UX, but surely Terraform is still catching up

comment 5y ago · link · parent

Any performance benchmark? I know it is hard to compare, but I do wonder if it is actually already faster than MongoDB.

comment 5y ago · link · parent

Any suggestions to learn and go deep in PostgreSQL for someone who worked mostly on NoSQL (MongoDB)?

From the few days I have explored it, it is absolutely incredible, so congratulations for the work done and good luck on keeping the quality so high!

comment 5y ago · link · parent

I had a similar experience, with 10-12 days of mild symptoms (up to 40°C fever), but the general feeling of tiredness and the infamous "brain fog" stayed for 3-4 weeks (it's not completely gone yet).

Definitely one of the worst sickness I've had, but both me and especially my parents (60+) had no respiratory problems and didn't need urgent treatment.

I was waiting for my second dose when I got it and my parents were vaccinated, but still I don't get how we can count on treating it as a flu and just get the virus, considering the lack of knowledge on long-term effects.

comment 6y ago · link · parent

This is so true and my experience completely checks out with it.

I started trying out Linux with the usual Ubuntu / Linux Mint distros, but I got so confused by the lack of structure and understanding of what is the correct way to do things - aka what I wanted to understand with Linux, for personal knowledge.

I moved to arch, and ease of use came free: everything you'll ever need is basically on the wiki, no weird PPA to add, nothing on sketchy tutorial sites - just the wiki. Definitely suggested for beginners (yeah the installation can be a pain but it's minimal compared to the advantages)

comment 6y ago · link · parent

I skimmed the contents, but I don't get any alternative to the standard calories counting.

It's the only way to quantify the intake without revolutionising the food industry packaging, or am I missing something?

comment 6y ago · link · parent

It happens A LOT with non-GSuite Gmail accounts (personal GMail accounts) too!

comment 6y ago · link · parent

Some fast implementations in C++?

In particular, I tried in the last weeks to work on a OpenMP / MPI driven CSV parser, but surely accounting for new lines inside quotes can be a pain the ass, I'm wondering if there's a go-to implementation or model to implement that.

comment 6y ago · link · parent

I think productivity enhancements are really tightly coupled with the domain and type of activity you are doing.

For example, as a university student, I noticed that timing the number of hours I pass on each topic is useful for 1. understanding if I'm doing too little and fixing it 2. getting the idea where I'm spending most of my time and trying to adjust accordingly

On the other hand, if the work is more project-based, I find it more difficult to track time since I find myself switching more often to different things - a solution I'm employing is writing a little todo list every morning on what I want to work on and it's working a little better

123456