|
1 | | -# Overview |
| 1 | +# Overview |
| 2 | + |
| 3 | +## Bjarne Talks about the C++ language |
| 4 | + |
| 5 | +### How to learn C++, what is the best strategy to learn C++ |
| 6 | + |
| 7 | +I think first you need an overview of the language.<br> |
| 8 | +A lot of students dig in and want to know everything about some little detail. |
| 9 | +But the point is , they can't understand it until they have a broader view of the language. |
| 10 | + |
| 11 | + |
| 12 | +As people go in and they see, oh, pointers.<br> |
| 13 | +Great, I want to know everything about pointers, and why would you want to do that? |
| 14 | + |
| 15 | + |
| 16 | +They should be work together with classes and other data types, and how do you do a traversal or a container and such. |
| 17 | + |
| 18 | + |
| 19 | +You shouldn't obsess about one little thing, or they go in and they say, well, there're 32 different basic arithmetic types. It's probably right. I can't remember. |
| 20 | + |
| 21 | + |
| 22 | +I mean, that's just the sew of little type or rules for conversion. |
| 23 | +Most of the time, I don't use all of those types, and most of the time, I don't have to think about those things. |
| 24 | + |
| 25 | + |
| 26 | +So instead of digging into the little details, pointers, how to do a class, hierarchy, things like that, get an overview. |
| 27 | + |
| 28 | +### What should students focus on when learning C++? |
| 29 | +I think first of all they should try and look at C++ as a modern language. |
| 30 | + |
| 31 | +Far too many have learned C++ as if it was just C or as if it was still 1985, and that pains me a lot because it's much better these days. |
| 32 | + |
| 33 | +You look at it and you see how to use the abstraction mechanisms, you use the libraries. |
| 34 | + |
| 35 | +They are the standard library which is fundamental data structures, few algorithms, timing, regular expressions, that kind of stuff. |
| 36 | + |
| 37 | +Then there are specific libraries for specific areas, the database interfaces, you have specific graphic libraries, animations libraries, and such. |
| 38 | + |
| 39 | + |
| 40 | +So I think when you start programming, you stick to the fundamentals for a while, because well , the fundamentals are the fundamentals. |
| 41 | + |
| 42 | + |
| 43 | +You have to know your algorithms, you have to know your data structures, you have to know a little bit of machine architecture if you want to write at that level. |
| 44 | + |
| 45 | + |
| 46 | +Then you're going to actually do something. If you're writing video game, you have to know what game's engine and the libraries that go in there. |
| 47 | + |
| 48 | + |
| 49 | +So you go through the fundamentals and then something specific to your interest. |
| 50 | + |
| 51 | +## 编译型语言vs解释型语言 |
| 52 | + |
| 53 | +**编译型语言**会在编译阶段将错误或者潜在的风险提示出来;<br> |
| 54 | +相反动态类型语言可能会在运行时期报错,但是这时候用户是无法处理这些问题的,因为他们很可能不是开发人员。<br> |
| 55 | +编译器是开发人员的好帮手,可以生成代码,转换代码,也可以发现风险。<br> |
| 56 | +编译型语言的优势也是劣势,相比动态类型语言,我们需要先通过编译器生成目标平台上的可执行文件,再将该文件发布给用户;因此,为了支持多种平台,我们还需要针对每个平台编译生成对应的目标文件,再将其提供给用户。甚至还需要为了目标平台而去构建**交叉编译工具链**。<br> |
| 57 | +还有一个优势,编译型的语言生成的是最终可执行的目标文件,因此**运行效率高**。 |
| 58 | + |
| 59 | +**动态类型语言**(比如python,JavaScript等)拥有很好的跨平台特性以及容易上手等特点。<br> |
| 60 | +因此,在web开发、系统管理等方面非常适合使用这一类型的语言,当下他们也获得了蓬勃的发展。<br> |
| 61 | +还有一种场景适合动态类型语言,当目标场景是交互式的时候,此时效率不是那么重要。比如AI和数据科学实验时,使用Jupyter Notebook进行即时开发,用户无需频繁地等待编译器处理&执行修改后的代码这个繁琐的流程。<br> |
| 62 | +动态类型的语言往往**运行效率比较低**,因为大多数是解释型语言,在运行时依赖解释器逐行将代码转换成目标系统的指令来运行。 |
| 63 | + |
| 64 | +--- |
0 commit comments