Live data from Hacker News

Streem – a new programming language from Matz

github.com

81–90 of 199 posts

Re: Streem – a new programming language from Matz

#81
post #26

Earlier quoted context omitted.

It's not any shorter. The extra check as to whether or not to print the line break cancels out the mod 15 check. In my opinion, it's cleaner to have three conditionals of the same type than two checking mods and a third checking the OR of the first two. Of course, it can be actually shorter with a goto.

string output = numb.toString(); if(numb % 3 == 0) ouput = "Fizz"; if(numb % 5 == 0) output.Append("Buzz"); write output; It is possible to use two checks to cover all three fizzbuzz components.

5Buzz

Re: Streem – a new programming language from Matz

#82

Earlier quoted context omitted.

I would hope never to find a bomb like that in the code I'm maintaining.

Really? I find that one line far more pleasant than the Python example above it, with variables being assigned, etc. Both are quite clear in their intention, I think, assuming you recognize "join". I don't even recognize the language of the one-liner, but it makes perfect sense to me as a reader. It looks like a Perlish solution, but the string method is strange, I think. Maybe Perl 6 or Ruby?

It's Python as well.

Re: Streem – a new programming language from Matz

#83

Earlier quoted context omitted.

I would hope never to find a bomb like that in the code I'm maintaining.

Really? I find that one line far more pleasant than the Python example above it, with variables being assigned, etc. Both are quite clear in their intention, I think, assuming you recognize "join". I don't even recognize the language of the one-liner, but it makes perfect sense to me as a reader. It looks like a Perlish solution, but the string method is strange, I think. Maybe Perl 6 or Ruby?

The one-liner is valid Python. It's slightly non-idiomatic in that it uses a list-comprehension where a generator expression would do, and uses range instead of xrange (in Python 2.x; in 3.x range is the idiomatic alternative).

Re: Streem – a new programming language from Matz

#84
post #3

Why do most implementations of FizzBuzz special case % 15? I haven't ever really understood this. Maybe it's just my math-y background, but it always seemed to me you should just check mod 3 and mod 5 without an else between them, concatenating Fizz and Buzz. Can anyone else comment on this? Most canonical FizzBuzz programs special case 15, and I don't get it.

Well, its more direct in that, while it increases the number of branches, it minimizes the number of statements executed on any branch. It's also the solution that maps most directly to the problem statement, and, absent a strong technical reason to do otherwise, a direct mapping from requirements to code is a good thing.

I disagree that it maps most directly to the problem statement. You're performing a common factor computation in your mind, which may be more difficult given numbers other than 3 and 5. In my opinion, pattern matching offers the most direct solution and comes with an abundance of compiler optimizations. Here's an example in Rust...

        for i in range(1i, 101) {  
            match (i % 3, i % 5) {  
                (0, 0) => println!("Fizzbuzz"),  
                (0, _) => println!("Fizz"),  
                (_, 0) => println!("Buzz"),  
                _ => println!("{}", i),  
            }  
        }

Re: Streem – a new programming language from Matz

#85
post #78
post #72

If you ever meet Matz, talk to him about programming languages. While he gets some flak for all the problems of his original hobby project (Ruby), he obviously loves programming languages and gives things more thought then people give him credit for. I had the chance to talk to him while I was still a student and full of ideas how the language could be made "better" and he shot them all down. For good reasons, as I k…

Does he really get a "lot of flak" for Ruby? While I know not everyone loves Ruby, it seems crazy to me that people would denigrate Matz on a personal level...to me (admittedly, a novice in designing languages), Ruby always seemed well-thought out...that is, the trade-offs do not seem out of line given the philosophical benefits, and not everyone can make claim to turning a personal project into a worldwide language.…

I don't think so many people have a problem with Ruby the language so much as the culture around Rails.

Re: Streem – a new programming language from Matz

#86
post #78
post #72

If you ever meet Matz, talk to him about programming languages. While he gets some flak for all the problems of his original hobby project (Ruby), he obviously loves programming languages and gives things more thought then people give him credit for. I had the chance to talk to him while I was still a student and full of ideas how the language could be made "better" and he shot them all down. For good reasons, as I k…

Does he really get a "lot of flak" for Ruby? While I know not everyone loves Ruby, it seems crazy to me that people would denigrate Matz on a personal level...to me (admittedly, a novice in designing languages), Ruby always seemed well-thought out...that is, the trade-offs do not seem out of line given the philosophical benefits, and not everyone can make claim to turning a personal project into a worldwide language.…

See the amount of people complaining about the missing spec for Ruby in this thread, which is his doing. At some point ~50% of the comments here were downvoted.

I should clarify that I meant Ruby the implementation, not Ruby the language.

Edit: I changed the word to "some", maybe that was a bit of a hyperbole. I see quite some unreflected bashing though.

Re: Streem – a new programming language from Matz

#87
post #67
post #29

Earlier quoted context omitted.

I've never heard of Elixir, but I always assumed that the |> originated in F#. Ocaml has it pretty much standard, too, although you can define it in one line in Ocaml: let (|>) x f = f x

In Elixir, |> does not flip arguments. It lets you chain together multiple functions by inserting the result of the previous function as the first argument of the following function. Here's an example from http://www.theerlangelist.com/2014/01/why-elixir.html The following code computes the sum of squares of all positive numbers of a list: list |> Enum.filter(&(&1 > 0)) |> Enum.map(&(&1 * &1)) |> Enum.reduce(0, &(&1…

F# doesn't flip arguments either. It's an operator:

    let (|>) x f = f x
Is basically saying:

    x |> f  is equal to  f x
So in F# it's the same as Elixir, but the value x is applied to the function f (passed as the last argument). i.e.

    list |> List.filter (fun x -> x > 0)
         |> List.map (fun x -> x * x)
         |> List.reduce (fun s x -> s + x)

Re: Streem – a new programming language from Matz

#88
post #59

Earlier quoted context omitted.

> However I hope that they provide some very robust tools for controlling input splitting Yes, splitting and combining. Looking at the code example, I feel like so much opportunity is just being squandered, where something like Rust's mapping constructs would feel so much better. Yours is definitely more in that vein, here's something a little closer: STDIN | /\w+/{|word| /house/ => "foo" /car/ => "bar" "literal" =>…

Streaming, pattern matching, and regex combined in one sounds pretty damn cool. Might also be nice to borrow some of Scala's features for terser code than Ruby, like ary | { _ + 5 } instead of ary | { |el| el + 5 }

I prefer

    {|el| el + 5}
more than

    { _ + 5 }
the latter is too implicit for my taste, also I imagine it could become more confusing in a more complex context.

Re: Streem – a new programming language from Matz

#89

I am glad that someone is working on a new stream processing language, it is a very interesting paradigm. However I hope that they provide some very robust tools for controlling input splitting. As I have spent too much time fighting with awk and wishing it was more flexible(it is frustrating always having exactly two levels of splitting with only matchers on the first and only inverse splitting on the second). As is…

" new stream processing language"... which are the olds?

I'm playing with the idea of build a language, where the functions are unix-like, with STDIN, OUT & ERR. So, instead of raise a exception, it put data in ERR... and make it easy to compose them.

Post reply on HN