oakland / tecblog

My tech blogs
4 stars 0 forks source link

C语言 #293

Open oakland opened 3 years ago

oakland commented 3 years ago

keyword: c语言,c, c language, learn c

在线 c 语言执行器

https://www.programiz.com/c-programming/online-compiler/

最近在技术群里看到这样的内容:

想搞nodejs做后端的,有C++/java基础的,无所谓。没基础的,最好能从C语言,apue这些开始。去理解系统调用,进程管理,调度。内存管理 这些基础知识。往上选go 或 java深入进去。 至于nodejs,如果真心要用的话。至少要明白,为什么单线程的js 能做到并发。底层的C++ 到底做了什么。比如线程池,比如io多路复用。 最终你会明白,js在nodejs平台之上只是个 调用的api。

于是就萌生了学习 c 语言的想法,打算学一下 c 语言,然后再进阶到 go,走这样一条路线,看看能不能走出什么新花样来。单纯的学习 前端,其实太局限了。我是会打算继续在前端的这条道路上发展下去,但是实际上如果你不能对于计算机的本质和微观内容有更深刻的理解的话,单纯的前端技术只是表象而言。所以打算开始学习 c。

https://www.learn-c.org/

指针 pointer

关于指针的一篇不错的文章

计算机概论

关于计算机的概论,一直没有学习,看知乎中关于指针的文章的时候,看到了 foundations of computer science 的内容,觉得这本书可以不错,打算拿来学一学看一看。

关于 C 语言的各种操作

https://zhuanlan.zhihu.com/p/64599971

预编译:gcc -E hello.c -o hello.i 编译:gcc -S hello.i -o hello.s 汇编:gcc -c hello.s -o hello.o 链接:gcc hello.o -o hello

感觉目前最能看懂的就是 编译

图灵完备

https://www.zhihu.com/question/20115374/answer/288346717 https://www.zhihu.com/question/19963523/answer/81966707

好几个回答都提到了 brainfuck 的这门语言

此外,这个语言因为简洁,也是第一次练习写编译器的一个非常好的选择。

不同编程语言之间的本质区别

https://www.zhihu.com/question/55461445/answer/151770379

关于 printf 的精确定义

printf is general purpose output formatting function...It's first argument is a string of characters to be printed, with each % indicating where one of the other (second, third, ...) argument is to be substituted, and in what form it is to be printed. Each % construction in the first argument of printf is paired with the conrresponding second argument, third argument, etc; they must match properly by number and type, or you'll get wrong answers. format-specifiers-in-c,这篇文章里列举了 printf 的 placeholder

parameter VS argument

We will generally using parameter for a variable named in the parenthesized list in afunction definition, and argument for the value used in a call of the function. The terms formal argument and actual argument are sometimes used for the same distinction.

关于 side effect

在函数式编程中,我们经常听到关于 side effect 的描述,虽然说对这个 side effect 有所理解,但是你要真说我感觉还是说不上来这个 side effect 的精确定义。直到今天,我在 the c programming language 中看到下面这段话,我觉得对于 side effect 又多了一层理解。

第 30 页 Some functions return a useful value; others, like copy, are used only for their effect and return no value. The return type of copy is void, which states explicitly that no value is returned.

从是否返回值这个角度来看,react 中的 useEffect 确实是具有副作用的。也就是说这个函数和组件的渲染内容没有关系,完全是一个独立的内容。并没有返回任何值。我们经常说直接调用 dom 方法,还有 setTimeout 这类函数都具有副作用,确实,他们并没有参与函数本身的渲染,而是在渲染之后直接操作了渲染之后的内容,所以说他们具有副作用。

declaration VS definition

You should note that we are using the words definition and declaration carefully when we reger to external variables in this section. "Definition" refers to the place where the variable is created and assigned storage; "declaration" refers to places where the nature of the variable is stated but no storage is allocated.

之前就一直分不清 js 中的 function declaration 和 function definition,现在终于分清楚了。有等号的就是 definition,没有的是 declaration。

variable VS symbolic

https://stackoverflow.com/questions/5062019/what-is-the-point-of-symbolic-constants

symbolic 就是 constant,也就是声明之后不会发生变化的。这种不发生变化的内容,编译的时候,会自动把 名称 替换为 值,而不是通过查找内存地址的方式去查找这个值,因此可以节约一部分的编译时间。

大概 js 中的这个 const 应该也是这个原因?