14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions
comment 9y ago · link · parent
comment 9y ago · link · parent
The classic fizzbuzz will use %3 and %5 operations to test divisibility. As we know from the same source as OP, these are horrifically slow. In addition, the usual approach to fizzbuzz has an annoying duplication, either of the strings or of the predicates.
So, the challenge is, write an optimized fizzbuzz with the following properties: the state for the divisibility testing is a function with a period of 15, which can be calculated in 2 C operations. There are 3 tests for printing, each of the form 'if (...) printf("...");' where each if test is one C operation.
Good luck and have fun!
comment 9y ago · link · parent
comment 9y ago · link · parent
And yes, if there were a good reason to, Google could bring considerable resources (including marketing) to bear.
comment 9y ago · link · parent
My estimate of a million users is what might happen after another year or two of building out the whole vision, and with organic growth from numerous sub-communities (for example, I'd expect Rust users to be quicker to adopt it because it's in Rust). At that point, it's clear that the project would need at least a full time person to be its maintainer. And I don't see how to sustain that.
Thanks for emphasizing the focus on marketing; it is indeed a knob I can turn.
comment 9y ago · link · parent
B) Because if I build out my full ambition, it would be better by most objective metrics (speed, features, integration with IDE-like capabilities) than all the free editors out there, and I think there is a real demand for a better editor.
I know what you mean about the struggle for traction. It is of course possible I'm massively mis-estimating the potential userbase.
comment 9y ago · link · parent
The biggest item in my portfolio is xi-editor, and I confess I'm wrestling with some of the questions raised in this thread. I think it has the potential to be a serious player in the editor space, with extremely high performance goals (including fast startup and low RAM usage) yet a modern feel. It also has a great little open-source community around it who have been contributing significant features.
Yet it's at the point where it's _almost_ done enough to use for day-to-day editing, and I'm hesitating a bit before pushing it over the line. I think I'm scared of having lots of users. It's also the case that I'm very interested in the engine and the core of the UX, but the complete product needs a plugin ecosystem and along with that ways to discover, upgrade, and curate the plugins (including making sure they are trustworthy, lately a fairly significant concern). That's potentially a huge amount of work, and it doesn't really line up with my interests.
I'm wondering if it's possible to focus on the parts I care about and try to foster the community to take care of the rest, but I'm not quite sure how that would work.
If this were a business and I had some way of making a few coins from every user, then my incentives would be lined up to make the best overall product possible, including the less fun parts. But that's off the table; among other things, there are a number of good free editors out there, and the niche for a better but non-free editor is also well occupied.
Maybe the HN crowd has some ideas?
comment 9y ago · link · parent
comment 9y ago · link · parent
Probably the majority of languages are philosophically the same as Go; in single-threaded operation there's not much undefined behavior, but once you go multithreaded and have a data race, all bets are off. The "memory model" document is not very precise, but mostly states that if you avoid data races, things will be ok.
All languages with FFI to C, of course, inherit C's approach to undefined behavior through that mechanism.
comment 9y ago · link · parent
[0]: https://internals.rust-lang.org/t/crates-io-package-policies...
comment 9y ago · link · parent
I personally have had one IARC approved and one denied (and something like a dozen opensource launches), but from what I've seen, the above statement is accurate.
comment 9y ago · link · parent
Besides, what's a "line"? Is it a source line, or a visual line after wrapping? In an editor, you care deeply about both, depending on what exactly you're doing. With an array of lines, you pick one for the representation, and when you want the other one, it's quite painful. With ropes, no problem at all, just two different Cursor objects into the same rope.
I agree, other decisions besides buffer representation are important, and I'm doing my best to get those right too.
comment 9y ago · link · parent
As I said elsewhere on the thread, the good thing about ropes is their worst case performance. Super-long line? Rope still efficient. 10 million line file? Rope still efficient. Massive sequence of edits relative to the pristine file? Rope still efficient. It's pretty easy to write code which works well in the common cases but then degrades when things get interesting. I'm not going to apologize for caring about that.
comment 9y ago · link · parent
That said, I'm very skeptical that lz4 on text would be worth it.
comment 9y ago · link · parent
[The actual analysis is much more subtle, as the tree invariants are a minimum and maximum number of children for non-root non-leaf nodes, and a minimum and maximum leaf size. When freshly loaded, the code is careful to maximally pack both, and after extensive editing the distribution will be more varied. However, it's still rigorously O(log n), so it ends up being a small constant factor. Might be worth doing some empirical performance testing.]
comment 9y ago · link · parent
comment 9y ago · link · parent
As to being a young person, I don't know if you remember, but I was already of drinking age when you and me and Adam Sah hung out a bit and talked about the "rush" language.
I admit to being excited, but because I think "modern" editors really are too bloated and slow and it causes a thousand paper cuts throughout the day, and I think that can be fixed.
comment 9y ago · link · parent
When I first wrote that code, I was targeting 32 bit ARM, with possibly very weak floating point units. These days, on the types of chips you'd see in phones (or computers in the $9-$40 range like rpi 3), the floating point calculation is _so_ fast (especially with simd) that the cost of the memory lookup starts dominating. So, the NEON implementation computes 4 sin values in a gulp, using a floating point polynomial approximation about the same precision as above[1].
[0] https://github.com/google/music-synthesizer-for-android/blob...
[1] https://github.com/google/music-synthesizer-for-android/blob...
comment 9y ago · link · parent
Feeling guilt about not being able to do more is a natural consequence of suicide. But it sounds like you were there for him, able to really listen. Think of how many people struggling with these sorts of problems don't have that.
comment 9y ago · link · parent
Like most undefined behavior, it can work in practice. Probably. Most of the time. If you stick to using older compilers.
comment 9y ago · link · parent
These theoretical concepts might or might not be that relevant for real-world applications. For example, in real-time audio (the main domain of interest to me for lock-free techniques), what you really care about is that the audio rendering thread will produce one buffer worth of sound before the hardware finishes outputting the previous buffer. This sounds like a match for "wait-free", but it depends on the details. If the non-audio thread can cause a 100x slowdown (but no more) that would technically be wait-free, but you'd miss your buffer, and so it's not acceptable. Another system might use mutexes, but be carefully engineered so that the locks are never held for more than 100µs (say, using locks designed to handle priority inversion), and thus reliably meet the needs even if it's not technically anything like lock-free.
But, as with anything, these concepts are useful tools, and I _love_ lock-free algorithms for audio.
comment 9y ago · link · parent
But none of that had a serious effect on C and C++ practice until C++ started formalizing the memory model. Even today, we still have to deal with a lot of legacy code that uses pre-memory model primitives such as __sync_synchronize, __atomic_cmpxchg, InterlockedCompareExchange, etc. I'd like to see all that stuff go sooner rather than later. In my opinion, the original article is not helping, as it shows C code that does reads and writes through pointers, expecting them to behave as atomic operations.