News for hackers. Stuff that matters.
Re:John Carmack working on Scheme as a VR scripting language by kgabis on Wednesday July 01, 2015 @09:42AM (#9811696)
I never understood why people consider lisps superior, mind explaining exactly what changed your mind?
Re:John Carmack working on Scheme as a VR scripting language by moron4hire on Wednesday July 01, 2015 @10:38AM (#9812087)
It's not that there is anything particularly special about what you can do in Lisp than what you can do in, say, C#. It's that Lisp provides facilities for metaprogramming that most other languages lack. Most other languages make metaprogramming hard enough, or require it all be done at runtime, that it is very discouraging against the concept in general. Lisp creates a culture around metaprogramming that fundamentally changes how you approach programming forever after.

You stop writing programs. You start writing programs that write programs. It's a lever that multiplies the power of the programmer. That can be both good and bad. For a hacker coding in earnest on her own, it can be extremely good.

Yes, if you are the type of beginner or intermediate programmer that still struggles to just write programs, advanced metaprogramming in any language is not for you. If you're an intermediate programmer looking to become an expert programmer, learn Lisp, where metaprogramming is easy, and take the lessons on to whatever other languages you eventually end up using.

That's what people mean.

Re:John Carmack working on Scheme as a VR scripting language by stray on Wednesday July 01, 2015 @03:47PM (#9814638)
I've never had to change my mind about Lisp -- but to me, Common Lisp's condition system kicks the crap out of every other language because it allows you to handle conditions without unwinding the stack.

And whenever you get dropped into the debugger, you can edit and reevaluate the broken code or values or whatever -- and then continue on with the task.

In other words, you can begin a task with imperfect code -- and refine it as you go along -- figuring out how to handle corner cases as you go. All without starting the task over from the beginning.

I know of only one other language that allows you to explore a problem space like that.

Besides, the parentheses make the code less jagged looking and jagged looking code imo, is more tiring to look at. Lisp is simply prettier.

Re:John Carmack working on Scheme as a VR scripting language by muraiki on Wednesday July 01, 2015 @03:57PM (#9814704)
Smalltalk also drops you into a debugger on an error, letting you inspect the state of the system, correct your code, and resume. Check out Pharo Smalltalk.
Re:John Carmack working on Scheme as a VR scripting language by stray on Wednesday July 01, 2015 @04:02PM (#9814750)
TIL.

I have edited my comment to account for smalltalk.

Re:John Carmack working on Scheme as a VR scripting language by TeMPOraL on Wednesday July 01, 2015 @04:16PM (#9814827)
Smalltalk probably supports this as well, but what's cool about Common Lisp's condition system is that it doesn't depend on user interaction or debugger to work. Conditions let you separate the code making the decision about how to handle an error from actual error handling. The decision doesn't have to involve interactive debugger, you can have your code making the choice about which restart (unit of error handling code) to invoke. The common use case is that you install various restarts as you go down the call stack; then, when an exception happens, control goes up the stack until appropriate decision code, which selects restart, and control goes back down the call stack to the selected restart block.

It's an incredibly flexible system that makes exception handling much more useful.

Re:John Carmack working on Scheme as a VR scripting language by squeaky-clean on Wednesday July 01, 2015 @10:12AM (#9811897)
Not a lisp user myself, so I can't speak firsthand, but Paul Graham has several essays about it. http://www.paulgraham.com/lisp.html
Re:John Carmack working on Scheme as a VR scripting language by k__ on Wednesday July 01, 2015 @10:34AM (#9812054)
Can languages with other syntax have the same properties?
Re:John Carmack working on Scheme as a VR scripting language by TeMPOraL on Wednesday July 01, 2015 @10:53AM (#9812189)
Tcl I heard has string-based homoiconicity. Otherwise, I'm yet to see a proof you can get an actual, usable and not incredibly annoying macro system working without turning your language into a Lisp. People keep trying, but it's always some inelegant subset bolted onto the core syntax.
Re:John Carmack working on Scheme as a VR scripting language by leephillips on Wednesday July 01, 2015 @01:39PM (#9813671)
Julia is homoiconic and, of course, has lisp-style macros. It has a syntax similar to something like array fortran.

http://julialang.org/

Re:John Carmack working on Scheme as a VR scripting language by kkylin on Wednesday July 01, 2015 @02:10PM (#9813933)
I love using Julia, but for me writing Julia macros came with a steeper learning curve than in Lisp / Scheme, due in part to the syntax. I kept wishing Julia was a layer on top of a Lisp, and that I can just write Lisp macros. (I know the parser is currently in Scheme, but you can't exploit that easily.)
Re:John Carmack working on Scheme as a VR scripting language by ihnorton on Thursday July 02, 2015 @10:34AM (#9819135)
I tend to end up writing `Expr` objects directly when I'm building larger macros as I find them much easier to reason about. It's clearly not as convenient/clean as Lisp though. (David Moon actually sent a PR last year to make hygiene much easier.. unfortunately it got stuck for a while, but the PR was recently rebased and hopefully will be merged eventually).

Regarding the learning curve: we rewrote the first half of the Metaprogramming section of the manual a few months ago to try to provide a more gradual introduction, especially for people without a Lisp background. Objectively I don't know if the change has helped, but I tell myself that the number of macro-related questions has gone down :)

We would really like to make these tools accessible to people both with and without a formal CS background (probably the majority of Julia users will fall in the latter category). So, if you have any suggestions for doc/pedagogy improvements in this area, I would be very happy to hear them!

Re:John Carmack working on Scheme as a VR scripting language by grayclhn on Wednesday July 01, 2015 @04:31PM (#9814928)
The obvious solution is to write a julia macro that implements lisp macros as a DSL ;)
Re:John Carmack working on Scheme as a VR scripting language by KenoFischer on Wednesday July 01, 2015 @06:58PM (#9815816)
No need, Julia comes with a builtin lisp.
Re:John Carmack working on Scheme as a VR scripting language by pjmlp on Wednesday July 01, 2015 @12:36PM (#9813140)
Dylan? Then again it is a Lisp with Algol syntax.
Re:John Carmack working on Scheme as a VR scripting language by stray on Wednesday July 01, 2015 @05:16PM (#9815222)
I believe Dylan used to be a Lisp with Lisp syntax.
Re:John Carmack working on Scheme as a VR scripting language by pjmlp on Wednesday July 01, 2015 @06:37PM (#9815726)
Re:John Carmack working on Scheme as a VR scripting language by stray on Wednesday July 01, 2015 @07:32PM (#9815976)
Thanks for the link. The page on that site that gives the history including the original lispy syntax is here:

http://opendylan.org/history/index.html

Re:John Carmack working on Scheme as a VR scripting language by BruceM on Thursday July 02, 2015 @04:50AM (#9817589)
We talk sometimes about having an additional reader to support another syntax ... but so far, it isn't something where someone's actually volunteered to step up and help. It'd be interesting to play with some ideas from David Moon's PLOT as well ...
Re:John Carmack working on Scheme as a VR scripting language by sklogic on Wednesday July 01, 2015 @10:56AM (#9812200)
Take a look at Converge, Nemerle, TH and many other similar languages - they're doing just fine without any homoiconicity. All you need is a decent quasiquotation.
Re:John Carmack working on Scheme as a VR scripting language by TeMPOraL on Wednesday July 01, 2015 @11:06AM (#9812295)
Thanks for the pointers, I never heard of those languages before.

I am actually looking at the Converge documentation on macros now, and I found the perfect quote to highlight the problem I see with those approaches:

Quasi-quotes allow ITree's to be built using Converge's normal concrete syntax. Essentially a quasi-quoted expression evaluates to the ITree which represents the expression inside it. For example, whilst the raw Converge expression 4 + 2 prints 6 when evaluated, [| 4 + 2 |] evaluates to an ITree which prints out as 4 + 2. Thus the quasi-quote mechanism constructs an ITree directly from the users' input - the exact nature of the ITree is of immaterial to the casual ITree user, who need not know that the resulting ITree is structured along the lines of add(int(4), int(2)).

That is, quasi-quotes take some code and turn it into a tree object. This tree object can then somehow get compiled into actual code later. Compare that with Lisp approach, in which code is data. You don't think about the code as something separate from the tree that represents it. The code is the tree. There is no ITree object.

It may seem like just "semantics", but I find this to be a significant cognitive difference.

Re:John Carmack working on Scheme as a VR scripting language by sklogic on Wednesday July 01, 2015 @11:11AM (#9812323)
> Compare that with Lisp approach, in which code is data.

It's not any different. It does not matter if your `(,a ,b) is compiled into (list a b), or your ` \a\ = \b\` is compiled into make_binary('=',a,b) - both are constructors, essentially.

Take a look at what I'm doing with just a quasiquotation here: https://github.com/combinatorylogic/clike

Re:John Carmack working on Scheme as a VR scripting language by chadzawistowski on Wednesday July 01, 2015 @02:34PM (#9814119)
Other languages can technically have homoiconicity, but there's something to be said for the simplicity of Lisp forms.
Re:John Carmack working on Scheme as a VR scripting language by ArtB on Thursday July 02, 2015 @12:12PM (#9819834)
The property of homoiconicity is shared by all Lisps, Forths, and Prolog amongst others: https://en.wikipedia.org/wiki/Homoiconicity
Re:John Carmack working on Scheme as a VR scripting language by cwp on Wednesday July 01, 2015 @03:20PM (#9814461)
Yes. See Smalltalk for a language with object-oriented homoiconicity.
Re:John Carmack working on Scheme as a VR scripting language by stray on Wednesday July 01, 2015 @08:06PM (#9816115)
That's not really homoiconicity though, is it?

Smalltalk source code does not appear to be expressed in terms of a Smalltalk data structure. Whereas Lisp source code is expressed as lists of lists.

Re:John Carmack working on Scheme as a VR scripting language by cwp on Wednesday July 01, 2015 @10:24PM (#9816533)
Sure it is. All parts of a Smalltalk program are present as objects that can be manipulated by sending them messages. Classes, methods, variable bindings, closures, stack frames, even individual messages are objects.

As a practical matter, methods also have a textual representation, but that's not strictly necessary. Ten or fifteen years ago, the Squeak method browser had a mode where you could write Smalltalk code using tiles, kind of like in Etoys, no parsing necessary. That was a hassle to use, though, so people stuck with writing methods using text.

By the way, Lisp has the same sort of "impurity". S-expressions are very simple, but they are syntax. It's surely possible to create a tool that would let one construct cons cells in memory directly, but that would be a hassle. Instead we use parentheses.

Re:John Carmack working on Scheme as a VR scripting language by stray on Thursday July 02, 2015 @12:55PM (#9820102)
The 'iconicity' part of homoiconicity refers to the textual representation.
Re:John Carmack working on Scheme as a VR scripting language by rakoo on Wednesday July 01, 2015 @07:07PM (#9815862)
Maybe not the same, but I feel like nim (http://nim-lang.org/docs/manual.html#templates) can have a comparable power ot redefining itself. But I'm absolutely not an expert neither in any lisp nor in nim so I can't really tell.
Re:John Carmack working on Scheme as a VR scripting language by PuercoPop on Wednesday July 01, 2015 @01:28PM (#9813576)
Yes, take a look at Dylan. But they almost never do.
Re:John Carmack working on Scheme as a VR scripting language by maaku on Wednesday July 01, 2015 @03:02PM (#9814332)
Dylan's approach works because it has lisp at its core.
Re:John Carmack working on Scheme as a VR scripting language by sklogic on Wednesday July 01, 2015 @10:53AM (#9812188)
Any language with a compile-time metaprogramming would do.