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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: Language proposal - dave

24 点作者 qixxiq大约 13 年前

9 条评论

evincarofautumn大约 13 年前
What is the advantage of this means of string escaping over strongly typed strings? If there is no implicit way to convert between a String and an XmlString or SqlString or what have you—or if an implicit conversion also correctly handles escaping—then the problem is moot. Look at Yesod, for instance, and how Persistent handles type-safe database access.<p>For those who haven’t seen it, the Programming Language Checklist[1] is worth a read. Forgive me my cynicism, but I don’t see the point of Yet Another Block-Structured Imperative Language. It’s <i>nice</i>, and there’s nothing <i>wrong</i> with it, but nothing really sets it apart, and I for one value innovation more highly than remixing.<p>[1] <a href="http://colinm.org/language_checklist.html" rel="nofollow">http://colinm.org/language_checklist.html</a>
评论 #3817358 未加载
评论 #3817406 未加载
tikhonj大约 13 年前
Here are a couple of my random thoughts, mostly based on preference rather than anything objective.<p>First--try to make the language as small as possible and as extensible as possible. This means that print should be a normal function rather than a statement and you should be able to add your own types of string encoding.<p>The ?: operator seems identical to || in JavaScript; I am not sure why you want to have it.<p>I think having functions return the value of their last statement by default (e.g. making the return keyword optional) makes writing code in a more functional style simpler.<p>In this same vein, you should have a nice and compact lambda syntax--one of the most annoying things with JavaScript (a language I happen to really like) is that even the simplest of anonymous functions is long, which makes certain types of code harder to read. I personally like Haskell's style (where \ x -&#62; x is the same as function (x) { return x } in JavaScript), but anything short would work.<p>If everything else uses curly brackets, why does the for loop have a colon? I think you'd find this[1] post by Brendan Eich about braces interesting.<p>[1]: <a href="http://brendaneich.com/2010/11/paren-free/" rel="nofollow">http://brendaneich.com/2010/11/paren-free/</a><p>Have you considered using Haskell's syntax for comprehensions over Python's? I find the former easier to read and it's more extensible. Where in Python you would write [x for x in xs if x &#62; 10], in Haskell you would write [x | x &#60;- xs, x &#62; 10]. This doesn't look much different, but is easier to read in more complex cases. The Haskell syntax can also be used for what they call "parallel list comprehension" which act like a zip rather than a cross product. (So zipWith fn xs ys would look like [fn x y | x &#60;- xs | y &#60;- ys] while the normal version would be [fn x y | x &#60;- xs, y &#60;- ys].)<p>As far as object oriented features go, if you like JavaScript's approach, take a look at Lua's tables.They're similar to but more flexible than JavaScript's objects.<p>Something like pattern matching or at least "destructuring assignment"[2] would be nice as well. This makes certain types of code <i>much</i> easier to read and write.<p>[2]: <a href="https://developer.mozilla.org/en/New_in_JavaScript_1.7#Destructuring_assignment_%28Merge_into_own_page.2Fsection%29" rel="nofollow">https://developer.mozilla.org/en/New_in_JavaScript_1.7#Destr...</a><p>Overall, I like your idea and wish you luck implementing it.
serichsen大约 13 年前
I don't understand the attractiveness of "no-semicolon" in the sense of "a statement/expression ends at a line end, except if ...", with some arbitrary rules replacing "...". This seems to be a current trend. Why can't we have simple, unambiguous syntax with no pitfalls in new languages?<p>I want to point at the start of a statement/expression, ask "where does this end?", and get back a single, general answer, like "at the semicolon" or "at the corresponding closing parenthesis".<p>That is what punctuation is for. Imagine reading an english text with no punctuation, where the author just made sure to end a line wherever he wanted a sentence to end. Do you really want to stop at each line end and have to answer the question whether it ends the sentence?
评论 #3817686 未加载
评论 #3817689 未加载
评论 #3817655 未加载
评论 #3817668 未加载
chubot大约 13 年前
Take a look at ECMAScript quasi-literals -- they are solving the same problem that you're trying to address:<p><a href="http://wiki.ecmascript.org/doku.php?id=harmony:quasis" rel="nofollow">http://wiki.ecmascript.org/doku.php?id=harmony:quasis</a><p><a href="http://www.2ality.com/2011/09/quasi-literals.html" rel="nofollow">http://www.2ality.com/2011/09/quasi-literals.html</a><p>I think they are going further because they can do auto-escaping. From what I see of your language, you still have to do html:"$var". What happens if you mis-type the prefix? Do you get incorrect escaping and a security hole? Some web devs won't even <i>know</i> what language they're writing in.<p>FWIW I don't think it's worth building an entire language around this concept. It's a feature, not a language. I think using Python plus a template language with good escaping basically solves the problem.<p>Also, it would be weird if html: and sql: are built in to the language -- that should be a layer on top of a smaller language (just like quasi-literals).<p>Also, a server-side language with special escaping support doesn't seem compelling, because these days you would want special escaping support on the client too. I'm not sure of the status of quasi-literals, but if they make it into V8 then Node.JS will have this feature on the server.
indutny大约 13 年前
Have you seen Candor: <a href="https://github.com/indutny/candor" rel="nofollow">https://github.com/indutny/candor</a> ? I think I'm trying to accomplish pretty same thing as you're.
xd大约 13 年前
Your article begins by linking to anti-PHP articles that are 6-8 years old .. You might want to start by bringing your research up to date.
karterk大约 13 年前
I really think you should consider using a shorter identifier than <i>function</i>. <i>def</i>? Or take the dart approach.
评论 #3817646 未加载
评论 #3817653 未加载
tszming大约 13 年前
What is the point of using "var" declaration in your language?
评论 #3817559 未加载
septerr大约 13 年前
why is it called dave?