Live data from Hacker News

Streem – a new programming language from Matz

github.com

131–140 of 199 posts

Re: Streem – a new programming language from Matz

#131
post #48

Earlier quoted context omitted.

just because 15 HAPPENS to be a concatenation of the output of 3 and the output of 5 today doesn't mean it will be tomorrow. If I said "say Fizz for multiples of 3, Buzz for multiples of 5, and 'this is a silly coding problem' for multiples of 3 and 5 then you'd have to rewrite your code. Some of us know that clients ALWAYS change their minds, specs are rarely equivalent to the end result, and code against future cha…

This is absolutely true for real-world coding. However, for the purposes of an exercise, I think the fact that 15 was chosen was not an accident, but is part of the exercise. Does the coder recognize the relationship between the multiples, and recognize the ability to optimize by removing an extraneous comparison? It's kind of a trivial test for that sort of recognition, but anything as small as FizzBuzz is going to…

As with most of these little tests, the actual question is, "Can you explain your decision, and does your explanation make sense?"

Really, the FizzBuzz test is a check to see if someone is bullshitting when they say they can code. Testing deeper than that is expecting too much of it.

Re: Streem – a new programming language from Matz

#132

Earlier quoted context omitted.

That manual is possibly the single most useful technical document that I have ever read. It has enabled me to write extremely powerful programs that no one I know can understand. It would however be nice to have a tool with similar power but simpler, more comprehensible syntax. One of the other commenters linked to an interesting document on sam, which has a better control flow but equally arcane syntax.

I think I could argue that Perl is that tool. I'm not looking forward to people chiming in about the syntax that have little to no experience with it though.

Perl indeed. I know there are a lot of modern compilers out there, but speaking about parsing files I think perl suits me the most in terms of code readability/speed balance.

Re: Streem – a new programming language from Matz

#133
post #124

Earlier quoted context omitted.

> I'm not sure why Scala is so obsessed with it, since it's used for so many featurse You might check out http://stackoverflow.com/a/8001065/3614122 . The interesting thing (to me) is that the majority of those are actually the same feature (lifting functions). It's just such a powerful/flexible one that it's often misinterpreted as an entirely new thing in different contexts. ary.map(_ * 2) Is no different than: val…

Your last example code is missing a closing-brace. I know no Scala, though, so I'm actually not sure where it should go.

Thanks. Missed it in the for-comprehension just before the yield.

Re: Streem – a new programming language from Matz

#134
"Then said Jesus unto him, Put up again thy sword into his place: for all they that take the sword shall perish with the sword" (Matthew 26:52, King James Version)

Sony played hard many times, e.g. closing Linux on Playstation 3 devices. I do not condone the attack, although I have no sympathy at all for such kind of companies.

Re: Streem – a new programming language from Matz

#135
post #84

Earlier quoted context omitted.

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, _…

The solution in Haskell is quite clean, I believe.

  fizzBuzz n 
     | n `mod` 15 == 0 = "FizzBuzz"
     | n `mod` 3  == 0 = "Fizz"
     | n `mod` 5  == 0 = "Buzz"
     | otherwise       = show n

  main = mapM_ (print . fizzBuzz) [1..100]
I agree with you about generalizing pattern matching for less simple cases. Your example brought to mind view patterns, about which Oliver O'Charles had a nice writeup recently [1]. Nifty little extension.

[1] https://ocharles.org.uk/blog/posts/2014-12-02-view-patterns....

Re: Streem – a new programming language from Matz

#136
post #125

Can someone help explain what's going on here: \"([^\\\"]|\\.) \" [seen here in context]( https://github.com/matz/streem/blob/master/src/lex.l#L49 ). Now it seems to be finding literal strings (so "strings" e.t.c.). That would explain the literal double quotes on either side. so without that we get: ([^\\\"]|\\.) so zero or more repeating versions of [^\\\"]|\\. What I don't understand is why there is the explicit or…

Because if there's a \ you want to skip over the next character, even if it's a ", but if it's not escaped then you want " to be the end of the string.

You're completely right, I think I had read it as \. rather than \\. and thus didn't understand it. Thanks for helping me get it straight in my head.

Re: Streem – a new programming language from Matz

#137
post #43

Earlier quoted context omitted.

just because 15 HAPPENS to be a concatenation of the output of 3 and the output of 5 today doesn't mean it will be tomorrow. If I said "say Fizz for multiples of 3, Buzz for multiples of 5, and 'this is a silly coding problem' for multiples of 3 and 5 then you'd have to rewrite your code. Some of us know that clients ALWAYS change their minds, specs are rarely equivalent to the end result, and code against future cha…

For any implementation you can manufacture an example which will require a person to re-structure their code. Additionally, using %15 is not DRY. If the spec changes from saying "Fizz" on multiples of 3 to saying "Fizz" on multiples of 4, then you will have to also update 15->20. If you forget to do this, you have a bug. The correct implementation is dependent on the problem's context, and such context is not availab…

Part of my point (which i obviosuly didn't communicate well) is that Fizz concatenated with Buzz is a premature optimization. It's the developer taking advantage of a linguistic coincience. The instructions are to output 3 different strings based on %3, %5, or %3 and %5. I have never seen a set of fizzbuzz instructions that actually specified that the last option should be a concatenation of the 1st two. It's always specified as a 3rd string that people independently notice is a concatenation of the two.

Re: Streem – a new programming language from Matz

#138
post #93

Earlier quoted context omitted.

Personally I like it and find it clear. Compare: ary.map(_ * 2) ary.map(x => x * 2) "_" is perhaps an ugly choice of character (frankly I'm not sure why Scala is so obsessed with it, since it's used for so many featurse), but I think the semantics are sensible. Of course, in a more functional language you could perhaps just write ary.map(* 2)

What about a middle ground on swift's syntax? Arr.map { $1 * 2 }

That was going to be my suggestion too. With the added benefit that is supports multiple arguments.

Re: Streem – a new programming language from Matz

#139
post #26

Earlier quoted context omitted.

I suppose it's a style issue as to whether an extra mod is better than checking if one of the triggers has passed. I would propose it's more DRY to do it the short way though.

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.

In some languages you can hide the extra check:

for i in range(1,100):print("Fizz"(i%3==0) + "Buzz"(i%5==0) or i)

Re: Streem – a new programming language from Matz

#140
post #109

Interesting that he chose a C-like syntax after going the complete opposite direction with Ruby.

Huh? Ruby also has a C-like (algol derived) syntax. The replacement of "}" with "end" etc, is a trivial replacement, not a different type of syntax. Lisp, Prolog, etc, would be a non-C syntax.

Obviously you can flatten this inheritance tree any way you like, but while all C-likes are obviously algol-likes I do think it's useful to consider C-like a distinct branch within that.

That said I think you probably want more than just curly braces to define C-like even then.

Post reply on HN