News for hackers. Stuff that matters.
Re:Why Perl 6 is different by prog on Tuesday April 20, 2010 @08:44AM (#1279259)
I use Python as my primary scripting language but I spent some time looking at Perl 6 in the context of Parrot and it really has a lot of good ideas that post mentions:

  - multi-methods
  - rules (builtin parsing capability)
  - macros
  - and a whole bunch of other good stuff.
I really made me want to use Perl6 and Parrot. That said the only reason I couldn't what perhaps the same reason I use Python over Perl5. I somehow couldn't get myself to go with such a _rich_ syntax. But if Perl5 is your thing then Perl6 is something that you will definitely like.
Re:Why Perl 6 is different by stcredzero on Tuesday April 20, 2010 @08:59AM (#1279278)
The industry as a whole errs too much on the side of syntax as the focus of the community. Syntax should fade out of the way. It should be infrastructure, not features. Libraries are the proper object of focus. Libraries can be modified, forked, debugged without dividing a language community. Doing that to a programming language syntax weakens and divides such communities. In contrast, those actions on libraries actually strengthen programming language communities.
Re:Why Perl 6 is different by loup-vaillant on Tuesday April 20, 2010 @10:26AM (#1279460)
Syntax has two problems: (1) it is the most visible thing in programming languages, and (2) there is only one per language.

I believe we should be able to modify, fork, or debug syntax the same way we do libraries. So what about a syntax meant to be read by computer instead of by humans?

    # Factorial example, machine syntax
    fac
      -> int int
      \
        0 -> 1
        n ->
          *
            n
            - n 1
It could be displayed in human readable form by an IDE or converted back and forth by suitable preprocessors:

    -- Factorial example, Haskell syntax
    fac :: int -> int
    fac 0 = 1
    fac n = n * fac (n - 1)

    // Factorial example, C syntax
    int fac(int 0) { return 1; }
    int fac(int n) { return n * fac(n - 1); }
No more quibbling over prefix vs infix, curly braces vs indentation, familiarity vs terseness… That would take a flame war away from language design and put it where it belongs: the IDE.
Re:Why Perl 6 is different by jerf on Tuesday April 20, 2010 @11:19AM (#1279623)
I've seen some people try this. It has problems once you extend past Ye Olde Factorial Example. Try converting larger chunks of syntax and it rapidly develops that you are quite obviously just putting different skins on the same semantics and it also quite rapidly becomes clear that having multiple skins is a disadvantage, not an advantage. All putting a new language in a skin that looks more "familiar" to you does is fool you into programming Old-Language-in-New-Language; you really need the syntactic differences to remind you that you are not in OldLanguage.

Try translating at the deeper semantic level and you also discover that you basically can't. The C-semantic equivalent of the Haskell is closer to a for loop, and even that isn't an exact match. (An exact match probably involves "goto".) Non-trivial examples just explode in complexity, and that's long before you get to useful code.

This is in the class of "things that have been possible for decades but haven't taken off for good reasons", right up there with the purely-visual languages and other classic "good ideas".

Re:Why Perl 6 is different by stcredzero on Wednesday April 21, 2010 @01:48AM (#1281487)
The "syntax as infrastructure" idea has been around in many moderately successful incarnations. (Lisp and Smalltalk, to name a couple.) Another way to think of this: shift Syntax into Meta-syntax, so it gets out of the way of the libraries.

No need for "syntax skins" in that case.

Re:Why Perl 6 is different by loup-vaillant on Tuesday April 20, 2010 @04:30PM (#1280504)
> you are quite obviously just putting different skins on the same semantics

That was exactly my intention. Translating "at the deeper semantic level" is reserved for actual compilation. Now you may be right about syntax being useful for differentiating languages. My stance right now is that we should try (or look at the failed attempts you speak of, do you have any link?).

Testing my idea will require quite a bit of work: I need to write a compiler and an IDE with some kind disciplined editing. I also will have to bootstrap all this stuff, so it passes the minimum credibility threshold. If I ever get to this point, I will (at last) be able to test my language for actual (f)utility.

Re:Why Perl 6 is different by gruseom on Wednesday April 21, 2010 @12:44AM (#1281421)
What a great comment: deep, suggestive, and a pleasure to read from start to finish. I just read it three times.
Re:Why Perl 6 is different by jimbokun on Tuesday April 20, 2010 @10:43AM (#1279508)
I'm pretty sure the C example will not compile with a C compiler.

Which may seem like a nit, but the reason is because the semantics of Haskell and C are extremely different. Furthermore, the semantics strongly influence the design of the language. In Haskell, whitespace denotes function application, because the most common thing to do in Haskell is to apply a function. C has semicolon delimited statements, because imperatively executing statements one after the other is a very common thing to do in C programs. In Haskell, you cannot guarantee the exact order in which things happen without going to great lengths (monads, etc.).

In short, I don't think offering a skinnable syntax buys much, and is likely to just generate greater confusion.

Re:Why Perl 6 is different by loup-vaillant on Tuesday April 20, 2010 @04:05PM (#1280451)
Of course it won't compile with a C compiler. It wasn't meant to. I just invented a C-like syntax for pattern matching. I had to, so it could be translated to the machine version, which will be compiled. (As you may have guessed such a compiler doesn't exist —yet.)

On the benefits of skinnable syntax: look at C++, Java, and Javascript. They have two things in common: their popularity, and their syntax. Coincidence? I think not. By stealing the syntax of C, they build on it's original success.

I painfully know that C syntax isn't suited to functional code with gazillions of nested function calls. However, this is a known syntax. It makes learning far easier (or at least looks that way, so people are actually willing to try).

Re:Why Perl 6 is different by eru on Tuesday April 20, 2010 @11:05AM (#1279580)
> C has semicolon delimited statements, because imperatively executing statements one after the other is a very common thing to do in C programs.

Actually that would be an argument for making newlines delimit statements, like in, say, Python. Instead of requiring extra work by the programmer.

Re:Why Perl 6 is different by pyre on Tuesday April 20, 2010 @08:44PM (#1281044)
Why? "imperatively executing statements one after the other" does not imply that they have to be on different lines.
Re:Why Perl 6 is different by loup-vaillant on Wednesday April 21, 2010 @03:05AM (#1281559)
They don't have to, but they are, most of the time. Knowing that, "newline as delimiter" yields the lightest syntax.
Re:Why Perl 6 is different by eru on Wednesday April 21, 2010 @10:58AM (#1282332)
Plus optional semicolons to put some on the same line as in Python.
Re:Why Perl 6 is different by moe on Tuesday April 20, 2010 @10:44AM (#1279516)
Congratulations, you have just invented... the compiler. ;-)

More seriously though:

Interestingly of the two languages that come close to this model - lisp with minimal syntax and perl with very flexible syntax - one remained in academic obscurity while the other became wildly popular.

Re:Why Perl 6 is different by astine on Tuesday April 20, 2010 @12:51PM (#1279914)
You're comparing apples to oranges with Lisp to Perl based on popularity. Perl came on the scene just as Lisp was beginning to lose ground to Unix. They grew up in different worlds. Even then, Lisp never languished in academic obscurity. It was, for a while, very popular in the marketplace.
Re:Why Perl 6 is different by lispm on Tuesday April 20, 2010 @02:37PM (#1280215)
Wait, Lisp is a programming language. Unix is an operating system. Category error?
Re:Why Perl 6 is different by tsuraan on Tuesday April 20, 2010 @03:06PM (#1280293)
I think he's referrring to the old Lisp Machines, which were in direct competition with the UNIX machines for a while. I recall reading some old rant about the new-fangled UNIX machines by a die-hard Lisp machine hacker a long time ago (can't find it now). There was something in it about how amazingly quickly a UNIX machine could boot, which was good, since it had to do so rather often.

EDIT: it's the preface to the UNIX haters handbook, of course. A copy is up at http://www.art.net/~hopkins/Don/unix-haters/preface.html

Re:Why Perl 6 is different by lispm on Tuesday April 20, 2010 @03:36PM (#1280369)
Lisp Machines were never that much in direct competition with UNIX machines as such. They were competing with UNIX + LISP. Research labs who programmed in Lisp bought Unix systems plus a Lisp environment (like Allegro CL) or bought a Lisp system (like Allegro CL) for their existing Unix environment. But Unix systems were used for quite different things than Lisp programming or running Lisp apps.

When Lisp Machines lost in the market, the Lisp users moved to UNIX + Lisp. Companies like Franz and Harlequin/LispWorks that came from that market still exist today.

Lisp was always used on different systems. When Lisp Machines were 'popular' (we are talking about less then ten thousand machines that were ever build and sold), Lisp was used on Windows, Macs, Mainframes, Unix and other operating systems.

I should also mention that almost all Lisp Machines were single user personal workstations - initially specially aimed mostly at AI programmers.

Re:Why Perl 6 is different by DannoHung on Tuesday April 20, 2010 @11:17AM (#1279617)
Sounds like what Charles Simonyi has been trying to do for the last two decades with Intentional Programming.

Of course, I couldn't make heads or tails of the small demos they've given.

Re:Why Perl 6 is different by lispm on Tuesday April 20, 2010 @02:22PM (#1280176)
Lots of things are human readable. Chinese for example.
Re:Why Perl 6 is different by arohner on Tuesday April 20, 2010 @05:07PM (#1280598)
Libraries are heavily influenced by the semantics of the language they're written in / designed for. It's quite easy to see this in the Clojure community today, by Java libraries are good from the clojure perspective.

The goodness of a java library has little to do with syntax (because clojure can easily call any java library), but semantics. For instance, java commonly uses mutable state. A fundamental principle of Clojure is that data should be immutable. Immutability makes testing easier, it makes parallelization easier. Clojure was built to make pmap easy. If I have a java library where I have to remember that Foos are thread-safe, but Bars are not, that adds to the incidental complexity of my solution, and reduces my ability to bring Clojure's new tools to bear on the problem.

As another commenter pointed out, syntax of a language is heavily influenced by the semantics of the language. A language starts with a few high level principles, and a favorite hammer or two. The syntax of the language is designed around making those common operations easy. Libraries written in that language will tend to follow those same principles.

Having Java libraries available to Clojure is a huge advantage, but it's not the be-all end-all, because the semantics of those libraries may be incompatible with your new language.

Instead, focus on semantics. Figure out which high level principles are good. What abstractions and design principles result in better, easier to understand solutions? From that follows your libraries and syntax.

Re:Why Perl 6 is different by torial on Tuesday April 20, 2010 @10:12AM (#1279421)
While I agree in general thrust with your focus on infrastructure -- one may argue that a lot of improvements of ignoring language have occurred. .Net allows for multiple languages on a single infrastructure, I believe Java VM does as well, and there is Parrot too.

I do think that there is a healthy focus on syntax -- at least my own experience bears it out. It was the syntax of doing things the python way that allowed me to grok polymorphism and MVC despite programming in an OO language for .Net for years. I find that if I want to learn a concept, the syntax is extremely helpful. I also find that if I have to program quickly, syntax being close to how I think is also helpful, and will get frustrated having to make yet another translation of my thought into a syntax that wasn't well thought out. I would also bet that a lot of people find a different syntax to intuitive, and others counter-intuitive than I do. And I'm fine w/ that! Just because there is difference doesn't mean there has to be division!

Re:Why Perl 6 is different by draegtun on Tuesday April 20, 2010 @09:47AM (#1279370)
And Perl5 already has some of those features:

* multi-methods - There are two implementations on CPAN, Class::Multimethods (old) and MooseX::MultiMethods

* rules - Ditto. Perl6::Rules (old) and Regexp::Grammars

* macros - Have a look at Devel::Declare. Not Perl6 macros but still powerful stuff!

* and a whole bunch of other good stuff - Lots have been backported to Perl5 (direct and into CPAN). For eg. smart match, given/when, Perl6::Junction, Perl6::Gather and also things like Moose & Class::MOP which are heavily influenced by Perl6

Re:Why Perl 6 is different by avar on Tuesday April 20, 2010 @11:53AM (#1279733)
For some value of "already":

* multi-methods: MooseX::MultiMethods and MooseX::Method::Signatures add a lot of overhead to subroutine calls (blogged in http://blogs.perl.org/users/aevar_arnfjor_bjarmason/2010/02/...). Sometimes this doesn't matter, but they're certainly not a replacement for having a native type system. All the magic is done at runtime.

* rules: Perl6::Rules and Regexp::Grammars are both depended on by a grand total of 0 CPAN modules. They're interesting experiments but not something in use, and not a replacement of rules with its "your regex opcodes are a normal method" model.

* macros: Devel::Declare and the B::* modules are usable but they're a long way away from the Lisp model of being able to easily write macros. TryCatch is 800 lines of Perl and C to implement try { ... } catch { ...}. In any Lisp this would be trivially done with a macro in under 50 lines.

As for the other stuff pretty much anything except smart match (which is now in Perl 5 core), Class::MOP and Moose falls under the "neat but some combination of: underused, slow, unstable, epic hack nobody wants to use".

Re:Why Perl 6 is different by mst on Tuesday April 20, 2010 @12:05PM (#1279781)
MooseX::MultiMethod and MooseX::Method::Signatures and MooseX::Declare were apparently slow for the purposes for which you used them.

However I've used them in a number of production applications now and they've never shown up anywhere high on my profiles.

Perl is "very slow" compared to C. That doesn't make it universally a bad idea.

Re:Why Perl 6 is different by jrockway on Tuesday April 20, 2010 @07:52PM (#1280956)
Perl is "very slow" compared to C. That doesn't make it universally a bad idea.

The same could be said of his "epic hack" comment. Everything is an epic hack. Especially Perl.

Devel::Declare is really not that scary.

Re:Why Perl 6 is different by draegtun on Tuesday April 20, 2010 @02:07PM (#1280136)
...list of modules are neat but some combination of: underused, slow, unstable, epic hack nobody wants to use

Thats a sweeping statement. Lets have a look...

* My opinion is only just that. The list is informative to what prior art there is. Always go and test and come to ones own measured conclusion.

* I postfixed old to modules that may have issues.

* Everything else I use and have no issues with (as listed elsewhere in thread)

* Haven't used MooseX::MultiMethods much recently but I do use MooseX::Declare regularly and find this and whole Moose type system a godsend that I couldn't live without now.

* re: Regexp::Grammars is new because its dependant upon 5.10 (replaceable RE engines). So it will have no other modules dependant on it yet but it looks like a worthy successor to the venerable Parse::RecDescent to me.

* re: Devel::Declare - I've already said its no "Perl6 macro" so comparing to a Lisp macro is a tad unfair :)

Hopefully that covers my value of "already" :)

Re:Why Perl 6 is different by autarch on Tuesday April 20, 2010 @12:01PM (#1279761)
Huh, Moose is underused? There a lot of modules on CPAN using Moose, and a lot of modules extending Moose.

Also, in what way is Moose unstable? Moose, and modules which use Moose, are used in production at a lot of places (if you use a recent Catalyst, you're using Moose).

Edit: doh, totally misread the OP's sentence.

Re:Why Perl 6 is different by avar on Tuesday April 20, 2010 @12:10PM (#1279794)
It's not. I was talking about Perl6::Gather, Perl6::Junction etc.: "pretty much anything except smart match [...], Class::MOP and Moose falls under the ... underused".

So Moose is not underused. But some of the other modules that draegtun cited are. It's disingenuous to cite some crazy module Damian wrote that nobody uses as an example of Perl 6 features in Perl 5.

Re:Why Perl 6 is different by draegtun on Tuesday April 20, 2010 @12:46PM (#1279896)
I use MooseX::Declare, Perl6::Gather, Perl6::Junction and Regexp::Grammars in production regularly so on that basis my listing them is totally sincere.

However stating that I'm disingenuous to list them at all... is well a very disingenuous slant directed at me :(

Re:Why Perl 6 is different by Vivtek on Tuesday April 20, 2010 @12:10PM (#1279795)
Not what he said.