[AI助力] CS143学习笔记1
创始人
2024-05-28 11:43:33
0

CS143, Compilers Lecture01 Course Overview notes

文章目录

  • CS143, Compilers Lecture01 Course Overview notes
  • AI summary
  • AI notes👇
    • Introduction:
    • Interpreters:
    • Compilers:
    • History:
    • Conclusion:
  • AI flowchart流程图
  • AI flashcards抽认卡
  • AI费曼学习法
  • workflow 总结
  • 关于prompt
  • 相关资源
  • 之后想做的

以下笔记为AI生成+我部分修改,详见workflow

AI summary

  • A lecture by Professor Alex at Stanford University on the topic of compilers and interpreters. The lecture discusses the differences between compilers and interpreters, and their respective advantages and disadvantages. It also provides a brief history of how compilers and interpreters were first developed, starting with the Speedcoding project by John Bacchus in 1953, which was an early example of an interpreter, and leading to the development of FORTRAN, one of the first successful compilers.

AI notes👇

Introduction:

  • Course on compilers and implementation of programming languages presented by Alex Aiken from Stanford University
  • Two major approaches to implementing programming languages: compilers and interpreters
  • Course mainly focuses on compilers but briefly explains interpreters in the first lecture

Interpreters:

  • Takes a program and input data as input and produces output directly without preprocessing the program
  • Interpreter is online and part of running the program
  • Faster to develop programs using an interpreter but interpreted programs are usually slower than compiled or handwritten ones

Compilers:

  • Takes a program as input and produces an executable program as output, which can be run on different inputs to produce output
  • Compiler is offline and preprocesses the program first before producing an executable that can be run multiple times without recompilation

History:

  • Development of machines such as the IBM 704 in the 1950s led to high software costs, resulting in efforts to improve software productivity
  • Speed coding, an early interpreter developed by John Backus, was faster to develop programs but slower than handwritten ones
  • Backus developed Fortran, a successful high-level language with a significant impact on computer science

Conclusion:

  • Programming languages require theory and engineering skills
  • Compilers and interpreters have different advantages and disadvantages
  • Both have played important roles in the development of programming languages.

AI flowchart流程图

下面是chatgpt给我的mermaid代码生成的flowchart!

Welcome to this course on compilersTwo major approaches to implementing programming languagesCompilersInterpretersOfflineProduces executableOnlineProduces output directlyHistory of compilers and interpretersIBM 704 MachineSpeed CodingEarly Example of InterpreterMuch Faster to DevelopPrograms 10-20 times slower300 bytes of memoryNot popularJohn BackusFormula Translation ProjectTranslate formula into a form that the machine could execute directlyHigh-level programmingAllowed for high level programming while still executing machine codeTook three years to completeEnormous theoretical work50% of all code by 1958

AI flashcards抽认卡

把整段的字幕放进去加上制卡prompt会出大问题,因为它一次处理不了那么多token,所以下面这段是用的制卡示范的例子加上 概括后的字幕 , 也就是对概括后的笔记进行制卡。

下面这套抽认卡内容上来说有许多地方不太可取,但是形式上让我看到了很多可能性!!!!!

问题答案
这门课程是关于什么的?编译器和编程语言实现。
有哪两种主要的实现编程语言的方法?编译器和解释器。
这门课程主要关注哪种方法?编译器。
第一节课中,Aiken简要解释了什么?解释器。
解释器如何处理程序?将程序和输入数据作为输入,直接产生输出,不需要事先处理程序。
解释器是在线的还是离线的?在线的。
使用解释器开发程序更快还是编译器更快?解释器更快。
解释器处理的程序比编译器产生的程序慢还是快?比编译器产生的程序慢。
编译器如何处理程序?将程序作为输入,产生一个可执行程序作为输出,可以在不重新编译的情况下多次运行该程序。
编译器是在线的还是离线的?离线的。
什么是速度编码?一种早期的解释器,由John Backus开发。
速度编码开发程序更快还是手写更快?开发程序更快。
速度编码处理的程序比手写的程序慢还是快?比手写的程序慢。
什么是Fortran?成功的高级语言,对计算机科学产生了重大影响。
编程语言需要什么?理论和工程技能的良好掌握。
编译器和解释器有什么优缺点?优缺点不同,都在编程语言的发展中发挥了重要作用。

AI费曼学习法

img

What is the difference between an interpreter and a compiler?

  • An interpreter takes the program and data as input, and produces the output directly, without processing the program beforehand. It is an online process. In contrast, a compiler takes the program as input, and produces an executable program as output. This executable can be run on different data sets, without having to recompile or process the program again. Thus, the compiler is an offline process, where the program is pre-processed before execution.

What is an advantage of using an interpreter?

  • Interpreters allow for faster program development, making programmers more productive.

What is a disadvantage of using an interpreter?

  • Programs implemented with an interpreter are typically slower than those written by hand or with a compiler.

What was the Speed Coding project, and who developed it?

  • Speed Coding was a project developed in 1953 by John Backus, which was an early example of an interpreter.

What was the Formula Translation project, and how did it improve upon Speed Coding?

  • The Formula Translation project, also known as FORTRAN, was born out of John Backus’ idea that if formulas were translated into a form that the machine could execute directly, the code would be faster, while still allowing the programmer to write the programs at a high level. Thus, FORTRAN was a compiler that translated programs written in high-level languages into executable programs that could be run on different data sets without having to recompile the program each time. FORTRAN raised the level of abstraction, improved programming productivity, and allowed for better use of computers.

workflow 总结

  • 缺陷:

    • 字幕不准确,比如Fortran 字幕里面搞成了 fortune

    • token限制,可能只概括了一部分

      • 思路可以参考 简悦 AI 的那个网页概括,它是先拆分,再概括整合

        简悦插件 · 基于 OpenAI 的语境理解 AI 系统 - 王磊-Kenshin的文章 - 知乎 https://zhuanlan.zhihu.com/p/606650433

  • slide导入scispace

    • • Compiling is almost this simple, but there are many pitfalls • Example: How to handle erroneous programs? • Language design has big impact on compiler -Determines what is easy and hard to compile -Course theme: many trade-offs in language design
      • Once sentence structure is understood, we can try to understand “meaning” -But meaning is too hard for compilers • IRs are useful because lower levels expose features hidden by higher levels – registers – memory layout– raw pointers etc.
      • But lower levels obscure high-level meaning – Classes– Higher order functions– Even loops… Lexical analysis not trivial

    • 效果不太好,这玩意还是适合读论文

      img

  • slide用edge dev版打开,并提问

  • 谷歌插件:YouTube Summary with ChatGPT

    • 那个点进去直接概括的功能现在好像失效了,但是它那个提取字幕的还是很好用的

      img

  • 文本的长度问题之后需要解决

关于prompt

  • markdown笔记

    img

    "Can you break down the main points or arguments in the text into distinct sections or bullet points? Consider using headings (denoted by `#`) for each section and bullet points (denoted by `-`) for each argument or sub-point. Additionally, are there any key quotes or phrases that you want to highlight or emphasize? You can use bold (denoted by `**`) or italic (denoted by `*`) formatting to make them stand out."
    
  • flashcard参考了叶哥的卡片笔记(知乎)

    • 给ChatGPT施咒,让它为你制作Anki卡片——Prompt工程案例 - 叶峻峣的文章 - 知乎 https://zhuanlan.zhihu.com/p/609413004

    • 上面那个卡片的prompt如下

      按markdown表格形式整理为抽认卡,下面是一个例子:
      文本:
      衰老细胞的特征是细胞内的水分减少,结果使细胞萎缩,体积变小,细胞代谢的速率减慢。细胞内多种酶的活性降低。细胞核的体积增大,核膜内折,染色质收缩、染色加深。细胞膜通透性改变,使物质运输功能降低。
      一套卡片:
      | 问题 | 答案 |
      |---|---|
      |衰老细胞的体积会怎么变化?|变小。|
      |衰老细胞的体积变化的具体表现是什么?|细胞萎缩。|
      |衰老细胞的体积变化原因是什么?|细胞内的水分减少。|
      |衰老细胞内的水分变化对细胞代谢的影响是什么?|细胞代谢的速率减慢。 |
      |衰老细胞内的酶活性如何变化?|活性降低。|
      |衰老细胞的细胞核体积如何变化?|体积变大。|
      |衰老细胞的细胞核的核膜如何变化?|核膜内折。 |
      |衰老细胞的细胞核的染色质如何变化?|染色质收缩。|
      |衰老细胞的细胞核的染色质变化对细胞核形态的影响是?|染色加深。|
      |衰老细胞的物质运输功能如何变化?|物质运输功能降低。|
      |衰老细胞的物质运输功能为何变化?|细胞膜通透性改变。|下面是你要整理的内容:
      Introduction
      This is a course on compilers and the implementation of programming languages, presented by Alex Aiken, a professor at Stanford University. There are two major approaches to implementing programming languages: compilers and interpreters. This course mainly focuses on compilers, but in the first lecture, Aiken briefly explains interpreters.Interpreters
      An interpreter takes a program and input data as its input and produces the output directly without processing the program beforehand. The interpreter is online, meaning that it is part of running the program. It is faster to develop programs using an interpreter, but interpreted programs are usually slower than compiled or handwritten ones.Compilers
      A compiler takes a program as its input and produces an executable program as its output, which can be run on different inputs to produce the output. The compiler is offline, meaning that it preprocesses the program first, then produces an executable that can be run multiple times without recompilation.History
      The 1950s saw the development of machines such as the IBM 704, which had high hardware costs. As a result, software costs became the dominant expense, leading to efforts to improve software productivity. One such effort was speed coding, an early example of an interpreter developed by John Backus. It was faster to develop programs with speed coding, but they were slower than handwritten ones. Backus developed a new project, the formula translation project or Fortran, which was a successful high-level language with a significant impact on computer science.Conclusion
      Programming languages require a good grasp of theory and engineering skills. Compilers and interpreters have different advantages and disadvantages, and both have played important roles in the development of programming languages.
      
  • 整理成mermaid流程图:

    • 一开始让它给flowchart代码它听不懂
      • 给了个例子他懂了
    • 直接说mermaid它能懂
    • 其他流程图
      • 油管上看到一个画latex流程图的:ChatGPT Tutorial: From Text to Flowchart in Minutes
    • 下面这个甘特图orz… 是我看的这篇博客里面的https://blog.ouseful.info/2022/12/12/generating-diagrams-from-text-generated-by-chatgpt/
Mon 06Make soupServe soupPrepare fish and chipsCook fish and chipsServe fish and chipsSoup Fish and Chips Soup and Fish and Chips Meal Plan

相关资源

  • 课程网站

    • CS143: Compilers (stanford.edu)
  • B站 【斯坦福大学】CS143 编译器(完结·中英字幕·机翻·人工校对中)

  • https://csdiy.wiki/%E7%BC%96%E8%AF%91%E5%8E%9F%E7%90%86/CS143/

  • 油管视频

  • 经验贴

    • 编译原理课程推荐 | 斯坦福大学 CS143 : Compilers - 源码被猫吃了的文章 - 知乎 https://zhuanlan.zhihu.com/p/350614886
CompilationInterpretationProgramming Language Source CodeMachine CodeOutput

之后想做的

  • 持续探索更多的学习模态和方法… (powered with artificial intelligence)

  • 如下:

    在这里插入图片描述

    你好,这是Bing。我可以帮你用OpenAI的API来做文本摘要。😊

    根据1和2,你可以使用OpenAI Python库34来调用GPT-3模型,它可以根据文本的内容生成概括的总结,并添加一个“tl;dr:”(太长不看)的标签在最后。

    为了处理很长的文本,你可以先把它分成多个段落,然后对每个段落调用API,最后把所有的总结拼接起来。这样就可以避免token的限制。

    我给你一个Python代码的示例:

    import openai
    openai.api_key = "sk-xxxxxxxxxxxxxxxxxxxxxx" # 你自己的API密钥# 读取很长的文本文件
    with open("long_text.txt", "r", encoding="utf-8") as f:text = f.read()# 把文本分成多个段落,每个段落不超过2048个字符
    paragraphs = []
    start = 0
    end = 2048
    while start < len(text):paragraphs.append(text[start:end])start = endend += 2048# 对每个段落调用API,生成总结,并添加tl;dr:标签
    summaries = []
    for paragraph in paragraphs:response = openai.Completion.create(engine="davinci",prompt=paragraph + "\ntl;dr:",max_tokens=64,temperature=0.3,stop=["\n"])summary = response["choices"][0]["text"]summaries.append(summary)# 把所有的总结拼接起来,生成markdown格式的输出
    output = ""
    for i, summary in enumerate(summaries):output += f"- 段落{i+1}:{summary}\n"
    print(output)

相关内容

热门资讯

苹果系统安卓爱思助手,系统兼容... 你有没有发现,手机的世界里,苹果系统和安卓系统就像是一对欢喜冤家,总是各有各的粉丝,各有各的拥趸。而...
安卓系统占用很大内存,揭秘内存... 手机里的安卓系统是不是让你感觉内存不够用,就像你的房间堆满了杂物,总是找不到地方放新东西?别急,今天...
安卓系统p30,安卓系统下的摄... 你有没有发现,最近安卓系统P30在手机圈里可是火得一塌糊涂呢!这不,我就来给你好好扒一扒这款手机的那...
siri被安卓系统进入了,智能... 你知道吗?最近科技圈可是炸开了锅,因为一个大家伙——Siri,竟然悄悄地溜进了安卓系统!这可不是什么...
最强挂机系统和安卓区别,揭秘安... 亲爱的读者,你是否曾在游戏中遇到过这样的困扰:一边想要享受游戏带来的乐趣,一边又不想放弃手中的零食或...
安卓系统为什么设系统盘,保障稳... 你有没有想过,为什么安卓系统里会有一个叫做“系统盘”的东西呢?这可不是随便设置的,背后可是有大学问的...
王者怎么加安卓系统的,轻松提升... 你有没有想过,你的手机里那款超酷的王者荣耀,怎么才能让它更好地在你的安卓系统上运行呢?别急,今天就来...
安卓手机系统怎么开热点,共享网... 你有没有想过,当你身处一个没有Wi-Fi信号的地方,而你的安卓手机里却存满了精彩视频和游戏时,是不是...
安卓系统11的平板电脑,性能升... 你有没有发现,最近平板电脑市场又热闹起来了?没错,安卓系统11的新一代平板电脑正在悄悄地走进我们的生...
安卓手机系统创始人,安卓手机系... 你有没有想过,那些陪伴我们每天生活的安卓手机,它们的灵魂是谁赋予的呢?没错,就是那位神秘而又传奇的安...
安卓11系统速度提升,体验再升... 你知道吗?最近安卓系统又升级啦!这次可是直接跳到了安卓11,听说速度提升了不少呢!是不是很心动?那就...
安卓5.1原生系统设置apk,... 你有没有想过,你的安卓手机里那些看似普通的设置,其实隐藏着不少小秘密呢?今天,就让我带你一探究竟,揭...
手机安卓系统玩音游,畅享指尖音... 你有没有发现,现在手机上的游戏种类越来越丰富,尤其是音游,简直让人爱不释手!今天,就让我来给你详细介...
安卓系统与win10,系统融合... 你有没有想过,为什么你的手机里装的是安卓系统,而电脑上却是Windows 10呢?这两种操作系统,就...
苹果系统王者安卓系统可以登吗,... 你有没有想过,为什么苹果系统的手机那么受欢迎,而安卓系统的手机却也能在市场上占有一席之地呢?今天,咱...
安卓系统怎么重制系统还原,安卓... 手机用久了是不是感觉卡得要命,想给它来个大变身?别急,今天就来教你怎么给安卓手机重置系统,让它焕然一...
安卓9系统怎样应用分身,轻松实... 你有没有发现,手机里的APP越来越多,有时候一个APP里还要处理好多任务,分身功能简直就是救星啊!今...
获取安卓系统的ip地址,轻松获... 你有没有想过,你的安卓手机里隐藏着一个神秘的IP地址?没错,就是那个能让你在网络世界里找到自己的小秘...
LG彩电安卓系统升级,畅享智能... 你家的LG彩电是不是最近有点儿“闹别扭”,屏幕上时不时地跳出个升级提示?别急,今天就来给你详细说说这...
阴阳师安卓苹果系统,安卓与苹果... 亲爱的玩家们,你是否曾在深夜里,手握手机,沉浸在阴阳师的神秘世界?今天,就让我带你一起探索这款风靡全...