Location>code7788 >text

"Let go of that code and let me!" --The Amazing Journey of the Cursor to Help You Write Code

Popularity:20 ℃/2024-09-22 17:23:40

Let's get right to the point: programming is cool, but it's also torturous. Those long hours staring at the screen, debugging endlessly, only programmers know how sour it is. And just in this world of programming anxiety, theCursorOut of nowhere, with an array of magical features, like a smart wand in your hand, it makes writing code as easy as cooking instant noodles.

Cursor, an AI-based programming assistant that claims to generate code from natural language, automatically fix bugs, and even write documentation for you. How exactly is it made? And how to set off a technological revolution in the programming world? Will it be the ultimate boon for programmers, or will it bring the cold wind of unemployment? Today, let's talk about this amazing AI tool.

I. The past and present life of Cursor

1. The Origins of Cursor: The Rise of the AI Programming Assistant

That said, artificial intelligence has made a big splash in the past decade, from being able to play GoAlphaGoTo the one who can draw.DALL·E, AI is everywhere. But programmers are finding that AI is putting them out of work (well, automation) while at the same time they can't get away from them (well, debugging code). So a team of geniuses thought: since AI can do so many things, why not help programmers save their labor too?

as a resultCursorIt was born, it uses the core technology of AI, especially natural language processing (NLP) and large-scale language models (such as GPT-4), to assist programmers to complete a variety of programming tasks. At first, it could only do some simple code completion and error alerts, which was simply an "efficient retarded assistant". But with the evolution of technology, it becomes smarter and smarter, can accomplish more and more tasks, and gradually upgraded from a "code secretary" to a "programming wizard".
Reproduced with permission from the original source at the beginning of this article: /Sunzz/p/18425390

2. Cursor's Superpower: The Ultimate Weapon for AI Programming Assistants

You may be asking, "What exactly can Cursor do? Will it write my project for me?" Don't worry, it doesn't do the whole thing for you yet, but it definitely saves you a lot of hair.

2.1 Code auto-completion: finally, no need to knock out those annoying details by hand!

Remember those days when you felt your eyes hurt every time you wrote a loop or a function declaration?Cursor solves this problem directly. It automatically completes the code for you based on what you're currently writing. It's like having a smart little helper standing right next to you, watching you code, and saying, "Oh, I see what you're doing! Let me fill in the rest of the code for you!"

Example: you write afor loop, Cursor may have guessed that you wanted to iterate over some array, and then auto-complemented the logic inside the loop. It's like it knows you better than you know you.

2.2 Automated Bug Detection and Fixing: Bug Hunters Out in Force

Cursor is not only an efficient coding assistant, but also a "bug hunter". It can automatically recognize errors in the code and provide suggestions for fixing them. For example, when you write a wrong variable name, Cursor will immediately pop up to remind: "Old iron, here is a problem, help you fix it."

If you've ever missed a comma for half a day without finding it, then you've probably kowtowed to Cursor in gratitude right away.

2.3 Generating code from natural language: a programmer's 'mind translator'

This is one of the killer features of Cursor. It translates your "human words" into "machine words". For example, if you type "I need a function that calculates the sum of the squares of all odd numbers", Cursor will generate code based on your description. Cursor generates code based on your description. Imagine: you no longer need to think up complex logical processes, just say what you need, and the code is immediately presented.

2.4 Code optimization advice: be your programming mentor

Cursor doesn't just help you write code, it helps youWrite better.. It can make code optimization suggestions, show you where you can use more efficient algorithms or more concise syntax, and act like a personal programming mentor, ready to point you in the right direction.

2.5 Automatic Document Generation: The Ultimate Tool to Help You Be Lazy

Cursor automatically generates comments and document descriptions for you. Every line of code you write, it can help you with elegant comments, the perfect solution to the "code as a poem, comments as a grave" situation.

2.6 Multi-language support: no matter what 'programming country' you're in

Cursor is not just limited to one programming language, it supports a wide range of programming languages - Python, JavaScript, Java, C++, you name it, it basically handles the mainstream languages. This means that you can enjoy Cursor's AI magic in any programming language.

Reproduced with permission from the original source at the beginning of this article: /Sunzz/p/18425390

II. Use of Cursor

1. Scenarios for using Cursor: it's used in all corners of programming

1.1 Rapid prototyping: writing code with it is like turning on a gas pedal

When you need to build a product prototype quickly, Cursor can save you tons of time. It automatically generates code and helps you validate ideas quickly. Instead of spending hours building a project from scratch, Cursor helps you generate the underlying logic directly "from scratch".

1.2 Complex project debugging: it is your "detective assistant" in debugging

Debugging code in large projects is a time-consuming and laborious task, and Cursor can automatically find errors and even propose fixes through intelligent analysis. In the face of complex system debugging, it is your most powerful AI "detective assistant".

1.3 The newcomer to programming: it's the mentor that "takes you flying"!

For the uninitiated, Cursor is simply theDream Teacher. Can't write code? No problem, Cursor can translate your natural language descriptions into code. Don't know how to debug? No problem, it automatically helps you find the problems in the code. It not only allows you to quickly get started with programming, but also helps you learn how to optimize your code with half the effort.

1.4 Cross-Language Project: A Multilingual Assistant for Developers

If you're developing a cross-language project, Cursor's multi-language support eliminates the need to re-adapt every time you switch languages. It will help you quickly switch minds, whether it's JavaScript on the front end or Python on the back end.

2. Let Cursor write a dns server

Today we're going to use Cursor to write code and experience whether he's superb or just a little chicken.

1. Download and install

Official website:/

Downloading and installing, registering and logging in are skipped here, so let's save the content for the useful parts.

2. Getting started

I'll just create a new folder MYCURSOR here.

Then Command + i pops up a dialog box.

3. Write a dns server

Enter the function I want him to perform

Write a simple DNS server in python, required features to include.

1. Support query A record, CNAME record.
2. You can set the superior DNS server, such as setting the superior DNS to 223.5.5.5.
3. Read the content from dns_config.txt, if there is no corresponding resolution record in dns_config.txt then go to the higher level DNS server to query, if there is then return the result.
4. dns_config.txt content is formatted as follows:
A 1.2.3.4
CNAME
5. My local IP is 192.168.2.20, request can use for example nslookup 192.168.2.20 for query.

A few seconds later, in a fierce operation he gave an unknown reliable content, and come to enjoy it.

Not only write out the simple_dns_server.py file or give instructions on how to use it.

first edition
 import socket
import struct
import threading
import time
from dnslib import DNSRecord, DNSHeader, DNSQuestion, RR, A, CNAME, QTYPE

# superiorsDNSserver (computer)
UPSTREAM_DNS = '223.5.5.5'
# this localityIP
LOCAL_IP = '192.168.2.20'
# DNSconfiguration file
CONFIG_FILE = 'dns_config.txt'

# retrieveDNSconfigure
def load_dns_config():
    config = {}
    with open(CONFIG_FILE, 'r') as f:
        for line in f:
            parts = ().split()
            if len(parts) == 3:
                domain, record_type, value = parts
                config[(domain, record_type)] = value
    return config

# 查询superiorsDNSserver (computer)
def query_upstream(query):
    sock = (socket.AF_INET, socket.SOCK_DGRAM)
    (5)
    try:
        ((), (UPSTREAM_DNS, 53))
        data, _ = (1024)
        return (data)
    except :
        return None
    finally:
        ()

# deal withDNSrequesting
def handle_dns_request(data, addr, socket):
    request = (data)
    reply = DNSRecord(DNSHeader(id=, qr=1, aa=1, ra=1), q=)

    qname = str()
    qtype =

    dns_config = load_dns_config()
    
    if qtype == :
        if (qname, 'A') in dns_config:
            reply.add_answer(RR(qname, , rdata=A(dns_config[(qname, 'A')])))
        elif (qname, 'CNAME') in dns_config:
            cname = dns_config[(qname, 'CNAME')]
            reply.add_answer(RR(qname, , rdata=CNAME(cname)))
            if (cname, 'A') in dns_config:
                reply.add_answer(RR(cname, , rdata=A(dns_config[(cname, 'A')])))
        else:
            upstream_reply = query_upstream(request)
            if upstream_reply:
                reply = upstream_reply
    elif qtype == :
        if (qname, 'CNAME') in dns_config:
            reply.add_answer(RR(qname, , rdata=CNAME(dns_config[(qname, 'CNAME')])))
        else:
            upstream_reply = query_upstream(request)
            if upstream_reply:
                reply = upstream_reply

    ((), addr)

# main function
def main():
    sock = (socket.AF_INET, socket.SOCK_DGRAM)
    ((LOCAL_IP, 53))
    print(f"DNSserver (computer)运行在 {LOCAL_IP}:53")

    while True:
        data, addr = (1024)
        (target=handle_dns_request, args=(data, addr, sock)).start()

if __name__ == "__main__":
    main()

Instructions for use

4. Accept the content generated by the Cursor

Simply click accept all in the bottom right corner to keep the code

You can see that the file simply_dns_server.py has been saved in the left and right file columns

5. Generate configuration files

Next have him help generate the dns_config.txt configuration

The contents of the document are as follows:

6. Practice is the only criterion for testing the truth

Now it's time to witness the miracle, run the code and test it to see if it works as expected.

Let's start by installing dnslib, which is required by the instructions.

pip3 install dnslib               
Defaulting to user installation because normal site-packages is not writeable
Collecting dnslib
  Downloading dnslib-0.9. (63 kB)
     |████████████████████████████████| 63 kB 63 kB/s 
Installing collected packages: dnslib
Successfully installed dnslib-0.9.25
WARNING: You are using pip version 21.2.4; however, version 24.2 is available.
You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.

Then start the dns server

sudo python3 simple_dns_server.py

Then run nslookup to query the results.

nslookup  192.168.2.20

7. Splashed a pot of cold water

Follow the configuration filedns_config.txtConfiguration in the A 192.0.2.1 should be queried as 192.0.2.1 to meet the expectation, let's try it out

It's obviously not reading what's in the config file, so tell cursor to improve it.

8. Make Cursor face the wall

It is possible that two things have changed in the code since his modification.

Click Accept all to accept the changes

9. The Great Work is Done

Re-run the dns server

sudo python3 simple_dns_server.py

9.1 Then parse the query

This time you can see that the return result is as expected.

9.2 Testing another cname record.

nslookup  192.168.2.20

You can see that the settings in the configuration file are met.

9.3 Query a configuration file for a parsed record that does not exist;

nslookup  192.168.2.20

You can see that when querying for resolution records that don't exist in the configuration, he will query the upper level dns.

At this point, Cursor has completed the code as required.

The final code is as follows:

import socket
import struct
import threading
import time
from dnslib import DNSRecord, DNSHeader, DNSQuestion, RR, A, CNAME, QTYPE

# superiorsDNSserver (computer)
UPSTREAM_DNS = '223.5.5.5'
# this localityIP
LOCAL_IP = '192.168.2.20'
# DNSconfiguration file
CONFIG_FILE = 'dns_config.txt'

# retrieveDNSconfigure
def load_dns_config():
    config = {}
    with open(CONFIG_FILE, 'r') as f:
        for line in f:
            parts = ().split()
            if len(parts) == 3:
                domain, record_type, value = parts
                config[((), record_type)] = value
    return config

# 查询superiorsDNSserver (computer)
def query_upstream(query):
    sock = (socket.AF_INET, socket.SOCK_DGRAM)
    (5)
    try:
        ((), (UPSTREAM_DNS, 53))
        data, _ = (1024)
        return (data)
    except :
        return None
    finally:
        ()

# deal withDNSrequesting
def handle_dns_request(data, addr, socket):
    request = (data)
    reply = DNSRecord(DNSHeader(id=, qr=1, aa=1, ra=1), q=)

    qname = str().lower().rstrip('.')
    qtype =

    dns_config = load_dns_config()
    
    if qtype == :
        if (qname, 'A') in dns_config:
            reply.add_answer(RR(qname, , rdata=A(dns_config[(qname, 'A')])))
        elif (qname, 'CNAME') in dns_config:
            cname = dns_config[(qname, 'CNAME')]
            reply.add_answer(RR(qname, , rdata=CNAME(cname)))
            if ((), 'A') in dns_config:
                reply.add_answer(RR(cname, , rdata=A(dns_config[((), 'A')])))
        else:
            upstream_reply = query_upstream(request)
            if upstream_reply:
                reply = upstream_reply
    elif qtype == :
        if (qname, 'CNAME') in dns_config:
            reply.add_answer(RR(qname, , rdata=CNAME(dns_config[(qname, 'CNAME')])))
        else:
            upstream_reply = query_upstream(request)
            if upstream_reply:
                reply = upstream_reply

    ((), addr)

# main function
def main():
    sock = (socket.AF_INET, socket.SOCK_DGRAM)
    ((LOCAL_IP, 53))
    print(f"DNSserver (computer)运行在 {LOCAL_IP}:53")

    while True:
        data, addr = (1024)
        (target=handle_dns_request, args=(data, addr, sock)).start()

if __name__ == "__main__":
    main()

The contents of dns_config.txt are as follows:

A 192.0.2.1
CNAME
A 192.0.2.2
A 192.0.2.3
CNAME
A 192.0.2.4
A 192.0.2.5
CNAME
A 192.0.2.6
A 192.0.2.7

10. Thinking about it in detail

We gave cursor a total of three sentences, and he generated everything and did what I asked for

First sentence: state my needs.
Second sentence: have him generate the dns_config.txt configuration file.
Third sentence: Give him the error and let him correct it.

Do you think Cursor is powerful and will it replace you one day?

Reproduced with permission from the original source at the beginning of this article: /Sunzz/p/18425390

III. Cursor's impact on the programmer industry: will you lose your job?

With the rise of AI programming tools such as Cursor, many programmers have a realistic concern: "Will this thing replace me?" While Cursor does make coding more efficient, it does not put programmers "out of a job". Instead, it is shifting the way programmers work, and the future is likely to rely more on creative and strategic skills rather than simply writing code.

1 The challenge for junior programmers: the demise of repetitive labor

Sorry, newbie programmers, but AI is a bit "rude". If you are new to the industry, you may be engaged in a lot of repetitive tasks, such as writing template code, implementing simple functions, fixing bugs, etc. These tasks usually do not require much creativity, but rather rely on experience and patience. These tasks usually do not require much creativity, but rely more on experience and patience. These "tedious tasks" are Cursor's strengths.

(for) instance: Suppose you are a newly hired programmer tasked with building a user registration module for the backend of an e-commerce website. Traditionally, you would need to:

  • Write form validation logic
  • Setting up database interactions
  • Realization of checking and processing of input data

And Cursor automatically generates these common modules and logic. Template code that might take you hours to complete, it does in seconds. This means that companies may be able to reduce the number of junior programmers required, as much of the foundational code can already be generated quickly with AI tools.

But don't panic! The opportunity still exists.

The challenge junior programmers face is not that they will be completely replaced, but rather thatCharacters and skillswill need to be redefined. In the future, entry-level programmers will need to get up to speed more quickly on the following:

  • Mastering the use of AI tools: How to work with AI tools like Cursor will become an essential skill.
  • Improve ability to understand business requirements: AI can generate code, but understanding business requirements and translating them into technical implementations still requires human intervention.
  • Cross-cutting knowledgeFor example, you can understand UI/UX design, product development, etc., so that you are not just a "coder" but a developer with diversified skills.

2 Demand for senior programmers on the rise: you need to learn to harness 'magic'

Compared to junior programmers, the outlook for senior programmers is more optimistic. In fact, the widespread adoption of AI tools such as Cursor will accelerate theDemand for Senior DevelopersThe reason. The reason for this is that while AI tools are capable of generating code, the design, architecture, and complex decisions involved in advanced development work still require creative human thinking and experience.

(for) instance: If you are a senior architect in charge of building a large enterprise system with a microservices architecture. You need to consider:

  • System scalability and fault tolerance
  • How to design communication protocols between microservices
  • How to optimize data storage and retrieval

These high-level system design issues, AI can not be replaced. although Cursor can help you quickly generate some basic service logic, but when it comes to performance optimization, cross-team technical collaboration and complex architectural design, you still have to rely on the "magic formula" in your head.

Cursor has become a **"super assistant "** to help you automatically generate some trivial code, so that you have more time and energy to think about the overall architecture of the system, forward-looking technology planning, innovative functional design and other high-level issues.

So instead of being replaced by Cursor, senior programmers will be able to focus more on utilizing their creativity and experience, using AI as a tool to improve development efficiency.

The point is: harness the tools, not be controlled by them.

To do this, senior programmers need to further strengthen their skills in the following areas:

  • Architecture Design Capabilities: Understand the architecture of complex systems, especially the design of systems capable of handling large scale and high concurrency.
  • strategic thinking: Be able to not only write code, but also think about the impact of the code on the overall project, product and business.
  • Deep mastery of AI tools: Advanced programmers need to be able to not only use AI tools, but also adapt and customize them to meet complex needs.

3 The Evolution of Programming Skills: You're Not Just a 'Coder', You're a 'Technical Conductor'

The role of the programmer will change significantly in the future as AI tools become more commonplace. Programming is no longer simply writing code - more thinking about how to solve problems, how to design complex systems, how to collaborate with machine intelligence. This allows programmers to transform from "code craftsmen" to "technical commanders".

(for) instance: Imagine that instead of sitting in front of a computer and writing lines of code, your role is now like that of a conductor, assigning different AI tools to handle various parts:

  • Let Cursor generate code
  • Let another AI tool do the code review
  • You're responsible for putting all the modules together into a complete system.

In this context.Evolution of Programming SkillsVery critical:

  • Strategic systems thinking: The programmer of the future needs to know not only how to write code, but also how to design and control the technical strategy as a whole.
  • Problem solving skills: AI tools can help you generate code, but they won't solve all the problems you face - especially those challenges involving deep business logic and complex algorithms.
  • Cross-team collaboration: As AI tools become more popular, development teams will focus more on designing and implementing innovative features. How to work closely with designers, product managers and even AI tools will become an important part of the development work.

Transformation of skills: mastering the convergence of AI and technology

Programmers need to learn not only programming languages, but how to coexist and work with AI. One of the core skills of the future isHow to seamlessly integrate AI tools into your own workflownotice from

In summary: Impacts and opportunities for Cursor

Ultimately, Cursor and other AI programming tools present not only challenges, but a wealth of opportunities. While junior programmers may face some level of stress, the future will see an influx of more advanced development needs and more work focused on strategy, architecture, and complex problem solving.

The role of the programmer will not disappear with AI, but will become more creative and valuable.CursorIt's not a "replacement" for programmers, but an additional tool in their "toolbox". Mastering how to dance with AI tools will become the core competitiveness of every programmer in the future technology world.

So don't worry about losing your job, the key is how to use AI tools to become smarter and more efficient, and to always be learning and evolving in the midst of new technology waves.

Why don't you give it a try?Cursor? Let it fly with you and feel the magic of AI programming assistant!