12 ms·
Overview of the Crystal language
- cyber1 9y agoNice language. Is someone use it in production?
- sdogruyol 9y agoWe have a dedicated wiki page for Crystal production users :) https://github.com/crystal-lang/crystal/wiki/Used-in-production https://github.com/crystal-lang/crystal/wiki/Used-in-product...
- isaiahg 9y agoRuby like syntax huh. Man I wish the Python syntax would catch on more. Most clean and readable code I've ever laid my eyes on. Wish I could use it but it's just too slow for the stuff I do. What would I give for a language at least the speed Java but with a Python like syntax.
- isaiahg 9y ago+ and strongly typed.
- _raul 9y agoNim is the closest language to what you're describing that I've found so far https://nim-lang.org/ https://nim-lang.org/
- arc776 9y agoDefinitely fits the bill: * Python-like syntax * Compiles to C/C++/JS/Object-C * Supports Windows, Linux and Mac. * Multithreading * Extensive metaprogramming * VERY fast compiler * Dead code elimination * Very strongly typed, with related features (eg distinct types) * Type inference * Excellent structural generics, type classes, and compile-time concepts Basically looks like python, runs like C. Because it compiles to C, you can run it anywhere you have a C compiler (which is almost anywhere).
- sbarre 9y agoNim looks super cool! There goes my holiday free time..
- jhasse 9y agoMy idea for a more Python-like C++: https://bixense.com/coffeepp/ https://bixense.com/coffeepp/
- tomc1985 9y agoUgh, I hope not. Python looks too much like Visual Basic.
- sdogruyol 9y agoCrystal is a Ruby inspired compiled language, allowing it to run blazingly fast with a very low memory footprint. It uses LLVM for emitting native code, thus making use of all the optimisations built into the toolchain. Website: https://crystal-lang.org/ https://crystal-lang.org/ Github: https://github.com/crystal-lang/crystal https://github.com/crystal-lang/crystal
- pjmlp 9y agoFor me Crystal is what Ruby might have turned out to be, if its designers cared to take some inspiration from Dylan.
- byroot 9y agoThat makes no sense to me. Most of what makes Crystal different from Ruby results from the former being a static language and the later being dynamic. I understand that dynamic languages are not popular these days on HN, but it's silly to suggest they should become static languages. They just offer different tradeoffs, a bit like screws and nails.
- pjmlp 9y agoDylan is a Lisp (thus dynamic) with Algol-like syntax. Dylan supports AOT compilation like Crystal, and had optional type checking, so one could make it into Crystal if all variable declarations happened to be annotated. Don't forget Dylan was intended to be used as Newton systems programming language and the team managed to create their own OS, even after C++ was decided to take Dylan's role. Personally dynamic languages without AOT or JIT support were never popular with me beyond shell scripting tasks.
- seanmcdirmid 9y agoI thought NewtonScript took Dylan’s place in Newton development?
- 9y ago
- skocznymroczny 9y agoDoes it support Windows yet?
- sdogruyol 9y agoWindows support is still WIP, recently we are making some good progress https://github.com/crystal-lang/crystal/pull/5339 https://github.com/crystal-lang/crystal/pull/5339
- pritambarhate 9y agoI really want a nice OO language with Garbage Collector / ARC that compiles to native code on Windows, Mac and Linux. Swift is good, but Windows story is weak. I am personally waiting for Kotlin Native to mature. Until that time Go it is.
- shakna 9y agoRed [0] has a fantastic cross-compilation story, is a tiny compiler, and is a kind of Lispy version of Object-Oriented. Includes GUI support in the native runtime. It's meant to be a sort of "better Rebol". [0] http://www.red-lang.org/p/getting-started.html http://www.red-lang.org/p/getting-started.html
- Shoothe 9y agoRed (and Rebol) are fantastic but unfortunately the learning curve is very steep for people that don't know it. I spent a month reading everything on the internet about Rebol, then Red was obvious but before that it's really hard to get into that world. IMHO Red should have something like a definitive book covering all aspects in one place (like [0]) because it has a vast array powerful features (URI, money, time literals, parse and other dialects) etc. Without concise but a complete guide the language appears to be just a weird "let's use [ ] instead of { }" construct. [0]: http://shop.oreilly.com/product/0636920040385.do http://shop.oreilly.com/product/0636920040385.do
- k__ 9y agohow can it have a learning curve for people already know it?
- Shoothe 9y agoBecause "already know it" is not a single defined point on that curve but rather a region. It's easy to prove by negative, if "already know X" would be so easy to pinpoint the entire recruiting industry would cease to exist.
- 9y ago
- nnq 9y ago> In Crystal, as in Ruby, everything is an object. [...] When you write Crystal code, most of the time, you write classes. Why, God, why?! Really, OOP is a great way of structuring lots of types of code (not all!). But I don't think it really helps anyone to treat everything as an object. Some things are not objects they just are whatever they are. A function is just that, a function. If I have to call a `.call` method on a "function" as in ruby, then that's simply not a function anymore. And... it's not an object either semantically, because objects are about things that can receive and send multiple messages and sometimes encapsulate state... and that's not how anyone thinks about functions! By making everything be an object, you actually f up the concept of "object" itself... I like Ruby's elegance, but every time I see the "OOP at the core" part, I suddenly get more love for Python and Javascript for at least getting this right.
- pjmlp 9y agoPython is also OOP at the core, in case you have not been paying attention. Likewise Prototype-based programming is OOP.
- jhbadger 9y agoPython kind of cheats, though. Not everything is an object -- most low level things like arrays and numbers aren't. Ruby is from the Smalltalk tradition where everything literally is an object -- and I say that as a good thing. Even the "functions" that you can define are really methods of the Object class -- it just happens to be the case that Object.foo(x) can be abbreviated as foo(x).
- pjmlp 9y agoFor the regular user they behave like objects > import builtins > builtins.int => <class 'future.types.newint.newint'> class myint(int): pass
- joaodlf 9y agoI have never used Crystal before, but I don't understand how you can be against "everything is an object" and then say Python and Javascript are different... Pretty much everything in Python and JS is an object... So really, what does fundamentally differ?
- didibus 9y agoI don't know why, but off all languages I've tried, Ruby's syntax I just hate. I can't do it, dunno why. That's what turns me off of crystal also.
- izietto 9y agoI guess you are a Java enthusiast (in my experience Java coders just tilt with Ruby). Anyway you should try Elixir, it is Ruby "The right way" in my opinion.
- dudul 9y agoPlease let's stop spreading this "elixir is like fast/better ruby". The syntax is not even that similar, and the runtime is completely different, the patterns and tools available not the same at all. I know it's probably a hill on which I'm gonna die and get a lot of downvotes, but we should really try to not force Elixir into being a new, fast ruby and let it evolve and solve problems in its own ways.
- deleted 9y ago[deleted]
- regulation_d 9y ago"elixir is like fast/better ruby" is simplistic but it's also not entirely untrue. When I first started playing with Phoenix I found it palpably similar to Rails, but also faster and better in a lot of ways, especially the WebSockets story. When I started writing Elixir I didn't know how great it was nor did I understand how different it was from Ruby. The BEAM is a challenging thing to grok. As I used it more and more, I did learn and appreciate those things. But at no point, did I feel deceived about how similar Elixir and Ruby were supposed to have been. I was surprised and relieved by how many of the things I had to worry about in Ruby, I didn't have to worry about in Elixir. At the end of the day, Elixir's similarity to Ruby is part of what gets a lot of people like me in the door. It's a hook and I think it's a good one. I mean, sure, we're going to have to explain to people why they don't need something like Sidekiq, and we're going to do it many, many times. But that's what we do as a welcoming community. I guess it's a balance. If we have a lot of people trying out Elixir and leaving because they feel they were misinformed, that's definitely relevant. But I don't hear much of that. On the other hand, if we can use this similarity to get OO people to try out this crazy, awesome FP language that uses the actor model, that could really help grow the language. You're on point that Elixir really is a completely different paradigm, but I don't know if I agree that it really matters from a marketing perspective, particularly when marketing to Rubyists.
- eatonphil 9y agoCrystal seems like a great high-level language and alternative to Ruby, but the biggest blocker for me using it more generally is the lack of multi-threading support. There is WIP support for threading but it has not been committed. Moreover the Crystal developers either don't do a great job of updating their multi-threading roadmap [0] or work on multi-threading has died off. (I assume it is the latter because the thread-support branch has not gotten any commits in 10 months [1].) Ultimately if I wanted the high-level aspects of Ruby or Python and wanted more performance and great thread support I'd probably go with Elixir (even taking into consideration BEAM weirdness). [0] https://github.com/crystal-lang/crystal/wiki/Threads-support https://github.com/crystal-lang/crystal/wiki/Threads-support [1] https://github.com/crystal-lang/crystal/tree/thread-support https://github.com/crystal-lang/crystal/tree/thread-support
- k__ 9y agoWhat is so good about multi-threading?
- Doctor_Fegg 9y agoIf you're considering Crystal over Ruby, chances are that speed is part of your reasoning. And if speed is important to you, then you want to use all 4/8/16 cores of your machine, not just one.
- smitherfield 9y agoAny web application is going to be almost entirely network and database-bound, not CPU-bound. CPU-bound tasks are stuff like scientific computing, video encoding, the Ruby interpreter and Crystal compiler themselves, etc. The advantage of multithreading in a web application is not "using all cores" but rather that the application can spawn a thread to "asynchronously" wait for a response from the network or database while it continues doing other work in the main execution thread, instead of "synchronously" blocking all work while it waits. In other words, web applications leverage concurrency with their use of multithreading, not parallelism. I will caveat that having more cores can give concurrent applications a small performance improvement, because even though each thread is only using a CPU core at around 0 to 15% (in short bursts) of capacity, switching between two threads on the same core is a context switch, a fairly expensive operation. More cores means fewer context switches. But, unlike with parallelism, making use of more cores is not the reason concurrency offers performance benefits. ~99% of the performance benefit of concurrency is realized on even a single-core machine, whereas parallelism by definition requires multiple cores to offer a speedup. Concurrent applications such as web servers (e.g. Apache, Nginx) typically spawn hundreds or even thousands of threads per CPU core.
- RX14 9y agoThe consensus in this thread is that Crystal has lost a lot of steam recently and little is being done. In fact, it's been nearly 6 months since the last release. As a member of the core team, I'll be honest: this is correct. Manas, Crystal's main commercial backer has had a very tough year and has been unable to donate as much manpower to the project as previous years. The non-manas members of the core team have had difficulty finding time too. This has been a low point in the project, but it's very possible that 2018 will be a different story. Development is picking up right now, extremely basic windows support is just a few days from being merged into master, and the 0.24.1 release is imminent. There will be a blog post regarding this on crystal-lang.org soon.
- kyledrake 9y agoDo you think it's reached the point where Crystal should consider some way to get funding outside of just Manas to allow for some full-time development on the project? I think it deserves full time developers, and there may be sources of untapped funding for potentially doing this if there is interest. It may also make sense (at some point) to consider putting together a nonprofit that could make it easier to get access to this sort of funding in the future.
- RX14 9y agoI'm not sure what you mean of "outside of manas" but we have a bountysource [1] which contributes to the hours of the Manas developers to work on Crystal. [1] https://salt.bountysource.com/teams/crystal-lang https://salt.bountysource.com/teams/crystal-lang
- kyledrake 9y agoWell if the sponsor company is having a "tough year" as you said, and that means they can no longer support full-time development of Crystal anymore, it makes sense to put together a structure so that your core team can work on it full time. In the future you're going to need more than an internet tip jar to get access to the better sources of funding you'll need, which are largely institutional. It's going to be the most depressing news ever if we're doomed to a hundred years of toilet dumpster programming languages because Crystal loses steam due to one company's tough year. Let's make sure that dark future never happens.
- willcodeforfoo 9y agoWorth nothing: Thoughtbot is working on a web framework for Crystal, called Lucky: https://luckyframework.org/ https://luckyframework.org/ It looks quite promising, but as others (including core team members) have noted, development on Crystal seems to be losing steam. It's tempting but seems like a bit of a gamble to pick Crystal for anything serious, especially with great new languages like Elixir and Go gaining traction.
- rubyfan 9y agoSurprised this is the only mention of Lucky. Seems to have a lot of promise. I wrote off Crystal some time ago but Lucky has my interest piqued and I’ve been building a few things with Lucky recently.