Re:Why Crystal is the most promising programming language of...
by RX14 on Friday June 15, 2018 @08:41AM
(#17319311)
No, it's not because it's compiled, it's because of the global type inference algorithm (which is very different from any existing type inference algorithm). Crystal used to have a repl but it was removed because it was buggy and difficult to maintain. Maybe crystal will get a repl in the future, but I wouldn't count on it because it's a huge effort.
Re:Why Crystal is the most promising programming language of...
by sam0x17 on Friday June 15, 2018 @08:14AM
(#17319155)
Yeah, to clarify this should be possible, but I don't think it's going to happen for some time. There is a shard that creates a REPL, but it re-executes all previously executed commands each time you enter something new, which is super bad and dangerous. What we need is something that will compile just the line that was entered, and somehow "inject" that line into the existing program, and execute only that next line. Also there might always be a bit of lag between when you enter a line and when you get your response because the compiler is invoked. I'm not sure if that could be optimized to the point where it isn't noticable, but that would be super cool. I added on functionality for the Amber framework that allows you to execute one liners via `amber exec "code here"` as a replacement for `rails console` (amber is basically the rails of the crystal world).
Re:Why Crystal is the most promising programming language of...
by _old_dude_ on Friday June 15, 2018 @08:22AM
(#17319199)
Both scala and Java provides a REPL by compiling each lines + maintaining a context containing all local variables, functions, classes, etc
Re:Why Crystal is the most promising programming language of...
by pjmlp on Friday June 15, 2018 @08:28AM
(#17319239)
Check Swift Playground demos.
Re:Why Crystal is the most promising programming language of...
by dan00 on Friday June 15, 2018 @08:08AM
(#17319132)
> First of all, the problem isn't that it's "compiled" - Python is "compiled" too, but still has one of the best REPLs available.
In a way it is. For a REPL you most likely need an interpreter for your language, like Cling is for C++.
Re:Why Crystal is the most promising programming language of...
by gilgoomesh on Friday June 15, 2018 @08:19AM
(#17319179)
You don't need an interpreter for a REPL. Swift's REPL performs line-at-a-time compilation, running the program to that line and suspending it until you write and compile another line.
Re:Why Crystal is the most promising programming language of...
by coldtea on Friday June 15, 2018 @09:12AM
(#17319484)
>You don't need an interpreter for a REPL. Swift's REPL performs line-at-a-time compilation
Isn't that another way to say "interpreter"?
Re:Why Crystal is the most promising programming language of...
by notacoward on Saturday June 16, 2018 @02:18PM
(#17328615)
For all practical purposes, yes. In the strictest technical sense it's a form of JIT compilation, but that can be considered an optimization or implementation technique. If the user doesn't perceive a separate compilation step, it's effectively an interpreter and only a dedicated pedant would "well actually" that it's compilation.
Re:Why Crystal is the most promising programming language of...
by creatornator on Saturday June 16, 2018 @03:25PM
(#17328882)
Not really. An interpreter doesn't convert the language syntax tree into machine code, instead it just performs the operations. It sounds like Swift's REPL actually converts the lines into opcodes and runs those.
Re:Why Crystal is the most promising programming language of...
by unwind on Friday June 15, 2018 @08:15AM
(#17319162)
It can be argued that "compiled/interpreted" is not a property of programming languages, but of programming language implementations.
Re:Why Crystal is the most promising programming language of...
by crypto-jeronimo on Friday June 15, 2018 @09:57AM
(#17319784)
I second this.
First of all, the problem isn't that it's "compiled" - Python is "compiled" too, but still has one of the best REPLs available.
The problem is that the language is static. But static (and compiled) languages can have REPLs, for example C++ has an excellent REPL called Cling.
It's not impossible, just requires some more effort.
As for Crystal, it looks like a neat language. However, if it's going to try to compete with the fast compiled runtimes such as Java, it will need some parallelism support.