Just wanted to mention, that chatGPT is aware of Crystal and can write and/or explain Crystal code (at least to some degree). It’s not in a way that one can just lean back and let the AI do all the work, and it’s only to some amount reliable. But at least it’s in general “supported”. I was somewhat surprised and find it to be not totally useless. Distrust in the answers is absolutely justified and a must (as the AI will just make things up if “necessary”), but some of the answers (to some very simple questions) were very useable and would compile (and do what was requested); but there were also moments in which the code wouldn’t compile. It doesn’t replace other resources (and sadly isn’t reusable by others as well - unlike for example posts in the Help & Support forum) but if you need a quick answer, it’s probably worth giving it a try.
Here is an example:
Me:
write a method to calculate fibonacci numbers in Crystal
ChatGPT:
Certainly! Here is a method for calculating Fibonacci numbers in Crystal:
def fibonacci(n : Int64) : Int64 if n <= 0 return 0 elsif n == 1 return 1 else return fibonacci(n-1) + fibonacci(n-2) end
This method uses recursion to calculate the Fibonacci number at the given index
n
. The base cases are whenn
is less than or equal to 0, in which case the function returns 0, and whenn
is 1, in which case the function returns 1. For all other values ofn
, the function calculates the Fibonacci number by adding the previous two Fibonacci numbers (which are calculated recursively).Here’s an example of how you can use this method:
puts fibonacci(0) # prints 0 puts fibonacci(1) # prints 1 puts fibonacci(2) # prints 1 puts fibonacci(3) # prints 2 puts fibonacci(4) # prints 3 puts fibonacci(5) # prints 5
I hope this helps! Let me know if you have any questions.
If you haven’t used it so far, this is how you get the answers presented (if you use directly their website and not any client via api).
Although the code is neither correct nor good nor efficient in this case, but it might still be enough help if one was stuck with some problem.
Also: the AI gets really tricky to solve some problems and will use shards which don’t exist and it just made up (which can be useful occasionally as well, as the naming might be close to existing c libraries)
And here are two more examples of possible questions/ answers (sorry to everyone who uses the forum with some translation - this time it’s just the picture as it’s too much text).
Not amazing and always to be taken with some doubt and distrust, but imho it can be useful sometimes, and it’s easy and quick to access.
Maybe it helps someone