Re:CL21: An experimental project redesigning Common Lisp
by malisper on Thursday February 19, 2015 @07:25PM
(#9078155)
> I wonder how the lazy sequence support stacks up to Clojure, Haskell, etc. support.
A bit of a tangent, but I've been looking at the series library[0] recently. It makes it possible to write functional style code which is compiled into a loop for efficiency. For example:
(defun integers ()
"Returns a series of all of the integers."
(declare (optimizable-series-function))
(scan-range :from 1))
(defun squares ()
"Returns a series of all of the square numbers."
(declare (optimizable-series-function))
(map-fn t
(lambda (x) (* x x))
(integers)))
(defun sum-squares (n)
"Returns the sum of the first N square numbers."
(collect-sum (subseries (squares) 0 k)))
Although the above definition of sum-squares seems like it would be inefficient, it is roughly the same as the following: (defun sum-squares (n)
"Returns the sum of the first N square numbers."
(loop for i from 1 to n
for square = (* i i)
sum square))
I find it pretty awesome that it is possible to write code that is efficient and functional like that, but I guess series is a bit too magical to be put to actual use.
Re:CL21: An experimental project redesigning Common Lisp
by Immortalin on Friday February 20, 2015 @01:59AM
(#9079320)
I can understand the reasons why people prefer to target the CLR/JVM/LLVM/BEAM/Name-your-favorite-vm but I yearn for more compiled-to-native-languages such as Golang. As attractive as partially-compiled/interpretated languages are, I simply do not enjoy creating programs in a language that can be decompiled to source so easily. We need more languages that have decent performance instead of having to drop down to pointer optimizing in C wherever we need some performance. A functional Fortran would certainly be nice...
Re:CL21: An experimental project redesigning Common Lisp
by agentultra on Friday February 20, 2015 @09:13AM
(#9080449)
Some Common Lisp implementations do compile down to machine code. An example of one I'm told is quite good is SBCL:
* (disassemble #'(lambda () (loop for i from 1 upto 10 summing i)))
; disassembly for (LAMBDA ())
; Size: 62 bytes. Origin: #x100306FE84
; 84: BB02000000 MOV EBX, 2 ; no-arg-parsing entry point
; 89: 31C9 XOR ECX, ECX
; 8B: EB21 JMP L1
; 8D: 0F1F00 NOP
; 90: L0: 48895DF8 MOV [RBP-8], RBX
; 94: 488BD1 MOV RDX, RCX
; 97: 488BFB MOV RDI, RBX
; 9A: 41BBA0010020 MOV R11D, 536871328 ; GENERIC-+
; A0: 41FFD3 CALL R11
; A3: 488BCA MOV RCX, RDX
; A6: 488B5DF8 MOV RBX, [RBP-8]
; AA: 4883C302 ADD RBX, 2
; AE: L1: 4883FB14 CMP RBX, 20
; B2: 7EDC JLE L0
; B4: 488BD1 MOV RDX, RCX
; B7: 488BE5 MOV RSP, RBP
; BA: F8 CLC
; BB: 5D POP RBP
; BC: C3 RET
; BD: CC0A BREAK 10 ; error trap
; BF: 02 BYTE #X02
; C0: 19 BYTE #X19 ; INVALID-ARG-COUNT-ERROR
; C1: 9A BYTE #X9A ; RCX
Keep in mind that's with full run-time type checking and other nice debugging features. You can hint the compiler to turn these things off in your hardened code sections for even smaller, tighter code.
Re:CL21: An experimental project redesigning Common Lisp
by Moyamo on Friday February 20, 2015 @09:30AM
(#9080527)
I think the parent comment about VMs was aimed at clojure.
Re:CL21: An experimental project redesigning Common Lisp
by bmh100 on Friday February 20, 2015 @10:28AM
(#9080776)
By functional Fortran, do you mean like a "functional programming language" or "more productive Fortran"? As one who has developed in Fortran before, I would also like to see enhanced functional capabilities, as well as a more productive way to write code. I have spent so much time on declaring variables and function arguments over and over across subroutines that it becomes quite a pain. To avoid writing many subroutine interfaces, I also tend to put everything in a single module. My dream is to combine the expressiveness of Lisp with the numerical performance and memory efficiency of Fortran and C.
Re:CL21: An experimental project redesigning Common Lisp
by phabian on Friday February 20, 2015 @01:37PM
(#9081999)
What happened with Fortress, fortran like enchanced language Guy Steele was developing with his team?
Re:CL21: An experimental project redesigning Common Lisp
by bmh100 on Friday February 20, 2015 @02:01PM
(#9082169)
I had not heard of Fortress before. It seems that Oracle's sponsorship of the project ended in 2012. Guy Steele emphasizes the difficulty of implementing Fortress's type system on virtual machines. [1]
[1]: https://blogs.oracle.com/projectfortress/entry/fortress_wrap...
Re:CL21: An experimental project redesigning Common Lisp
by Immortalin on Saturday February 21, 2015 @08:38AM
(#9085469)
Both :D
Re:CL21: An experimental project redesigning Common Lisp
by one-more-minute on Friday February 20, 2015 @04:33AM
(#9079680)
Have you met Julia? I don't know if I'd quite call it a functional Fortran, but it's not that far off, either.
Re:CL21: An experimental project redesigning Common Lisp
by tempodox on Friday February 20, 2015 @10:24AM
(#9080759)
Sadly, Julia will not produce stand-alone executables in the foreseeable future. It's nothing more than a bit of native glue between two Python scripts. The main acceptance group doesn't use it for production, only in the lab.
Re:CL21: An experimental project redesigning Common Lisp
by one-more-minute on Friday February 20, 2015 @10:30AM
(#9080794)
Stand-alone executables are on the roadmap for Julia 0.4, which is on the horizon (next six months or so).
Re:CL21: An experimental project redesigning Common Lisp
by elektronjunge on Friday February 20, 2015 @10:13AM
(#9080705)
LLVM isn't a vm like the others, its a generic compiler backend. Languages with LLVM backing generally compile to native.
One difficulty with promoting a more modern layer to common lisp is that Clojure is already such a productive and practical language. I have written a few common lisp books, and remain a fan of the language, and an upgrade does sound good.
I am curious to hear the opinions of the heavy hitters in the common lisp world.