Hacker News new | ask | show | jobs
by CaptainHiggins 2618 days ago
Just because the features exist does not mean you have to use them.
4 comments

stares in C++; stares in Perl

But seriously, I think C++ and Perl have taught us that if you give programmers the logical equivalent of a Swiss Army Knife, they will use/abuse absolutely every single bit of it to write their programs.

I used to be a big fan of "more than one way to do it", but these days, I'd gladly take "one reasonably clear way to do it that not everyone likes but 'everyone' can live with".

> I used to be a big fan of "more than one way to do it"

I used to firmly believe that that was the way a programming language should be. Let me do what I want to do, however I want to do it.

I've finally found myself falling in to almost the complete opposite, with a small addition: "There should be one way to do it, and it should be obvious"

Python mostly scratches that itch for me, but even there it has multiple methods to do the same stuff within the standard library, like list.sort() and sorted(list) https://medium.com/@DahlitzF/list-sort-vs-sorted-list-aab92c...

Come to the Lua side and learn to enjoy "mechanisms over policy"

"...A fundamental concept in the design of Lua is to provide meta-mechanisms for implementing features, instead of providing a host of features directly in the language. For example, although Lua is not a pure object-oriented language, it does provide meta-mechanisms for implementing classes and inheritance. Lua's meta-mechanisms bring an economy of concepts and keep the language small, while allowing the semantics to be extended in unconventional ways."

>same stuff within the standard library, like list.sort() and sorted(list)

Those have different use cases. `sorted` is for situations where you would use a list comprehension and immediately consume the result vs `.sort` where you need the iterable sorted for future use.

As a quick scribble, you can do something like the following to sort random numbers in a single line:

  result = sorted(random.random() for x in range(10))
From your Medium post:

  def list_sort(arr):
    return arr.sort()

  def sorted_builtin(arr):
    return sorted(arr)
Only the `sorted_builtin` function returns the array, `list_sort` returns None. The `list_sort` function would have to become:

  def list_sort(arr):
    arr.sort()
    return arr
Edit: goofed the formatting
> Python mostly scratches that itch for me, but even there it has multiple methods to do the same stuff within the standard library, like list.sort() and sorted(list)

There's also the list vs tuple thing. I can understand it from an efficiency point of view, but it isn't as consistent as just having one such data structure (e.g., a perl array)

I don't think it's that simple. C++ has a lot of features whose syntax have little consistency.

Ruby has a lot of features but they all feel reasonably thought out. The language still feels quite elegant.

Obviously, it's not that simple. But my suppositions are a response to the statement Just because the features exist does not mean you have to use them.

There is a cost to functionality that exists in a language and you can't just ignore it because someone will use it and you will still need to understand it.

Although I don't personally like the Go language, I can empathize and understand the reasoning behind its strong, opinionated language choices. Go is a perfect example of doing things in a way that not every one likes, but "everyone" can live with, just like gofmt.

Just because you don't use features does not mean they don't add complexity when you're trying to understand some piece of code, or when you're trying to design a piece of code that should interact with other code. (Not taking sides about this language's complexity; I don't know the language)
John Carmack said it well when he said something to the effect of "everything that is syntactically correct eventually makes it into the codebase".

But I have no opinion of Crystal, just prefer small, concise languages in general.

Just because you don't use them doesn't mean someone else won't.