Most people’s journey toward learning to program starts with a single late-night Google search.
大多數人學習編程的旅程都是從一個深夜Google搜索開始的。
Usually it’s something like “Learn ______”
通常它類似于“學習______”
But how do they decide which language to search for?
但是,他們如何決定要搜索的語言呢?
“They always joke about Java on Silicon Valley. I guess I should learn that.”
“他們總是在硅谷開玩笑說Java。 我想我應該學那個。”
Or:
要么:
“Haskell. So hot right now. Haskell.”
哈斯克爾。 現在太熱了。 哈斯克爾。”
Or:
要么:
“That Go gopher is just so gosh-darn cute.”
“那個地鼠真是太可愛了。”
And then there’s the rest of us. We’ll probably search for something like:
然后是我們其余的人。 我們可能會搜索類似的內容:
“Which programming language should I learn first?”
“我應該首先學習哪種編程語言?”
Few questions are so commonly asked that they get the full infographic treatment. But this is one of them:
很少有人問過這么普遍的問題,以至于他們得到完整的信息圖表處理。 但這是其中之一:
Deciding on your first programming language can be a fun process — kind of like one of those “Which Quentin Tarantino character are you?” personality quizzes.
確定您的第一門編程語言可能是一個有趣的過程-有點像“您是哪個昆汀·塔倫蒂諾角色?”中的一個。 個性測驗。
But before you run off to learn Ruby because you enjoyed playing with Play-Doh as a kid, let me remind you: the stakes are pretty high here.
但是在您因為小時候喜歡玩Play-Doh而開始學習Ruby之前,讓我提醒您:這里的賭注相當高。
It will take you hundreds of hours of practice to become even remotely competent with your first programming language.
要想遠程掌握第一門編程語言,將需要數百小時的練習時間。
So you should consider the following factors:
因此,您應該考慮以下因素:
- the job market for the language 語言的就業市場
- the long term prospects for the language 語言的長期前景
- how easy the language is to learn 語言學習起來有多容易
- what projects you can build while you’re learning (and share with friends so you can stay motivated) 您在學習時可以構建哪些項目(并與朋友分享,以便保持動力)
Every year brings new programming languages, and with them, new academic papers. And new web comics.
每年都會帶來新的編程語言,并隨之帶來新的學術論文。 以及新的網絡漫畫。
Seriously. Check out this gem from last month:
說真的 看看上個月的這張寶石:
When it comes to choosing a first programming language, there’s no shortage of options. To narrow it down a bit, here are the most common Google searches related to learning programming, over the past 12 years:
在選擇第一種編程語言時,不乏選擇。 為了縮小范圍,以下是過去12年中與學習編程相關的最常見的Google搜索:
Java has had its ups and downs.
Java經歷了風風雨雨。
Python has gradually risen to become the most popular choice.
Python已逐漸成為最受歡迎的選擇。
But tucked away below these is the Little Engine That Could, slowly choo-choo’ing up in popularity over the past few years. And that engine is JavaScript.
但是隱藏在這些之下的是“可能制造的小引擎”,在過去幾年中逐漸流行起來。 該引擎是JavaScript。
Before I talk about these programming languages, let me clarify:
在討論這些編程語言之前,讓我澄清一下:
- I’m not arguing that any one language is objectively better than any other 我并不是說任何一種語言在客觀上都比其他任何一種都要好
- I agree that developers should eventually learn more than one language 我同意開發人員最終應該學習多種語言
- I’m arguing that first they should learn one language well. And — as you can probably guess from the upside down text in my headline — that language should be JavaScript. 我在爭辯說他們首先應該學習一種語言。 而且-正如您可能從標題中的上下顛倒文字中猜測的那樣-該語言應為JavaScript。
Let’s kick things off by exploring how programming is currently taught in school.
讓我們開始探索目前學校如何教授編程的事情。
計算機科學101 (Computer Science 101)
Universities have traditionally taught programming under the umbrella of computer science, which itself is often seen as an extension of mathematics, or tie-in to an electrical engineering degree.
傳統上,大學在計算機科學的保護下教授編程,這本身通常被視為數學的擴展,或與電氣工程學位緊密結合。
Of course, as you may have heard by now:
當然,如您現在所聽到的:
“Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter.” — Eric S. Raymond
“計算機科學教育不能使任何人成為專家程序員,而學習畫筆和顏料可以使某人成為專家畫家。” —埃里克·雷蒙德(Eric S. Raymond)
As of 2016, many universities still treat programming like it’s computer science, and computer science like it’s math.
截至2016年,許多大學仍將編程視為計算機科學,而將計算機科學視為數學。
As a result, many introductory programming courses focus on low-level-of-abstraction languages like C, or mathematically-focused languages like MATLAB.
因此,許多入門編程課程都將重點放在諸如C的低層次抽象語言或諸如MATLAB的以數學為重點的語言上。
And department chairs generally stay the course, pointing to annual programming language leaderboards like the TIOBE Index, or this one from the IEEE:
部門主席通常會繼續學習,指向年度編程語言排行榜,例如TIOBE Index或IEEE的這一排行榜:
Most of these leaderboards look virtually identical to how they were 10 years ago.
這些排行榜中的大多數看上去幾乎與10年前一樣。
But change does happen. Even in academia.
但是改變的確發生了。 即使在學術界。
In 2014, Python overtook Java as a the most popular language of instruction at top US Computer Science programs.
2014年,Python 超過Java ,成為美國計算機科學頂級程序中最流行的指令語言。
And yet another change is bound to… eventually… happen.
然而,另一改變必將……最終……發生。
Because if you look at the languages actually used by the workforce, it paints a very different picture:
因為如果您查看勞動力實際使用的語言,它會描繪出截然不同的畫面:
More than half of all developers use JavaScript. It’s vital to front-end web development and increasingly relevant for back-end development. And it’s rapidly expanding into areas like game development and the Internet of Things.
所有開發人員中超過一半使用JavaScript。 這對前端Web開發至關重要,并且對后端開發越來越重要。 而且它正在Swift擴展到游戲開發和物聯網等領域。
Job postings also mention JavaScript more than any programming language other than Java:
職位發布還提到JavaScript,而不是Java以外的任何其他編程語言:
It’s no accident that we built our open source community’s curriculum around JavaScript. Over the past two years, more than 5,000 people have used Free Code Camp to get their first developer job.
我們圍繞JavaScript構建開源社區的課程并非偶然。 在過去的兩年中,有超過5,000人使用Free Code Camp獲得了他們的第一份開發人員工作。
I’m not advocating JavaScript because I teach it. I teach JavaScript because it’s the surest path to a first developer job.
我不提倡JavaScript,因為我教過它。 我教JavaScript是因為這是完成第一項開發人員工作的最可靠途徑。
But is JavaScript right for you? Is it worthy of being your first programming language? Let’s explore those factors I mentioned earlier.
但是JavaScript是否適合您? 值得成為您的第一門編程語言嗎? 讓我們探討一下我前面提到的那些因素。
因素1:就業市場 (Factor 1: The job market)
If you’re learning to program purely out of intellectual curiosity, feel free to skip this factor. But if you — like the vast majority of people learning to program — want to use this skill to get a job, this is an important consideration.
如果您純粹出于好奇心而學習編程,請隨時跳過此因素。 但是,如果您(像絕大多數學習編程的人一樣)想要使用此技能來找到工作,這是一個重要的考慮因素。
As I mentioned earlier, Java is mentioned in more job postings than any other programming language. JavaScript is a close second.
正如我之前提到的,職位招聘中提到的Java比其他任何編程語言都多。 JavaScript緊隨其后。
But here’s the thing about JavaScript: even though it’s been around for 20 years, it only recently became a serious tool that companies like Netflix, Walmart, and PayPal would build entire applications around.
但是,關于JavaScript的事情就是這樣:盡管它已經存在20年了,但直到最近它才成為一種重要的工具,像Netflix,Walmart和PayPal這樣的公司可以圍繞它構建整個應用程序。
As a result, plenty of companies are hiring JavaScript developers, but there just aren’t that many on the job market.
結果,很多公司都在雇用JavaScript開發人員,但是在就業市場上的人并不多。
There are 2.7 Java developers competing for every open Java position. Competition for PHP and iOS jobs is similarly fierce.
有2.7位Java開發人員爭奪每個Java開放職位。 同樣,PHP和iOS工作的競爭也很激烈。
But for every open JavaScript position, there are only 0.6 JavaScript developers. It is very much a sellers’ market for developers with JavaScript skills.
但是對于每個開放JavaScript職位,只有0.6個JavaScript開發人員。 對于具有JavaScript技能的開發人員來說,這是一個很大的賣方市場。
因素2:長期前景 (Factor 2: The long term prospects)
The average JavaScript project receives twice as many pull requests as the average Java, Python, or Ruby project. And on top of this, JavaScript is growing faster than any other popular language.
普通JavaScript項目收到的拉取請求是普通Java,Python或Ruby項目的兩倍。 最重要的是,JavaScript的增長速度快于任何其他流行語言。
JavaScript’s ecosystem also benefits from a heavy investment of money and engineering talent from companies like Google, Microsoft, Facebook, and Netflix.
JavaScript的生態系統還得益于Google,Microsoft,Facebook和Netflix等公司的巨額資金和工程人才的投資。
For example, TypeScript (a statically-typed superset of JavaScript) has more than 100 open source contributors, many of whom are Microsoft and Google employees being paid to work on it.
例如,TypeScript(JavaScript的靜態類型超集)擁有100多個開源貢獻者,其中許多人是Microsoft和Google的雇員,正在為其工作。
This type of inter-company cooperation is harder to find with Java. Oracle — who effectively owns Java through its acquisition of Sun Microsystems — often sues companies who try to expand upon it.
用Java很難找到這種類型的公司間合作。 通過收購Sun Microsystems來有效擁有Java的Oracle 經常起訴那些試圖對其進行擴展的公司。
因素3:學習困難 (Factor 3: Difficulty to learn)
Most programmers would agree that high-level scripting languages are relatively easy to learn. JavaScript falls into this category, along with Python and Ruby.
大多數程序員都同意高級腳本語言相對容易學習。 JavaScript以及Python和Ruby都屬于這一類。
Even though universities still teach languages like Java and C++ as first languages, they’re considerably harder to learn.
即使大學仍將Java和C ++之類的語言作為第一語言來教,但它們卻很難學習。
因素4:可以用它構建的項目 (Factor 4: Projects you can build with it)
This is where JavaScript really shines. JavaScript runs on any device that has a browser, right there in the browser. You can build basically anything with JavaScript, and share it anywhere.
這就是JavaScript真正發揮作用的地方。 JavaScript可在裝有瀏覽器的任何設備上運行,就在瀏覽器中。 您基本上可以使用JavaScript構建任何東西,然后在任何地方共享。
Because of JavaScript’s ubiquity, Stack Overflow co-founder Jeff Atwood coined his now-famous law:
由于JavaScript的普及,Stack Overflow聯合創始人Jeff Atwood提出了他現在著名的法律:
“Any application that can be written in JavaScript, will eventually be written in JavaScript.”
“ 能在JavaScript編寫的任何應用程序,最終將用JavaScript編寫的。”
And with each passing month, Atwood’s Law holds strong.
而且, 隨著時間的流逝 ,阿特伍德定律變得越來越強大。
Java once promised to run everywhere, too. You may remember Java Applets. Oracle officially killed them off earlier this year.
Java曾經承諾也可以在任何地方運行。 您可能還記得Java Applets 。 Oracle今年早些時候正式殺死了他們。
Python suffers from much the same problems:
Python遭受很多相同的問題:
“How can I give this game I made to my friend? Even better, is there a way can I put this on my phone so I can show it to kids at school without them having to install it? Um.” — James Hague in Retiring Python as a Teaching Language
“如何將我制作的這款游戲給我的朋友? 更好的是,有什么方法可以將其放在手機上,這樣我就可以將它們展示給學校的孩子,而無需他們安裝嗎? 嗯。” -James Hague,《 退休使用Python作為教學語言》
By contrast, here are some apps that members of our open source community built in their browsers on CodePen. You can click through and use these right in your browser:
相比之下,這是我們的開源社區成員在CodePen的瀏覽器中構建的一些應用程序。 您可以在瀏覽器中單擊并使用以下內容:
很好地學習一種語言。 然后學習第二個。 (Learn one language well. Then learn a second one.)
If you keep jumping from language to language, you won’t get far.
如果您不斷從一種語言跳到另一種語言, 那么您將走不遠 。
In order to move beyond the basics, you need to learn your first language well. Then your second language will be much, much easier.
為了超越基礎知識,您需要很好地學習母語。 這樣,您的第二語言就會容易得多。
From there, you can branch out, and become a more well-rounded developer by learning lots of languages:
您可以從那里分支出來,通過學習許多語言來成為更全面的開發人員:
- C is a great way to learn how computers actually work in terms of memory management, and is useful in high-performance computing C是學習計算機在內存管理方面實際工作方式的一種好方法,并且對高性能計算很有用。
- C++ is great for game development. C ++非常適合游戲開發。
- Python is awesome for science and statistics. Python對于科學和統計資料來說是很棒的。
- Java is important if you want to work at large tech companies. 如果您想在大型高科技公司工作,那么Java非常重要。
But learn JavaScript first.
但是先學習JavaScript。
OK, now I’m going to attempt the impossible — I’m going to try and anticipate objections from the comments section.
好的,現在我將嘗試不可能的事情-我將嘗試并預期評論部分的反對意見。
異議1:但是JavaScript不會慢嗎? (Objection 1: But isn’t JavaScript slow?)
JavaScript is — for most practical purposes — as fast as high-performance languages.
在大多數實際情況下,JavaScript的速度與高性能語言一樣快。
JavaScript (Node.js) is orders of magnitude faster than Python, Ruby, and PHP.
JavaScript(Node.js)比Python,Ruby和PHP快幾個數量級。
It is also nearly as fast as high-performance languages like C++, Java, and Go.
它也幾乎與C ++,Java和Go等高性能語言一樣快。
Here are the results of the most comprehensive recent cross-language benchmark:
以下是最近最全面的跨語言基準測試的結果:
異議2:但是JavaScript不是靜態類型的 (Objection 2: But JavaScript isn’t statically typed)
Like Python and Ruby, JavaScript is dynamically typed, which is convenient. But you can get into trouble. Here I intend for exampleArray
to be an array. I set its values, then check its length — meaning the number of elements it contains.
像Python和Ruby一樣,JavaScript是動態類型的,這很方便。 但是您可能會遇到麻煩。 在這里,我打算將exampleArray
作為一個數組。 我設置了它的值,然后檢查了它的長度,即它包含的元素數量。
exampleArray = [1, 2]
-> [1, 2]exampleArray.length
-> 2
But then I accidentally assign it to be a string.
但是后來我不小心將其分配為字符串。
exampleArray = “text”
-> “text”exampleArray.length
-> 4
These kinds of errors happen all the time in dynamically typed languages. Most developers just put checks in place to prevent them, and write tests accordingly.
這些類型的錯誤始終以動態類型的語言發生。 大多數開發人員只是將檢查放在適當的位置以防止它們發生,并相應地編寫測試。
If you absolutely must have static typing in your first programming language, then I still recommend you learn JavaScript first. Then you can quickly pick up TypeScript.
如果您絕對必須在第一種編程語言中進行靜態鍵入,那么我仍然建議您首先學習JavaScript。 然后,您可以快速選擇TypeScript。
“Typescript has a learning curve, but if you already know JavaScript, it will be a smooth one.” — Alex Ewerl?f on TypeScript
“ Typescript有一個學習曲線,但是如果您已經了解JavaScript,那將是一個平穩的過程。” — TypeScript上的AlexEwerl?f
異議3:但我真的很想開發一個移動應用 (Objection 3: But I really want to make a mobile app)
I still recommend learning JavaScript first.
我仍然建議先學習JavaScript。
JavaScript features several tools for making native mobile apps, such as Angular Cordova and React Native.
JavaScript具有用于制作本地移動應用程序的多種工具,例如Angular Cordova和React Native 。
- In order for your mobile app to actually do anything interesting, it will probably need a proper back end, which you’ll want to build with a proper web development framework, like Node.js + Express.js. 為了使您的移動應用程序實際執行任何有趣的操作,它可能需要一個適當的后端,您需要使用適當的Web開發框架(例如Node.js + Express.js)來構建該后端。
Also, it’s worth pointing out that the mobile app development’s best days may very well be behind it.
另外,值得指出的是,移動應用程序開發的最佳時期可能已經過去。
For starters, as much as people use mobile apps, nearly half of all developer jobs are web development. Compare this with a mere 8% of jobs that involve mobile app development.
對于初學者來說,與使用移動應用程序的人一樣多,幾乎所有開發人員的工作都是Web開發。 與此相比,僅有8%的涉及移動應用程序開發的工作。
The grand vision of “there’s an app for that” has not come to pass. Instead, most smartphone owners have stopped downloading new apps.
“為此目的有一個應用程序”的宏偉愿景尚未實現。 相反,大多數智能手機所有者已停止下載新應用 。
Sure — they still use apps. Mostly Facebook, Google Maps, and handful of others. As such, much of the demand for mobile app developers is concentrated in a few large employers.
當然-他們仍在使用應用程序。 主要是Facebook,Google地圖以及其他少數幾個。 因此,對移動應用程序開發人員的大部分需求都集中在少數大型雇主上。
The outlook for those mobile development jobs is hard to forecast. Many aspects of developing, maintaining, and distributing mobile apps are easier with JavaScript. So companies like Facebook and Google are investing heavily in better tools for building these using JavaScript.
這些移動開發工作的前景很難預測。 使用JavaScript可以更輕松地開發,維護和分發移動應用程序的許多方面。 因此,像Facebook和Google這樣的公司都在大力投資于更好的工具,以使用JavaScript構建這些工具。
As of 2016, pretty much all development is web development. Everything touches that big platform that is “the web.” And the next wave of devices that you’ll talk to around your home, and cars that pick your kids up from school — they’ll all be piped together using the web, too.
截至2016年,幾乎所有開發都是Web開發。 一切都觸及那個大平臺,即“網絡”。 下一波您將在家里與之交談的設備,以及將孩子接送學校的汽車-它們也都將通過網絡通過管道連接在一起。
And that means JavaScript.
那就是JavaScript。
異議4:JavaScript是否不是10天內編寫的玩具語言? (Objection 4: Isn’t JavaScript a toy language that was written in 10 days?)
JavaScript has a quirky history.
JavaScript具有古怪的歷史 。
You will undoubtedly hear people crack jokes at its expense.
毫無疑問,您會聽到人們為笑話而付出的代價。
Well people love to hate on C++, too. And like JavaScript, C++ has succeeded despite this hate, and now it’s pretty much everywhere as well.
人們也很喜歡討厭C ++。 和JavaScript一樣,盡管有這種討厭,C ++還是成功了,現在在幾乎所有地方也是如此。
So if anybody ever gives you a hard time for learning JavaScript instead of elite-language-of-the-week, just remember the famous words of the guy who created C++:
因此,如果有人讓您很難學習JavaScript,而不是每周學習精通語言,那么請記住創建C ++的那個人的著名話:
“There are only two kinds of programming languages: those people always bitch about and those nobody uses.” — Bjarne Stroustrup
“只有兩種編程語言:那些總是無聊的人和那些沒人使用的語言。” — Bjarne Stroustrup
I only write about programming and technology. If you follow me on Twitter I won’t waste your time. ?
我只寫關于編程和技術的文章。 如果您在Twitter上關注我,我不會浪費您的時間。 ?
翻譯自: https://www.freecodecamp.org/news/what-programming-language-should-i-learn-first-19a33b0a467d/