3 ms·
The main difference between compiled and static languages is that compiled languages go through a phase of "checking your work", where it compares parts of your
by ModernMech 8y ago
The main difference between compiled and static languages is that compiled languages go through a phase of "checking your work", where it compares parts of your program to other parts before running it. For example, if you misspelled a name, the compiler will look everywhere in your program for that name before you run it, and tell you it can't find the name. That's why we like compiled languages. By contrast, dynamic language handle this by looking up the name right before the code in question is executed. If the name's not there at that time, an error is thrown.
Now think about this in the context of a REPL, which again stands for Read, Evaluate, Print, Loop. If you write code and evaluate it right away, this whole business about checking your work won't work right. You would basically have to recompile your entire program on every REPL eval, which defeats the whole purpose of a REPL. There are lots of other tricks to getting this to work, as the article hints at, but they're all very unsatisfactory in delivering the freedom of a dynamic language.
- lispm 8y agoReally? SBCL: * (defun foo (a) (+ a 42)) FOO * (defun bar (b) (foo 10 20)) ; in: DEFUN BAR ; (FOO 10 20) ; ; caught STYLE-WARNING: ; The function was called with two arguments, but wants exactly one. ; (SB-INT:NAMED-LAMBDA BAR ; (B) ; (BLOCK BAR (FOO 10 20))) ; ; caught STYLE-WARNING: ; The variable B is defined but never used. ; ; compilation unit finished ; caught 2 STYLE-WARNING conditions BAR
- ModernMech 8y agoThat's not the point. You can run static languages in a REPL. Some easier than others. You've chosen a particularly easy static language to write REPLs for as a counterpoint. LISPs and other homoiconic languages are especially well suited for interpreters because they're especially well designed languages. Languages like C which require header files and a pre-processor are much harder to write REPLs for. You can try to do it and you can build a thing that works kind of like a REPL (look I type code and press enter and it evaluates, yay), but the experience always falls short of using a dynamic language in a REPL. It's just not even close, and that's just due to the simple fact you're trying to use something in a way it's not intended. Compiled languages simply are not designed with a tight development loop as a major design goal.
- lispm 8y agoSBCL is compiled, dynamic and supports REPL based programming.
- ModernMech 8y agoLike I said, Lisps are well suited for REPLs.
- sam0x17 8y agoThis explains it a lot better than I do in the article.
- ModernMech 8y agoAnd yet I got downvoted.
- tome 8y agoBecause it's not correct.
- ModernMech 8y agoThe correct response to a wrong post is to correct it, not to drive by downvote. Explain where I'm wrong and then we have the basis for a discussion on the merits. Otherwise you're not adding anything.
- tome 8y agoThere are plenty of corrections in the siblings.