News for hackers. Stuff that matters.
Re:Mars: a hybrid imperative-declarative higher-order language by Thiz on Tuesday July 08, 2014 @08:41AM (#8004217)
I hate the double colon, it's so unpythonic.

I believe the 'as' keyword would be more smooth:

    def hello(name as String) as String:
        var greeting as String
        greeting = 'Hello '+name
        return greeting
Re:Mars: a hybrid imperative-declarative higher-order language by jimktrains2 on Tuesday July 08, 2014 @08:45AM (#8004233)
This isn't Python. :: is common in many languages, especially functional ones (which aren't just using it as a scope resolution operator).
Re:Mars: a hybrid imperative-declarative higher-order language by pdabbadabba on Tuesday July 08, 2014 @09:20AM (#8004380)
Not sure what place "unpythonic" has as a criticism of a language other than Python. (As a matter of personal taste, I too prefer "as." Probably because I do most of my work in Python. But who cares?)
Re:Mars: a hybrid imperative-declarative higher-order language by seanmcdirmid on Tuesday July 08, 2014 @09:47AM (#8004476)
I personally use "is" in my own pythonic language (name is string), "as" sounds like coercion rather than being constraining.
Re:Mars: a hybrid imperative-declarative higher-order language by chton on Tuesday July 08, 2014 @09:56AM (#8004507)
I believe it the usage of 'as' comes from the idea that whatever value the variable contains, it should be seen AS and present itself AS the type you're supplying. It doesn't need to be a string, it just needs to act 'as' a string.
Re:Mars: a hybrid imperative-declarative higher-order language by neurobro on Tuesday July 08, 2014 @05:55PM (#8006928)

    Function hello(ByVal name As String) As String
        Dim greeting As String
        greeting = "Hello" + name
        Return greeting
    End Function
Re:Mars: a hybrid imperative-declarative higher-order language by chton on Tuesday July 08, 2014 @09:43AM (#8004468)
Even that isn't smooth enough for me. Why is the 'var as' still there? it's superfluous, ofcourse we're declaring a variable, there's nothing else that makes sense at that point. Why not:

  def hello(String name) as String:
        String greeting
        greeting = 'Hello '+name
        return greeting
which is how a lot of other languages are doing it. On the other hand, maybe I just don't like writing syntax that doesn't add any meaning :p
Re:Mars: a hybrid imperative-declarative higher-order language by seanmcdirmid on Tuesday July 08, 2014 @09:59AM (#8004523)
C style type annotations that put type before name were never as elegant as pascal style annotations that put name before type. They are also more consistent.
Re:Mars: a hybrid imperative-declarative higher-order language by chton on Tuesday July 08, 2014 @10:07AM (#8004561)
elegance is debatable, and consistency is a matter of how the rest of the language is built. But you can still eliminate the superfluousness (is that a word?) by using

  greeting as String
or even

  greeting :: String
Either is fine, though my preference would then go to the latter option, since it'll be faster when scanning.
Re:Mars: a hybrid imperative-declarative higher-order language by scott_s on Tuesday July 08, 2014 @10:29AM (#8004657)
Having a language keyword which means "we are now defining a new variable" makes parsing easier, and you run into less ambiguity. See: http://en.wikipedia.org/wiki/Most_vexing_parse
Re:Mars: a hybrid imperative-declarative higher-order language by chton on Tuesday July 08, 2014 @10:42AM (#8004719)
Ambiguity in the language is a whole problem of its own. Ambiguity in parsing is also ambiguity in writing, so a language should avoid it all cost. It's true that forcing actions to come with extra words is a way to do that, but it's by no means the only one. It's possible to strive for non-ambiguity without extra syntax.

A good example of this case would be Java (like it or not):

  String Hello(String name) {
    String greeting;
    greeting = "hello " + name;
    return greeting;
  }
Say of the braces and the semicolons what you will, but the core syntax is unambiguous and doesn't have a single word that doesn't have semantic meaning.
Re:Mars: a hybrid imperative-declarative higher-order language by scott_s on Tuesday July 08, 2014 @10:49AM (#8004754)
I was exclusively talking about parsing ambiguity.

Using a keyword to introduce entity definitions (variables, functions, packages, etc.) gives the language more space to grow in syntax without worrying about such ambiguities later. You can construct a grammar without any ambiguities that does not use such keywords - such as with your example of Java - but you're going to have to keep this pitfall in mind anytime you change the grammar.

Re:Mars: a hybrid imperative-declarative higher-order language by chton on Tuesday July 08, 2014 @11:07AM (#8004847)
That's true, it does make it easier to evolve the syntax. The negative side of demanding a terse syntax is clear enough in the C# 6 changes (http://msdn.microsoft.com/en-us/magazine/dn683793.aspx), which are really showing a lot of bloat.

It's possible to debate the positive side too, but I do agree that constructing a language with a verboser non-semantic grammar is easier.

Re:Mars: a hybrid imperative-declarative higher-order language by scott_s on Tuesday July 08, 2014 @11:27AM (#8004945)
For things like "var" and "def", I'm coming to see them as a smidgen of up-front verbosity to prevent much later monstrosities.
Re:Mars: a hybrid imperative-declarative higher-order language by seanmcdirmid on Wednesday July 09, 2014 @06:50AM (#8008967)
You are completely ignoring error recovery, which these days of language-aware IDEs is much more important than optimal conciseness.
Re:Mars: a hybrid imperative-declarative higher-order language by mborch on Tuesday July 08, 2014 @09:49AM (#8004480)
While definitely superfluous, it arguably makes it easier to read and scan.
Re:Mars: a hybrid imperative-declarative higher-order language by chton on Tuesday July 08, 2014 @09:52AM (#8004492)
I think that's a matter of habit. I've gotten far more used to the more condensed syntax, so for me that's faster to read and scan. I tend to prefer languages where there is little syntax wasted as a consequence.
Re:Mars: a hybrid imperative-declarative higher-order language by pdabbadabba on Tuesday July 08, 2014 @11:41AM (#8005026)
ArnoldC or go home.

  LISTEN TO ME VERY CAREFULLY hello
  I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE name
  GET TO THE CHOPPER greeting
  . . .
  ENOUGH TALK
  GIVE THESE PEOPLE AIR
  I'LL BE BACK greeting
  HASTA LA VISTA, BABY
(I have a truly marvelous ArnoldC string library (with string concatenation), which this margin is too narrow to contain.)

Of course, the comparison may not be very illuminating given that all ArnoldC variables are Int16s.

Re:Mars: a hybrid imperative-declarative higher-order language by chton on Tuesday July 08, 2014 @11:53AM (#8005121)
I'll counter your ArnoldC with http://shakespearelang.org/ But only because

  You are as brave as the sum of a fat little stuffed misused dusty old rotten codpiece and a beautiful fair warm peaceful sunny summer's day
is pure art.
Re:Mars: a hybrid imperative-declarative higher-order language by rilut on Tuesday July 08, 2014 @09:30AM (#8004419)
Reminds me of Cobra http://cobra-language.com/
Re:Mars: a hybrid imperative-declarative higher-order language by peaton on Tuesday July 08, 2014 @11:48AM (#8005089)
Re:Mars: a hybrid imperative-declarative higher-order language by munro on Tuesday July 08, 2014 @01:16PM (#8005559)
Actually, they could of borrowed from Python 3's type annotation syntax! [1]

    def hello(name : String) -> io String:
[1] http://legacy.python.org/dev/peps/pep-3107/
Re:Mars: a hybrid imperative-declarative higher-order language by seanmcdirmid on Tuesday July 08, 2014 @04:58PM (#8006716)
Colon already means block in Python, overloading it for type annotations (ala pascal) would make the parser more complex and less error tolerant. Besides it is inconsistent, you really want

    def hello(name : string) : io String
The only reason they didn't do that is because colon also means block....