Parallelism in Crystal
crystal-lang.org
crystal-lang.org
It’s been so successful at everything I’ve needed it for, I wouldn’t consider going back to either Ruby or similar interpreted languages, regardless whether it’s a little CLI helper or a larger monolith server app. I’ve found my ability to allow the compiler to catch bugs incredibly reliable without feeling bogged down with types. I hadn’t worked much with typed languages previously and as a Ruby developer it allowed me to ‘learn’ types without even feeling like I was doing any learning.
It’s still somewhat of an obscure language so I thought it would be helpful to describe my experiences with it.
Also, I assume Googleability is pretty much close to zero, you'd have to go to the primary sites (their forum?) to ask questions when stuck?
Having performance improvements of 100x in real-world scenarios is just astonishing. Ruby is still my go-to, especially because debugging and console support are so much better. But everything that gives me time to think gets reimplemented.
["crystal lang" <question>] usually works for google.
But as a simple example I accept that API calls to third party services is low hanging fruit so in terms of finding drivers for lower level protocols I've not had an issue that I'd class as a blocker. There are times where I've had to extend libraries or write a parser for this-and-that (e.g. PostGIS and Paseto, both of which were unused this time round) but I find I need to do this less and less as time goes on.
You do need to reach into the forums or gitter on rare occasions but I can count on one hand the number of times I've needed to, and it's typically because I was trying to do something unusual and quite low-level on the HTTP stack - as in something I've never had to do in a non-Crystal project, such as sending a specific packet. I've always found help there too and people are happy to engage.
2019 has been a good year for crystal. Basic multithreading is in. Windows support is making good headway. I am optimistic that a working windows compiler would be out by end of year.
The last major dragon for crystal to slay would be the compilation time. It still feels unreasonably high. Hopefully that would be a major focus of 2020
the api is consumed by a vanilla js spa. I talk more about my VanillaJS spa's architecture here https://dev.to/rishavs/making-a-single-page-app-in-ye-good-o...
There can be overhead introduced between the "1 thread" and ">1 thread" cases.
Now, I've been exposed to more ruby, and more metaprogramming in ruby, than in python - but this stil surprises/intrigues me.
What kind of metaprogramming do you find easier in python?
def m2():
print("nuovo")
object.new_method = m2
instead of redefining the class. It's similar to JavaScript. However I don't have a computer at hand now. I can't check the details and what could be done on Ruby.(No judgement from me on whether that's better/worse/about equal, just confirming.)
OTOH, if your problem is slightly different, I find the syntax to add methods to any class very practical and powerful, with of course the caveat that you can produce a maintainability nightmare if overused:
irb(main):001:0> a = 1
=> 1
irb(main):002:0> class Integer
irb(main):003:1> def hello
irb(main):004:2> puts "world"
irb(main):005:2> end
irb(main):006:1> end
=> :hello
irb(main):007:0> a.hello
world
=> nilI wouldn't recommend actually doing that, however.
If actually doing this (adding new method to a class) I think it's quite easy to re-open a class in ruby (see sibling comment(s)).
I can see adding methods actual instances (only) might be more work in ruby though.
What would be the typical use case for a special instance in a given scope, as opposed to a special class in a given scope?
Ed: i see qquark's so link address the technical part: define_singleton_method (so no need to open Object to add that...)
Now, why not Crystal over C++? Because it's way less mature, with way less documentation, way less resources, way worse tooling, way less libraries, way more implementation bugs, and, if we're realistic, it might never go anywhere...
Which for parallelism probably switches the question to “why Crystal over Pony”, since Crystal seems to preserve the key C++ footguns specifically linked to parallelism.
I don’t see why this should be the case, unless we as a community decides it will not go anywhere.
Languages of the quality of Smalltalk, and Ada, and Dylan, and Self, and CL have vanquished in the margins, and e.g. even something as celebrated as Haskell does hardly better in the industry (some financial companies, this or that project, and so on), so the chances of a new language like Crystal are slim to begin with...
Let's hope so, but I fear that's wishful thinking. What proof do we have of that?
It's not used anywhere important ("killer app"), barely makes the rest of the TIOBE index, along with staples like NATURAL, Alice, BBC Basic, Euphoria, Factor, Forth, and Icon, and has no major force like Google or Mozilla backing it.
It's only us here in HN who keep hearing about it.
Julia has had tons more publicity (even from some major outlets), and it's still going nowhere fast.
Don't you think us here at HN include quite a number of people standing centrally when it comes to "anywhere" in the tech industry? This is what I mean, when talking about "us as a community." Of course this does not go for everyone... but for a considerable amount, I'd say. (Myself am certainly not one of them.)
> Julia has had tons more publicity (even from some major outlets), and it's still going nowhere fast.
Well, Julia being made for extensive numerical computations and the like, I think it is doing very well, esp. in academical use, which is somewhere it's right at home. If not yet very much in use yet, at least many academics in relevant fields--which frankly are quite a lot days--have heard of the language. If Julia holds enough of its' promises, I don't see why they wouldn't migrate eventually, given time.
I don't see how any lang could get anywhere "fast," no matter how superb it'd be, "anywhere" tends to be sceptical of change if they're fine with what they have.
It's a joy to write due to its syntax.