Earlier quoted context omitted.
The grammar can be described with a single page in actual BNF. Thats AMAZING. The only languages have shorter grammars are core lisp/scheme. Ruby is fundamentally impossible to describe with a BNF.
> Thats AMAZING. The only languages have shorter grammars are core lisp/scheme. It's nice, but I'm not sure I'd go with amazing . Most or all of Niklaus Wirth's languages have shorter grammars, for example. I'd imagine quite a few others do as well. E.g. Oberon-2 has 33 EBNF productions: http://en.wikipedia.org/wiki/Oberon-2_(programming_language) - that fits fully on screen for me with my default font size... Regard…
Pyret: A new programming language from the creators of Racket
191–200 of 288 posts
Re: Pyret: A new programming language from the creators of Racket
#192The Ruby examples are unfair. Ruby intentionally makes parenthesis optional. So `do_something` is `do_something()`. For the first example, - method_as_fun = o.my-method - method_as_fun(5) # not reached + method_as_fun = o.method(:my_method) + method_as_fun.call(5) # or method_as_fun[5] And for the lexical scope thing, def f(x) g = ->y {x + y} g[2] end f(2) Or, explicitly use class variables, def f(x) @x = x def g(y);…
Re: Pyret: A new programming language from the creators of Racket
#193Earlier quoted context omitted.
That same regularity also means there are few guideposts as a student programs, and this makes it much harder to recover from mistakes. We've looked at a lot data on this (and have taught Racket at every level for decades).
If you need guideposts, use an editor with paredit support and rainbow delimiters. This makes Lisp feel far more intuitive and tree-like than normal.
Re: Pyret: A new programming language from the creators of Racket
#194Earlier quoted context omitted.
Syntax is tricky and contentious, and our team members do love our Schemes. Members of the Pyret team have actually done some research on the issue of parenthetical expressions in introductory programming, and seen that parens aren't necessarily the best: http://cs.brown.edu/~sk/Publications/Papers/Published/mfk-va... One issue is that it's too regular: since open-paren means so many different things (start of a "def…
Did you ever do any research/tests/courses with Smalltalk as the first language?
Re: Pyret: A new programming language from the creators of Racket
#195Earlier quoted context omitted.
> Thats AMAZING. The only languages have shorter grammars are core lisp/scheme. It's nice, but I'm not sure I'd go with amazing . Most or all of Niklaus Wirth's languages have shorter grammars, for example. I'd imagine quite a few others do as well. E.g. Oberon-2 has 33 EBNF productions: http://en.wikipedia.org/wiki/Oberon-2_(programming_language) - that fits fully on screen for me with my default font size... Regard…
If you think parsing is the hard part, wait for the semantics. See, for instance, the Ruby examples on the Pyret home page.
Re: Pyret: A new programming language from the creators of Racket
#196Earlier quoted context omitted.
As you wish! We now have two Ruby examples on the home page. You may not call it love. <-:
Thanks, but may want to correct: method_as_fun = o.my-method which should be: method_as_fun = o.my_method and the examples themselves just look a little crazy, imo. Not crazy because of what you are trying to do, but in how you are trying to do it. What was the intent of calling a method that defines an argument without an argument? That's not a problem of the language; that's just an error in coding. There are all k…
However: Some of our programming environment's server infrastructure is built in Ruby (mainly because it has great git support, and we commit all edits to repos). One of Pyret's lead developers spent over a year on a widely-used RoR system. We've given it far more than the old collegiate try. Some of us have lived in it.
If you're happy with Ruby, great! We're not trying to convert you. But there are people who would find the Ruby code we've written "natural" and the resulting behavior thus unnatural.
We've had the same conversation with lots of JavaScript and Python users based on our semantics work (http://cs.brown.edu/~sk/Publications/Papers/Published/gsk-es..., http://cs.brown.edu/~sk/Publications/Papers/Published/pclpk-..., http://cs.brown.edu/~sk/Publications/Papers/Published/pmmwpl...). Some people are appalled, others don't get the point. [This may be correlated with their reaction to Gary Bernhardt's WAT talk.]
But you also don't get partial static type-checking, etc. Again, those are features that don't appeal to you, and that's perfectly cool.
Re: Pyret: A new programming language from the creators of Racket
#197Pyret looks like a there's a lot going on, based on the examples. It has implicit returns, special purpose syntax for data structures, iterators, assertions, refinements, etc. Having support for more stuff makes it less suitable as a teaching language, not more. Pyret looks like a has the good bits of Python plus a whole bunch of other cool stuff. But the language is pretty complex as a result. Cool? Yup! Good for te…
Thanks for your comments! I have two responses: 1. You're right that exposing too much, too soon is a recipe for disaster. People can only fit so many new concepts in their head at once, and blasting them with refinement types from day one isn't a great idea. However, there's two things at work here: the role of the curriculum and the role of the language . Pyret is careful to allow a gradual transition to more and m…
Re: Pyret: A new programming language from the creators of Racket
#198Earlier quoted context omitted.
> Thats AMAZING. The only languages have shorter grammars are core lisp/scheme. It's nice, but I'm not sure I'd go with amazing . Most or all of Niklaus Wirth's languages have shorter grammars, for example. I'd imagine quite a few others do as well. E.g. Oberon-2 has 33 EBNF productions: http://en.wikipedia.org/wiki/Oberon-2_(programming_language) - that fits fully on screen for me with my default font size... Regard…
If you think parsing is the hard part, wait for the semantics. See, for instance, the Ruby examples on the Pyret home page.
The hard part of parsing Ruby is mostly trying to conform to MRI rather than to a formal grammar. In comparison the semantics are reasonably simple.
It's hard to compile Ruby efficiently, though, but for reasons unrelated to those examples.
(Incidentally I don't know if that scoping example is intentionally ignoring the fact that Ruby does support lexical scoping (EDIT: for blocks), or if it's lack of understanding of what what "def" is.
The Ruby way of achieving what that example is trying to do is:
def f(x)
g = proc do |y|
x + y
end
g[2]
end
f(2)
(g[2] is shorthand for g.call(2))"def" explicitly introduced a method-level scope of the innermost wrapping class scope. Nesting 'def's is not in any way idiomatic Ruby. It's not necessarily very useful to nest them given those semantics. But "def" is really just syntactic sugar for #define_method, and so it is logical for it to work where #define_method does.
I might be inclined to agree that the different Ruby ways of defining blocks, methods and closures could do with some simplification. Allowing "def" to bind surrounding variables would remove a lot of the need for class instance variable or class variables, for example. )
EDIT:
Also, the currying example would look like this in Ruby:
o = Object.new
def o.my_method(x)
self.y + x
end
def o.y
10
end
method_as_fun = o.method(:my_method)
method_as_fun[5]
You can argue for implicit currying if you want, but to me that's far more confusing. That said, it is extremely rare to find currying used in Ruby code.Re: Pyret: A new programming language from the creators of Racket
#199Pyret looks like a there's a lot going on, based on the examples. It has implicit returns, special purpose syntax for data structures, iterators, assertions, refinements, etc. Having support for more stuff makes it less suitable as a teaching language, not more. Pyret looks like a has the good bits of Python plus a whole bunch of other cool stuff. But the language is pretty complex as a result. Cool? Yup! Good for te…
The language is in use in introductory courses, with a gradual introduction of these topics. It's no different from using any other modern programming language in education. Our goal is to eventually create language levels, pioneered by DrRacket, based on what we learn from observation. This is a research project in addition to a development one, where the research is into human factors.
Refinement types are nice. I really wish those were more common.
Re: Pyret: A new programming language from the creators of Racket
#200I loathe template-based OO due to the possibility of monkey-patching but the fact that objects are immutable looks like it might ease this. (Generating efficient code might still be difficult.)
I don't see the use cases for the cyclic structure as presented. If your data at all resembles a database relation, then (a) you have scalar keys anyway so you don't need language support, and (b) you probably need to key off of more than one column.
The "method-as-fun" semantics seem weird. Given this code:
o = { x(self): self.y end, y: 10 }
f = o.x
f() returns 10, as per the examples on the front page. But then: p = o.{y: 15}
q = { x: o.x, y: 15 }
Clearly p.x() should return 15, but what does q.x() return? It doesn't seem clear whether it should return 10 or 15. (Without reading through the reference manual (it's late), my guess would be that method definition is special-cased, so that the answer would be 10.)