The Crystal Programming Language Forum

Real Crystal Capabilities

Hello everyone :heart: . I’m a newbie and have been using Crystal recently. Hopefully I’ve chosen the correct section for this.
I would like to know what the Crystal can do in addition to including some of Ruby’s features. I’m reading the documentation and I think it is a language for web development, services, etc. But when I saw error handling in the style of C code, then I thought that Crystal could be used to write, for example, drivers for systems.
Please tell me if I can use Crystal to write low-level applications? I was very inspired by the utilities of Crystal and my desire to study it is very strong.

1 Like

Hi, and welcome!

Crystal is a general purpose programming language, so you can basically use it for anything. I think there’s a tendency to use it for web development because its syntax is similar to Ruby, but I know it’s also been used for command line applications, background job processors and video games.

But when I saw error handling in the style of C code

Could you show an example of that? For error handling Crystal uses mainly exceptions, which don’t exist in C. Then you can also have a method return a value or nil, and handle that inline in the code. But it’s again different from C where mainly errno is used.

Please tell me if I can use Crystal to write low-level applications?

Could you describe what low-level applications you have in mind? With Crystal you can do raw pointer manipulation and interfacing with C libraries, but Crystal always includes a GC and a runtime. So for example writing drivers is probably not a good fit for the language.

1 Like

Thanks! I mean this:
STDERR.puts "ERROR: #{option_flag} is missing something." STDERR.puts "" STDERR.puts parser exit(1)
stderr reminded me of C :smiley:

e.g an application for managing processes in Linux, an application for using it in uefi

That code works exactly like this on Ruby :laughing:
And this isn’t error handling, it’s stream output. STDERR is just a standard stream the operating system’s process model.

That should technically be doable, yes. There is even an operating system written in Crystal: GitHub - ffwff/lilith: x86-64 os made in crystal =)

Theoretically Crystal can do most of the things C can. The only issue is how much stdlib overhead you carry with it.

2 Likes

Wow awesome! Thanks!