TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Pyret: A new programming language from the creators of Racket

396 点作者 sergimansilla超过 11 年前

30 条评论

terhechte超过 11 年前
&quot;&quot;&quot;Pyret makes testing a natural part of the programming process. Functions can end in a where: clause that holds unit tests for the function. These assertions are checked dynamically.&quot;&quot;&quot;<p>Fantastic idea! I&#x27;ll keep that in mind, should be fairly easy to extend Lisps or other AST-Macro enabled languages (Elixir, Julia, Python) with such a functionality. I really like that. It makes it easy to work on a function and code tests down without switching contexts (files, workspaces, etc)
评论 #6701872 未加载
评论 #6701837 未加载
评论 #6701906 未加载
评论 #6701921 未加载
评论 #6701796 未加载
评论 #6702478 未加载
评论 #6702122 未加载
评论 #6701917 未加载
评论 #6701860 未加载
评论 #6701871 未加载
评论 #6701875 未加载
评论 #6701787 未加载
评论 #6702470 未加载
tbenst超过 11 年前
I took CS019 with Shriram a few years back and immediately guessed the authors based on paradigms like making testing a natural part of the language and the encouragement to use annotations. In the class, we were taught a design process for Racket that will work very well for Pyret:<p>1. Identify the data - create data definitions (You are gixen x and expected to produce y)<p>2. Write concrete examples of the data (This is hard and takes time)<p>3. Write contract, purpose, header for functions (contract and header are annotations in Pyret, purpose should be a commented statement)<p>4. Write concrete examples of the function (This is hard and takes time. This means test cases!)<p>5. Write the template (This may only apply to recursion in Racket, but the idea is if you&#x27;re dealing with a cons, you always have the same structure of checking if a cons? or empty? and must recur)<p>6. Fill in the template (ie, complete the function)
评论 #6702723 未加载
评论 #6704238 未加载
gizmo超过 11 年前
Pyret looks like a there&#x27;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 <i>less</i> 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.<p>Cool? Yup! Good for teaching? Probably not.<p>Take a look at the grammar and judge for yourself: <a href="https://github.com/brownplt/pyret-lang/blob/master/src/lang/grammar.rkt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;brownplt&#x2F;pyret-lang&#x2F;blob&#x2F;master&#x2F;src&#x2F;lang&#x2F;...</a>
评论 #6702581 未加载
评论 #6702086 未加载
评论 #6701891 未加载
评论 #6704873 未加载
评论 #6703834 未加载
评论 #6703416 未加载
评论 #6702037 未加载
评论 #6701869 未加载
评论 #6701902 未加载
评论 #6702638 未加载
takikawa超过 11 年前
Pyret has lots of nice ideas, looking forward to see it evolve.<p>That said, the title of this post is a bit misleading so I wanted to correct it. The group of people who develop Racket and Pyret are mostly disjoint. I&#x27;m not trying to diminish Pyret at all, but wanted to make sure the right people get the credit. You can find out who develops Pyret here: <a href="http://www.pyret.org/crew/" rel="nofollow">http:&#x2F;&#x2F;www.pyret.org&#x2F;crew&#x2F;</a>
tinco超过 11 年前
Why the superfluous syntax? I think remembering syntax like this is orthogonal to the goal of being easy to learn.<p>The syntax is basically Ruby + Python + Haskell. Each of those languages has a lighter, more intuitive and memorable syntax.<p>Why would the syntax be:<p><pre><code> data BinTree: | leaf | node(value, left, right) end </code></pre> Instead of just<p><pre><code> data BinTree = leaf | node(value, left, right) </code></pre> The whole colon thing in Python is a mistake, it should have never been in Python, and it definitely not be repeated in other languages..
评论 #6701870 未加载
评论 #6702741 未加载
评论 #6701833 未加载
评论 #6701897 未加载
zem超过 11 年前
I really love the surface design decisions taken here. Particularly<p>* ML-like syntax for algebraic datatypes and matching. ML got it right; it always seems a bit off when languages try to make ADTs look like some other syntactic construct<p>* the cyclic and graph declarations<p>* accessing datatype variants using an OO-like syntax. simply brilliant.<p>* non-significant whitespace. for all the pros and cons, autoindenting is something i hate to give up.
tel超过 11 年前
Python-like syntax with pattern matching and recursive ADTs!? What a great idea!
评论 #6702157 未加载
评论 #6704276 未加载
mageofmath超过 11 年前
I also like the fact that you can put unit tests for helper functions that are inside of other functions. This means you can use the inputs to your outer function as part of the tests for an inner function, which has been hard to do in the past.
评论 #6708405 未加载
klrr超过 11 年前
This project seems really promising, but I got one concern. Lisp&#x27;s syntax have been one of its strength for beginners. Easy to learn, easy to solve common errors. I don&#x27;t see the point of having Python-like syntax really, the user could learn other syntax after they&#x27;ve understood <i>programming</i>.
评论 #6702641 未加载
评论 #6701866 未加载
评论 #6703929 未加载
评论 #6701936 未加载
kazagistar超过 11 年前
Somehow, it looks a lot more like lua with a bunch of type-checks and tests added then like python. No named parameters, no generators, no comprehensions that I can see, no focus on iteration in general, no significant indentation, etc.<p>Instead: &quot;end&quot; syntax, unified number type, all blocks produce new scopes (not just functions), local variables are explicit instead of default, etc.
评论 #6703130 未加载
评论 #6703197 未加载
b6fan超过 11 年前
The Ruby examples are unfair.<p>Ruby intentionally makes parenthesis optional. So `do_something` is `do_something()`.<p>For the first example,<p><pre><code> - 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] </code></pre> And for the lexical scope thing,<p><pre><code> def f(x) g = -&gt;y {x + y} g[2] end f(2) </code></pre> Or, explicitly use class variables,<p><pre><code> def f(x) @x = x def g(y); @x + y; end g(2) end f(2)</code></pre>
评论 #6705206 未加载
colanderman超过 11 年前
I can&#x27;t find any documentation on the type system. In particular, I&#x27;m interested in how objects are typed (that they&#x27;re both structurally typed and may be abstract is novel), and the capability of the type refinements.<p>I 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.)<p>I don&#x27;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&#x27;t need language support, and (b) you probably need to key off of more than one column.<p>The &quot;method-as-fun&quot; semantics seem weird. Given this code:<p><pre><code> o = { x(self): self.y end, y: 10 } f = o.x </code></pre> f() returns 10, as per the examples on the front page. But then:<p><pre><code> p = o.{y: 15} q = { x: o.x, y: 15 } </code></pre> Clearly p.x() should return 15, but what does q.x() return? It doesn&#x27;t seem clear whether it should return 10 or 15. (Without reading through the reference manual (it&#x27;s late), my guess would be that method definition is special-cased, so that the answer would be 10.)
评论 #6706417 未加载
jdnier超过 11 年前
&gt; Most “scripting” languages don&#x27;t support annotations for checking parameters and return values<p>PEP 3107 introduced function annotations to Python 3. The following syntax is valid:<p><pre><code> &gt;&gt;&gt; def square(n: int) -&gt; int: ... return n * n ... &gt;&gt;&gt; square(3) 9 </code></pre> Nothing is done with annotations by default. Here&#x27;s an article discussing this &quot;unused feature&quot;: <a href="http://ceronman.com/2013/03/12/a-powerful-unused-feature-of-python-function-annotations/" rel="nofollow">http:&#x2F;&#x2F;ceronman.com&#x2F;2013&#x2F;03&#x2F;12&#x2F;a-powerful-unused-feature-of-...</a>
评论 #6704062 未加载
kolev超过 11 年前
I lot more Ruby-like than Python. Not sure why it both has &quot;:&quot; and &quot;end&quot; and the &quot;|&quot; is kinda ugly the way it&#x27;s used.
kerryritter超过 11 年前
This doesn&#x27;t seem like it would be easy for novices to grasp, though it looks like a solid language. For teaching, I think Quorum (<a href="http://www.quorumlanguage.com" rel="nofollow">http:&#x2F;&#x2F;www.quorumlanguage.com</a>) seems like a stronger alternative (disclosure, I am a member of a CS senior project team building their web system).
progman超过 11 年前
Pyret looks very promising. Keep on the good work!<p>But please remove the minus sign from identifiers! I am concerned that people may abstain from Pyret for this simple reason. It is really annoying to embrace every operator with blanks. That should be an optional job for the IDE to increase readibility.<p>By the way, is there already a raco exe for Pyret?
评论 #6708267 未加载
garysweaver超过 11 年前
&gt; Most “scripting” languages don&#x27;t support annotations for checking parameters and return values<p>I coded in Java for many years and Ruby for the last several, the lack of explicit type checking in method signatures or via annotations built into Ruby has not gotten in the way enough where I felt I needed to add something to decorate methods to do some generic form of type checking in Ruby. When I really need to check the type of an object sent into a method, it is typically a method that can handle different types, and in that case, I&#x27;ll use respond_to?(...) to see that an object passed in as an argument responds to a method, use a case statement, is_a?(...), etc. but that is certainly not on every method- probably more like 1 in 20-30 methods.<p>Also, in the comparison section of the doc, OCaml and Python were represented, but not Ruby. As of late 2013, there are more jobs containing &quot;Ruby&quot; in the job description than &quot;OCaml&quot;: <a href="http://www.indeed.com/jobtrends?q=ocaml%2C+ruby&amp;l=" rel="nofollow">http:&#x2F;&#x2F;www.indeed.com&#x2F;jobtrends?q=ocaml%2C+ruby&amp;l=</a> So, imo it should give Ruby some love with a comparison.
评论 #6704706 未加载
jimktrains2超过 11 年前
Mostly OT: I&#x27;ve been working on the spec for a lang I&#x27;d like to implement at some point and would like feed back if anyone cares to give any?<p><a href="https://github.com/jimktrains/k5" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jimktrains&#x2F;k5</a>
dragonbonheur超过 11 年前
Those &quot;new&quot; languages keep looking more and more like BASIC.
评论 #6702445 未加载
lars512超过 11 年前
Incidentally, a Gist for installing Pyret using Marelle:<p><a href="https://gist.github.com/larsyencken/7424864" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;larsyencken&#x2F;7424864</a>
pekk超过 11 年前
Looks more like Ruby than Python, why the comparison to Python?
评论 #6702083 未加载
评论 #6704449 未加载
pcmonk超过 11 年前
I wonder how well this integrates with Racket? I see that it&#x27;s built with Racket, but I&#x27;d be curious if I could mix and match this with all my Racket code.
评论 #6704441 未加载
yashodhan超过 11 年前
dashes in function names! I&#x27;m in love.
JulianMorrison超过 11 年前
This looks like it could be useful as a way to prototype a real program.
fedvasu超过 11 年前
sounds like ML+contracts, but wait is it statically typed? Maybe not Racket folks hate types (with great dredd)
评论 #6710033 未加载
breezydon超过 11 年前
Pyret is so hot these days.
mrcactu5超过 11 年前
it sounds great to blend Python and Lisp!
评论 #6702062 未加载
mcpherson超过 11 年前
functions are fun
kudu超过 11 年前
&gt; end<p>-.-
k_bx超过 11 年前
&gt; Python-inspired syntax for functions<p>&gt; fun to-celsius(f):<p>&gt; (f * (5 &#x2F; 9)) - 32<p>&gt; end<p>Wait a minute..