首页 > 编程语言 >程序员如何与ChatGPT携手作战

程序员如何与ChatGPT携手作战

时间:2023-04-08 19:34:53浏览次数:31  
标签:word String 携手 程序员 version ChatGPT sha256

黄昏将至,还是黎明到来?


ChatGPT大火,使得程序员对于”35岁危机“的担忧又加一层:如何在35岁之前避免被 AI 淘汰?因为 ChatGPT擅长语言逻辑类的工作,这不正是程序员擅长的事情么?这不是要先革了程序员的命么?哎,人生真难。

实际上,ChatGPT并无意于淘汰任何人,它只是一种更为先进的工具。这种工具会加剧“马太效应“:好的让它更好,糟糕的让它更糟糕。

善于使用新工具的人,将会更加强大;而不善于使用新工具的人,则会慢慢被淘汰。这是无可回避的规律。

ChatGPT 擅长什么,不擅长什么

知己知彼,才能百战不殆。要想知道自己如何不被 ChatGPT淘汰,或者如何更好地与ChatGPT协作,首先得知道 ChatGPT 擅长什么,不擅长什么。

ChatGPT擅长的事情

一言以概之,知识类、信息类、事实类、语言类、逻辑类、经验建议类的工作。

比如,我想写一个 python 并发计数单词的程序,输入”python concurrent count words“, 以下是 ChatGPT 的回答。不仅给出了一段完整的程序,还对程序作出了必要的说明。

Here is an example Python program that counts the occurrences of words in a text file using concurrent programming:

import concurrent.futures

# Define a function to count the occurrences of words in a file
def count_words(filename):
    word_counts = {}
    with open(filename, 'r') as f:
        for line in f:
            # Split the line into words
            words = line.strip().split()
            # Update the word count for each word
            for word in words:
                if word in word_counts:
                    word_counts[word] += 1
                else:
                    word_counts[word] = 1
    return word_counts

# Define a list of filenames to process
filenames = ['file1.txt', 'file2.txt', 'file3.txt']

# Use a ThreadPoolExecutor to process the files concurrently
with concurrent.futures.ThreadPoolExecutor() as executor:
    # Submit a count_words job for each filename
    futures = [executor.submit(count_words, filename) for filename in filenames]

    # Aggregate the results from all the jobs
    results = {}
    for future in concurrent.futures.as_completed(futures):
        filename = future.result()
        for word, count in filename.items():
            if word in results:
                results[word] += count
            else:
                results[word] = count

# Print the final word counts
for word, count in results.items():
    print(word, count)


In this example, we define a function count_words() that takes a filename as input and returns a dictionary of word counts. This function reads the contents of the file, splits each line into individual words, and updates a dictionary of word counts.

We then define a list of filenames to process and use a ThreadPoolExecutor from the concurrent.futures module to submit a count_words() job for each filename. The submit() method returns a Future object, which represents the result of an asynchronous computation.

We use a loop to aggregate the results from all the jobs as they complete. The as_completed() function returns an iterator that yields Future objects as they finish. We extract the filename and word counts from each completed future and update a dictionary of aggregate word counts.

Finally, we print the final word counts to the console using a loop over the results dictionary.

顿时觉得我收集的那些命令、脚本、代码片段,都没啥用了(如果有 ChatGPT随身携带的话)。当然,也不必费尽心思在那些抄来抄去的千篇一律的博文中”徘徊“了。

我曾经想过:有木有一个程序能够帮我来写程序?没想到,在有生之年,这个愿望竟然能够部分实现。

另一个方面是寻求建议,比如:writing suggestions about how to write a technical essays。回答虽然是有点泛泛而谈,但有条有理。

Here are some suggestions for writing a technical essay:

Define your audience: Identify the target audience and tailor your writing style and language accordingly. A technical essay for developers might include more specialized terms than one for non-technical stakeholders.

Choose a specific topic: Select a specific and focused topic that you can cover in sufficient detail. Avoid broad or generic topics that would require a lot of background information and result in a shallow discussion.

Research thoroughly: Gather relevant and reliable sources of information, such as academic papers, books, articles, and reputable online resources. Use different sources to gain multiple perspectives on the topic.

Structure your essay: Start with an introduction that clearly states the topic, purpose, and scope of the essay. Organize the main body into sections or paragraphs that cover different aspects of the topic. End with a summary and conclusion that summarizes the key points and presents your conclusions.

Use clear language: Write in a clear, concise, and organized way. Use simple language and avoid unnecessary jargon or technical terms that may confuse the reader.

Use visuals: Use diagrams, charts, graphs, or other visual aids to illustrate your points and make your essay more engaging. However, make sure they are relevant and add value to the content.

Provide examples: Use real-world examples to demonstrate your points and show how the topic is applied in practice. This will make your essay more relatable and easier to understand.

Edit and review: Review your essay for grammar, spelling, and punctuation errors. Make sure it flows logically and has a consistent tone and style. Consider having someone else read and provide feedback on your work.

By following these suggestions, you can write a technical essay that is informative, well-structured, and engaging to the reader.

ChatGPT 不擅长的事情

ChatGPT不擅长的事情也很明显:

  1. ChatGPT 不善于感知人类所处的语境,因此无法知道全景,很难完整地完成一件事;
  2. ChatGPT 不善于人类沟通,不了解人类所面临处境的深层次的困难,因此,在交流沟通的任务上暂时还未必能发挥充分的作用。比如心理咨询、组织活动等。
  3. 设计复杂的系统和解决复杂的问题。由于复杂的系统和问题都涉及错综复杂的语境,而ChatGPT难以感知这种语境,因此,ChatGPT目前应该是难于解决这些问题的。

因此,ChatGPT目前很难完全取代人类的工作,而是部分地取代。

ChatGPT VS 搜索引擎

ChatGPT 类似一个专家对话系统,能够回答很多问题。它提供问题的答案,这与搜索引擎的功能有点重合。相较搜索引擎而言,它给出的不是大量良莠不齐的待筛选的信息,而是一个足够好的答案。这更像是遵循 python 之禅的一句话:

There should be one-- and preferably only one --obvious way to do it.

它给你一个很好的答案,但这个答案并不一定是唯一的。不能局限于此。因此,合理的做法是:将ChatGPT 和 搜索引擎结合起来使用。简单的问题,使用 ChatGPT 搞定就完了,复杂的问题,要结合 ChatGPT、搜索引擎乃至知识问答网站,不限于一家之言。

ChatGPT对程序员的冲击

ChatGPT对程序员的冲击是巨大的。因为两者擅长的事情有高度的重合度,而且人几乎是无法战胜不眠不休的自动化的且几乎不会犯逻辑错误的不会笔误的机器的。

  • 最先的冲击,来自于对初级程序员的冲击。大概率初级程序员的需求会减少很多。
  • 其次,对高级程序员的冲击也是很强的。ChatGPT使得高级程序员的许多开发经验都快速失效,只能保留那些最精髓的部分。
  • 不会使用ChatGPT的程序员大概率会早早出局,或者做得比较苦。
  • 无论哪个级别的程序员,薪酬都可能会相应地降低。

只有那些掌握 ChatGPT 完成天才般工作的人,才能站在人群之上笑傲江湖。

如何与 ChatGPT 携手作战

切忌与ChatGPT正面作战。更积极的问法是:程序员如何与ChatGPT 携手作战,提升自己的工作效率,让自己工作省心一点?

个人的建议是:

  1. 提升英文读写能力。毕竟,ChatGPT 的训练素材应该更多是基于英文的,对英文语境更熟悉一些。
  2. 练习写好的prompts。借用朋友的一句话:Good prompts produce good results.
  3. 避免简单重复的编码工作。ChatGPT 可以有效地完成简单重复的工作,如果你还只限于做简单重复的编码工作,那必定迟早被淘汰无疑了。这对初级工程师是不利的。他们尚未建立对一个领域的初步的理解,就面临如此强大的对手,心有戚戚然焉!因此,初级工程师要站稳脚跟,不仅要花时间去熟悉一个领域,还需要掌握 ChatGPT 加速自己的工作效率和成长速度。也许,未来工程师的简历会加上这么一句:善于使用ChatGPT提升工作效能。这里的效能,不仅仅指效率,也指创造性。
  4. 综观全局,明确知道自己想要做什么。人类应当努力成为一个任务策划者,而非任务执行者。

辅助编程

最先想到的,就是用 ChatGPT 辅助编程,自动生成代码,尽可能减少手写代码。

比如,generate pojo class named ScriptSampleResultDO, with lombok Getter Setter annotation on class , base on fields of id, md5, sha256, version, detail, status, createTime, updateTime with Field annotation with value of under_line form and sha256 with background Index annotation with collection name of app_ids_script_sample_result . 【提问】

或使用中文:

生成一个 ScriptSampleResultDO 类,字段有 id, md5, sha256, version, detail, status, createTime, updateTime。在类上加 Getter, Setter 注解。 字段上有 Field 注解,有 javadoc 注释,字段不要有 Getter, Setter 注解。sha256 加后台建索引,updateTime 加3个月过期索引, createTime 为 13 位 Long 型。这个类对应的表名为 app_ids_script_sample_result(定义成 ScriptSampleResultDO static 变量 COLLECTION_NAME)。加后台复合索引 status 正序, createTime 倒序,索引名类似 idx_索引名_1_索引名_-1。【提问】

ChatGPT 会自动生成类如下。注意,我并没有告诉它要对应 mongo 数据库啊,也没说要生成 Java 类,它却自动生成了与 mongo 数据库字段对应的 pojo Java 类。

以下是符合要求的 ScriptSampleResultDO 类:

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.index.IndexDirection;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.Date;

/**
 * Represents a record in the "app_ids_script_sample_result" collection.
 */
@Getter
@Setter
@Document(collection = ScriptSampleResultDO.COLLECTION_NAME)
@CompoundIndexes({
        @CompoundIndex(name = "idx_status_createTime", def = "{'status': 1, 'createTime': -1}")
})
public class ScriptSampleResultDO {

    /**
     * The name of the MongoDB collection that this class maps to.
     */
    public static final String COLLECTION_NAME = "app_ids_script_sample_result";

    /**
     * The unique identifier of the script sample result.
     */
    @Field("id")
    private String id;

    /**
     * The MD5 hash value of the script sample.
     */
    @Field("md5")
    private String md5;

    /**
     * The SHA256 hash value of the script sample. This field is indexed for faster querying.
     */
    @Indexed(background = true)
    @Field("sha256")
    private String sha256;

    /**
     * The version string of the script sample.
     */
    @Field("version")
    private String version;

    /**
     * Additional detail about the script sample.
     */
    @Field("detail")
    private String detail;

    /**
     * The status of the script sample result.
     */
    @Field("status")
    private String status;

    /**
     * The timestamp when the script sample result was created, in Unix time (milliseconds since epoch).
     */
    @CreatedDate
    @Field("create_time")
    private Long createTime;

    /**
     * The time when the script sample result was last updated. This field is indexed with a 3-month expiration time.
     */
    @LastModifiedDate
    @Indexed(name = "idx_updateTime_ttl", expireAfterSeconds = 7889230)
    @Field("update_time")
    private Date updateTime;
}

基于 ScriptSampleResultDO 生成一个查询类,根据 sha256 version 查询 【提问】

import lombok.AllArgsConstructor;
import lombok.Data;
 
@Data
@AllArgsConstructor
public class ScriptSampleResultQuery {
 
    private String sha256;
 
    private String version;
}
 
上述代码使用了 Lombok 的 @Data 注解和 @AllArgsConstructor 注解,在编译时自动生成了字段的 getter 和 setter 方法以及带参数的构造函数。您可以使用这个类作为参数来执行查询,例如:
 
ScriptSampleResultQuery query = new ScriptSampleResultQuery("my-sha256", "1.0");
List<ScriptSampleResultDO> results = mongoTemplate.find(Query.query(
        Criteria.where("sha256").is(query.getSha256())
                .and("version").is(query.getVersion())
), ScriptSampleResultDO.class);
上述示例中,ScriptSampleResultQuery 类的实例 query 包含了要查询的 sha256 和 version 值。在执行查询时,我们将这个对象传入查询条件中,并使用 Spring Data MongoDB 提供的 mongoTemplate 执行查询操作。

基于 ScriptSampleResultDO 和 ScriptSampleResultQuery 生成对应的 Service , ServiceImpl, Repository, RepositoryImpl 【提问】

以下是基于 ScriptSampleResultDO 和 ScriptSampleResultQuery 自动生成的 Service、ServiceImpl、Repository 和 RepositoryImpl:
 
ScriptSampleResultService.java:
 
public interface ScriptSampleResultService {
    List<ScriptSampleResultDO> findBySha256AndVersion(String sha256, String version);
}
ScriptSampleResultServiceImpl.java:
 
@Service
public class ScriptSampleResultServiceImpl implements ScriptSampleResultService {
 
    private final ScriptSampleResultRepository repository;
 
    @Autowired
    public ScriptSampleResultServiceImpl(ScriptSampleResultRepository repository) {
        this.repository = repository;
    }
 
    @Override
    public List<ScriptSampleResultDO> findBySha256AndVersion(String sha256, String version) {
        return repository.findBySha256AndVersion(sha256, version);
    }
}
ScriptSampleResultRepository.java:
 
@Repository
public interface ScriptSampleResultRepository extends MongoRepository<ScriptSampleResultDO, String> {
 
    List<ScriptSampleResultDO> findBySha256AndVersion(String sha256, String version);
}
ScriptSampleResultRepositoryImpl.java:
 
public class ScriptSampleResultRepositoryImpl implements ScriptSampleResultRepositoryCustom {
 
    private final MongoTemplate mongoTemplate;
 
    @Autowired
    public ScriptSampleResultRepositoryImpl(MongoTemplate mongoTemplate) {
        this.mongoTemplate = mongoTemplate;
    }
 
    @Override
    public List<ScriptSampleResultDO> findBySha256AndVersion(String sha256, String version) {
        Query query = new Query();
        Criteria criteria = Criteria.where("sha256").is(sha256).and("version").is(version);
        query.addCriteria(criteria);
        return mongoTemplate.find(query, ScriptSampleResultDO.class);
    }
}

三句话,绝大部分模板代码都自动生成了,省去了好多力气。你还可以“喂”给它模板代码,让它仿照这个模板生成新的代码(来自同事的实验)。这可有效减少项目中的重复代码开发。

除了自动生成代码,还可以请它帮忙Review代码,指出代码中存在的问题,它会给出修改后的代码让你审阅。

辅助学习和面试

比如我输入 ”how to interview a candidate understanding of distributing cache“,以下是 ChatGPT 的回答:

To assess a candidate's understanding of distributed cache, you can ask them the following questions:

1. What is caching, and why is it important for application performance?
2. What are the benefits of using distributed cache over local cache?
3. How does a distributed cache work, and what are some common implementation models?
4. Can you explain the concept of consistency models in distributed systems, and how they relate to distributed cache?
5. How do partitioning and sharding help improve performance and scalability in distributed cache systems?
6. What are the trade-offs between read-intensive and write-intensive caching workloads, and how might you design a distributed cache system to handle each type of workload?
7. Have you worked with any specific distributed cache technologies or frameworks? If so, can you describe your experience with them?
8. Can you discuss any challenges you've faced when implementing or scaling distributed cache systems in the past, and how you addressed those challenges?
These questions should help you gauge the candidate's knowledge of distributed cache concepts, implementation strategies, and real-world considerations. Additionally, you may consider providing hypothetical scenarios or technical assessments to evaluate the candidate's problem-solving skills and ability to apply their knowledge to practical situations.

这要真按照它的指示来提问啊,十年工作经验的工程师也未必不被难倒啊!反过来思考呢,我们完全可以根据它的指示来进行学习和作面试准备呢!

ChatGPT可以用来协助排查问题和总结知识,比如输入”reasons why redis reading timeout“,回答:

There are several reasons why Redis may experience read timeouts:

Network latency: If the Redis server is located in a different network or data center, it may take longer for data to be transmitted over the network, resulting in slow response times and potential timeouts.

Blocking commands: Some Redis commands, such as BLPOP, BRPOP, and BRPOPLPUSH, are blocking commands that wait for new data to arrive before returning. If these commands are used excessively, they can cause other clients to experience read timeouts.

Server overload: When a Redis server becomes overloaded with requests or when it exceeds its available resources (e.g., CPU, memory), it may fail to respond to client requests in a timely manner, causing read timeouts.

Large datasets: If a Redis database contains large amounts of data, reading all the data at once may take longer than the specified timeout value, resulting in a timeout error.

Firewall issues: Sometimes, firewalls or proxy servers can introduce delays or block network traffic, causing Redis read operations to time out.

Misconfiguration: Improperly configured Redis settings or network configurations may also result in read timeouts, such as setting an overly short timeout value or using an incompatible Redis client library.

To troubleshoot and resolve Redis read timeouts, it's important to identify the underlying cause and take appropriate measures, such as optimizing network configurations, reducing the use of blocking commands, optimizing server performance, and adjusting Redis configuration parameters.

真正重要有益的工作经验究竟是什么

考虑到ChatGPT对程序员的冲击,程序员有必要重新仔细地审视自己的工作经验,哪些才是真正重要有益的呢?和产品经理和测试同学怼来怼去的经验?写几行BUG的经验?熟悉开发流程的经验?多年的工作经验看上去确实很丰富可依赖么?

我觉得,工作经验,其实与年限无关。工作经验的实质,就是遇到的问题及解决方案(包括工具、方法、步骤、细节等)。主要包括:

  • 改进和调试一个程序,使之完善并能完成指定功能。
  • 与产品意见不同时,理解对方的意图,有理有据说明自己的理由,达成共识。
  • 发现项目中存在的风险,并及时关注和管控。
  • 线上疑难问题的排查和解决。
  • 棘手问题的解决。
  • 遇到一个技术问题可以设想的技术方案选项,权衡取舍,作出最优的决策。
  • 设计能够避免错误和资损的业务流程。
  • 设计复杂有难度的系统。
  • 写出高质量代码的经验。
  • 设计高性能、高可用、可复用、可扩展、可维护性系统的开发经验。
  • 单机环境下的开发经验、踩过的坑和经历的故障等。
  • 分布式环境下的开发经验、踩过的坑和经历的故障等。
  • 集群环境下的开发经验、踩过的坑和经历的故障等。
  • 高并发、大流量场景下的开发经验、踩过的坑和经历的故障等。
  • 对业务和行业痛点的理解和应用等。
  • 带领团队成功完成项目和系统。

至于拿到产品需求,编码实现,熟悉项目流程,那只算是最初级的开发经验,玩过一两次就会了。而学会使用 redis, mongo,mysql 等工具来实现需求,并学会队列、分布式锁等,则是稍微进阶一点的经验,但也只是前进了一小步而已。

从”遇到的问题及解决方案“的角度来看,某些程序员三年的工作经验,确实就顶上了一些程序员十年的工作经验。须知,程序员的工作经验,并不是通过简单重复的熟练度来体现的,而是通过任务难度来体现的。你遇到的问题的难度是不是逐渐增加着的?你的开发经验和解决方案是不是逐渐丰富和完善着的?还是只是解决着相同难度的事情,领着不变的薪水?

小结

ChatGPT 的出现,对于程序员来说,既是利好也是挑战。利好之处在于,如果你善于设计系统、规划路线图,那么 ChatGPT将能帮助你完成那些琐碎基础的事情;挑战在于,如果你只是满足于基本的编码工作,那将会面临最大的对手,而且这个对手几乎是碾压性的不可战胜的。你必须学会富有创造性地设计和工作,高质量的思考和决策,才能与这个强大的对手携手前行,去战胜更多的未知的障碍和挑战。

标签:word,String,携手,程序员,version,ChatGPT,sha256
From: https://www.cnblogs.com/lovesqcc/p/17299069.html

相关文章

  • ChatGPT4实现前一天
    目录提出需求代码实现需求分析单元测试等价类划分决策表软件测试作业,用ChatGPT4来帮个小忙,小划水,勿喷勿喷,近期有相关作业的同学看到我的文章,建议修改一下,别撞车了,哈哈哈~提出需求个人输入需求:Java实现键盘输入日期输出前一天,需要考虑润年和非润年,2月是否有29号,大月小月的区......
  • 使用ChatGPT快速实现灰度和RGBA图片转换为RGB三通道图片的Python数据清洗demo
    使用ChatGPT快速实现灰度和RGBA图片转换为RGB三通道图片的Python数据清洗demo任务需求Imganet数据集,由于原始图片有灰度图片、彩色图片和RGBA图片,我们的要求是将灰度图片和RGBA图片通过Image.open(img_path+img_name).convert('RGB')转换为RGB三通道图片重新保存起来。要求点......
  • ChatGPT中文在线官网
    ChatGPT中文在线官网:让智能对话更智能化随着人工智能的快速发展,智能对话系统已经逐渐成为了人们日常生活中不可或缺的一部分。作为一个基于GPT-3.5架构的大型语言模型,ChatGPT通过不断学习和自我完善,已经成为了全球范围内最受欢迎的智能对话系统之一。而为了更好地服务全球华语用......
  • 阿里版ChatGPT:通义千问突然上线
    我是卢松松,点点上面的头像,欢迎关注我哦!4月7日,阿里版的ChatGPT:通义千问突然上线了,由达摩院开发,目前开放预约,但仅面向企业。官网显示通义千问是一个专门响应人类指令的大模型,是效率助手,也是点子生成机。阿里云和达摩院,一个专攻算力一个擅长AI技术,这是阿里云未来AI的优势。阿里大模型......
  • 杂记——ChatGPT
    GPT4发布一段时间了,我去了解了一下,太震撼了!这绝对是一个疯狂的产品,能造就一个伟大的时代,全人类在知识、技能、逻辑上的鸿沟,将完全被踏平,能够和全人类有史以来最顶级的人的水准平起平坐,我总结了11件他可以做到的让我震惊的事。1、识图分析食谱,提取菜谱2、AI能根据图片看懂笑点3......
  • 【开源免费】ChatGPT-Java版SDK重磅更新至1.0.10版,支持Tokens计算,快来一键接入。
    简介ChatGPTJava版SDK开源地址:https://github.com/Grt1228/chatgpt-java,目前收获将近1000个star。有bug欢迎朋友们指出,互相学习,所有咨询全部免费。最新版:1.0.10<dependency><groupId>com.unfbx</groupId><artifactId>chatgpt-java</artifactId><version......
  • 通义千问——阿里版chatGPT
    通义千问——阿里版chatGPT通义千问内测地址;通义千问——阿里版chatGPT怎么样?通义千问——阿里版chatGPT邀请码如何获取?官网地址:tongyi.aliyun.com已开启企业邀测。获得到邀请码的话就可以填写在官网地址下面的,然后就可以正常使用了。申请注册申请体验填写企业信息、邮箱、用途......
  • 主数据系统建设步骤(chatGpt回答)
    建立主数据系统需要以下步骤:1.确定主数据:确定哪些数据是组织内的主要数据,如客户、产品和供应商等。2.设计主数据模型:设计一个清晰的主数据模型,包括各种对象之间的关系。3.选择主数据管理软件:选择一款适合组织需求的主数据管理软件,如SAPMasterDataGovernance、TIBCOMDM或Inf......
  • 中国多位AI专家赞成马斯克等人呼吁暂停ChatGPT技术的快速发展
    一些中国内地和香港的人工智能(AI)专家响应全球科技老将的呼吁,敦促暂停开发比GPT-4更先进的AI技术,因为他们认为当前的进展速度“过快”可能会带来危险。上个月,研究人类社会技术风险的“生命未来研究所”(FLI)起草了一封公开信,特斯拉的ElonMusk、苹果联合创始人SteveWozniak和历史学家......
  • 低代码是行业毒瘤吗?ChatGPT这样回答
    一、低代码现状从2019年开始低代码领域备受资本市场关注,在争议中不断发展,至今仍存在诸多尚未厘清的概念有待探讨,比如低代码是行业毒瘤吗?根据对行业近况的搜罗,总结以下现状:当前低代码行业在中国面临专业编程人员不常用到,业务人员不易熟练使用的痛点。不过笔者认为,在企业数字化转......