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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Usefulness of inventing programming languages

125 点作者 emilis_info大约 14 年前

11 条评论

onan_barbarian大约 14 年前
This particular instance is a little grotesque (tables? really?), but I salute the imagination involved.<p>It's at least _possible_ that we might be able to program with something that isn't ASCII art. That doesn't mean that we have to do down the loony 'try to program with pictures' approach, just that flat ASCII text isn't always that fantastic. I'd love, for example, to be able to select exactly what a comment refers to and ensure it doesn't get 'orphaned'. I'm also pretty convinced that the world of graphic design may offer some tasteful-yet-extremely clear assistance in resolving things like multiple nested blocks or brackets/parens...<p>Text, IMO, is still king, but it'd be nice to see a little imagination and experimentation in this area rather than the reflexive howling about how if someone touches the Sacred Holy Text File we won't be able to use all our other textual utilities from the 1970s and how it's all just a slippery slope leading to UML "Programming for Managers" systems. :-)
评论 #2484880 未加载
wccrawford大约 14 年前
I don't see it mentioned often, and I expected to see it here but didn't:<p>Writing harder code makes you better at writing easier code.<p>It's easy to continue at your same level and just go forever, not improving. If you challenge yourself, even on a project that doesn't matter, your code at lower levels will improve automatically. The lessons you learn from coding harder things will translate into better coding all around.
blahedo大约 14 年前
Interesting for its exploration of the idea of programming languages expressed in something other than linear text.
评论 #2484757 未加载
St-Clock大约 14 年前
The idea of using a table to represent a function implementation was proposed by Parnas, but in the context of software documentation.<p>This is quite nice if you can choose which function to represent with a table (as opposed to having to represent all functions as tables).<p>A recent publication on this:<p>Parnas D., Document based rational software development, Journal of Knowledge-Based Systems, 22(3):132-141, 2009. <a href="http://dx.doi.org/10.1016/j.knosys.2008.11.001" rel="nofollow">http://dx.doi.org/10.1016/j.knosys.2008.11.001</a>
评论 #2486425 未加载
julian37大约 14 年前
Regarding programming with tables, see also Subtext: <a href="http://www.subtextual.org/" rel="nofollow">http://www.subtextual.org/</a>
Peaker大约 14 年前
"It looks to me that dictionaries or mapping variable names to their values fit into this definition."<p>This is indeed similar, but a dictionary is a function with an enumerable domain. A function may not have an enumerable domain.
keyle大约 14 年前
I'm all for writing more readable code. Why hasn't pseudocode won ages ago?
评论 #2484501 未加载
评论 #2484723 未加载
bhrgunatha大约 14 年前
2 bottles of beer on the wall, 2 bottles of beer.<p>Take one down and pass it around, __1 bottles__ of beer on the wall.<p>Oops. This bug is more to do with not taking enough care over the problem, rather than the language. I <i>do</i> like pattern matching for arguments - it's a great feature of Haskell, but I suspect writing tables makes it more trouble to express than some other notation.
评论 #2486346 未加载
russellperry大约 14 年前
Anyone who thinks programming with tables is a neat idea hasn't had to write a complex Windows Installer/MSI deployment.<p>The horror...the horror...
评论 #2484755 未加载
scott_s大约 14 年前
<i>This raises some interesting questions. E.g. why this does not work: [1,2,3].map({2:4}) (in JavaScript)?</i><p>It seems obvious to me why, but the author's question made me realize that I couldn't immediately express <i>why</i> that's not possible. The glib answer is that it doesn't make any sense, but that's not very useful. I think what is more fundamental is that JavaScript, and most other languages, have separate concepts of data and code. A dictionary is data, a function is code.<p>Forgive me that I don't know JavaScript, so I'm going to switch to pseudo-Python for my examples.<p><pre><code> def f1(n): if (n == 2): return 4 return null f2 = {2:4} </code></pre> I said pseudo-Python because in real Python, when I query a dictionary for a value that is not there, it throws an exception. In my pseudo-Python, I'm going to assume that it just returns null. If we assume that, then f1 and f2 can be used to get the same result, even thought they have to called in different ways:<p><pre><code> res1 = f1(2) res2 = f2[2] </code></pre> Both res1 and res2 will have the value 2. In that way, dictionaries can be seen as a kind of function. I'm going to posit that the main reason we don't treat them the same in most languages is efficiency and simplicity. Dictionaries can only represent a limited number of functions - functions with integral and finite inputs. Even so, it will often be quicker to write a closed-form function than to write the full dictionary for a task. For example, if you want an entity that given an <i>N</i> between 1 and 1000 it will return to you the sum of all numbers from 1 to <i>N</i>, it is much easier to just say that this quantity will be <i>N</i>(<i>N</i> + 1) / 2 than it is to exhaustively list all options from 1 to 1000. (Of course, the dictionary could not represent if we wanted something that could handle arbitrarily large <i>N</i>.)<p>Going back to the author's question, if we assume that question was asked with this pseudo-Python, and we could query dictionaries in the same way as functions, then the answer would be [null, 4, null]. Is that useful? I'm not sure. But perhaps there is value in unifying how we call functions and how we query a dictionary. That is, if I give it a value, and it returns a value, it should be invisible to me whether it's a function or a dictionary. I know I can achieve this in C++ with operator overloading, and I think Python gives mechanisms for me to define classes that can behave like this, but there is still a fundamental difference in the language.<p>Lisps, of course, don't have the data-code divide, so querying a data structure and calling a function can look the same. But it's interesting to note that other languages don't have to make the two look different, but they do.<p>Finally, <i>[2,3] + [1,4] gives a string "2,31,4" in JavaScript, but shouldn't this produce [2,3,1,4] (which is equivalent to Array.concat([2,3], [1,4]))?</i><p>In most languages I'm familiar with, you will <i>not</i> get a string, but instead a concatenated list. I think that fact is a byproduct of the fact that JavaScript was designed for use in browsers. To the author, try exposing yourself to more languages. What you observe there is a quirk of JavaScript, not all programming languages.
评论 #2486047 未加载
评论 #2485339 未加载
评论 #2485582 未加载
zandorg大约 14 年前
In about 1988, I tried to write a language named after me, in Microsoft BASIC on a Sharp MZ-700 (creaky 8-bit computer). I didn't get very far.