zoukankan      html  css  js  c++  java
  • crystal-lang 学习一 安装基本环境

    crystal-lang 是一个不错的小众语言,ruby 模式的编写,c 级别的性能,不好的地方是目前社区的标准库有点少
    这篇主要介绍关于安装环境的

    linux 安装(centos)

    • 添加repo
     
    curl https://dist.crystal-lang.org/rpm/setup.sh | sudo bash
    • 安装
    sudo yum install crystal

    简单使用

    • 创建项目

      使用shards

    shards init
    • 添加入口
      修改shard.yml 文件
    name: mydemo
    version: 0.1.0
    # authors:
    #   - name <email@example.com>
    targets:
      myhttp:
        main: src/main.cr
    # description: |
    #   Short description of mydemo
    # dependencies:
    #   pg:
    #     github: will/crystal-pg
    #     version: "~> 0.5"
    # development_dependencies:
    #   webmock:
    #     github: manastech/webmock.cr
    # license: MIT
    • 构建
    shards build
    • 容器集成
      Dockerfile
     
    FROM crystallang/crystal:latest-alpine as build
    WORKDIR /app
    COPY . .
    RUN shards build --release --production --static
    FROM alpine:latest
    WORKDIR /app
    COPY --from=build /app/bin /app/bin
    CMD myhttp
    • perf 火焰图

    说明

    crystal-lang 目前是不直接支持Windows的,需要使用windows 子系统,同时通过火焰图也可以看出来crystal的调用连比较清晰,而且符号表还是比较全的
    分析问题还是比较方便的

    参考资料

    https://crystal-lang.org/install/

  • 相关阅读:
    [Algorithms] Counting Sort
    [LeetCode] Sort Colors
    [LeetCode] Contains Duplicate III
    [LeetCode] Contains Duplicate
    [LeetCode] Two Sum II
    [LeetCode] Linked List Cycle II
    [LeetCode] Linked List Cycle
    [LeetCode] Longest Palindromic Substring
    [LeetCode] Two Sum
    [LeetCode] Rectangle Area
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/13223381.html
Copyright © 2011-2022 走看看