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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Tell HN: I asked ChatGPT to build a login form in React and it gave me the code

172 点作者 jerrygoyal超过 2 年前
I asked OpenAI chatGPT to &quot;build a login form containing email, password, and login button in React using state&quot; and it gave me the full code along with an explanation. You can see the video of the prompt and response: <a href="https:&#x2F;&#x2F;cln.sh&#x2F;X4p01n" rel="nofollow">https:&#x2F;&#x2F;cln.sh&#x2F;X4p01n</a><p>I thought Copilot was fairly advanced, but this chatGPT takes it to a whole other level. What are your thoughts?

38 条评论

romanhn超过 2 年前
Prompt: <i>create a rap song about a guy named Roman writing .NET APIs</i><p>Sure, here is a possible rap song about a guy named Roman writing .NET APIs:<p><pre><code> Verse 1: I&#x27;m Roman, and I&#x27;m a code king I write .NET APIs, and I do my thing I&#x27;ve got Visual Studio on my screen Writing code that&#x27;s clean and lean Chorus: Roman, Roman, writing .NET APIs Roman, Roman, coding all day Verse 2: I&#x27;m a master of C#, no doubt I write APIs that always work out I&#x27;m a whiz with classes and objects too I can handle any challenge that comes my way Chorus: Roman, Roman, writing .NET APIs Roman, Roman, coding all day Verse 3: I&#x27;m a pro with ASP.NET and Web API I can build a server in a jiffy I know my way around REST and JSON I can make your data flow like a river Chorus: Roman, Roman, writing .NET APIs Roman, Roman, coding all day Verse 4: I&#x27;m a rockstar with Azure and the cloud I can make your apps run smooth and proud I&#x27;m a wizard with microservices and containers I can help your business grow and prosper Chorus: Roman, Roman, writing .NET APIs Roman, Roman, coding all day. Outro: Roman, Roman, the .NET API man Writing code that&#x27;s always in demand Roman, Roman, the code hero Writing .NET APIs for the win.</code></pre>
评论 #33826349 未加载
评论 #33833800 未加载
jw1224超过 2 年前
ChatGPT blew my mind this morning — I was struggling with a regex, so asked it to help me.<p>Here&#x27;s how it went: <a href="https:&#x2F;&#x2F;i.imgur.com&#x2F;PS6oPsq.png" rel="nofollow">https:&#x2F;&#x2F;i.imgur.com&#x2F;PS6oPsq.png</a><p>A pretty incredible developer experience, if you ask me!
评论 #33819582 未加载
评论 #33820976 未加载
评论 #33830145 未加载
评论 #33821680 未加载
评论 #33825603 未加载
评论 #33821073 未加载
satvikpendem超过 2 年前
I&#x27;ve done the same thing, first thing I tried with ChatGPT: <a href="https:&#x2F;&#x2F;imgur.com&#x2F;a&#x2F;d8LZicq" rel="nofollow">https:&#x2F;&#x2F;imgur.com&#x2F;a&#x2F;d8LZicq</a><p>Prompts:<p>- Write a simple CRDT implementation in Swift<p>- How can I make a GraphQL server using Rust using the async-graphql and actix-web libraries?<p>- Write code to create a Dropbox clone in Rust<p>- How do I make an HTTP request in Javascript?<p>However, just like with Copilot, it can introduce subtle bugs. For example, in the Dropbox example, notice how it uses synchronous code in an async function. Also, longer prompts will reach the token limit and get cut off.<p>Interestingly, this must be what Replit is also using for their AI codegen service too (<a href="https:&#x2F;&#x2F;replit.com&#x2F;site&#x2F;ghostwriter" rel="nofollow">https:&#x2F;&#x2F;replit.com&#x2F;site&#x2F;ghostwriter</a>) since I believe they have some connection to OpenAI, as they got early access to OpenAI&#x27;s service last year with their previous Codex product (<a href="https:&#x2F;&#x2F;blog.replit.com&#x2F;codex" rel="nofollow">https:&#x2F;&#x2F;blog.replit.com&#x2F;codex</a>).
评论 #33820120 未加载
评论 #33826694 未加载
评论 #33820242 未加载
patwolf超过 2 年前
I asked it a question about how to do something with dates in the .NET Entity Framework, and it give me a long explanation with code of how rowversion is used for optimistic concurrency control. Completely unrelated to what I was asking.<p>I did ask it something more basic: &quot;how to use fetch to download and parse a csv&quot;, and the code was helpful, although not much different from what I could find with google&#x2F;stackoverflow. However, this next part was what really impressed me. The results used Papa for parsing, so I then asked it to do it with csv-parse instead, and it worked! That seems like the advantage over something like Copilot--it has contextual history of the question which can be used conversationally to tweak the results.
评论 #33819728 未加载
评论 #33819719 未加载
评论 #33826809 未加载
tmaly超过 2 年前
This makes me wonder if the tech jobs or the future will fall into two camps:<p>1. those that can specify concise requirements for the AI<p>2. those that can check correctness of the code the AI generated.
评论 #33819906 未加载
评论 #33819613 未加载
评论 #33821408 未加载
评论 #33819897 未加载
nonameiguess超过 2 年前
I highlighted your prompt and clicked web search from the context menu and got this out of DuckDuckGo: <a href="https:&#x2F;&#x2F;www.educba.com&#x2F;react-login-form&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.educba.com&#x2F;react-login-form&#x2F;</a><p>It&#x27;s annoying blog spam that will hijack your attempt to scroll back with a modal asking you to enter an e-mail and subscribe, but it seems to be roughly the same thing, except the entire article appeared at once and I didn&#x27;t need to interact with it and wait five minutes for the full answer.
评论 #33819509 未加载
评论 #33819879 未加载
zug_zug超过 2 年前
I feel like I&#x27;ve mostly seen these AIs produce code on things that are mostly just copy-paste examples (login, fibonacci, primes). From a theoretical standpoint I&#x27;m only impressed if it&#x27;s combining things to do achieve something that has no code example on the internet.<p>From a practical perspective I do think a lot of programmers are doing copy-paste in their day jobs, which means they should be reusing existing code (I would imagine there are numerous reusable customizable login forms).<p>---<p>For example I asked it this:<p>Can you write a javascript function that takes a callback and returns the value of that callback, but returns a cached value if that function has been called less than 5 seconds ago?<p>And it produces code that looks right but doesn&#x27;t work (doesn&#x27;t handle arguments, failing its own example implementation). However, upon reminding it to support arguments it does work. I guess this is actually potentially useful.
评论 #33822311 未加载
评论 #33842103 未加载
评论 #33843788 未加载
ilaksh超过 2 年前
Since I found out about this last night I have already used it to do most of the work of three (relatively simple) programming tasks in bash and JavaScript. One of them was a simple class needed to prevent skipping&#x2F;reusing numbers in some process that multiple users were accessing (and could sometimes fail). The other was adding up and deleting some temp files in my specific directory structure. And then there was a certain way that I wanted to add a duration to a date and format it.<p>For a few of them it made a small error of one line that I had to fix. But also in a few cases I was able to just reply that there was a bug and what it was doing incorrectly and to fix it, and it worked.<p>It gave me code that was very specific such as using the methods as I named and described them in the request for the class.
quonn超过 2 年前
It really depends on what you want to do. I just told it to build a React-like framework in Prolog. It first told me that&#x27;s not possible because Prolog can&#x27;t be used to build GUIs (not really true either). I then told it that it could just output the DOM manipulations as text and it agreed. But said it&#x27;s just a text model and can&#x27;t write programs.
CJefferson超过 2 年前
I tried asking it some programming questions -- I found if I asked it things that I was likely to find lots of copies of (or similar things), it did quite well. As soon as I asked it something a bit more unusual, even if the program was quite small, it broke.<p>One easy way of catching out is to ask &quot;write X in language Y&quot;, where X isn&#x27;t something most people would write in Y -- it usually got it wrong for me.
评论 #33820141 未加载
chironjit超过 2 年前
Just got kicked out of it an hour ago because it&#x27;s too busy now.<p>Been playing with it the whole day - got an idea on how to fix an old bug in an old programme of mine(that is still running).<p>But, here&#x27;s the thing, how good it is depends on the available knowledge out there.<p>I&#x27;ve now tried, js, python, solidity, appscript(not tested the code), Excel and google sheets.<p>When you&#x27;re building common js, python, etc stuff, it&#x27;s really handy to have one screen that basically gives you the answer rather than having to google it, parse through the posts, etc.<p>However, if you&#x27;re on the bleeding edge of tech, or looking for more obscure topics, it really starts showing its limitations.<p>I managed to run into that for example looking for Jupiter notebook commands, optimisations, versioning (giving me python2 results instead of python3 with obsolete&#x2F;unmaintained packages).<p>Its limit is basically what has been created and knowledge already available.<p>Depending on what you&#x27;re building, would suggest understanding what you&#x27;re copy pasting and possible vulnerabilities that may arise from the code.<p>Overall, I&#x27;m sold - defo wouldn&#x27;t mind paying 20 to 40 a month for this. If it&#x27;s pricier, not so sure.
throwawaygo超过 2 年前
This is the new threat vector. AI copy pasta. Gonna make pen test research way more fun. Just describe the website you’re at and read the source code.
评论 #33820725 未加载
Waterluvian超过 2 年前
Glory to Zalgo, it’s finally been solved:<p><a href="https:&#x2F;&#x2F;ibb.co&#x2F;KwGLy9C" rel="nofollow">https:&#x2F;&#x2F;ibb.co&#x2F;KwGLy9C</a>
anupamchugh超过 2 年前
It&#x27;s decent for some results, but almost meaningless in others. I&#x27;d asked it to build a SwiftUI VideoPlayer application which is 5 lines of code. But I got an old solution, and despite giving proper guidance, it failed colossally and printed garbage towards the end.<p>Here&#x27;s my convo with ChatGPT: <a href="https:&#x2F;&#x2F;imgur.com&#x2F;a&#x2F;eIjvh8C" rel="nofollow">https:&#x2F;&#x2F;imgur.com&#x2F;a&#x2F;eIjvh8C</a><p>If the text and code are just random stuff making no sense then I wonder how different it is from the Copilot results (besides the convincing style of answers).
评论 #33826521 未加载
kelnos超过 2 年前
I wonder if this is lifted from a React tutorial, or if it is an amalgamation of other things.<p>The big question is: whose code is this? Is it, verbatim, someone else&#x27;s copyrighted code (assuming a snippet like that is novel enough to be copyrightable)? Or is it derived from someone else&#x27;s code? And if it&#x27;s derived, is it a derivative work in the legal sense, or is it no more derivative than if a human had read a tutorial or some documentation and then later written code like it?
thedangler超过 2 年前
What happens when AI is learning from AI and no new content or advancement in a field is from people? Won&#x27;t it be an eco chamber of recycled content?
评论 #33832048 未加载
CrackpotGonzo超过 2 年前
Genuine question for everyone here: if you were switching careers from a non-technical profession to learning computer science, where would you focus? Do you have any confidence in which skills will be future-proof? Or is everything open to being automated and humans are just biding our time? :)
评论 #33822854 未加载
sasha_fishter超过 2 年前
We just had conversation about this in the company. I think it&#x27;s a good way to give us the code that we know how to write but we waste some time to do that. I.e. I needed function that changes the index of the array, so I asked chatGPT which gave me correct function. I know how to do that but I need some time to think and to test it out. This is just a augmentation of the programming, tools that help us write better code.<p>Maybe it can substitute StackOverflow, we will get better and faster code &#x2F; explanation. But in the next 30-50 years, who knows. I guess it can write a lot of code for us, maybe we will be obsolete in that period of time, but as we know, prediction of the future often times goes really really wrong.
htorsdfd22超过 2 年前
I am stopping all my contributions to github. I dont want myself to be part of unemployed
评论 #33828671 未加载
pedrovhb超过 2 年前
I had a whole discussion with it yesyerday about category theory as applied to asynchronous streams, and it was great. I think if it was a person we&#x27;d both have come out better programmers, but I guess it was just me.
throwjlkjlk33超过 2 年前
ChatGPT has the IP problem with fast inverse square root again, like Copilot did: <a href="https:&#x2F;&#x2F;i.imgur.com&#x2F;BqYSq7C.png" rel="nofollow">https:&#x2F;&#x2F;i.imgur.com&#x2F;BqYSq7C.png</a>
评论 #33822218 未加载
minimaxir超过 2 年前
It should be noted (and admitted in the blog post) that the high-level results from the new GPT-3 text-davinci-003 model and chatGPT should be similar, albeit without fancy syntax highlighting.<p>Well, mostly. I tried the prompt in the OP into text-davinci-003 and got this:<p><pre><code> const handleLogin = (e) =&gt; { e.preventDefault(); &#x2F;&#x2F; check if the email and password are valid &#x2F;&#x2F; perform login console.log(email, password); }; </code></pre> Although that was with temperature = 0.7. temperature = 0.0 gives more reasonable results.
droobles超过 2 年前
I put this prompt in:<p>Write a javascript file using the Express framework in NodeJS containing CRUD routes for a TODO entity that contains a name, a description, and datapoint indicating whether the TODO is completed or not, and connect this entity to the Sequelize module from the npm package manager<p>And it spat out a full tutorial on how to write an express crud app hooked up to Sequelize with SQLLite with Sequelize types and all crud routes, it&#x27;s pretty impressive
egberts1超过 2 年前
Uh? Is it me or this openai website is literally demanding a cellular phone number? Only have a landline number.<p>What is this? I just gave my email. Isn&#x27;t this enough?.
ineedausername超过 2 年前
I&#x27;ve been playing with it, asking it to create a rest api for example for some blockchain testnet etc.<p>My assumptions up until now is that it provides kind of a template result for many things, which you could have searched online. It&#x27;s like a complement to a search engine.
muttled超过 2 年前
Did the code work?
评论 #33819223 未加载
TurkishPoptart超过 2 年前
I would like to use this, but I find it weird that it requires a phone number to use.
yrgulation超过 2 年前
This works wonders assuming all code moving forwards will only be written with tools it was trained against. I imagine it will have no clue how to get berate code for a fresh new framework.
aidenn0超过 2 年前
See also <a href="https:&#x2F;&#x2F;note89.github.io&#x2F;the-advent-of-code-ai-edition&#x2F;" rel="nofollow">https:&#x2F;&#x2F;note89.github.io&#x2F;the-advent-of-code-ai-edition&#x2F;</a>
lofaszvanitt超过 2 年前
Can it find errors though? I mean when people will start to rely too much on a computer brain, not using&#x2F;training their own, they essentially become slaves to this system.
qwertyuiop_超过 2 年前
WITCH companies “consultants” would be avid users of this feature.
chrisgd超过 2 年前
This is awesome. Would be amazing for a tutorial as well. I can code(defined loosely) in python, but seems like this would accelerate learning a new language significantly.
xigoi超过 2 年前
Can someone please try asking it to find proofs for unsolved mathematical conjectures?
candlemas超过 2 年前
Is this why Elon Musk is firing so many programmers at Twitter?
评论 #33992804 未加载
revskill超过 2 年前
This seems like the ideal friend&#x27;s developer, who can intelligently search google for nearly perfect answer.
criddell超过 2 年前
I wonder if ChatGPT could solve a travelling salesman problem?
评论 #33819936 未加载
评论 #33820126 未加载
lzooz超过 2 年前
Does it really generate the text like that, little by little, or is that just a needless animation?
评论 #33819460 未加载
评论 #33819862 未加载
Wronnay超过 2 年前
Wow