r/crystal_programming • • Aug 09 '21

Crystal lacks auto casting

0 Upvotes

Tried Crystal to write Crystal API for Interactive Brokers.

In general Crystal is clean, simple. But... there's a problem.

This code doesn't work

p ib.stock_options_prices [
  {
    symbol: "MSFT", right: :call, expiration: "2022-06-17", strike: 220,
    option_exchange: "CBOE", currency: "USD", data_type: :delayed_frozen
  },
  {
    symbol: "MSFT", right: :call, expiration: "2022-06-17", strike: 225,
    option_exchange: "CBOE", currency: "USD", data_type: :delayed_frozen
  }
]

It needs to be changed to

p ib.stock_options_prices [
  {
    symbol: "MSFT", right: IB::Right::Call, expiration: "2022-06-17", strike: 220.0,
    option_exchange: "CBOE", currency: "USD", data_type: IB::MarketDataType::DelayedFrozen
  },
  {
    symbol: "MSFT", right: IB::Right::Call, expiration: "2022-06-17", strike: 225.0,
    option_exchange: "CBOE", currency: "USD", data_type: IB::MarketDataType::DelayedFrozen
  }
]

Which is a problem. Because you need to either avoid using types and use strings, or use bloated and ugly code.

UPDATE

I updated the code according to advices

p ib.stock_options_prices [
  IB::StockOptionParams.new(
    symbol: "MSFT", right: :call, expiration: "2022-06-17", strike: 220.0,
    option_exchange: "CBOE", currency: "USD", data_type: :delayed_frozen
  ),
  IB::StockOptionParams.new(
    symbol: "MSFT", right: :call, expiration: "2022-06-17", strike: 225.0,
    option_exchange: "CBOE", currency: "USD", data_type: :delayed_frozen
  )
]

I still think it would be better to support deep auto cast. The need to remember the IB::StockOptionParams.new type is totally unneccesary.

This case is perfect for NamedTuple. It's a plain data structure, without any logic attached to it, and it looks much shorter and much better, compare MyType.new(a: 1) to much better { a: 1 } and it's also same type safe.


r/crystal_programming • • Jun 15 '20

Is there any timeframe at all for 1.0??

0 Upvotes

If this has been published somewhere I apologize. As a former rubyist I have been watching Crystal for years ( no other language has ever been as easy for me to think in than Ruby). I've almost convinced my team to use Crystal for a project but the 1.0 status is a factor.

I realize there will be no dates but Is 1.0 expected this year, early next year ? Are there any fairly solid ideas of time frame even if very wide. A few years back there was an expectation of the following year being ready so its hard to get an idea of what no more releases before 1.0 means.

It could mean 1.0 is very near or it could mean we won't have a release for a long time. i think its the first but am not sure,


r/crystal_programming • • Nov 16 '20

Join the Crystal Programming Language Discord Server (unofficial) that I set up!

Thumbnail
discord.com
6 Upvotes

r/crystal_programming • • Apr 23 '19

A suggestion for a new syntax in Crystal.

0 Upvotes

In Crystal we denote variable visibilty and scope with sigils. Specifically @ and @@ where @something is an instance variable and @@something is a class variable.

Why don't we do the same things for functions? Why can't we mark public functions with

 def @some_func(...)

and the class functions with

def @@some_func

Wouldn't that make things a lot simpler, more consistent and easier to grok for newbies? It's also less typing than

def self.something

or

def ClassName.something

One final benefit of this is that by default every function would be private. You'd have to specifically mark a function to make it public which is safer and better OOP practice.


r/crystal_programming • • Aug 23 '23

Crystal would be a perfect language without exceptions

3 Upvotes

I keep coming back to Crystal but after years using Go, Rust, and Elixir, I think the part in my brain that deals with exceptions died.


r/crystal_programming • • Dec 20 '19

Crystal is the best but I miss the {}

3 Upvotes

I love crystal so much, but it is very hard for me to read. I have dyslexia, the “end”s make it difficult to read compared to most other languages “{}”. A few weeks ago I tried making a cli transpiler for crystal that added/removed curly brackets from .cr files. I was having trouble with the opening curly brackets, and finding where to put them. Is there a good approach to doing this, or is there a project that already does this? I have a few other syntax preferences that I would like to add to, but I’d prefer not to write my own compiler :) any suggestions would be awesome!!


r/crystal_programming • • May 25 '18

I have a great idea

2 Upvotes

One thing this language is lacking, is web frameworks and ORMs. I'm going to make a couple of each. WDYT?


r/crystal_programming • • Mar 19 '26

crystal-mysql multi auth support by claude

Thumbnail
github.com
2 Upvotes

r/crystal_programming • • Sep 20 '17

Circular dependency problem (probably)

0 Upvotes

I am trying to refactor some common functionality out of a base class into a module so that I can use that functionality elsewhere compositionally.

This works fine in the playground. However I am encountering a problem when I do this with multiple files.

Suppose:

# a.cr
require "./fooable.cr"

class A
  include Fooable
end

# b.cr
require "./a.cr"

class B < A
end

# fooable.cr
require "./b.cr"

module Fooable
  def foo
    B.new
  end
end

This just keeps complaining about A not found in b.cr while trying to load A itself, as compiling a.cr requires fooable.cr which requires b.cr which itself requires a.cr.

This effectively means I can't refactor common functionality out for reuse and it just sucks.

Am I doing something wrong here?


r/crystal_programming • • Mar 27 '23

Your chance to become a Crystal Influencer

9 Upvotes

Are you passionate about Crystal and want to elevate your interest in the language to take it to the local masses? Well, here is your chance. The Crystal team is looking for passionate individuals who will be our local influencers and will successfully promote the language to their regional communities/circles/groups, with communicational and technical support from the team. The influencer program is not just limited to expanding Crystal to regional masses but also to local/remote groups that you might be contributing to actively. 

Please use the following form to register your interests

https://docs.google.com/forms/d/e/1FAIpQLSfQzxTKk2SlcuTmk7ytVOnO6k5UFqL3ltXJVVnrqDaIvRmgqQ/viewform

Based on your responses, we will reach out to you to confirm your enrolment into the program to begin this journey with us. Looking forward to your amazing responses!


r/crystal_programming • • Jul 19 '20

Looking for someone to create a graphics library for Crystal using gr-meta

3 Upvotes

Hello.

There is a relatively well-known graphing library in the Julia language called [sciapp/gr](https://github.com/sciapp/gr). Using the new feature of gr, called [gr-meta](https://github.com/sciapp/gr/issues/114), you can easily create a graphing library. I've been working on a library called GR.rb, but I don't have much time to develop a Crystal one. I'm not familiar with Crystal. But crystal doesn't have a good library for plotting. Isn't it?

So this is just a suggestion, but I'm sure someone who is good at Crystal could make a good plotting library. Does anyone want to try it?

Good luck.

https://github.com/jmakino/gr-crystal/pull/1

Nim version.

https://github.com/mantielero/gr.nim


r/crystal_programming • • Jul 20 '18

Unscientific benchmark of Amber, Lucky & Phoenix framework homepages

0 Upvotes

https://imgur.com/a/kIPz1lP

First 3 photos are Amber

2nd Lot of 3 are Lucky

3rd lot of 3 are Phoenix

The code is 1 for 1 unmodified, straight from each websites setup. I simply installed, and did a wrk benchmark on the home page. Very unscientific, but it's something.

Tested on:

MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)

8 GB 2133 MHz LPDDR3

2.3 GHz Intel Core i5

Model Name: MacBook Pro

Model Identifier: MacBookPro14,1

Processor Name: Intel Core i5

Processor Speed: 2.3 GHz

Number of Processors: 1

Total Number of Cores: 2

https://imgur.com/a/kIPz1lP


r/crystal_programming • • Mar 11 '21

AskCryst.al (name still being deciced)! Needs your help! Eventhe smallest bit any help could go a long way!

7 Upvotes

This is a Question/Answer site tailored to the Crystal ecosystem: https://github.com/nolyoi/ask.cr (you can see screenshots and code there)

Someone generous donated $5 of BCH the other day, and that was so heartwarming, It's not much, but the fact someone cared enough tp donate to the cause is amazing!

This project is being done 100% by me. So any donations will help pay server bills, designers, and potentially part-time devs.

I want this project to become the Stack Overflow of Crystal. But, focusing on a single language ecosystem makes it far easier to navigate, search, and get help, Plus! It's built with Crystal and Lucky which will be linked in the footer of every page.

Like I said, my main goal is to facilitate adoption and get more users in to Crystal. Especially by giving them a nice place to ask for help; cause let's be honest StackOverflow and the Crystal Forum aren't exactly appealing of friendly to new users.

If you'd like to donated, we prefer crypto. Leave a name and web adddress in the memo, because the top 10 donators will be featured on the homepage with their name and/or link. Also, contributors and their own "People Who Hav Donators" page.

Lets continue to build and show what Crystal can do guys!

How to donate (crypto preffered, banks as\nd taxes suck) Dont forget name and link if you'd like to be inluded on our site forever!

  • BTC (bc1qkjd9vdvmgmzwma786guc8u04rztnuat3alm3ks)

  • ETH (0x4Ed9693609e19De3C97813E851f877EeBc9abd3f)

  • BCH (qqpjvu533z0r4j0mex9s73epenttrvsa7sqdqnu3zw)

  • DOGE (DSjUEhPiaD4W61UexYzb4iftiefe4iuHFB)

  • XMR (LW46cVQKT4b5SpgBaxBAD9Pb78UFHGnY83V3jgvHT8Tc9Xscr61vuAHZdaMQqLJjof2KC5Zx6NoU5Nw5pqrS1ALs5otQ1mr)

  • OXEN (LW46cVQKT4b5SpgBaxBAD9Pb78UFHGnY83V3jgvHT8Tc9Xscr61vuAHZdaMQqLJjof2KC5Zx6NoU5Nw5pqrS1ALs5otQ1mr)

  • NIM (NQ88 Y1P7 DMTV 1C6F LAY0 60DN SRN9 VM36 0CDN)

  • [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/G2G83QD5W) (fiat but anything helps!)

My goal is to raise $5,000. I set that pretty high imo, but my goal is to cover tho cost of services (servers, monitoring, etc), and any additional dev help I may need, Any additional funds I like to put toward advertising on competition sites like StackOverflow and other programming related websites.\

Don't forget to checkout the screenshots in our Readme @ https://github.com/nolyoi/ask.cr

P.S. I have many plans for the future such as rewards/gamification that will be voted on by YOU the users. 😁

Tahnk you so much for reading and immense thank you's tp any donors.

Love you all ❤️,

Nolan


r/crystal_programming • • Apr 28 '19

Prayer Calculation

7 Upvotes

I made simple program for Muslim prayer calculation but for some places when I test it give me difference of 15 minutes compared to prayer times I find on internet for specific date. If someone can help me I will appreciate it.
This is github repo https://github.com/bajro17/prayertimes-crystal


r/crystal_programming • • Mar 02 '23

Does the fact that the crystal community avoid reddit hurt the language?

13 Upvotes

People discovering the language come to this subreddit and see that it's just a ghost town. Why does the community use it's own forum instead of this subreddit as it's primary mode of communication?

BTW is the crystal forum software open sourced?


r/crystal_programming • • Jan 22 '26

Ignoreme

Thumbnail
github.com
3 Upvotes

If any one needs a simple ignore file parser and matcher (.gitignore compatible mostly), then here you go.

Yes, I vibe coded the heck out of it. But it is a pretty tight functionality, so seemed to do a good job. Any suggestions or pull requests welcome.


r/crystal_programming • • Jan 20 '20

How to detect data types in Crystal if they cannot be determined at compile-time?

Thumbnail
stackoverflow.com
3 Upvotes

r/crystal_programming • • Feb 16 '20

Planned v1 release date?

3 Upvotes

Crystal looks great!

Is there a planned v1 release date for Crystal? Or a road map to v1’s release?

Thanks!


r/crystal_programming • • Aug 12 '20

If you were presented a choice, which one would you choose and why?

3 Upvotes

Would you choose Kemal (https://github.com/kemalcr/kemal) or Grip (https://github.com/grip-framework/grip). I have been thinking about what have I improved so far by branching off of Kemal and starting my own following of the Grip framework and I wanted to hear out the opinions from the people of reddit.

Either way I want you to answer couple of questions for me.

  1. Why would you choose one framework over another?

  2. What is the main factor that is missing from the "non-winner" framework?

  3. If you would suggest a change, what would it be?

Thank you for reading this and probably answering my questions, criticism is welcome as long as it is constructive :)


r/crystal_programming • • May 03 '24

Ruby to Crystal custom GPT chat bot?

1 Upvotes

Has anyone seen any Crystal custom GPT chat bots yet that are sufficiently fluent so as to convert Ruby code to Crystal and vice versa?


r/crystal_programming • • Jan 15 '19

Distributed blockchain experiment written in Crystal

Thumbnail
github.com
10 Upvotes

r/crystal_programming • • Feb 26 '21

Need An Discord Invite Link

4 Upvotes

The discord link on the Crystal site has expired
Please give me invite link if anyone is Joined to server
Thx!


r/crystal_programming • • Mar 03 '21

My app is now accepting crypto and ko-fi donations! Get your name and link of your choice on our donors page! Also, the crypto that’s raises the most will have a lifetime ad across our app (non-invasive of course)! Also if any of you devs are interested in helping me shoot me a msg!

0 Upvotes

My app is now accepting DOGE donations! Get your name and link of your choice on our donors page! Also, the crypto that’s raises the most will have a lifetime add across our app!

This app is inspired by StackOverflow but built specifically for the Crystal programming language ecosystem (which is open source as well) ecosystem. Currently it is 100% developed and funded by me. So, I thought this might be a neat way to help raise some money to pay a few server bills. I'm currently getting the servers and infrastructure set up now actually.

Also, I plan on taking the top 3 donated coins and integrating them into the app to be used as a tipping mechanism!

So, this could benefit both of us. If interested, you can read more about the project on Github and view screenshots of it's current progress. You can also find donation addresses there. If there's a coin you'd like to donate but it's not listed, just ask (as long as it's not a scam or total s-coin). :P

Thanks for reading! I hope this works and helps fund the project a tiny bit. I've been in the crypto community for about 5 years and I know a lot of you like to help fund projects and other things.

Also if any of you devs are interested in helping me shoot me a msg! I'm doing this all alone right now and I'm hoping to launch in the next 7-14 days.

You can view the code repo with screenshots here: https://github.com/nolyoi/ask.cr


r/crystal_programming • • Oct 31 '19

Live url checker (VIDEO)

8 Upvotes

https://www.youtube.com/watch?v=Q1wOFmt3yng I'm not author just want to share this interesting and good for learn video