-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,022 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
--- | ||
title: 2019年最快的Javascript框架 | ||
image: https://res.cloudinary.com/fengerzh/image/upload/fastest-framework_joqgvx.jpg | ||
category: 编程 | ||
tags: | ||
- javascript | ||
description: 来体验一下2019年最快的Javascript框架。 | ||
color: black | ||
--- | ||
|
||
来体验一下`2019`年最快的`Javascript`框架: | ||
|
||
![图片描述][1] | ||
|
||
速度是纯`nodejs`的`2`倍,更不用说其他依赖`nodejs`的框架例如`express/koa/hapi`了,根本不值一提,不但如此,性能还能吊打`spring`以及一众`php7`框架。 | ||
|
||
百闻不如一见,下面我们就来安装尝鲜: | ||
|
||
``` | ||
npm install -g es4x-pm | ||
``` | ||
|
||
这就装好了。下面我们来用它创建一个项目,新建一个空文件夹,然后: | ||
|
||
``` | ||
es4x init | ||
``` | ||
|
||
项目就建好了。 | ||
|
||
我们需要写一个最简单的 index.js 文件: | ||
|
||
```js | ||
console.log("hello"); | ||
``` | ||
|
||
直接启动吧: | ||
|
||
``` | ||
yarn start | ||
``` | ||
|
||
嗯,报了个错误: | ||
|
||
``` | ||
error package.json: Name can't start with a dot | ||
``` | ||
|
||
我们`package.json`里的名字不能只是一个点,得改一下: | ||
|
||
``` | ||
"name": "hello", | ||
``` | ||
|
||
再次启动,还是启不起,哦,我们还没有安装依赖: | ||
|
||
``` | ||
yarn add @vertx/core | ||
``` | ||
|
||
这样就能运行了,但是会报一个警告: | ||
|
||
``` | ||
ES4X is using graaljs in interpreted mode! Add the JVMCI compiler module in order to run in optimal mode! | ||
``` | ||
|
||
对于我们这样有洁癖的人不能忍受啊。 | ||
|
||
这是因为我们现在系统环境里的`Java`还是个旧的`Java`,而`Oracle`最新推出的`Graal`才是最新最好的`Java`,所以我们先安装一下`Graal`: | ||
|
||
``` | ||
brew cask install graalvm/tap/graalvm-ce | ||
``` | ||
|
||
再次执行`yarn start` | ||
|
||
现在警告也没有了,一切顺利! | ||
|
||
试着写点`ES6`的语法: | ||
|
||
``` | ||
const a = () => { | ||
console.log('hello') | ||
} | ||
a() | ||
``` | ||
|
||
一样可以顺利执行! | ||
|
||
再往后就是生成`http`服务器,连接`mysql`等等,这些就跟其他框架大同小异了,不再细讲。 | ||
|
||
## 原理 | ||
|
||
我始终认为,用什么语言根本就是无所谓的,只有外行才讲什么语言是最快的。`JS`慢只是因为底层的`Node`慢,而`Node`的`V8`引擎又不是拿`JS`写的,而是拿`C++`写的。 | ||
|
||
现在的这个[es4x][2] ([中文文档][3])它一样能解释`JS`语言,只不过它的底层换成了`Java`,用的是`Eclipse`的[Vert.x][4]技术,而原生的`Vert.x`技术用的是`Java`旧版引擎,对`ES6`支持不好,换成`Oracle`最新的[GraalVM][5]就一切都解决了。当然也不能就此说`C++`比`Java`慢,那样你就又浅薄了。 | ||
|
||
有人抬杠说`JS`不能写操作系统底层,有什么不能写的?无非就是个语言而已,你把它编译成二进制就什么都能干了,没听说过[nexe][6]吗? | ||
|
||
学了编译原理,你就知道语言是什么根本不重要。会说中文的没有必要看不起会说英文的,会说英文的没有必要看不起会说中文的,什么语言好,放在工程项目当中,重要的只是生态,其他都没有可比性。 | ||
|
||
[1]: https://segmentfault.com/img/bVbxYFf | ||
[2]: https://github.com/reactiverse/es4x | ||
[3]: https://reactiverse.io/es4x/zh/get-started/ | ||
[4]: https://github.com/eclipse-vertx/vert.x/ | ||
[5]: https://github.com/oracle/graal | ||
[6]: https://github.com/nexe/nexe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
--- | ||
title: 一站配齐所有国内镜像 | ||
image: https://image-static.segmentfault.com/347/504/3475044146-620ef27b108b1_cover | ||
category: 编程 | ||
tags: | ||
- javascript | ||
- python | ||
- rust | ||
- php | ||
description: 以下列出我常用的所有国内镜像,方便有类似需求的同学参考。 | ||
color: black | ||
--- | ||
|
||
开发过程中,我们经常会用到各种各样的包管理工具,几乎每种包管理工具缺省设置都是从国外服务器下载相应的软件安装包,或者下载很慢,或者干脆无法下载。以下列出我常用的所有国内镜像,方便有类似需求的同学参考**(不定期更新,感觉有用的同学请注意收藏)**。 | ||
|
||
我平常用的`shell`是`fish`,所以下面的语法全都是`fish`相关的`set -x`,如果是用缺省的`bash`,可以替换成`export`命令。 | ||
|
||
# 操作系统相关 | ||
|
||
## brew 国内镜像 | ||
|
||
``` | ||
cd /usr/local/Homebrew | ||
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git | ||
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core | ||
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git | ||
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask | ||
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git | ||
``` | ||
|
||
``` | ||
# brew国内镜像 | ||
set -x HOMEBREW_BOTTLE_DOMAIN https://mirrors.ustc.edu.cn/homebrew-bottles | ||
``` | ||
|
||
# Javascript 相关 | ||
|
||
## npm 国内镜像 | ||
|
||
``` | ||
npm config set registry https://registry.npm.taobao.org/ | ||
``` | ||
|
||
## yarn 国内镜像 | ||
|
||
``` | ||
yarn config set registry https://registry.npm.taobao.org/ | ||
``` | ||
|
||
## pnpm 国内镜像 | ||
|
||
``` | ||
pnpm config set registry https://registry.npm.taobao.org/ | ||
``` | ||
|
||
## electron 国内镜像 | ||
|
||
``` | ||
yarn config set electron_mirror https://npm.taobao.org/mirrors/electron/ | ||
set -x ELECTRON_MIRROR http://npm.taobao.org/mirrors/electron/ | ||
``` | ||
|
||
## node-sass 国内镜像 | ||
|
||
``` | ||
yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ | ||
set -x SASS_BINARY_SITE https://npm.taobao.org/mirrors/node-sass/ | ||
``` | ||
|
||
## fsevents 国内镜像 | ||
|
||
``` | ||
yarn config set fse_binary_host_mirror https://npm.taobao.org/mirrors/fsevents/ | ||
set -x FSE_BINARY_HOST_MIRROR https://npm.taobao.org/mirrors/fsevents/ | ||
``` | ||
|
||
## 更多 | ||
|
||
更多设置,或者懒得一个一个设置的同学也可以参考这里: | ||
|
||
<https://gist.github.com/hetykai/484209019b1b0d39ea649540e554a0a4> | ||
|
||
把这些代码下载到一个 shell 脚本里,一键添加完成。 | ||
|
||
# Python 相关 | ||
|
||
## pip 国内镜像 | ||
|
||
``` | ||
$ cat ~/.pip/pip.conf | ||
[global] | ||
index-url=https://pypi.tuna.tsinghua.edu.cn/simple | ||
``` | ||
|
||
## conda 国内镜像 | ||
|
||
``` | ||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ | ||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ | ||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ | ||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ | ||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/ | ||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/ | ||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ | ||
conda config --set show_channel_urls yes | ||
``` | ||
|
||
# PHP 相关 | ||
|
||
## composer 国内镜像 | ||
|
||
``` | ||
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ | ||
``` | ||
|
||
# Rust 相关 | ||
|
||
## rustup 国内镜像 | ||
|
||
``` | ||
set -x RUSTUP_DIST_SERVER https://mirrors.ustc.edu.cn/rust-static | ||
set -x RUSTUP_UPDATE_ROOT https://mirrors.ustc.edu.cn/rust-static/rustup | ||
``` | ||
|
||
## cargo 国内镜像 | ||
|
||
修改当前用户目录下`.cargo/config`文件,改为: | ||
|
||
``` | ||
[source.crates-io] | ||
registry = "https://github.com/rust-lang/crates.io-index" | ||
replace-with = 'ustc' | ||
[source.ustc] | ||
registry = "git://mirrors.ustc.edu.cn/crates.io-index" | ||
``` | ||
|
||
# 其它语言 | ||
|
||
## flutter 国内镜像 | ||
|
||
``` | ||
set -x PUB_HOSTED_URL https://pub.flutter-io.cn | ||
set -x FLUTTER_STORAGE_BASE_URL https://storage.flutter-io.cn | ||
``` | ||
|
||
# 补充 | ||
|
||
## github 国内镜像 | ||
|
||
如果是在`git clone`时遇到了问题,可以先在码云建立一个库,来源取自 github,然后同步码云这个库即可。 |
Oops, something went wrong.