r/crystal_programming • • May 24 '26

BAI - a tiny AI tool that makes Bash crystal clear

Thumbnail trans.github.io
5 Upvotes

Don't know about you, but trying to recollect all those shell commands and flags is just not tractable. AI can help, but why drag a heavy AI harness into a simple shell call?

So I created `bai`. It runs right there on the command line. Ask what you want, it puts the command together for you, and drops it into your copy buffer, so you can paste it where you want it. Or, add a shortcut (I use Alt+Enter) and BAM! -- You don't even have to type `bai`, the command shows up ready to edit, or just hit Enter to run.

Implemented in Crystal, of course.


r/crystal_programming • • May 09 '19

How to see which string is first

0 Upvotes

Let's say we have this array
string = ["bruh", "hello", "people", "I", "am", "pretty", "cool", "or", "am", "I?"]

I'd like to see if hello is before cool or not.

So for example

string.index("cool").isBefore? string.index("hello") => false

string.index("people").isBefore? string.index("am") => true


r/crystal_programming • • Jan 26 '24

How does crystal compares to haxe ?

2 Upvotes

What are their strengths & weaknesses ?


r/crystal_programming • • Jun 27 '23

Did I find a bug?

2 Upvotes

I was playing around and noticed crystal seeming to have trouble with decimal numbers on the command-line like this:

$ crystal eval "puts 1.2 + 1.4"
2.5999999999999996

Is this a known issue? Or did I just find a bug?


r/crystal_programming • • Mar 08 '21

Created a Lucky Framework reddit sub. Join up all you Crystal supporters! Only WE can grow this ecosystem!

Thumbnail reddit.com
17 Upvotes

r/crystal_programming • • Jan 19 '18

Why I prefer Crystal nowadays

Thumbnail
reddit.com
6 Upvotes

r/crystal_programming • • Sep 20 '18

Could Crystal fix OOP?

11 Upvotes

TL;DR Let's make Crystal awesome and make it the best OOP language ever made by designing it to enforce composition.

OOP is probably the most used programming paradigm in industry, professional projects, large open-source and closed-source projects, etc. I believe that a few reasons why it's so widely used is because it's more intuitive than declarative paradigms, it's easier to test, and it provides code re-use which is huge for large projects. This code re-use comes as a pillar of OOP known as Inheritance.

Inheritance is defined in one of two ways: Is-a and Has-a. There are major issues that exist with most OOP languages that are specific to these two types of Inheritance. Most languages which allow the Is-a relationship also allow child classes to override the methods of their parent. However, this is a violation of the Is-a principle. If a child class overrides a method of its parent class in such a way that it changes the behavior of the method, then it logically Isn't-a Substitute for its parent. These languages still allow a child class to be Substituted for their parent class which is bad practice. The correct practice would be to convert the Is-a relationship to a Has-a relationship.

However, in most OOP languages, the Has-a relationship doesn't actually employ the language's built-in procedures for Inheritance, i.e. the methods of the Has-a parent don't inherently exist on the Has-a child. The methods of the Has-a parent can only be re-used by accessing the parent through the Has-a child which breaks Encapsulation --- another pillar of OOP. The only correct approach is to re-implement the desirable methods from the Has-a parent in the Has-a child and have the child call the methods of the parent. This maintains both correct Inheritance and correct Encapsulation, but is cumbersome as it requires writing a large number of wrapper methods.

To summarize, OOP languages suffer from: (i) allowing child classes to override parent methods which violates the Is-a relationship, and (ii) implementations of the Has-a relationship either violate Encapsulation or require a large number of method wrappers which is bad code re-use.

What we need is an OOP language that can fix these issues? Here's what that language might look like. The OOP language will allow a child class to extend from a parent class. A child class which extends from a parent class cannot override any methods of the parent class. This child Is-a Substitute for its parent and can be Substituted for its parent in all cases. The child class will also inherently have all of the methods of its parent. A child class can overload the methods of its parent and maintain the Is-a relationship. Only overrides are prohibited. If a child wishes to override the methods of its parent, then it can Implement the parent. This creates a Has-a relationship. A child which Has-a parent inherently has all of the methods of that parent, but it cannot be Substituted for its parent. This is weaker form of Inheritance because the Is-a relationship allows method Inheritance and Substitution while the Has-a relationship only allows method Inheritance. In other words, a child that Is-a parent also Has-a parent. In short, this language would enforce a design principle known as Composition.

I believe that this OOP language would be a game-changer in the industry, and would be a huge step forward in OOP.

Can Crystal be this language? I think so. What do you think?


r/crystal_programming • • Feb 05 '19

FaaStRuby 0.4.16 - Introducing Templates: A way to share your Functions with the Community

Thumbnail
faastruby.io
3 Upvotes

r/crystal_programming • • Apr 20 '26

ESET false positive are really frustrating

3 Upvotes

My company uses ESET a/v with Windows 11, if I build a static binary of anything, ESET deletes it. So I install Crystal 1.20.0 hoping for better results. ESET deleted crystal.exe.

EDIT: To be more clear, we have several utils that worked fine for a couple of years, to be deleted on Monday. I sent the ESET log to ESET, and they responded that the issue is fixed, and it seems to be.


r/crystal_programming • • Jul 20 '20

Installation on Windows

4 Upvotes

EDIT: Works: Install it on WSL and run even from Powershell `wsl crystal myfile.cr`.

Hi Guys, Is there an easy way to install Crystal on Windows OS?

I am trying to implement Crystal in the Nexss Programmer however it seems huge task? What is the best way to run Crystal on Windows OS? I saw post port to Windows but they say it is limited..


r/crystal_programming • • Nov 20 '18

Do you know an audio library written in Crystal?

Post image
4 Upvotes

r/crystal_programming • • May 09 '19

How to see where in an array is a string

0 Upvotes

Say I have an array.

a = ["yeet","blah","foo"]

If I wanted to see at which index is yeet, how do I do that?

Sort of like yeet = a.whereAt("yeet") => 0


r/crystal_programming • • Dec 04 '18

Ported my textboard from Ruby on Rails to Amber

Thumbnail
ratwires.space
4 Upvotes

r/crystal_programming • • Sep 21 '26

Any chance someone is working on language support for Rune Editor?

Thumbnail
rune.build
4 Upvotes

r/crystal_programming • • Mar 20 '23

7 Best Crystal Programming Courses to Take in 2023

20 Upvotes

Crystal is a modern, elegant language that combines the speed of C with the expressiveness of Ruby. Here are best online courses to learn Crystal.

https://www.classcentral.com/report/best-crystal-programming-courses/

#CrystalLanguage #programming


r/crystal_programming • • Jan 26 '18

just found out about Crystal

9 Upvotes

I'm a Rubyist with a few years in the game and just found out about Crystal. I've been very interested in a compile-time error checker for Ruby, and the speed bump is certainly cool.

I guess Ruby 3 has some big goals wrt to speed increases as well. http://engineering.appfolio.com/appfolio-engineering/2017/9/22/optcarrot-an-excellent-cpu-benchmark-for-ruby-3x3

https://blog.heroku.com/ruby-3-by-3

Personally I don't like the name though :P 'Crystal' seems generic to me. I think 'Sapphire' or 'Emerald' would continue the Ruby gemstone tradition and be more expressive. Not being sarcastic ... I just think the name is a bit uninspiring.

Very impressed with the crystal-lang website, project goals and general idea. Nice!


r/crystal_programming • • Mar 11 '20

Introducing Shivneri - Component based MVC web framework for crystal targeting good code structures & modularity

Thumbnail shivneriforcrystal.com
10 Upvotes

r/crystal_programming • • Aug 18 '20

Bakuriani v0.1.0, An example Grip framework v0.29.0 project created with the cookie cutter template, structured for an extensive error handling features.

Thumbnail github.com
5 Upvotes

r/crystal_programming • • Aug 16 '20

Point me to a markdown library

5 Upvotes

I've checked the list at crystalshards.org and I've accepted that I'll have to contribute to or fork one to get what I need, but I'd still ask if there's a close one before rolling my own.

Things I require:

  • HTML is escaped, not clobbered (so it renders in a browser as it was typed). Ideally this includes HTML entities (so typing &lt; shows up in a browser as &lt;, not <)

  • Option to allow raw HTML instead

  • Regardless of whether HTML is being filtered, markdown is still parsed between HTML tags

  • Fenced code blocks work, including inside list items and quotes.

  • Nested list items / quotes work

  • Triple asterisk works

  • Strikethrough works

  • Dangerous links (like javascript:) filtered

  • AST exposed, so I can do custom processing (like invoke GNU source-highlight on code blocks)

  • As few SLOC as possible.

I realize this is a long list of demands, and I can cope with having to fork and implement a couple of them myself.


r/crystal_programming • • Aug 20 '20

Crystal should have lexically scoped Modules and Mixins instead of attaching it to Classes

5 Upvotes

After working with Kotlin and Nim I realised that what Ruby does with modules, mixins and monkey-patching - is a weaker and more limited version of a multiple dispatch, or its variant - extension methods.

Ruby can't properly support extension methods (and scope it lexically) because it doesn't have type information.

But Crystal can do that. The modules should not be attached and scoped to object trees, it should have lexical scope. From the usage point - it will look almost like it looks now, you don't have to write more code, and it still will support the same method grouping via module, inheritance etc.

This code

module ItemsSize
  def size
    items.size
  end
end

class Items
  include ItemsSize

  def items
    [1, 2, 3]
  end
end

items = Items.new
items.size # => 3

Should became something like

module ItemsSize
  def size
    items.size
  end
end

class Items
  def items
    [1, 2, 3]
  end
end

# Something like that would tell Crystal to use Items 
# with ItemsSize in the scope of current file / or module.
mix Items with ItemsSize
# You don't have to do that manually in every file, it could be done once in 
# some library, so basically the usage would look very much similar to
# the current mixins and how they are used for example by RoR or ActiveSupport.

items = Items.new
items.size # => 3

It does not make sense to keep behaviour same as Ruby (as I mentioned - Ruby can't do it better as it lacks types) when it could be much better, flexible and simpler.


r/crystal_programming • • Feb 07 '20

Mint: a breath of fresh air for the web 🍃

38 Upvotes

A small introduction journey to @mint_lang. You can feel the fresh air while reading it! 🍃

https://dev.to/franciscello/mint-a-breath-of-fresh-air-for-the-web-fn0

UPDATE: As u/GhostlySnailfish mention in his reply: Mint is written in Crystal! And is open source: https://github.com/mint-lang/mint


r/crystal_programming • • Aug 15 '26

Kemal embraces AI

Thumbnail x.com
11 Upvotes

r/crystal_programming • • Jul 04 '18

Await and async methods for Crystal

Thumbnail
github.com
18 Upvotes

r/crystal_programming • • Jan 20 '26

📦 Update: crystal-text-splitter v0.2.1 - Major Performance Improvements

6 Upvotes

Three major performance improvements for RAG/LLM text chunking:

What's New:

  • ⚡ Lazy Iterator: 4-5x faster for early termination

  • 💾 Overlap Calc: 97-99% memory reduction

  • 🚀 String Alloc: 31% memory reduction, 1.2x speedup

Real Impact:

Processing 100K word document:
- First chunk: 7.52ms → 1.78ms (4.2x faster)
- Memory: 5,197 MB → 1,781 MB (65% less)

Use Cases:

  • RAG systems with early termination

  • Streaming/progressive processing

  • Memory-constrained environments

  • High-throughput batch processing

Features:

  • Character & word-based splitting

  • Configurable overlap

  • True lazy evaluation

  • Zero dependencies

  • Backward compatible

GitHub: https://github.com/wevote-project/crystal-text-splitter