開源日報 每天推薦一個 GitHub 優質開源項目和一篇精選英文科技或編程文章原文,堅持閱讀《開源日報》,保持每日學習的好習慣。
今日推薦開源項目:《天氣 earth》
今日推薦英文原文:《How To Learn Any New Programming Language Quickly》
開源日報第601期:《天氣 earth》
今日推薦開源項目:《天氣 earth》傳送門:GitHub鏈接
推薦理由:雖然看起來是個古物,但是這個項目可是實打實的想要將地球天氣可視化的展現出來。天氣這玩意幾乎完全無法控制,所以看天氣預報就顯得十分重要,這個項目雖然不是天氣預報,也只有風向的展示,但是這會是一個好的想法——畢竟可視化的天氣預報雖然提供的信息有點偏觀賞性而不是實用性,但是好看也是很重要的一部分,誰又能肯定積雨雲里真的沒有一大群像這些風線一樣的透明魚和雲之龍什麼的在裡面生活呢?
今日推薦英文原文:《How To Learn Any New Programming Language Quickly》作者:
原文鏈接:https://medium.com/better-programming/how-to-learn-any-new-programming-language-quickly-94996895669b
推薦理由:編程語言來來去去有些東西是不會變的

How To Learn Any New Programming Language Quickly

An essential checklist of fundamentals

This article assumes you already know at least one programming language; however, the concepts here will help you get started with programming.

When I was in school, a teacher told me something I share with new developers: The hardest programming language you』ll ever learn will be your second.

Don』t let this be disheartening — it means that when you first learn how to program, you have all of these preconceived ideas about programming. You end up making more syntax connections and assumptions than you should. Because of this, you have to 「unlearn」 these assumptions when you learn your second language. Try to keep this in mind if you』re attempting to learn your second language or even your third.

Anatomy of Programming

There are a lot of programming languages, easily over 5,000, but the TIOBE index lists the top 250. All of the top 20 languages that aren』t unique cases will have similar standard libraries.

I think the best way to think about programming is to strip out all of the extra 「stuff」 so you』re left with only the necessities.

The Atoms

Every aspect of every language can be reduced down to true and false. Why? Because electricity works this way — you either have a charge, or you don』t. Memory stores values in the form of 0s and 1s, and either this bit is charged, or it』s not.

Eight bits is equivalent to one byte, which is enough to list any character on the ASCII table. The bits are flipped in such an order that it provides the DECimal representation of the character. The computer understands how to translate this representation into a letter.
開源日報第601期:《天氣 earth》
Basic binary representation showing how the word Hello is created.

Having an understanding of this one concept, 「the why,」 will make the rest of this a lot easier on you.

The Tools

開源日報第601期:《天氣 earth》
Photo by Fleur on Unsplash

The tools are all the same, and while they can be learned in any order, this is the order I usually take.

Variables

This seems simple enough, but seriously, how do you create a variable?

Operators

What are the operators, and how are they used? You can assume you have basic math operators, but what about logical operators? Is an 「AND」 operator spelled out as 「and」 or 「AND,」 or does it use symbols such as 「&&?」

Conditionals

Surprisingly, my most read articles for both Swift and Python have to do with decision making. The next thing you need to know is how you can make decisions in your program. Does the language you are trying to learn use the traditional 「if/else if/else」 or something more Pythonic such as 「if/elif/else?」 Does your language have a 「switch」 or 「guard」 statement?

Loops

How can you loop through repetitive tasks? Does the language contain for-loops, while loops, do-while loops, or for-each statements?

Functions

Is it possible to create functions? If so, how do you do it? How do you include parameters in these functions? Knowing how to properly use functions will save you time and make your life so much easier.

Classes and structs

Does this language understand the concept of classes or structs? It sounds like a dumb question, but some languages don』t have either, or they have only one. If it does, how do you create a class or struct? Does the class require a constructor or init method?

Error handling

Errors are inevitable. When they occur, does this language have a robust error handling solution and how do you use it? Is it 「try/catch,」 「try/except,」 or something else? Are there other clauses such as 「else」 or 「finally」 that allow other options for errors?

Testing

How do you test your code? Is there a built-in library for testing or do you have to download a separate tool?

All of these tools should be in most modern programming languages. Even the older languages such as COBOL have most of these, but they may be called something different, like paragraphs or copybooks.

Getting Good

Once you understand these tools, the next thing you need to do is use them and write an application. You can know of a language by reading the docs, but you don』t know the language until you』ve written a few applications with it.

By writing an application, you』re forced to think like an X programmer. I can say that I know C++ because I took a class in C and read the docs on C++, but I really don』t know it until I』ve written an application in C++ using features specific to the language.

A good starter project is Blackjack. Blackjack requires variables, operators, conditionals, loops (based on the number of players), functions, classes/structs, and error handling. You can include test cases for potential failures, such as running out of cards.

Other good starter projects might include Shoots and Ladders, Yahtzee, or a Slot Machine.

For something more advanced, try to recreate a game like Monopoly. Worry more about the mechanics and keep it text-based.

It』s key to remember that if you short yourself on the difficulty of the task (such as skipping the double down or split features of blackjack), you』re only limiting your comprehension of the language.

What Else?

I know that the list of things above isn』t everything that a language has to offer. The truth is you can write just about anything with the tools listed above, but the additional functionality included in standard libraries just make it easier. Most standard libraries include the same functions, and so you can rely on similar names between languages.

The more you work with a language, the more you can discover about the standard library, but be sure to learn the tools beforehand.

As you work with a language, try to figure out what its strengths and weaknesses are. These will help you understand which language to use for a particular problem.

Need to do some data science quickly? Look at a few Python packages or R. Need to write a fast service? Look at C or Go. How about a web server? Look at Java or Python.

I didn』t just know this by looking at the languages. I learned this by using these languages.

Since this is possibly my shortest article to date, I』m going to leave you with a challenge to yourself to learn a new language. Good luck!
下載開源日報APP:https://openingsource.org/2579/
加入我們:https://openingsource.org/about/join/
關注我們:https://openingsource.org/about/love/