8 ms·
The Crystal Programming Language
- mosselman 9y agoI built a client for http://woordenlijst.org/#/ http://woordenlijst.org/#/ (Dutch word existence checker basically) and it is super fast. The syntax is only slightly different from Ruby and it starts up instantly. The only thing that I have against crystal is that my compiled binary didn't work on all other machines I tried it on. Even the practically identical macbook of a friend of mine. Looking around on their wiki pages and in the issues on github didn't give me any real solutions. So right now, as the version numbering suggests, it isn't ready for production.
- yorwba 9y agoWhen a compiled binary doesn't run on a different machine with the same hardware, it's probably a problem with dynamic linking. That seems to have been discussed on the issue tracker https://github.com/crystal-lang/crystal/issues/2003 https://github.com/crystal-lang/crystal/issues/2003
- mosselman 9y agoThanks, I have looked over this thread a while back, but it did not fix my issues. I might give it another go sometime.
- jaequery 9y agoCrystal looks really cool but if speed is what its after, i think it misses the target for most people. because for most apps, you will be bottlenecked by the database server. it is the slowest hanging fruit on the tech stack, be it postgres , mysql, or mongo. so unless you are working on number crunching tasks that do not involve any db queries, i fail to see the benefit of a language like Crystal. i wait for the day until the day Crystal becomes a 100% drop in replacement ready for Ruby apps. until then, Sinatra is more than fast enough for most things.
- WJW 9y agoHow small is the lightest sinatra app though, when deployed in a container? We lately had some experience with dockerizing a moderately complex ruby app and it was pretty shocking how large they get compared to simple statically linked binaries.
- jaequery 9y agoim not sure what you are asking for in terms of lightness but its incredibly light in both concept and execution. i mean it doesnt get any lighter than this. require ‘sinatra’ get ‘/‘ do “hello” end you should check out https://github.com/jaequery/jasis https://github.com/jaequery/jasis its a dockerized Sinatra app with all the bells and whistles and see how light it is yourself.
- AYBABTME 9y agoSure but no useful app can be described by this "Hello HTTP" example. I've seen the same as parent: Ruby services require a lot more memory in their steady state than say, their Go service counterpart, for a same complexity.
- jaequery 9y agoyou must be referring to Rails. sure they can be pretty big, as they are what you call a monolithic framework. thats why i recommend Sinatra for performance conscious devs, as its a fast and minimal framework. and you get to load only what you need. check the github.com/jaequery/jasis github project and peek at the Gemfile / boot.rb to see all that it loads for a full fledged mvc app. its pretty explicit and lean if you ask me. if are talking about server resource then you probably referring to the web server. for which we have ‘puma’ and it is also incredibly light and fast. much lighter than a php stack running Apache and mod_php for sure. but i see you compared to Go to which we have no comparison Go will run circles around Ruby. but Go is not really a well suited environment for web applications yet so ill just leave it at that.
- yxhuvud 9y ago
- WJW 9y agoCrystal is pretty neat and ticks off almost all of the boxes for me atm (For example the websockets server functionality in Kemal is super neat), but the lack of proper parallelism is kind of a killer. I know it's in the works, but afaict it has been so for almost a year now without much news...
- pjmlp 9y agoParallelism is always possible UNIX old style, use multiple processes. It is anyway the trend we are getting back to, after we have learned our lesson how threads and plugins can bring whole processes down, while being good vehicles for security exploits.
- WJW 9y agoWhile forking is always possible, there are some things that it does solve well enough IMO. For example, sharing and reusing database connections via a connection pool is much nicer if all threads can actually access the same memory. Shared memory is both a curse and a blessing of course :|
- hawski 9y agoOne can always use a bit of shared memory between processes. At least it would be contained to the parts that one really want to share. There are a few ways to do that. The easiest one is mmap MAP_SHARED|MAP_ANONYMOUS.
- jsjohnst 9y ago> For example, sharing and reusing database connections via a connection pool is much nicer if all threads can actually access the same memory. Why is this inherently easier to you with threads rather than forks? Many very successful apps use a forking model and do what you say, so I’m genuinely curious on your reasoning here.
- yellowapple 9y agoThe conventional approach would be to have a process dedicated to database communication. Other processes would then talk to that process via some IPC mechanism. This is reflected in the Erlang way of doing things (since there's no such thing as "shared memory", at least not directly); a process needing data from the DB sends a message to the DB connector process, which runs the query via one of a set of pooled connections and sends the result back as another message to the requesting process.
- naiyt 9y agoI've been a fan of Ruby for about 5 years, but lately I've been leaning a lot more heavily towards statically typed languages. Which is why Crystal is at the top of my "want to learn" list. Ruby inspired syntax and statically typed? Yes please. The speed is just a bonus for me.
- slx26 9y agoI consider speed to be extremely important, because it enables me to use the language in many more practical scenarios. And that's a joy. Writing in most other imperative languages after having learned Ruby feels so painful to me.
- tomhoward 9y agoPrevious discussions: https://news.ycombinator.com/item?id=9669166 https://news.ycombinator.com/item?id=9669166 (3 years ago) https://news.ycombinator.com/item?id=10014178 https://news.ycombinator.com/item?id=10014178 (3 years ago) https://news.ycombinator.com/item?id=10803635 https://news.ycombinator.com/item?id=10803635 (2.5 years ago) https://news.ycombinator.com/item?id=15574714 https://news.ycombinator.com/item?id=15574714 (5 months ago)
- fuzzythinker 9y agoSome news in the past 5 months: Crystal is now %100 funded for a full-time developer working on core - https://twitter.com/CrystalLanguage/status/982292238821675008 https://twitter.com/CrystalLanguage/status/98229223882167500... Crystal Automated Release towards 1.0 - https://crystal-lang.org/2018/03/09/crystal-automated-release.html https://crystal-lang.org/2018/03/09/crystal-automated-releas... A summary of why vs. why not - https://medium.com/@DuroSoft/why-crystal-is-the-most-promising-programming-language-of-2018-aad669d8344f https://medium.com/@DuroSoft/why-crystal-is-the-most-promisi... Web Frameworks Status: Rails inspired (with Influence from Phoenix): Amber - https://github.com/amberframework/amber https://github.com/amberframework/amber Lucky - https://github.com/luckyframework/lucky https://github.com/luckyframework/lucky Both look healthy in terms of community and updates but Amber seems to have a slight edge. Sinatra inspired: Kemal - https://github.com/kemalcr/kemal https://github.com/kemalcr/kemal
- squarefoot 9y agoI played with Ruby like 15 years ago and loved it, but surely speed wasn't exactly a selling point, so I welcome this project. One question though for the gurus out there: they say the compiler is written in Crystal; is it good practice to do it that soon? To me it could slow down development, if a subtle error occurs it could make harder to nail it to a bug in the compiler or in the language.
- relics443 9y agoThis is typical of new languages. A good showcase of dogfooding.
- skybrian 9y agoSure it's a little risky, but if you bootstrap from a stable, frozen version, it serves as a good integration test. There are still bugs, but if it compiles itself and the compiled version still passes all the tests, how bad can the bug be?
- ModernMech 9y agoBootstrapping your compiler is a vanity project for languages. It's cool to show you can do it, but pretty pointless in a practical sense unless your language is targeted at building compilers.
- pjmlp 9y agoIt is not vanity at all. It takes out of the table the typical argument that the language is not serious enough because it is written in C or something. The usual old time joke "my compiler compiles your language".
- ModernMech 9y agoNot all languages target C or C like workloads. Not all languages are particularly good at expressing parsers either. If your language is targeting e.g. Writing graphical visualizations, I don't see how writing compilers in the language serves anyone's interests except the language designer's.
- mberning 9y agoI have written a few small apps in it and so far I like it. I hope it gets traction and we see broad support for it dev tools. Would be cool to have debugger support in rubymine or idea for example.
- neokantian 9y agoI had a quick look at the language and checked about my two pet pieves. What does the code look like when handling JSON data? (that is when I slammed the door on Golang) What does the code look like when starting an external process, supplying stdin, args and capturing return code, stdout, and stderr? (that is when I slammed the door on lua). Well, I must say that crystal-lang manages to dodge the bullet twice. It handles both situations quite elegantly. So, yes, I am interested.
- 013a 9y agoWhat exactly frustrates you about Go's JSON handling? In my experience its among the best in typed languages. Define a struct (or just use an untyped map), optionally specify json tags for field names, pass it and the json to json.Unmarshal. Go is literally designed for this use case; systems programming, sharing messages between systems. Compared to other typed languages like Rust or Java, its at least as simple, if not simpler.
- aczerepinski 9y agoAgreed. Go is wonderful with JSON. Reasonable defaults and very flexible.
- 3pt14159 9y agoIt might be wonderful now, but I first used Go in 2009 and it was really hard to work with back then, so maybe the OP has a warped view of the current state?
- ccccccccccccc 9y agoThat was almost 9 years ago. Go has changed at a pretty rapid pace since then.
- tigershark 9y agoFrom what I know about go and JSON and what is possible in other languages I would never call it wonderful.
- odammit 9y agoWhen I was younger, I programmed predominantly in Java and types were infuriating to me. Then I found ruby and loved how simple it was to not worry about a type system. Then I found out how infuriating it was to not have types. Now I’m older and appreciate having types. Cool story, bro. Crystal looks cool!
- weavie 9y agoThere's a lot more to Types vs No Types than Java vs Ruby would imply!
- nine_k 9y agoIndeed. You learn e.g. Haskell and find that Java painfully lacks in the types department. You learn Perl and find that Ruby is unexpectedly rigid in the types department :)
- yellowapple 9y agoPerl also has the ability to effectively build class instances from scratch by manually blessing arbitrary data structures (usually hashes, but not much stopping you from blessing an array or scalar). For some folks (like me), it's a blessing for making hard problems at least slightly easier to solve. For others, well, there's always Moose. Basically, a lot of Perl's object-orientation weirdness derives from it all being exposed to you. It's an excellent learning experience if you ever want to know what it means to be a "class" or an instance thereof, since "methods" are just ordinary subroutines that expect your object (or class, for constructors) as the first argument, and class instances are just ordinary scalar/array/hash objects blessed with a package name. Nothing hidden or abstracted away. Simple and flexible enough to fit into the TMTOWTDI philosophy.
- luckydude 9y agoOne of the few languages that I've seen in years that I liked right away. Checks a lot of my boxes, I like the inferred types and I like static typing. Nice job!
- innocentoldguy 9y agoI've been using Crystal on a mobile checkout application to watch for and parse incoming pricing files. I've been extremely happy with it so far. It is fast, the type system is nice, and I really enjoy the Ruby-like syntax and ease of development. I've also been happy with the developers and the community. The community is supportive and the developers are making good progress on the language and are quite responsive to community feedback. If you like the idea of a fast, compiled, statically-typed, Ruby-like programming language, you can support Crystal development here (NOTE: I'm not affiliated with the Crystal project in any way. I'm just a happy consumer): https://crystal-lang.org/sponsors/ https://crystal-lang.org/sponsors/
- phaedryx 9y agoIt is also a potential compile-to-webassembly language.
- MR4D 9y agoLooks like a nice effort. As a fan of Python over Ruby, I would love to see something like this for Python fans, but efforts like this give me hope that one day it will happen.
- Aardappel 9y agoStrongly typed language with Python-esque syntax: http://strlen.com/lobster/ http://strlen.com/lobster/