9 ms·
I wrote some Crystal recently for a hobby project. I have to say, I really like it. • Nice syntax (mostly just that blocks/procs are easy to use— Ruby-like syn
by nicholaides 7y ago
I wrote some Crystal recently for a hobby project. I have to say, I really like it.
• Nice syntax (mostly just that blocks/procs are easy to use— Ruby-like syntax is nice, but it’s not really that important)
• straight-forward class/object model
• type system is simple but powerful (union types + type inference are a great combo)
• syntax and std lib that enables functional-style programming, but isn’t strictly functional
• Pretty darn fast— compiles to machine code via LLVM, and seems like it’s not far behind C, C++ and Rust in most benchmarks, despite being garbage collected
What other languages offer a similar profile? D? Swift? Kotlin (via LLVM)?
- dom96 7y ago> What other languages offer a similar profile? D? Swift? Kotlin (via LLVM)? Nim? :)
- sansnomme 7y agoNot a lot of options if you don't want curly braces.
- k__ 7y agoClojure, Haskell, Nim, Python, and I think you could even write JavaScript without using curly braces.
- sansnomme 7y agoOther than Haskell and Nim, the rest are hardly compiled to machine code.
- k__ 7y agoOCaml, maybe?
- makapuf 7y agoWell C can be used without those: #define BEGIN {
- k__ 7y agoHaha. To me BASIC syntax always looks like a clunky version of C syntax and the pre-processor code you wrote is just what I have in mind when seeing this. It always feels like someone wanted to do ML syntax, but didn't go all the way with it.
- 1ark 7y agoThere are a few Schemes that can compile to C or machine code.
- eigenspace 7y ago> What other languages offer a similar profile? D? Swift? Kotlin (via LLVM)? Julia. It’s fast, JIT compiled (static compilation is possible but it’s quite rough around the edges), has a fantastic type system, uses multiple dispatch to achieve some very cool stuff, has quite powerful lispy macros, and a really great community / library ecosystem, especially in scientific computing.
- ziotom78 7y agoI'm an enthusiastic user of Julia, but I would not think of it as a language with a "similar profile" as Nim or Crystal. As you said, it's hard to produce static binaries, and they are huge if compared with Nim's or Crystal's. Moreover, the typical workflow for writing code is very different from what users of static languages follow (edit, compile, run, loop over).
- vosper 7y ago> Moreover, the typical workflow for writing code is very different from what users of static languages follow (edit, compile, run, loop over) Would you elaborate on what's different about writing Julia?
- ziotom78 7y agoJulia's typical workflow [1] is mainly REPL-based: you test ideas in the REPL, accumulate functions in modules and build larger payloads at the prompt (or in a Jupyter notebook, or using Juno [2] or VSCode). That's a sensible way of working for its main target: scientific computing and number-crunching tasks, where you must often explore and understand your data before betting able to implement real algorithms. [1] https://docs.julialang.org/en/v1/manual/workflow-tips/ https://docs.julialang.org/en/v1/manual/workflow-tips/ [2] https://junolab.org/ https://junolab.org/
- vosper 7y agoHmm, that’s interesting - I enjoy REPL-based development, having spent a lot of time working in Python, and a little Clojure. How does the REPL experience play with the static typing (that I think) Julia has? If you change the type signature of a function in the REPL what happens?
- smt88 7y agoF#. I hate the syntax, but anyone who enjoys ML will like it. Curly braces are optional. It also meets all of your other requirements, including the "isn't strictly functional" part (which is somewhat rare). Scala has most of these qualities, but people say it's extremely complicated and supports too many different paradigms in a single language. I've never used it.
- Barrin92 7y agoI'd second F# and also in the same vein recommend Ocaml, in particular, if fast-running native code is a requirement. I haven't benchmarked it enough but I suspect that in most cases Ocaml might be a good deal faster. I'm also very sympathetic to the non-functional aspects. I think being able to write imperative code easily (and it's surprisingly pleasant in ocaml/f#) is a huge plus.
- 3PS 7y agoAs always, take these numbers with a grain of salt, but benchmarks seem to suggest that F# on .NET Core is significantly faster than OCaml [1]. I wouldn't be surprised if that were the case myself given how much work Microsoft has put into optimizing .NET Core for performance. [1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/fsharp.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- igouy 7y agoAnd how much work Anthony Lloyd has put into optimizing those programs ;-) https://benchmarksgame-team.pages.debian.net/benchmarksgame/measurements/fsharpcore.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- agumonkey 7y agoDoes F# offers native builds ? I thought it was CLR only. Also Scala is about to jump to a new compiler (and maybe a new language). It's a weird time for scala (from the few that I know).
- zem 7y agod and ocaml are both nice. i like ocaml's syntax, but if you don't there is always reasonml, an alternate syntax that is a bit more c-like.
- agumonkey 7y agoAnybody toyed with crystal onto rpi or even microcontrollers ?
- lmm 7y agoOCaml. Sometimes I feel like the last 20 years of language development have mostly been spent on catching up to OCaml.