Crystal语言-飞快如 C,灵巧似 Ruby

斜高翰
2023-12-01

Warmly welcome you to give Crystal language a try :)

 

Crystal is a programming language with the following goals:

  • Have a syntax similar to Ruby (but compatibility with it is not a goal)
  • Statically type-checked but without having to specify the type of variables or method arguments.
  • Be able to call C code by writing bindings to it in Crystal.
  • Have compile-time evaluation and generation of code, to avoid boilerplate code.
  • Compile to efficient native code.

Why?

  1. We love Ruby's efficiency for writing code.
  2. We love C's efficiency for running code.
  3. We want the best of both worlds.
  4. We want the compiler to understand what we mean without having to specify types everywhere.
  5. We want full OOP.

Oh, and we don't want to write C code to make the code run faster.

语法源自于 Ruby,这使得我们能够更自然的阅读及撰写 Crystal,且对于有经验的 Ruby 开发者们在学习曲线上更有助益。
# A very basic HTTP server
require "http/server"

server = HTTP::Server.new do |context|
  context.response.content_type = "text/plain"
  context.response.print "Hello world, got #{context.request.path}!"
end

puts "Listening on http://127.0.0.1:8080"
server.listen(8080)

Language Website: https://crystal-lang.org/

Learning: https://crystal-lang.org/reference/getting_started/

 Community: https://crystal-lang.org/community/

Github: https://github.com/crystal-lang/crystal/

 

 类似资料: