HN user

nercury

894 karma
Posts26
Comments155
View on HN
www.darpa.mil 1y ago

Eliminating Memory Safety Vulnerabilities Once and for All

nercury
1pts0
mht.wtf 6y ago

A Ghost Story

nercury
1pts0
paytonturnage.com 7y ago

Synthesizing Structures with `Immense`

nercury
1pts0
medium.com 7y ago

Making of Newton Protocol

nercury
3pts0
www.ncameron.org 8y ago

What do you think are the most interesting/exciting projects using Rust?

nercury
2pts0
smallcultfollowing.com 8y ago

In Rust, ordinary vectors are values

nercury
2pts0
fulmicoton.com 9y ago

Of tantivy, a search engine in Rust

nercury
3pts0
medium.com 9y ago

TRAFI Transit App Expands in US

nercury
1pts0
medium.com 10y ago

Running .NET Core on Docker

nercury
8pts0
nblumhardt.com 10y ago

Exploring Rust (from C#)

nercury
148pts131
smallcultfollowing.com 10y ago

Parallel Iterators Part 1: Foundations

nercury
5pts0
os.phil-opp.com 10y ago

Accessing and Modifying Page Tables in Rust

nercury
2pts0
www.redox-os.org 10y ago

This Week in Redox 4

nercury
2pts0
medium.com 10y ago

Rust to the Rescue

nercury
3pts1
www.ralfj.de 10y ago

Formalizing Rust

nercury
3pts0
aturon.github.io 10y ago

Resurrecting impl Trait

nercury
11pts3
medium.com 10y ago

Asynchronous IO in Rust

nercury
160pts110
www.oreilly.com 10y ago

Why Rust? [pdf]

nercury
134pts183
mr-byte.github.io 11y ago

Traits on Generics

nercury
2pts0
benashford.github.io 11y ago

Rust traits for developer friendly libraries

nercury
102pts44
marketingshmarketing.net 11y ago

Lexus NX name fails in Lithuania

nercury
1pts0
faq.sealedabstract.com 11y ago

A Swift guide to Rust

nercury
6pts0
community.amd.com 11y ago

One of Mantle's Futures: Vulkan

nercury
1pts0
www.khronos.org 11y ago

SPIR-V: Intermediate Language for Graphical Shaders and Compute Kernels [pdf]

nercury
32pts5
community.amd.com 11y ago

AMD drops Mantle

nercury
9pts1
www.gamasutra.com 11y ago

Reactive Game Dev: How Serious Sam 4 Became the Talos Principle

nercury
1pts0

If someone spent their time learning their tools, they will make better choices when writing the code without any additional time cost.

There are two variants of very similar code. Both do the same thing, both are readable and maintainable. The difference is not primarily in performance, it's in quality of craft.

Yes, I would not put it just anywhere. But I have few rules about ORMs:

- Proper DB design first. You should be able to remove the ORM and DB should still function as intended. This means application-side cascade operations or application-side inheritance is banned.

- No entities with magical collections pointing to each other. In other words, no n to n relations handled by ORM layer. Create in-between table, for gods sake. Otherwise it becomes incredibly confusing and barely maintainable.

- Prefer fetching data in a way that does not populate collections. In other words, fetch the most fine-grained entity and join related data. Best if you craft special record entities to fetch data into (easy with EF or Doctrine).

- Most ORMs allow you to inspect what kind of queries you create. Use it as query building tool. Inspect queries often, don't do insane join chains and other silly stuff.

I would use ORM in one kind of app: where I would work with data that shares records that might need to be either inserted or updated, and there is several nesting levels of this kind of fun. You know, you need to either insert or update entity, if it exists, you should update, and then assign related entities to it, if it does not, then you should insert, and assign related entities to the newly created id. The ORM can easily deal with that, and on top of that it can do efficient batched queries, which would be really annoying and error-prone to hand-craft.

If the app does not require this kind of database with these kind of relations, I would not use ORM.

Pardon me for the tangent (just a general comment not directed to OP).

What I have learned over the years is that the only way to properly use ORM is as a fancy query tool. Build the query, fetch/update data, MOVE THE DATA to separate business objects. Don't leave ORM entities shared across the sea of objects!

Phew, thanks, I got that off my chest.

struct Node<'a, 'b, 'c> { data1: &'a Data data2: &'b Data data3: &'c Data }

Wow. It's like teaching C++ and starting from SFINAE. Or C# and starting from type parameter constraints.

Please think of a real-world examples when teaching stuff. I am very eager to see the program a beginner would need to write that requires: 1) references in a struct; 2) 3 separate lifetime parameters for the same struct.

Leaving LinkedIn 2 years ago

Yes of course. You have to demonstrate that you are very skilled at building with the particular bricks they use. Don't mention anything else to show your commitment to particular brick usage.

Bytes aren't bricks. Reshuffling them from scratch after a smallest change is cheap and fast. Taking advantage of that is not stupid. Proper communication and work with client is a skill, and architects have to deal with stupid requests too!

If's fun little article, but is a bit short-sighted. Probably because otherwise it would not work.

It pains to see the need for a microservice to even start thinking about system architecture. As if the additional database and additional set of classes could not be done on the same instance. And then everyone shrieks in pain when they see the monthly costs :)

I admit I don't know enough about kernel development, but from general experience one common example is resource cleanup.

Say, you have several resources that must be cleaned up in certain order. In C, you would just call the appropriate free functions. When abstracting over that with rust, you have to make an annoying choice:

Do what's in C, don't implement automatic Drop, but mark your functions unsafe. You get leanest zero-cost implementation, it is straightforward to understand, but needs additional maintenance care to prevent bugs.

Wrap resources in unsafe structs that have automatic drop (when goes out of scope). IMO this is a terrible choice, because the maintainer suddenly has to know about which structures have this unsafe cleanup going on. Simple scopes suddenly matter, order of items suddenly matter, it's a mess.

Use reference-counting wrappers to track usage and drop the items when they are no longer in use. Most libraries do this, but it's no longer the leanest possible API.

There might be another choice, to achieve both zero-cost execution and correct cleanup using metaprogramming, be it macros, generics, or both. That's exactly what I fear the most.

I am Rust developer. My advice: favor less abstractions. Especially when interfacing with C, you can always make almost 1:1 rust interface. Start with that. Then, when common patterns start to emerge, do the data abstractions first, i.e. define data structures shared by different implementations.

There is no reason why you can't write simple code in Rust. Well, except that it's tempting to over complicate things. Start using traits and generics everywhere, and you will enter meta-programming in generics hell. Soon after, you will start demanding new compiler features to survive there.

I would argue that the bloat comes when the performance impact is not perceivable compared to the development time.

The easiest optimization strategy is just to load it all up into the memory. Compare that to other strategy like catching partial file data, and it's obvious why the simpler solution is often chosen.

Another example that comes to mind is vector art vs baked art. You can render nice icons as vector art. Or you could ship perfect baked icons for all possible size variations. There are clear trade-offs here. One of them wastes more CPU cycles, and another one wastes storage space and download time.

The more you use GPT, the more you will understand that it's not the replacement for your attention to the work. And without the attention to the work, you can't spot bugs, blatant inefficiencies, or better design choices - in other words, if you don't take care, you won't even know what you are missing.

I write code with GPT every day for almost a year now, and it helped me greatly to kickstart code that was hard in the past, namely, audio synthesis, vulkan rendering, and other things that were hard to approach. But it's very clear at this point that it shall not be trusted, because it's like a coat of a nice paint put on top of all the clever or dumb stuff that exists on the internet. You never know which one you get, but sure it will be worded convincingly.

I would not sing praises for Microsoft Flight Simulator 2020. First, the cockpit displays are rendered at lower framerate, because they take considerable chunk of frame time. Second... It may be fine to render display and UI using js, but if you dig in, you will also find the autopilot there on top of inheritance hell.

The biggest wrapper that gives guarantees is the standard library, and usually, when people say that Rust does not do something, they have standard library in mind. For example, standard library made the choice to hide panics in out-of-memory situations. That does not mean you can't write your own version of relevant structures to gain different guarantees. I like to highlight the actual strengths of Rust (as a tool) instead of particular implementation details, especially when we are talking about situation (kernel) where Rust is used without its standard library.

I would avoid saying that it's "Rust" that "gives guarantees". It paints Rust as this magical thing that will solve anything. My preferred explanation is that Rust provides better tools to build wrappers that can't be misused. The idea is to solve hard problem once, and reap the benefits many times. But it all depends on wrapper author. In that regard, it is perfectly possible to write horrible Rust code.

First and foremost, algebraic data types, specifically, proper sum types, called "enums" in rust. Think safe C unions or sane C++ variant. Everything is built on them, they help to encode various states and ensure they aren't misused.

Second, moves by default. They make building wrappers that depend on creation and destruction of a value much easier. They can track various things: memory usage, threads, temporary pointers, or whatever else. Unlike unique_ptr, they are on stack and part of the type system.