Recent submissions

Comment · 3 months ago
Comment · 3 months ago
Comment · 1 year ago
My understanding is that RC is relatively expensive in time (especially for atomic RC) but uses a lot less memory than state of the art fast GC. And RC doesn't handle cycles.
Comment · 3 years ago
D doesn't store capacity in each slice. This allows a slice to fit in registers more often. Instead for GC allocated slices, the GC will store metadata before the first element of the allocation. That does make it slower to access, particularly when the slice points past the first element, but it is cached to speed up repeated accesses to the same allocation. Repeated appending can be further speeded up by using a dedicated Appender type.
Comment · 3 years ago
Because Go designers don't like OOP and didn't want low-level system programming as core features. They also were not keen on generic programming. Basically they wanted a simpler language. (Then they realized generics are useful, ironically their constraints add complexity). Also they wanted a segmented stack and coroutines + channels as language features.
Comment · 3 years ago
This compiles:

    ref ubyte[n*2] requires_ptr_twice_as_large_as_input(uint n)
    (
        const ref ubyte[n] input,
        ref ubyte[n*2] output,
    ) {
        output[0..n] = input[0..n];
        output[n..2*n] = input[0..n];
        return output;
    }

    void main()
    {
        ubyte[10] input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
        ubyte[20] output;
        requires_ptr_twice_as_large_as_input!(10)(input, output);

        import std.stdio;
        writeln(output);
        assert(output == input ~ input);
    }
Comment · 4 years ago
Comment · 4 years ago
Class instances can go on the stack too using `scope`:

  scope obj = new Object;
  ...
  // destroyed at end of scope
Comment · 14 years ago
Arrays and slices really have nothing to do with generic programming. Java has poor generic support (type erasure) and C++ has poor syntax and a bad design for iterators. Languages with decent generics support have none of these problems.

If this is 'armchair criticism' why do Go's designers say they are considering adding generics support?

Comment · 14 years ago
Lack of generics does not ease development speed. Generic programming is about safe reusability. (Development speed includes the test, debug, fix cycle).

No generics actually harms code clarity and destroys type safety.

Comment · 14 years ago
C's preprocessor means C code can often do interesting tricks, such as the X macro: http://www.drdobbs.com/the-new-c-x-macros/184401387

There are tons of other interesting uses for macros. Obviously I'd rather a language had safer equivalents to a C preprocessor.

Comment · 14 years ago
None of those things cause as much greenhouse gas emissions as a high meat diet.

The level of meat consumption in rich countries is unjustifiable.

Comment · 14 years ago
> C++ has the best (imperative) language support for templates

D's template support is far superior: static if, constraints, compile-time function execution, string mixins, opDispatch. These features make templates much more practical and more powerful.

Comment · 14 years ago
Actually it is simple: eat less meat. Meat production is vastly more wasteful than vegetable production calorie-for-calorie.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton