News for hackers. Stuff that matters.
Re:Perl 6 Released by 3dfan on Saturday December 26, 2015 @06:05PM (#10795607)
Variable names can contain dashes?

Then how do you know what this means:

    users=users-churn-rate*time
oh, i see ... they are prefixed with $. so it's:

    $users=$users-$churn-rate*$time
Hm... still a bit confusing. But ok. It can be avoided by avoiding dashes in variable names.
Re:Perl 6 Released by pyre on Saturday December 26, 2015 @06:13PM (#10795628)
I could craft you unreadable code in any language. Someone removing all of the whitespace between their operators is not going to be producing code that I want to be responsible for maintaining... in any language.
Re:Perl 6 Released by sirclueless on Saturday December 26, 2015 @11:37PM (#10796427)
Go has an interesting take on whitespace-around-operators -- it starts removing whitespace around binary operators if there are higher precedence operators in the same expression. So, for example, you get:

    x = 2 * y
    x = 2*y + 5
This is pretty readable. In fact I think it is more readable than the usual convention of "spaces around every binary operator," but it would be untenable without the existence of gofmt. The most common argument against a convention like this is, "subtle bugs will be introduced if the actual precedence is different than the one implied by whitespace," which is why it's great to have a benevolent formatting overlord telling you when or not your formatting is consistent.
Re:Perl 6 Released by pronik on Sunday December 27, 2015 @05:56AM (#10797092)
That's why Perl 5 is still an unbeaten champion in terms of managing the complexity of legacy code. Perl::Tidy (and Perl::Critic) is a super-configurable beast to the extent I've not yet seen in other languages.
Re:Perl 6 Released by pyre on Sunday December 27, 2015 @12:11PM (#10798006)
You could probably do something similar in Javascript or Python, there are many tools that provide you access to the AST, it's just that no one has written such a tool on top of it (or maybe they have, but they never gained traction).
Re:Perl 6 Released by pronik on Sunday December 27, 2015 @03:29PM (#10798657)
The funny thing is: most languages have a development philosophy completely opposed to TIMTOWTDI, so they are all trying to write a tool for the one perfect formatting style, not a universal tool with enough flexibility for the different styles. The former usually leads to enough segmentation for every effort to die in its infancy, the latter to Perl::Tidy.

This is especially apparent with Python with its PEP8 standard -- most formatting tools only deal with PEP8 compatibility and only in one direction. Especially with Python, automated code formatting is mistaken for beautification and thus there is a remark in PythonTidy's documentation "Python scripts are usually so good looking that no beautification is required".

I tend to think this is exactly the same thinking that has lead Perl into the mess that's slowly being fixed since about 2005 and I cherish the difference between a language community which has had its painful experience with insufficient tooling and learned from it and the one which hasn't.

Re:Perl 6 Released by pronik on Sunday December 27, 2015 @05:23AM (#10797029)
Having programmed in Perl for a couple of years and later in Python and JavaScript, I really started to appreciate sigils. There is literally no ambiguity about what's a variable name and what not. Things like reserved words (think JavaScript's commonly used 'klass' monstrosity) are just a non-issue in Perl.
Re:Perl 6 Released by zoffix222 on Saturday December 26, 2015 @06:30PM (#10795680)
I found dashes are by far easier to type than underscores and I'd certainly have whitespace between operators in my code, so I'd never run into the problem you describe. It is possible to have variables without sigils and in that case, your first example would be a parse error about undeclared users-churn-rate. Also, apostrophes are valid in variable names as well.
Re:Perl 6 Released by 3dfan on Saturday December 26, 2015 @06:37PM (#10795705)

    your first example would be a parse error about undeclared users-churn-rate
What if users is 10 and churn-rate is 3 and i want to substract the churn-rate from users?
Re:Perl 6 Released by labster on Saturday December 26, 2015 @10:08PM (#10796234)
You can either use U+2212 MINUS SIGN instead of a hyphen, too. Spaces would probably be preferable from a maintenance point of view, though.
Re:Perl 6 Released by JadeNB on Saturday December 26, 2015 @08:01PM (#10795954)
Just use white space! (EDIT: Sorry, I hadn't refreshed for a while, and so didn't see that zoffix (https://news.ycombinator.com/item?id=10795739) beat me to the punch by quite a bit.)
Re:Perl 6 Released by zoffix222 on Saturday December 26, 2015 @06:48PM (#10795739)
Use the space, Luke ;)
Re:Perl 6 Released by mbrock on Saturday December 26, 2015 @06:48PM (#10795741)
That's been a non-issue for Lisp since 1958...
Re:Perl 6 Released by _yosefk on Sunday December 27, 2015 @03:08AM (#10796808)
Lisp is infix though so it's (- some-name other-name), not $some-name-$other-name. I think the former is slightly more readable than (- some_name other_name), while the latter is slightly less readable than $some_name-$other_name.
Re:Perl 6 Released by zoffix222 on Saturday December 26, 2015 @06:49PM (#10795744)
Something I see no one mentioned, dashes (and apostrophes) aren't the only neat thing you can use in term names. You can use other languages too. $контрольная-работа is a valid variable name.
Re:Perl 6 Released by tlikonen on Sunday December 27, 2015 @04:40AM (#10796958)
That's nice. Common Lisp implementations, too, allow any characters in symbol names, even spaces and the empty string. Javascript allows wide character set too. I think it's good that languages break out of [a-zA-Z_-]. That said, I'd use pretty limited charset in internationally developed multi-OS code base. People have different keyboards, input systems, knowledge etc.
Re:Perl 6 Released by collyw on Sunday December 27, 2015 @08:39AM (#10797407)
That's something I wouldn't like to see in source code, as I wouldn't have a clue how to type it. How do Russians see that issue? (Is it Russian?)
Re:Perl 6 Released by zoffix222 on Sunday December 27, 2015 @10:52AM (#10797740)
I think you've missed the point: you can program in your native tongue. I think the expectation is a Russian company would not care whether you can type their variable names :P
Re:Perl 6 Released by xaduha on Sunday December 27, 2015 @09:19AM (#10797499)
Just because you can doesn't mean you should, but Perl isn't a kind of language that's going to stop you.
Re:Perl 6 Released by wtetzner on Saturday December 26, 2015 @06:15PM (#10795635)
...or you could just put whitespace around - when you mean subtract.
Re:Perl 6 Released by Ultimatt on Sunday December 27, 2015 @02:37AM (#10796754)
It's not that common variable names use dash in the wild. Far more common is method names do. In part because of this clash but also to distinguish method names. Also jees use whitespace!! Assuming that was a serious question.