Live data from Hacker News

Microfeatures I'd like to see in more languages

buttondown.email

71–80 of 539 posts

Re: Microfeatures I'd like to see in more languages

#73

Comptime. After having discovered Zig, I've been missing that feature in every other language.

For me, yes and no.

Sure, comptime is great, but I've also found it hard to reason about code with it. I prefer my comptime stuff separated out into its own section/file/whatever. With that small change, it becomes so much easier.

But yeah, still powerful and nice.

Re: Microfeatures I'd like to see in more languages

#74

Earlier quoted context omitted.

How is that third one readable at all? I’d assume it meant integer division.

Mathematica uses a lot of syntactic sugar. You will find all Mathematica code unreadable until you've learned to read it; `//` is no exception.

I find Mathematica code unreadable full stop.

Its convenient when writing though.

Re: Microfeatures I'd like to see in more languages

#75
post #15

> Instead of writing 10000500, you can write 10_000_500, or 1_00_00_500 if you’re Indian. I hate this so much. It means I can't grep for a constant.

You already can't, because someone can write the constant in hex, or even (shudder) octal.

Re: Microfeatures I'd like to see in more languages

#77
I want more implicit typing in typed languages. Quite often the compiler knows exactly what type a function will return, but I still need to write it there. Sometimes it’s easy („int“), but what about HashSet>>

Typescript does it well. F# (completely statically typed) too…

Re: Microfeatures I'd like to see in more languages

#78

Php supports kebab-case variables: ${"variable-name"}=123; Isnt it beautiful?

How many languages support kebab case with any Unicode dash that isn't the ASCII one? :)

F# allows arbitrary names within double-backtick identifiers. The following is a valid declaration, where I've used a hyphen, en-dash, and em-dash:

    let ``foo-bar–baz—quux`` = 3

Re: Microfeatures I'd like to see in more languages

#79

Negative array subscripts. So a[-1] means the last element of an array, a[-2] means the second last, and so on.

Any language that supports overriding the index operation should support this. You should be able to do this in C# with a struct with a backing array, for instance. If you're going to do this, use the word "Circular" in it, and I would also insist that if a has 4 elements, then a[0] == a[4] == a[8]. In other words, you always just take the (positive) index modulo the size of the area. Then a[-1] is the same as a[N-1] for an array of size N. This could be useful in a lot of contexts, but should be made explicit.

Re: Microfeatures I'd like to see in more languages

#80
post #58

Lua also allows you to choose the string delimiter. If your string contains "]]" you can delimit it with [=[ or [==[ instead. Any number of "=" so long as the opening and closing delimiters match.

And that's why all modern languages implement streams/string helpers/string builders. You do not want to actually write strings/manipulate them using "+" (concatenation symbol) in code directly because, in modern Unicode world, it tends to become a point of failure for obscure bugs / a maintenance horror show.
Post reply on HN