News for hackers. Stuff that matters.
Re:Crystal 0.28.0 Released by CaptainHiggins on Thursday April 18, 2019 @04:31PM (#19694513)
Just because the features exist does not mean you have to use them.
Re:Crystal 0.28.0 Released by binarycrusader on Thursday April 18, 2019 @06:20PM (#19695317)
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".

Re:Crystal 0.28.0 Released by Twirrim on Thursday April 18, 2019 @07:31PM (#19695693)
> 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...

Re:Crystal 0.28.0 Released by pull_my_finger on Friday April 19, 2019 @02:20AM (#19697464)
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."

Re:Crystal 0.28.0 Released by silly_giraffe on Thursday April 18, 2019 @10:49PM (#19696705)
>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
Re:Crystal 0.28.0 Released by ryl00 on Thursday April 18, 2019 @09:35PM (#19696342)
> 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)

Re:Crystal 0.28.0 Released by sosodev on Thursday April 18, 2019 @06:28PM (#19695356)
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.

Re:Crystal 0.28.0 Released by binarycrusader on Thursday April 18, 2019 @06:42PM (#19695442)
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.

Re:Crystal 0.28.0 Released by jstimpfle on Thursday April 18, 2019 @04:41PM (#19694586)
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)
Re:Crystal 0.28.0 Released by newnewpdro on Thursday April 18, 2019 @06:43PM (#19695450)
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.

Re:Crystal 0.28.0 Released by recursive on Thursday April 18, 2019 @05:07PM (#19694779)
Just because you don't use them doesn't mean someone else won't.