diff --git a/Ch01/README.md b/Ch01/README.md index 06441ed..b1ab12f 100644 --- a/Ch01/README.md +++ b/Ch01/README.md @@ -1,7 +1,7 @@ -# Ch01 前端工程簡介和 React 生態系簡介 +# Ch01 Web Front-End Development Introduction and React Ecosystem Introduction -1. [Web 前端工程入門簡介](https://github.com/kdchang/reactjs101/blob/master/Ch01/front-end-introduction.md) -2. [React 生態系入門簡介](https://github.com/kdchang/reactjs101/blob/master/Ch01/react-ecosystem-introduction.md) +1. [Web Front-End Development Introduction](https://github.com/sycherng/reactjs101/blob/en-US/Ch01/front-end-introduction.md) +2. [React Ecosystem Introduction](https://github.com/sycherng/reactjs101/blob/en-US/Ch01/react-ecosystem-introduction.md) -## :door: 任意門 -| [回首頁](https://github.com/kdchang/reactjs101) | \ No newline at end of file +## :door: Nexus +| [Home](https://github.com/sycherng/reactjs101/tree/en-US) | diff --git a/Ch01/front-end-introduction.md b/Ch01/front-end-introduction.md index fa3928c..3915f03 100644 --- a/Ch01/front-end-introduction.md +++ b/Ch01/front-end-introduction.md @@ -1,28 +1,29 @@ -# Web 前端工程入門簡介 +# Web Front-End Development Introduction - + -## 前言 -隨著現代化網頁(Modern Web)開發專業和複雜性的提昇以及對於使用者體驗的要求下,網頁開發已從過去的 Web Developer 一夫當關,轉向專業分工,更加細分成網頁前端(Web Front End)、網頁後端(Web Back End)等職位。此外,由於跨平台、跨瀏覽器的需求日益增加,技術變化更迭快速,市場上對於前端工程師(Web Front End Engineer)的需求也與日俱增,前端工程的(Front End Engineering)所要面對的挑戰也越來越多。 +## Foreword +Due to rising complexity within professional modern web development and increasing demand for User Experience(UX), web development has transitioned from the "Web Developer" roles of the past where one developer handled the entire product, to role specialization, adding detailed division of work with roles in Web Front-End and Web Back-End. Additionally as demand for cross-platform and cross-browser support grows and the technologies and skills used rapidly evolve, the market's demand for Web Front-End Engineers also increases by the day, and challenges of Front-End Engineering will be ever increasing. - -## 前端工程範疇 -事實上,在目前的業界,前端工程的定位光譜非常廣泛,有聚焦在網頁設計(Web Design),也有專注在軟體工程(Software Engineering)的部份,本書則是將前端工程定位在軟體工程的範疇。而 HTML、CSS 和 JavaScript 是前端工程最重要的技術基礎。過去一段時間,我們所認為的前端工程主要專注在瀏覽器平台,但現在的 Web 平台已經不再侷限於桌面瀏覽器,而是必須面對更多的跨平台、跨瀏覽器的應用開發場景,其中包含: + -1. 網頁瀏覽器(Web Browser),一般的網頁應用程式開發 -2. 透過 CLI 指令去操作的 Headless 瀏覽器(Headless Application)。例如:[phantomJS](http://phantomjs.org/)、[CasperJS](http://casperjs.org/) 等 -3. 運作在 WebView 瀏覽器核心(WebView Application)的應用。例如:[Apache Cordova](https://cordova.apache.org/)、[Electron](http://electron.atom.io/)、[NW.js](http://nwjs.io/) 等行動、桌面應用程式開發 -4. 原生應用程式(Native Application),透過 Web 技術撰寫原生應用程式。例如:[React Native](https://facebook.github.io/react-native/)、[Native Script](https://www.nativescript.org/) 等 +## Front-End Development Scope +In truth, currently within the industry, the scope of Front-End Development falls under a wide spectrum, some focus on Web Design alone, and some include aspects of Software Engineering, this book will focus on the latter. HTML, CSS, and Javascript are the most important fundamental skills in Front-End Engineering. Sometime in the past, we knew Front-End Engineering to be focused on browser platforms, but today's Web platform is no longer only about desktop browsers, instead it now encompasses cross-platform, cross-browser application development environments, including: -過去幾年,前端開發就像經歷了文藝復興(Rinascimento)的年代,開始了各種框架、套件百花齊放的時代。雖然現在有更多好用工具可以協助開發,但前端工程師似乎並沒有變得比較輕鬆。以往若能妥善運用 jQuery 等函式庫就可以應付大部分前端工程師的工作,但現在前端徵才廣告上不僅要求精通 HTML、CSS 和 JavaScript,還要對於還要對於 [Backbone](http://backbonejs.org/)、[Ember](http://emberjs.com/)、[Angular](https://angularjs.org/)、[React](https://facebook.github.io/react/)、[Vue](https://vuejs.org/) 等 JavaScript 框架或函式庫有一定程度的了解。 +1. Web Browser, webapp development +2. Using command-line interfaces (CLI) to operate Headless Applications, for example: [phantomJS](http://phantomjs.org/), [CasperJS](http://casperjs.org/), etc +3. WebView Applications. For example: [Apache Cordova](https://cordova.apache.org/), [Electron](http://electron.atom.io/), [NW.js](http://nwjs.io/) to permit mobile and desktop application development. +4. Native Applications written with web development technologies, for example: [React Native](https://facebook.github.io/react-native/), [Native Script](https://www.nativescript.org/), etc. -在眾多 JavaScript 框架或函式庫中,[React](https://facebook.github.io/react/) 是 Facebook 推出的開源 [JavaScript](https://en.wikipedia.org/wiki/JavaScript) Library,它的出現讓許多革新性的 Web 觀念開始流行起來,例如:Virtual DOM、Web Component、更直覺的宣告式 UI 設計、更優雅地實現 Server Rendering 等。接下來本書將透過介紹 React 生態系(ecosystem)帶領讀者入門 React 的世界,讓讀者可以從零開始真的動手用 React 開發跨平台應用程式。 +In the past few years, Front-End development seems to have experienced a Rinascimento (French for renaissance), marking the beginnings of an era with a plethora of various frameworks and modules. Althrough there are now numerous great tools to assist in the development process, the work of a Front-End developer has not become easier. In the past, sensible use of jQuery library methods was sufficient to cover the bulk of a Front-End developer's job, but nowadays recruitment adverts not only ask for mastery in HTML, CSS, and Javascript, they also ask for a specific level of comprehension of JavaScript frameworks and libraries such as [Backbone](http://backbonejs.org/), [Ember](http://emberjs.com/), [Angular](https://angularjs.org/), [React](https://facebook.github.io/react/), [Vue](https://vuejs.org/) etc. -(image via [bsdacademy](http://bsdacademy.com/wp-content/uploads/2014/10/html-css-js.png)、[firebase](https://www.firebase.com/resources/images/website/logos/frameworks.png)) +Amongst the numerous Javascript frameworks and libraries, [React](https://facebook.github.io/react/) is an open-source [JavaScript](https://en.wikipedia.org/wiki/JavaScript) Library developed by Facebook. Its appearance enabled many revolutionary web concepts to become mainstream, for example: Virtual DOM, Web Component, more intuitive declarative UI design, more elegantly realized Server Rendering, etc. The rest of this book will use an introduction to the React ecosystem to introduce readers to the React world, allowing readers to write cross-platform React applications from scratch. -## :door: 任意門 -| [回首頁](https://github.com/kdchang/reactjs101) | [下一章:React 生態系(Ecosystem)入門簡介](https://github.com/kdchang/reactjs101/blob/master/Ch01/react-ecosystem-introduction.md) | +(image via [bsdacademy](http://bsdacademy.com/wp-content/uploads/2014/10/html-css-js.png), [firebase](https://www.firebase.com/resources/images/website/logos/frameworks.png)) -| [勘誤、提問或許願](https://github.com/kdchang/reactjs101/issues) | +## :door: Nexus +| [Home](https://github.com/sycherng/reactjs101/tree/en-US) | [Next article: React Ecosystem Introduction](https://github.com/sycherng/reactjs101/blob/en-US/Ch01/react-ecosystem-introduction.md) | + +| [Corrections, questions, or requests](https://github.com/kdchang/reactjs101/issues) | diff --git a/Ch01/react-ecosystem-introduction.md b/Ch01/react-ecosystem-introduction.md index fb2235f..58cdf2a 100644 --- a/Ch01/react-ecosystem-introduction.md +++ b/Ch01/react-ecosystem-introduction.md @@ -1,123 +1,126 @@ -# React 生態系(Ecosystem)入門簡介 +# React Ecosystem Introduction -入門簡介") + + +According to the explanation from [React's official page](https://facebook.github.io/react/), React is a Javascript Library that specializes in UI/Views. Ever since Facebook publicly launched React as an open-source library in 2013, its ecosystem has expanded rapidly. In fact, through the process of learning about the React ecosystem, we can also pick up important concepts in modern web development (examples: modularization, ES6+, Webpack, Babel, ESLint, functional programming design etc), thereby becoming even better developers. -根據 [React 官方網站](https://facebook.github.io/react/) 的說明:React 是一個專注於 UI(View)的 JavaScript 函式庫(Library)。自從 Facebook 於 2013 年開源 React 這個函式庫後,相關的生態系開始蓬勃發展。事實上,透過學習 React 生態系(ecosystem)的過程中,可以讓我們順便學習現代化 Web 開發的重要觀念(例如:模組化、ES6+、Webpack、Babel、ESLint、函數式程式設計等),成為更好的開發者。 ## ReactJS -ReactJS 是 Facebook 推出的 JavaScript 函式庫,若以 MVC 框架來看,React 定位是在 View 的範疇。在 ReactJS 0.14 版之後,ReactJS 更把原先處理 DOM 的部分獨立出去(react-dom),讓 ReactJS 核心更單純,也更符合 React 所倡導的 `Learn once, write everywhere` 的理念。事實上,ReactJS 本身的 API 相對單純,但由於整個生態系非常龐大,因此學習 React 卻是一條漫長的道路。此外,當你想把 React 應用在你的應用程式時,你通常必須學習整個 React Stack 才能充分發揮 React 的最大優勢。 +ReactJS is a Facebook-developed JavaScript library, if viewed from a MVC framework perspective, React falls under the scope of View(s). In ReactJS v0.14 onwards, ReactJS even isolated the DOM processing feature (react-dom), allowing ReactJS' core to become more pure, fulfilling React's philosophy of `Learn once, write everywhere`. Actually, ReactJS' API is relatively simple, but due to an enormous ecosystem, learning React is a rather long path. Furthermore, when you want to incorporate React in an application, you usually have to learn the entire React Stack to fully unleash React's biggest advantage. + -## JSX -事實上,JSX 並非一種全新的語言,而是一種語法糖([Syntatic Sugar](https://en.wikipedia.org/wiki/Syntactic_sugar)),一種語法類似 [XML](https://zh.wikipedia.org/wiki/XML) 的 ECMAScript 語法擴充。在 JSX 中 HTML 和組建這些元素標籤的程式碼有緊密的關係,這和過去我們強調 HTML、JavaScript 分離的觀念有很大不同。當然,你可以選擇不要在 React 使用 JSX,不過相信我,當你真正開始撰寫 React 元件(Component)時,你會很慶幸有 JSX 真好。 +## JSX +In truth, JSX is not a completely new language, but rather it is ([Syntatic Sugar](https://en.wikipedia.org/wiki/Syntactic_sugar)), with similar syntax as [XML](https://zh.wikipedia.org/wiki/XML) supplementing ECMAScript syntax. JSX code is closely related to the HTML and constructing elements it refers to, this vastly differs from the concept enforced in the past of separating HTML from JavaScript. Of course, you can opt not to use JSX in React, but believe me, when you begin to write React Components, you will be grateful JSX exists. ## NPM -NPM(Node Package Manager)是 Node.js 下的主流套件管理工具。在 NPM 上有非常多的套件,可以讓你不用再重造輪子,更可以讓你可以輕鬆用指令管理不同的套件。由於 NPM 主要是基於 [CommonJS](https://en.wikipedia.org/wiki/CommonJS) 的規範,通常必須搭配 Browserify 這樣的工具才能在前端使用 NPM 的模組。然而因 NPM 是基於 Nested Dependency Tree,不同的套件有可能會在引入依賴時會引入相同但不同版本的套件,造成檔案大小過大的情形。這和另一個套件管理工具 [Bower](https://bower.io/) 專注在前端套件且使用 Flat Dependency Tree(讓使用者決定相依的套件版本)是比較不同的地方。 +Node Package Manager (NPM) is the mainstream package manager for Node.js. There are numerous packages in NPM, so you will not have to reinvent the wheel, and it allows you to manage all packages with ease. Because NPM follows [CommonJS](https://en.wikipedia.org/wiki/CommonJS) specifications, usually a tool like Browserify must be used to use NPM modules in the front-end. But because NPM relies on a Nested Dependency Tree, packages could potentially require different versions of dependent packages, causing a bloat in file size. This is a notable difference between NPM and another package manager [Bower](https://bower.io/), which specializes in front-end packages and utilizes a Flat Dependency Tree (permits users to decide on the versions for dependent packages). ## ES6+ -[ES6+](https://babeljs.io/blog/2015/06/07/react-on-es6-plus) 係指 ES6(ES2015)和 ES7 的聯集,在 ES6+ 新的標準當中引入許多新的特性和功能,彌補了過去 JavaScript 被詬病的一些特性。由於未來 React 將以支援 ES6+ 為主,因此直接學習 ES6+ 用法是相對好的選擇,本書的所有範例也將會以 ES6+ 撰寫。 +[ES6+](https://babeljs.io/blog/2015/06/07/react-on-es6-plus) collectively refers to ES6(ES2015) and ES7, in the new specification under ES6+, many new characteristics and features were introduced, filling in the lacking points of past versions of JavaScript. Because in the future React will mainly support ES6+, going straight to learning ES6+ is a relatively sound choice, this book will use ES6+ for all code examples. ## Babel -由於並非所有瀏覽器都支援 ES6+ 語法,所以透過 [Babel](https://babeljs.io/) 這個 JavaScript 編譯器(可以想成是翻譯機或是翻譯蒟篛)可以讓你的 ES6+ 、JSX 等程式碼轉換成瀏覽器可以看得懂的語法。通常會在資料夾的 root 位置加入 `.babelrc` 進行轉譯規則 `preset` 和引用外掛(plugin)的設定。 +Because not all browsers support ES6+ syntax, we can use [Babel](https://babeljs.io/), a JavaScript pre-processor (you can think of it as a translator), allowing your ES6+ and JSX code to be converted to a syntax that the browser can understand. Usually in the root of project folders we will add a `.babelrc` for translation `preset`s and plugin configurations. + +## modularized JavaScript development +As WebApps increased in complexity, modularized Javascript development became an inevitable trend, below I show a simple introduction to Javascript modularization and its related rules. In fact, in the early days when there was no official specification, there were an assortment of different standards developed and practised by various communities. -## JavaScript 模組化開發 -隨著 Web 應用程式的複雜性提高,JavaScript 模組化開發已經成為必然的趨勢,以下簡單介紹 JavaScript 模組化的相關規範。事實上,在一開始沒有官方定義的標準時出現了各種社群自行定義的規範和實踐。 1. CDN-Based - 也就是最傳統的 `
- + - + -