Microfeatures I'd like to see in more languages
buttondown.email
Microfeatures I'd like to see in more languages
1–10 of 539 posts
Re: Microfeatures I'd like to see in more languages
#2There's a whole section in the manual [1] for string quoting operators (qq, qw, qx, ...)
In general, I feel like Perl is one of those languages that has a high amount of these "quality of life" syntactic features, and helps make it enjoyable to write, once you get over the learning curve.
Re: Microfeatures I'd like to see in more languages
#3Re: Microfeatures I'd like to see in more languages
#4Another one from Nim is the implicit result variable. Instead of having to do this:
func sum(nums: seq[int]): int =
var result = 0
for num in nums:
result += num
return result
you just do this: func sum(nums: seq[int]): int =
for num in nums:
result += num
It saves so much time and I'm disappointed that more languages don't have it.Re: Microfeatures I'd like to see in more languages
#5 ${"variable-name"}=123;
Isnt it beautiful?Re: Microfeatures I'd like to see in more languages
#6 d'2020-02-20'
I also tried to make it so that every comparison had both english and symbol representations, a range syntax, and an approximation/match comparison (e.g. "=~", "!~") which could work with both floating point numbers and strings properly.I found this useful, and wish it was in more languages.
Re: Microfeatures I'd like to see in more languages
#7Re: Microfeatures I'd like to see in more languages
#8I have long wondered why Ruby's symbols aren't in every language.
Re: Microfeatures I'd like to see in more languages
#9My favorite is uniform function call syntax. In several languages (Nim, Koka, D, …), you can always write bar.foo(baz) instead of foo(bar, baz) and vice-versa. Another one from Nim is the implicit result variable. Instead of having to do this: func sum(nums: seq[int]): int = var result = 0 for num in nums: result += num return result you just do this: func sum(nums: seq[int]): int = for num in nums: result += num It…
func sum(nums []int) (result int) {
for _, n := range nums {
result += n
}
}
No clue if it's an idiomatic usage, and named returns always felt a little too magic for me.Re: Microfeatures I'd like to see in more languages
#10Php supports kebab-case variables: ${"variable-name"}=123; Isnt it beautiful?