如何看待工作中大规模使用 AI 写代码

71 天前
 beryl
写工作生成代码

先说我的观点:不赞成写生产环境的工作代码,质量真的是污染代码

但是写点脚本,小 demo 可以,或者多行补全也可以接受
6697 次点击
所在节点    程序员
69 条回复
ty29022
71 天前
不如你贴出手写的一些代码片段和 chatgpt 生成的片段来做个对比
solituders
71 天前
不如你贴出手写的一些代码片段和 chatgpt 生成的片段来做个对比
13482034233
71 天前
要想要好的 output, 就先得有好的 input, 所以同样一个模型, 同样一个产品业务逻辑, 有的人就能用大模型写出好的代码, 有的则不行
charlie21
71 天前
人审核代码合理性的审核的能力 > AI 写代码的写的能力 > 人写代码的写的能力
l4ever
71 天前
生成->使用->了解为什么这么写, 和自己设想有何出入->取舍->利用.

挺好的, 学习速度明显快了.
FreshOldMan
71 天前
chagpt o1 写的还不错
mightybruce
71 天前
最近这种低质量的贴怎么越来越多, 来活跃社区的吗
xuefeng0578
71 天前
面对现实吧,早点谋下其它出路
liujl
71 天前
昨天用 claude 这可一个油猴脚本, 纯自然语言,代码规范度,质量非常不错, 程序员的出路回到家编程的本质“理解业务,设计程序业务逻辑,交互逻辑,呈现结果”
wangtian2020
71 天前
写代码的事你少管
junas7
71 天前
你也是出租车司机吗,来抗议 ai 智能驾驶
GeekGao
71 天前
使用 AI 也有技巧的,能力不行,用 AI 也很难与同行竞争 LOL
zjh7890
71 天前
路过…推荐下 JetBrains IDE 可用的类 cursor 插件,gpt-tools…
zjh7890
71 天前
我时常觉得,ai 写得比我好…结构清晰…
zhouxelf
71 天前
污染代码?? please show your code
bmpidev2019
71 天前
大概率你写的代码质量不如 Claude 的高,除非是一些专业领域,它没有训练过的,但是最佳实践,编程范式,设计模式,它都能吊打你的水平。
lyxxxh2
71 天前
```
# 以下由 gpt 生成
def init_input_and_output_door(self):
frame_results = copy.deepcopy(
self.frame_results
) # self.frame_results 会被以下代码改变 找太麻烦了 直接拷贝到新对象
door_line = [[828, 438], [1208, 868]]
door_area_line = [[623, 523], [1144, 982]]
door_line = [[336, 0], [1698, 1222]]
door_line =[[186, 0], [1428, 1222]]
door_line = [[336, 0], [1698, 1222]]
def is_above_line(point, line):
(x1, y1), (x2, y2) = line
return (y2 - y1) * (point[0] - x1) > (x2 - x1) * (point[1] - y1)
def filter_boxes_above_line(frame_results, door_area_line):
filtered_results = []
for frame in frame_results:
filtered_boxes = []
for box in frame["boxes"]:
x_min, y_min, x_max, y_max = box
box_center = [(x_min + x_max) / 2, (y_min + y_max) / 2]
if is_above_line(box_center, door_area_line):
filtered_boxes.append(box)
if filtered_boxes:
filtered_frame = {
"id": frame["id"],
"boxes": filtered_boxes,
"reid_dets": frame["reid_dets"], # 保留每个帧的 reid_dets
}
filtered_results.append(filtered_frame)
return filtered_results

filtered_frame_results = filter_boxes_above_line(frame_results, door_area_line)
filtered_frame_results = [
item for item in filtered_frame_results if len(item["boxes"]) != 0
]

# 使用 IOUTracker 类
tracker = IOUTracker(iou_threshold=0.3)
all_tracks = tracker.track_objects(filtered_frame_results)

# 用于记录人的信息、reid_dets 和 frame_ids
person_groups = defaultdict(list)
person_reid_dets = defaultdict(list)
person_frame_ids = defaultdict(list)
for frame, track_ids in zip(filtered_frame_results, all_tracks):
for box in frame["boxes"]:
matching_id = [
id for id, tracked_box in track_ids.items() if tracked_box == box
]
if matching_id:
box.append("person_id: {}".format(matching_id[0]))
person_groups[matching_id[0]].append(box[:-1]) # 不包括 person_id
person_reid_dets[matching_id[0]].append(
frame["reid_dets"]
) # 记录 reid_dets
person_frame_ids[matching_id[0]].append(
frame["id"]
) # 记录 frame id

crossing_events = {}
final_crossing_frames = {}

# 门线参数
m = (door_line[1][1] - door_line[0][1]) / (
door_line[1][0] - door_line[0][0]
) # 斜率
c = door_line[0][1] - m * door_line[0][0] # 截距

def check_position(x, y):
line_y = m * x + c
return y - line_y # > 0 在线上方,< 0 在线下方

for person_id, boxes in person_groups.items():
last_pos = None
entry_index = None
exit_index = None
# if person_id != 2:
# continue
for idx, box in enumerate(boxes):
x_center = (box[0] + box[2]) / 2
y_center = (box[1] + box[3]) / 2
current_pos = check_position(x_center, y_center)

if last_pos is not None:
if last_pos > 0 and current_pos < 0:
exit_index = idx
elif last_pos < 0 and current_pos > 0:
entry_index = idx
last_pos = current_pos

crossing_events[person_id] = {
"input_index": exit_index,
"output_index": entry_index,
}

for person_id, events in crossing_events.items():
person_data = []
boxes = person_groups[person_id]
reid_dets = person_reid_dets[person_id]
frame_ids = person_frame_ids[person_id] # 获取 frame id 列表

if events["input_index"] is not None:
input_index = events["input_index"]
input_frames = boxes[input_index : input_index + 3]
input_reid_dets = reid_dets[input_index : input_index + 3]
input_frame_ids = frame_ids[
input_index : input_index + 3
] # 取相应的 frame ids
person_data.append(
{
"type": "output",
"all_box": input_frames,
"reid_dets": input_reid_dets,
"frame_ids": input_frame_ids,
"ids": list(
range(input_index, input_index + len(input_frames))
),
}
)

if events["output_index"] is not None:
output_index = events["output_index"]
output_frames_start = max(0, output_index - 2)
output_frames = boxes[output_frames_start : output_index + 1]
output_reid_dets = reid_dets[output_frames_start : output_index + 1]
output_frame_ids = frame_ids[
output_frames_start : output_index + 1
] # 取相应的 frame ids
person_data.append(
{
"type": "input",
"all_box": output_frames,
"reid_dets": output_reid_dets,
"frame_ids": output_frame_ids,
"ids": list(range(output_frames_start, output_index + 1)),
}
)

final_crossing_frames[person_id] = person_data
```

之前让 gpt 写的。
也不是不能用,就是没一点"设计"的感觉。
让他再优化下,直接处 bug 。
逻辑越复杂,我就不敢用 ai 。
因为描述太麻烦了,得写篇作文给他。
再者很难阅读和修改。


后面我直接重写了
```
# 定义数据
for box, person_id in zip(data["head_boxes"], person_ids):
if person_id is None:
continue
if person_id not in self.door: # 初始化 key
self.door[person_id] = []
self.user_door_status[person_id] = None # 用户和门状态
for device in self.devices: # 用户和设备状态
if person_id not in device["persons"]:
device["persons"][person_id] = []

self.door[person_id].append(
{"box": box, "up_or_line": self.box_line_up_or_down(box)}
) # 添加到门记录器
if len(self.door[person_id]) > 100: # 用户超过一百
self.door[person_id] = self.door[person_id][-50:]
for device in self.devices: # 添加到设备记录器
if person_id not in device:
device["persons"][person_id].append(
self.calculate_containment_ratio(device["box"], box)
)
if len(device["persons"][person_id]) > 100:
device["persons"][person_id] = device["persons"][person_id][-50:]

# 根据
for person_id in self.door:
...
....
```
delacey
71 天前
@bmpidev2019 感觉程序员这行危险了,既然 ai 代码水平超过大部分程序员,那大家以后怎么和 ai 竞争呢?
justfindu
71 天前
你都是生成直接上? 不会在给它提点要求优化一下代码和逻辑?
FreshOldMan
71 天前
@delacey #18 就是没法竞争,不仅包括程序员

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://tanronggui.xyz/t/1093648

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX