Hacker Newsnew | past | comments | ask | show | jobs | submit | Yokohiii's commentslogin

The suggestions are really all over the place. Feels AI.

What are the options? Repeated allocations are a huge performance sink.

> Aside from where you've only duplicated something that already exists (in which case why bother?)

If we had stopped reiterating on the wheel our cars would drive on wooden logs.


Of course, a wheel doesn't duplicate a wooden log. The wheel most certainly 'wow'-ed people when it was first introduced.

But if you release a wheel today, same as any other wheel you can already buy, don't expect much fanfare.


My point (and that of the previous poster) is that "wow" isn't required as an initial property to do anything. Pretty sure the dude who made the first wheel just did something that was useful for him in that situation. He didn't think how he could do something to impress his peers. He maybe wasn't even aware he made the first wheel or something innovative.

Also if I'd dive into how F1 wheels are made, I'd expect I learn stuff that is fascinating and far from boring.


The question asked — paraphrasing to include the context you have added — is how you could create something like a wheel, or a novel adaptation on the wheel like an F1 wheel, without sparking 'wow'? It just doesn't seem impossible. You may not come with the intent to create 'wow', but it is going to happen anyway.

I am confused on your use of "duplicating".

I think straight duplication is quite unlikely. You even say it's inevitable. Which is also confusing. Most code written is probably quite unremarkable, yet useful. Usefulness is a dominating factor, wow has a lot of depends.


> I think straight duplication is quite unlikely.

Is it? There are many different people selling wheels that are all pretty much indistinguishable from one another. The first one no doubt brought the 'wow'. But when the second person showed up with the same thing, what 'wow' would there be?

Our entire system of trade assumes that duplication occurs as an intrinsic piece, with the only defining difference in that duplication is the effort to make the same thing for cheaper. Otherwise known as competition. Are you suggesting that doesn't happen?


I am stuck with your phrasing. Duplication is for me something like cloning or a perfect copy. Which I think is unusual. You will find a chinese phone that looks like an iPhone but is totally different and magnitudes cheaper. What you talk about is probably more like mimicking. Offering something that people are used to to get into the market. But every competitor will eventually look for things to make a brand or product different. What is inevitable, is to diverge from mimicry. So duplicating is an evolutionary process itself.

> Duplication is for me something like cloning or a perfect copy.

That's fair. But if you aren't offering a perfect clone, then you're offering something novel that will 'wow' your customers, no? The market will never take interest in what you are selling if there is no 'wow' factor.

> Which I think is unusual.

You make a fair point that unreasonable terms on intellectual property laws has made it much more unusual than it should be, but isn't unusual historically, and shouldn't be unusual given our system of trade that assumes that clones will be produced. It's the only way most people can participate in the economy (and why they currently feel left out; but that's another topic for another day).


It's weird that this thread argues to keep the fun in hobby projects and you ask for the exact opposite.

It's precisely because of the hobby nature of my projects that I want this feature. Support and collaboration are a lot of work. I have trouble conjuring up enough motivation to work on my projects as it is.

I found working with AI as the code buddy to be motivating (ironically). You get to chat about the project, ask opinions and in general have somebody do the work you don't find inspiring.

AI often doesn't do things your way, but if your doing something for yourself you usually care more about the goal than the technicalities. Also AI working on a hobby code base is less prone to overcomplication since it basically copies what you've wrote yourself.


I had a similar experience. Just chatting about stuff, shooting ideas and concepts back and forth with the AI is quite stimulating. I get to be an obnoxious help vampire without draining other humans of their patience and motivation. It's like having a developer friend with infinite patience to chat with.

In terms of productivity it's having something of a mixed effect. It gives me very clear ideas and direction but at the same time everything just feels done afterwards. All that's left is actually executing the tasks which is... Boring.

I'm not sure I trust ChatGPT to do it for me like an agent. The examples it gives me are never quite right. It's probably a lot better at generating frontend javascript code than programming language interpreter code.


Sponsors can have quite a bit more entitlement then the average github dude. But well, maybe if you lock it down for sponsors the stress level is overall lower.

> Sponsors can have quite a bit more entitlement then the average github dude.

Is this some sort of unwritten agreement? When I was setting up my sponsor page, I explored the sponsor pages of other users for ideas. I don't think there were many sponsorship tiers with special features. Some people offered advertising space on the README, others offered access to an exclusive Discord channel, most just thanked the sponsor.

I'm still new at this so I wouldn't know. I only ever had one sponsor. Happened organically after my work was independently posted here on HN once.


Oh my mistake I was thinking of individual donations, which may be implied as some premium service. I think a company/org sponsor should be more professional. In theory you can just cancel a sponsor if it doesn't fit. You can turn your back on on donations, but you somehow owe the donators forever.

Edit: https://pocketbase.io/faq/

Look at the bottom, just an example how sponsors/donors may affect you.


Fun hobby project with the option to change that if someone offers a big enough bag of money.

Yeah. That option is always on the table.

Escape analysis sends large allocation to the stack. The information is there.

Can you elaborate on the stack analyzer? All I could figure out was to see runtime.morestack calls that affected the runtime, but as far I remember the caller timings did exclude the cost. Having a clearer view of stack grow rates would be really great.

I’m not sure what you mean? Are you asking for information about what it is or how to use it?

I never heard of "stack analyzer" and didn't get meaningful results for it, do you mean escape analysis?

Sorry, yes, I meant “escape analyzer”. I’ve been jet lagged.

Ok no problem. Take a good sleep soon!

I am currently learning go and your comment made me sort some things out, but probably in a counterintuitive way.

Assuming to everything allocates on the heap, will solve this specific confusion.

My understanding is that C will let you crash quite fast if the stack becomes too large, go will dynamically grow the stack as needed. So it's possible to think you're working on the heap, but you are actually threshing the runtime with expensive stack grow calls. Go certainly tries to be smart about it with various strategies, but a rapid stack grow rate will have it's cost.


Go won’t put large allocations on the stack even if escape analysis would permit it, so generally speaking this should only be a concern if you have very deep recursion (in which case you might have to worry about stack overflows anyway).

> Go won’t put large allocations on the stack even if escape analysis would permit it

Depends what you mean by “large”. As of 1.24 Go will put slices several KB into the stack frame:

    make([]byte, 65536)
Goes on the stack if it does not escape (you can see Go request a large stack frame)

    make([]byte, 65537)
goes on the heap (Go calls runtime.makeslice).

Interestingly arrays have a different limit: they respect MaxStackVarSize, which was lowered from 10MB to 128 KB in 1.24.

If you use indexed slice literals gc does not even check and you can create megabyte-sized slices on the stack.


There is a option -smallframes that seems to be intended for conservative use cases. Below are the related configs and a test at what point they escape (+1).

  // -smallframes
  // ir.MaxStackVarSize = 64 * 1024
  // ir.MaxImplicitStackVarSize = 16 * 1024
  a := [64 * 1024 +1]byte{}
  b := make([]byte, 0, 16 * 1024 +1)
  // default
  // MaxStackVarSize = int64(128 * 1024)
  // MaxImplicitStackVarSize = int64(64 * 1024)
  c := [128 * 1024 +1]byte{}
  d := make([]byte, 0, 64 * 1024 +1)
Not sure how to verify this, but the assumption you can allocate megabytes on the stack seems wrong. The output of the escape analysis for arrays is different then the make statement:

  test/test.go:36:2: moved to heap: c
Maybe an overlook because it is a bit sneaky?

> Not sure how to verify this, but the assumption you can allocate megabytes on the stack seems wrong.

    []byte{N: 0}

doesn't make sense.

And yet it does: https://godbolt.org/z/h9GW5v3YK

And creates an on-stack slice whose size is only limited by Go's 1GB limit on individual stack frames: https://godbolt.org/z/rKzo8jre6 https://godbolt.org/z/don99e9cn


Yea with more context it suddenly makes sense :p

Interesting, [...] syntax works here as expected. So escape analysis simply doesn't look at the element list.


Escape analysis accounts for size, so it wouldn't even permit it.

The initial stack size seems to be 2kb, a more on a few systems. So far I understand you can allocate a large local i.e. 8kb, that doesn't escape and grow the stack immediately. (Of course that adds up if you have a chain of calls with smaller allocs). So recursion is certainly not the only concern.


For that to be a problem you either have to have one function that allocates an enormous number of non-escaping objects below the size limit (if the Go compiler doesn't take the total size of all a function's non-escaping allocations into account – I don't know), or a very long series of nested function calls, which in practice is only likely to arise if there are recursive calls.

I think we mix things up here. But be aware of my newbie knowledge.

I am pretty sure the escape analysis doesn't affect the initial stack size. Escape analysis does determine where an allocation lives. So if your allocation is lower then what escape analysis considers heap and bigger then the initial stack size, the stack needs to grow.

What I am certain about, is that I have runtime.newstack calls accounting for +20% of my benchmark times (go testing). My code is quite shallow (3-4 calls deep) and anything of size should be on the heap (global/preallocated) and the code has zero allocations. I don't use goroutines either, it might me I still make a mistake or it's the overhead from the testing benchmark. But this obviously doesn't seem to be anything super unusual.


I don't know about your code, but in general, goroutine stacks are designed to start small and grow. There is nothing concerning about this. A call to runtime.newstack triggered by a large stack-allocated value would generally be cheaper than the corresponding heap allocation.

I found my issue, I was creating a 256 item fixed array of a 2*uint8 struct in my code. That was enough to cause newstack calls. It now went down from varying 10% to roughly 1%. Oddly enough it didn't change the ns/op a bit. I guess some mix of workload related irrelevancy and inaccurate reporting or another oversight on my side.

Pointers escape to the heap by default.

You point out the cultural issue that this creates and sweep it under the rug, violently.

The thought model complicates the process of writing new code, "what pattern do i need here?" and the perception of existing code, "oh this is pattern X, why isn't that communicated clearly?". The truth is that design patterns are at best stagnant in quality and quantity over time (GoF is over 30 years old!), but the quantity and quality of problems is infinite.

I've thought in patterns quite some time in my early career. With my colleague back then everything was an pattern and we were kind of in sync with that approach. But it quickly falls apart if you have peers that are less try hard on it. You can spend days, weeks, months to study design patterns and then have to explain it to someone in 5 minutes that simply doesn't care. I can't blame anyone to not care, so that has to be accounted for.

I think the common language argument is tempting, but also too stressed. Good and useful programming knowledge is bound by reality. An integer is a indisputable thing that is always useful. A "singleton" is just a fancy rephrasing of "global state".


I did not mean "everybody has to learn the vocabulary". I meant the opposite, actually: it's fine not to know the word for the tool (I don't enjoy reading about patterns just to learn about patterns, it's not my thing at all).

Say I build a tool that makes it easier for me to drive a nail and call it a "Naildriver". If I show it to a colleague, they may be able to tell me "oh, this is generally called a hammer!". Maybe they will even tell me how I may improve my hammer, because they happen to like to learn about hammers in their free time. Or maybe now that they said it's a known concept, I will enjoy reading about hammers online (doesn't mean I will now read the entire encyclopedia of tools).

The fact that there is a name for the concept ("it's called a hammer") does not say you have to know the word. It's just useful to have a word for it, because then we can reference it in discussions and share knowledge about it more easily.


The other thing that design patterns allow, is to learn pitfalls, applications and other attributes about them.

To keep in your analogy, if you have a 3KG naildriver with a 2m handle you'll quickly find out that driving nails into a drywall with that leaves you with no wall. And that it's a bad idea to use a "Naildriver" to drive these "spiralled-slothead-nails" (aka screws) into wood.

But with a common language, such as design patterns, you can easily learn where they are good, what their limits are, in what cases other patterns fit better, and what pitfalls to avoid and so on.

If I search the web for "why is it so hard for my naildriver to drive in spiralled-slothead-nails" I'll get zero results. But when I search for "why is it hard to hammer in a screw" I'll get good results. May sound like a silly example, but for me that sillyness illustrates how obvious designpatters should be.


I totally agree with that!

And it doesn't mean at all that everybody should learn the whole encyclopedia of tools by heart. But having it formalised somewhere is useful: as soon as someone tells me "what you're trying to do sounds like this design pattern", I can start searching and reading about it.

Of course if that someone tells me "you suck, you should know that there is a design pattern for that because you should read about design patterns every night before you go to sleep", it will be different :-).


I have mixed feelings about this.

I think Julian Assange once said he would refer to things in discussion just as "Tomato" (or similar), in discussion to have a shortcut for something unnamed with some meaning. We do this all day in programming, we give a complex component a name and it means a lot more then just the actual word. The problem is that this specific meaning is often not universal, it's contextual.

If you take a hammer, an integer and design patterns, the latter is the least universal thing. They depend on domain, context and conventions, and can change quite a lot depending on the language. Removing hammers and integers from the world would cause collapse, removing design patterns would do almost nothing.

I guess the active celebration of design patterns as a catalogue of general wisdom is my primary issue here. I'd welcome any project/team/company that maintains a catalogue of their individual "patterns". But a universal source of truth has too much bible flavor to me. (Oh it also dictates OOP by default which renders it's inherent "wisdom" completely useless in many languages)


I feel like we're talking past each other. I tend to agree with you, I don't like having a "bible" and "celebration of design patterns as a catalogue of general wisdom".

But formalising concepts with words makes sense. If your company maintains a catalogue of their patterns, and someone happens to know that this specific pattern is usually called a "singleton", I would find it weird to call it a tomato.

Some patterns have different names in different contexts or languages, and that's fine. I don't find it weird to have a discussion around "in this language there is this pattern that they call X, does that ring a bell for you working on that other language? The idea is [...]", and maybe the answer is "yep we have it too" or "oh, we call that Y, but that's pretty similar".


Well I guess I am not clear enough. Naming stuff is a normal human habit, maybe even why we have language? So we can agree on that, it's helpful. But you say it yourself, a thing is called different in another language, so the thing is bigger then the word. But everyone can handle it better in his own head and in communication with a word for it. I guess my usual grief is that any kind of excessive celebration and ceremony comes down to some kind of brainwash. Which mostly affects newbies and cultists. The article for example isn't overtly critical on singletons, while past design pattern writings often heavily disregarded the use of it. So we don't just always reiterate the good, but also the bad.

I don't mind the celebration and ceremony as long as they don't bother me personally. I wouldn't fight against the existance of a PatternConf, I just wouldn't go :-).

I've had some debates with junior devs who really wanted to enforce their newly-learned patterns, and my experience there is that passed a certain point, there is no convincing anymore: if they really insist about overengineering something with their newly-learned concept and the hierarchy doesn't allow me to prevent them from doing it, anyway they will do it. So instead of fighting I just let them, and if it turns out to be a waste of time in the end... well that's not my problem: I was not in a position to prevent it in the first place.

It's not only patterns though: some juniors have a way to try to use every exciting framework or library or tool they just discovered.


The silly thing is that I've been the same when I started. A high energy kid playing around and celebrating everything fresh and new, with a big ego.

Probably a bad habit trying to stop them, they need to learn walking before they can sprint. The question is always how to put limits on them? I say it's overengineered, they say it's modern code and I am old. So what do you do if they send you a PR that is just plain wrong? I mean it seems like you delay the conflict from upfront design/planning to pull requests.


I have been in two different situations:

* Functional teams (established companies): enough seniors are here to tell the juniors when they are wrong, and the juniors naturally accept the criticism because it's expected in that environment.

* Dysfunctional teams (startups): most devs are juniors anyway, there is no clear hierarchy, managers are still at their first job so they have never seen a functioning team or had a competent manager themselves.

In the second case, there was absolutely no way I could win an argument: the "high energy kids with big egos" never believed me, I was the "old guy" as you mention. I remember an example where the "kid" failed and gave up with their "right" way after 3 months and I solved it in 3 days, exactly how I had suggested they did it in the first place. Next discussion, nothing had changed, they still knew better.

I can't really blame them, because the whole environment was like this. Everybody was always right, knew better, etc, even though it was their first job.

What I've learned is to protect myself and move away from that. Either by changing job, or by changing project. In startups I have been pretty successful at saying "I can help with this project if we do it this way, but if we do it that way, I can't help and I will work on something else". Of course it meant that I could not work on the most exciting project, but they made a mess out of them, so all in all I feel it was better working on my boring, stable, maintainable components.


> The truth is that design patterns are at best stagnant in quality and quantity over time (GoF is over 30 years old!), but the quantity and quality of problems is infinite.

I think once you have spent enough time in a software space, nothing is really new under the sun. That's why I think the GoF has aged well (controversial opinion I know!).


I am a bit confused about the API pollution issue with arenas. I think it's a valid point to think about, but at the same time I don't think the average dev will do any extra steps for the faster thing to do.

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

Search: