TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why do our programs need to read input and write output?

40 pointsby nicolapcweek94over 7 years ago

11 comments

dahartover 7 years ago
What&#x27;s the appeal of taking pure functional all the way to an executable tautology? Inputs can be passed around in a pure FP world without reducing purity, so why remove them?<p>We never got around to output at all. Assuming the compiler can&#x27;t write the output file before the program runs, how would you see the result of any program run in this world?<p>What about UI or network input?<p>I&#x27;m imagining that if only the compiler were allowed to do I&#x2F;O, I&#x27;d have to rebuild Chrome whenever I wanted to see a new site, or even see an update to a site, or change my preferences. Wait, scratch that, I can&#x27;t change preferences, because it can&#x27;t save. Is the shell allowed to do I&#x2F;O? What about output to the monitor, does that count? It&#x27;s not a file, but it&#x27;s Turing equivalent to an output file.
评论 #15429017 未加载
评论 #15428993 未加载
maxxxxxover 7 years ago
I don&#x27;t understand the article. It&#x27;s still input and output but in a more convoluted way and therefore better? Reminds me a little of articles you see from time to time like &quot;if-less programming&quot;.
评论 #15428856 未加载
rocquaover 7 years ago
So, I am missing how this would work. Let me pick 2 examples.<p>The first is about networking. How would I build, say, an http server in this thing? From the rest of this thread, it seems like you would advocate essentially a separate compiler for networking, and to &#x27;read&#x27; from a socket, you just import. That seems like you are moving a lot of complexity to the world of compilers.<p>Moreover, I don&#x27;t see any way to then &#x27;write&#x27; to that socket. Does the compiler essentially take a return value of main and then say &#x27;well, guess this is what I want to send back&#x27;. That would suggest you can&#x27;t do something like &#x27;recieve handshake&#x27; &#x27;send handshake&#x27; &#x27;receive request&#x27; &#x27;respond to request&#x27;. It seems to block interspersing input with output.<p>My second example is a gui. It feels to me like your program couldn&#x27;t in any way define the interface layout. All it could do is &#x27;receive&#x27; and &#x27;issue&#x27; events. It would take a specialized compiler, and a whole separate mark-up language to actually define the interface. How do you change the interface in response to input?<p>I love pure code, and see the value in pushing the boundary of pure code as close to the edges as possible. However, code still needs side-effects to be useful, and I&#x27;d like to specify those side-effects in the same language as I specify my pure code. I&#x27;d like to decide for myself how far out to push the boundary of purity.
评论 #15429196 未加载
评论 #15429200 未加载
hexmilesover 7 years ago
Like others i do not understand this article.<p>It seem to propose an abstraction where we separate the I&#x2F;O part from the &quot;elaboration&quot; part of a programs, so that our programs are entirely pure. But i don&#x27;t understand why the import system and why only the compiler can read and write?<p>Why can&#x27;t we have the same benefits by using multi-threading&#x2F;process? we can have &quot;pure&quot; thread and &quot;i&#x2F;o&quot; thread that communicate with message passing? i feel like I&#x27;m missing something from the article.
评论 #15429310 未加载
Etheryteover 7 years ago
Perhaps I simply didn&#x27;t understand the argument, but doesn&#x27;t this simply move reading and writing to a different abstraction? Perhaps someone can reword the author&#x27;s point, I feel like I&#x27;m missing something here.
评论 #15428520 未加载
tree_of_itemover 7 years ago
Excellent, I&#x27;ve actually been working on something similar and I&#x27;m glad to see it validated.<p>As I expected though, most people in this thread don&#x27;t get it, which is understandable since it&#x27;s pretty out there compared to the mainstream. I think they will once larger, &quot;real&quot; programs are written.<p>I don&#x27;t think I&#x27;m gonna be able to &quot;reword&quot; this for people here so it suddenly clicks, you&#x27;re probably just going to need to see it in action to understand it.
评论 #15428978 未加载
评论 #15428977 未加载
dredmorbiusover 7 years ago
Dismissing inputs for the moment: if you cannot write or transmit outputs, how does your program actually perform anything. If your answer is &quot;side effects&quot;, you&#x27;ve merely redefined the term &quot;outputs&quot;.<p>As I see it, you&#x27;d have to have a program which was supplied its input, by the compiler, was evaluated by the compilier, and had its output imputed, by the compiler. You&#x27;ve only shifted the problem of input and output sanitisation elsewhere.
评论 #15431249 未加载
robgibbonsover 7 years ago
How would this IO model affect, say, Unix piping on the command line?
mcnamaratwover 7 years ago
My favorite part is that injecting an attacker&#x27;s code would not cause a security problem, because the platform is immune to side effects.
评论 #15429275 未加载
millstoneover 7 years ago
Say the user clicks somewhere in my program’s window. How does my program discover the location of the click without reading some input?
评论 #15429168 未加载
tosstossyover 7 years ago
I want my five minutes back.