News for hackers. Stuff that matters.
Re:Racket: The Lisp for the Modern Day by theanonymousone on Thursday June 29, 2023 @09:09AM (#36519871)
Isn't Clojure the literal "Lisp for the modern day(a.k.a JVM)"?

I hope I don't get kicked out of HN altogether for this comment :)

Re:Racket: The Lisp for the Modern Day by mejutoco on Thursday June 29, 2023 @09:21AM (#36519993)
IMHO Common Lisp is the modern one. Using the JVM is nice for certain uses, and clojure is a fine language, but going bare metal from higher abstractions is some power of Lisp that we should not give up. Same with macros and code generation.

Luckily all of them can coexist, so we do not need to choose.

Re:Racket: The Lisp for the Modern Day by dom2 on Thursday June 29, 2023 @09:42AM (#36520274)
There is also ABCL, an implementation of common lisp on the JVM https://armedbear.common-lisp.dev/
Re:Racket: The Lisp for the Modern Day by freilanzer on Friday June 30, 2023 @07:06AM (#36532877)
And it has a great name: Armed Bear Common Lisp.
Re:Racket: The Lisp for the Modern Day by criddell on Thursday June 29, 2023 @09:39AM (#36520224)
How is code generation handled on modern operating systems and CPUs? Isn't there normally a strict separation between code and data to prevent exploits?
Re:Racket: The Lisp for the Modern Day by andsoitis on Thursday June 29, 2023 @09:59AM (#36520452)
> How is code generation handled on modern operating systems and CPUs? Isn't there normally a strict separation between code and data to prevent exploits?

You compile code, which is text (data), all the time, don’t you?

Re:Racket: The Lisp for the Modern Day by Zambyte on Thursday June 29, 2023 @10:52AM (#36521191)
The difference is that the output of the compiler is usually not loaded into the same process that did the compiling. That is not the case for applications that are developed On Lisp™.
Re:Racket: The Lisp for the Modern Day by andsoitis on Friday June 30, 2023 @12:27AM (#36530491)
True. Well, since it works on the latest CPUs and OS's, presumably it isn't verboten.
Re:Racket: The Lisp for the Modern Day by p_l on Thursday June 29, 2023 @10:04AM (#36520500)
At worst you have to ensure that you separate what needs to be writeable from executable, and then flip mappings RW->RX when generating new code, just like other JIT compilers do.
Re:Racket: The Lisp for the Modern Day by criddell on Thursday June 29, 2023 @10:32AM (#36520871)
Oh okay. I was thinking of self-modifying, not just code generation. That was something that was done occasionally by DOS and Windows programmers before the introduction of DEP in Windows XP.
Re:Racket: The Lisp for the Modern Day by trws on Thursday June 29, 2023 @11:36AM (#36521900)
Yeah, self modifying has become harder. As far as I know the most robust solution to that now is like what Julia does, where it can compile new generations of any module to update call targets, for example. At worst, when seccomp disallows flipping a writable page to executable at runtime, you can always compile into a file then dlopen the file. In other words, it can take many more contortions now than it used to, but it’s still possible.
Re:Racket: The Lisp for the Modern Day by dorfsmay on Thursday June 29, 2023 @10:12AM (#36520601)
Was lisp compiled code, not code.running in a repl, ever able to self modify?

It looks like that wasn't the case even in 1996:

https://groups.google.com/g/comp.lang.lisp/c/O1dDXlQsVkw

Re:Racket: The Lisp for the Modern Day by pfdietz on Thursday June 29, 2023 @01:13PM (#36523390)
One can define and compile functions in a running Common Lisp. There's a standard function, compile, that does this.

In SBCL, any evaluation of an expression is done by first compiling it.

Re:Racket: The Lisp for the Modern Day by dreamcompiler on Thursday June 29, 2023 @03:00PM (#36525162)
Self modifying code in the sense of changing one instruction to another at runtime (as was commonly done in assembler in the 1960s) is not generally possible with modern Common Lisps mostly because modern operating systems don't allow it. And that's a good thing because such code would be hopelessly insecure and impossible to reason about.

But if you mean "compile a new function called X and replace the old X at runtime", that's easy in Common Lisp. It's not commonly done unless you're explicitly writing some kind of compiler.

What is commonly done is to create a lexical closure at compile time and change its bound values at runtime. IOW changing the private data of a function at runtime is more generally useful than changing its instructions.

What's most common is to write lisp programs that emit lisp source code and compile it at compile time (but usually not run time). Such programs are called macros.

Re:Racket: The Lisp for the Modern Day by perihelions on Thursday June 29, 2023 @11:00AM (#36521317)
I just checked: SBCL on Linux/amd64 puts compiled functions in a r+w+x page. You could write Lisp that writes Lisp that writes self-modifying machine code, and it would (I think) run by default.

    (compiled-function-p #'f) ; T
    
    (disassemble 'f)
    ; disassembly for F
    ; Size: 58 bytes. Origin: #x5350CD14                          ; F
    ; 14:       498B4510         MOV RAX, [R13+16]                ; thread.binding-stack-pointer
    ; 18:       488945F8         MOV [RBP-8], RAX
    ; 1C:       4883EC10         SUB RSP, 16
    ; [...]


    $ pmap $PID --range 5350CD14
    442331:   /usr/bin/sbcl
    0000000053498000 122272K rwx--   [ anon ]
     total           122272K
Re:Racket: The Lisp for the Modern Day by waffletower on Thursday June 29, 2023 @11:08AM (#36521426)
No, 'eval' is available in many dynamic languages and needs to be utilized with care
Re:Racket: The Lisp for the Modern Day by mark_l_watson on Thursday June 29, 2023 @10:47AM (#36521113)
I agree, Common Lisp is crufty but really stands the test of time. I have been using Common Lisp since about 1982 and old code still runs fine.

My relative use of Lisp languages: Common Lisp 60%, Racket 20%, Haskell 5%, Clojure 5%, and various other Schemes 10%. Unfortunately since most of my work in the last 8 years has been deep learning, LLMs, LLM chains, etc., I spend a little over half my time now using Python. So it goes...

Re:Racket: The Lisp for the Modern Day by i_am_a_peasant on Thursday June 29, 2023 @11:53AM (#36522152)
That Vonnegut reference at the end ;D
Re:Racket: The Lisp for the Modern Day by deckard1 on Thursday June 29, 2023 @02:57PM (#36525113)
"old code runs fine" is a poor benchmark for how well a language holds up over time. All x86 code still runs fine. Perl 5 is from, I think, 1994. It's still maintained and in development. Most C code from the '80s would still compile and run just fine (at least POSIX-based, Windows however...). You can trivially find Pascal, Fortran, COBOL, and Forth code that all "still runs fine."

I don't think it's a particularly unique or interesting quality, that some old code still runs. After all, I can go to archive.org right now and run all of that ancient DOS, Amiga, whatever code in a 100% exact (or close to) emulator in my browser.

Re:Racket: The Lisp for the Modern Day by waffletower on Thursday June 29, 2023 @11:01AM (#36521336)
I am curious how performant compiled Common Lisp is compared to GraalVM compiled Clojure native images. You certainly don't give up macros and code generation when using Clojure, though you do give up a specific class of explicit reader macros. Some reader extensibility can be had (and is used in Clojure.core) via reader functions (data_readers.clj)
Re:Racket: The Lisp for the Modern Day by pfdietz on Thursday June 29, 2023 @01:10PM (#36523337)
You don't give macros and code generation when using compiled Common Lisp, either.
Re:Racket: The Lisp for the Modern Day by systems on Thursday June 29, 2023 @09:36AM (#36520178)
the problem with clojure is you have to learn java (or at least some java) same issue i see with F#, you still need to have at least some basic knowledge of C#

unfortunately running on JVM actually really means running on Java same for .net it mean running on C#

i dont mind learning two languages, its expected from most developers to know more than one, but context switching in a single function between two language is not fun

Re:Racket: The Lisp for the Modern Day by pjmlp on Thursday June 29, 2023 @09:59AM (#36520454)
The curse of guest languages.

However F# suffers from a bigger issue, that clojure doesn't, belonging to the platform owner, that behaves as if it was an error to make it part of VS 2010.

Re:Racket: The Lisp for the Modern Day by jeremyjh on Thursday June 29, 2023 @10:16AM (#36520652)
Isn't that because F# failed to win any significant market share? I think F#'s problem is that C# is too good and this was true even in 2010, its not like Scala vs. Java in 2010.
Re:Racket: The Lisp for the Modern Day by josephferano on Thursday June 29, 2023 @10:45AM (#36521076)
I worked with F# for about 3 years and the sentiment of most F# developers after using it in anger, including myself, is "I don't want to go back to C#". In my opinion, it didn't win significant market share because Microsoft didn't want it to. This goes even further back than 2010. I don't know if it's because F# was open source and C# was not, as Microsoft's FOSS stance hadn't really come around yet till what, 2016?
Re:Racket: The Lisp for the Modern Day by systems on Thursday June 29, 2023 @10:39AM (#36520972)
F# is way nicer than C# (and Clojure is still way nicer than Java)

And I dont think F# failed, I just think it needs to find a way to hide C# and OOP better

But the language is doing fairly well, tons of educational resources, tons of videos on youtube , several nice projects on github, solid vs code mode, it is part of .net , but still a lot can be improved, and microsoft is far from abandoning, C# is one of MS flagship products , F# is not a flagship product

Re:Racket: The Lisp for the Modern Day by soulbadguy on Thursday June 29, 2023 @10:56AM (#36521264)
Big F# fan here, but i don't really "doing fairly well" is a fair assessment of the F# ecosystem right now.

> microsoft is far from abandoning

Might has well. When you look at the resources actually being deployed for F#, it's clear that MSFT either don't care or don't really have plan for F#. Most of the work is done by the community. The number of actual paid/full time MSFT dev on F# is very limited. The tooling is extremely limited, there is no official F# libraries for pretty much any MSFT and azure services (have to relie on C# libs.) In leetcode where the have C# (so already have the infra to run .net stuff, and language like elixir and racket (so they do have more niche language), they still don't have F#.

The salvation for F# would come from finding a killer app, something akin to pytorch/numbpy or rails.

Re:Racket: The Lisp for the Modern Day by trenchgun on Thursday June 29, 2023 @11:53AM (#36522148)
Killer library. Not an app.
Re:Racket: The Lisp for the Modern Day by guhidalg on Thursday June 29, 2023 @10:45AM (#36521083)
Maybe, and it's a good case study to compare F# vs. C# with Java vs. Scala to understand why Scala seems to have higher penetration than F#.

In my opinion, and I mean this in the broadest way possible, the average C# developer is probably less motivated to learn a new language than the average Java developer. That's because C# developers are prescribed by Microsoft what to do, and Microsoft could deliver a productive-enough experience with C# + .NET Framework + Visual Studio for a long long time.

Java's fractured IDE story and runtime (OpenJDK vs. HotSpot) I think lead to a higher concentration of programming language people looking at the JVM as a viable target to build a better experience on top of, so we got Groovy, Scala, Kotlin, (anyone remember Xtend?), IDEA, Eclipse, etc...

The bazaar produced and embraced a functional programming language whereas the cathedral treats F# as thunderdome for new C# features.

Re:Racket: The Lisp for the Modern Day by Capricorn2481 on Thursday June 29, 2023 @12:33PM (#36522761)
Scala pretty much hangs on a thread and is only breathing cause of Spark
Re:Racket: The Lisp for the Modern Day by bmitc on Thursday June 29, 2023 @11:36AM (#36521888)
Reading C# code makes me shudder. It is so hard to read with all the brackets, spacing, indentation levels, and overall verboseness. I honestly don't know how people do it.

F# can do OOP just as well if not better than C#, and F# is anywhere from 2-10 times more concise than C#.

That being said, the mistake of Microsoft was viewing F# as a competitor to and research lab for C# and the community for viewing and selling it as a replacement for C#.

What Microsoft and the community should have done is treated F# as a competitor and replacement for Python from the start.

Re:Racket: The Lisp for the Modern Day by pjmlp on Thursday June 29, 2023 @02:52PM (#36525028)
That is what F# folks tried to pivot the language as of latest, only to be sidestepped yet again by Microsoft, when they hired Guido and managed to be the company that changed his mind regarding CPython optimizations.

Also see the development effort Microsoft spends on Python across all their IDEs and what F# gets.

Re:Racket: The Lisp for the Modern Day by deckard1 on Thursday June 29, 2023 @03:11PM (#36525304)
> The curse of guest languages.

Every language lives under the iron fist of libc and the C ABI.

Re:Racket: The Lisp for the Modern Day by pjmlp on Thursday June 29, 2023 @03:26PM (#36525512)
Not every OS is an UNIX clone.
Re:Racket: The Lisp for the Modern Day by bmitc on Thursday June 29, 2023 @11:33AM (#36521850)
You really don't need to know C# to use F#. You need to understand .NET, but that is not the same as needing to know C#. F# sits on top of .NET and the CLR in a much more clean way than Clojure sits on top of the JVM. F# also has excellent error messages and is also much easier to install.

I know F# quite well at this point but only barely know C#. I know C# maybe only mildly better than C++ or Java in terms of being able to read it and guess what it's doing. I certainly can't write in it without looking up a bunch of stuff.

Re:Racket: The Lisp for the Modern Day by Capricorn2481 on Thursday June 29, 2023 @12:30PM (#36522710)
Aren't most libraries you want in C# though? Isn't there a bit of impedance mismatch between how functional F# is and how OOP C# is? I have heard from a few F# fans how frustrated they are that they have to keep interacting with C#
Re:Racket: The Lisp for the Modern Day by nifty_beaks on Thursday June 29, 2023 @12:54PM (#36523172)
I recently did a small project in F# just to try it out. This was my exact experience. Syntacticly it seemed very nice and in some ways it was cool to have all the libraries I'm used to in C#, however due to the latter it ends up being possible to suddenly have `null` or other weird non-functional thingies suddenly pop up.
Re:Racket: The Lisp for the Modern Day by bmitc on Thursday June 29, 2023 @09:33PM (#36529446)
OOP is very natural in F#, so it's not that. Interacting with .NET is not an issue. Interacting with a third-party library can sometimes be an issue, if they're doing a bunch of funky C# stuff. For my own use cases, I haven't needed to pull in a bunch of C# developed, third-party libraries. When I did, for example Silk.NET's window bindings, it was easier to just write my own. I couldnimagine that's different for some more industrial use cases though.
Re:Racket: The Lisp for the Modern Day by wildermuthn on Thursday June 29, 2023 @09:31AM (#36520105)
Unfortunately, IMHO Clojure’s maintainers hold an iron grip on the language and actively limit the growth of an ecosystem around it. See “Open Source is not about you”.

It’s too bad, because itself is really terrific.

Re:Racket: The Lisp for the Modern Day by pjmlp on Thursday June 29, 2023 @09:58AM (#36520439)
To their right, Rich Hickey almost got bankrupted while developing Clojure.

The usual "expect all for free, give nothing back" attitude.

Re:Racket: The Lisp for the Modern Day by threatofrain on Thursday June 29, 2023 @10:29AM (#36520825)
Rich Hickey basically wrote this in response to one of the notable and respected contributors of his ecosystem (Chas Emericks). If Rich wanted open source to be nothing more than a license and delivery mechanism then he shouldn’t have accepted volunteers. But a language without an ecosystem of volunteers is a dead language.
Re:Racket: The Lisp for the Modern Day by pjmlp on Thursday June 29, 2023 @11:23AM (#36521654)
Many languages do quite well as commercial products.
Re:Racket: The Lisp for the Modern Day by erichocean on Thursday June 29, 2023 @11:24AM (#36521675)
Clojure "the language" is certainly ossified, but Clojure "the ecosystem" is doing very, very well.
Re:Racket: The Lisp for the Modern Day by nocman on Thursday June 29, 2023 @01:06PM (#36523297)
I'm genuinely curious. What about the language do you feel is "ossified"? I am interpreting that as being a negative description.

Stability is extremely valuable. A lack of change to the core language over extended periods of time can be a very good thing, especially if certain changes would break existing code. Rich has made it clear that he is indeed targeting this kind of stability.

Again, I would be very interested to hear what specific changes you think need to be made to 'Clojure "the language"'.

Re:Racket: The Lisp for the Modern Day by erichocean on Thursday June 29, 2023 @03:52PM (#36525810)
No changes, I'm a happy Clojure user. Long-term stability is one of its selling points.
Re:Racket: The Lisp for the Modern Day by nocman on Tuesday July 11, 2023 @09:38AM (#36680795)
Been busy and didn't see the response...

So... you meant 'ossified' in a good way?? If so, I guess I would have used a different term that didn't have such a negative connotation.

Re:Racket: The Lisp for the Modern Day by wartijn_ on Thursday June 29, 2023 @10:18AM (#36520679)
Re:Racket: The Lisp for the Modern Day by fulafel on Thursday June 29, 2023 @10:31AM (#36520857)
I think being conservative about evolving the language, and ecosystem growth are mostly different issues, the open source post was about the core language.

Comparing to other languages I think the stability of the language has served the user community really well and been an enabler of the ecosystem. I guess the continuous language additions and resulting complexity & library/framework chuirn in some otherlanguages can also be seen as vitality and growth, but for many of us it's the wrong kind of growth.

(And yes there are also disadvantages to the centralised development model of the core language)

Re:Racket: The Lisp for the Modern Day by waffletower on Thursday June 29, 2023 @11:17AM (#36521553)
The iron grip is on a decidedly double-edged sword. I applaud the continuity and maintainability of Clojure and its ecosystem. The consistency of the language has come from this stern stewardship. Rich makes very clear that the source code for the language is available to be forked. Very interesting developments have come from this, most notably babashka.
Re:Racket: The Lisp for the Modern Day by c_crank on Thursday June 29, 2023 @09:15AM (#36519937)
Clojure is opinionated against using all the potential features of Lisp.
Re:Racket: The Lisp for the Modern Day by masijo on Thursday June 29, 2023 @10:19AM (#36520698)
What would be those potential features of Lisp that Clojure is missing?
Re:Racket: The Lisp for the Modern Day by fulafel on Thursday June 29, 2023 @10:41AM (#36521010)
It steers you pretty heavily toward functional programming.
Re:Racket: The Lisp for the Modern Day by c_crank on Thursday June 29, 2023 @10:30AM (#36520837)
Multi paradigm support, low level / C interop capacity, really any sort of native features
Re:Racket: The Lisp for the Modern Day by waffletower on Thursday June 29, 2023 @11:13AM (#36521499)
Clojure is a multi-hosted language. Clean native interop would be nice to have I agree though.
Re:Racket: The Lisp for the Modern Day by waffletower on Thursday June 29, 2023 @11:11AM (#36521470)
That is fair, though not a negative for many. Clojure prefers immutable data structures and functional constructs. Rich Hickey even wishes that he added fewer OOP constructs in the language (such as structs) and leaned more heavily on Clojure rooted functional concepts like 'transducers' which came later in the life of the language.