News for hackers. Stuff that matters.
Re:Show HN: Bel by chrismorgan on Saturday October 12, 2019 @06:17AM (#21231917)
You and I both like Rust. Concrete performance is one key reason why I choose to use Rust for various things, and all Lisps I know of are just generally slower and use more resources; I’m not aware of any Lisp attempting to address this problem, and from what I do understand of Lisps (though I’ve never seriously coded in one) they seem at least somewhat incompatible with such performance. I’m interested in whether you have any remarks on this apparent conflict of goals.

(I’d love to be credibly told I’m completely wrong, because syntax aside, which I could get used to eventually, I rather like the model of Lisps and some of the features that supports.)

Re:Show HN: Bel by nickpsecurity on Saturday October 12, 2019 @08:51AM (#21232648)
You can build a Lisp to stay close to the metal with zero-cost abstractions. Most people drawn to Lisp are wanting productivity instead of max performance. Besides, the commercial Lisps and fastest in FOSS are really fast.

There was a systems type of Lisp called PreScheme that was closer to what you're envisioning. Carp also aims at no-GC, real-time use. Finally, ZL was C/C++ implemented in Scheme with both their advantages compiled to C. Although done for ABI research, I've always encouraged something like that to be done for production use with tools to automatically make C and C++ library bindings.

https://en.wikipedia.org/wiki/Scheme_48

https://github.com/carp-lang/Carp

http://zl-lang.org/

Re:Show HN: Bel by iamwil on Saturday October 12, 2019 @11:37AM (#21233943)
There's a post about the three tribes of programming. https://josephg.com/blog/3-tribes/

    Tribe 1: You are a poet and a mathematician. Programming is your poetry
    Tribe 2: You are a hacker. You make hardware dance to your tune
    Tribe 3: You are a maker. You build things for people to use
alfiedotwtf falls in the first tribe. You fall in the 2nd. Different tribes have different values, and hence all the back and forth.
Re:Show HN: Bel by dkarras on Saturday October 12, 2019 @02:32PM (#21235191)
What if I'm kind of all of them? Eternal damnation?

I've always strived to write beautiful code - for things people find very useful - in ways that push boundaries for what people think is possible with the machines we use.

I have succeeded in balancing any two of the above, to terrible detriment of the third. Never been able to juggle the 3 at the same time and this bothers me a lot. The upside is this pushes me to learn a lot, downside is I'm never content with my craft.

I'd have loved to solve domain specific important problems with a domain specific language I craft with a LISP and have state of the art performance while doing so.

Re:Show HN: Bel by kirillzubovsky on Saturday October 12, 2019 @02:41PM (#21235254)
Love this distinction. Makes a lot of sense, and is probably a key to happiness, to both realize which tribe you're in, and whether you're trying to argue with the tribe with another set of principles.
Re:Show HN: Bel by alfiedotwtf on Saturday October 12, 2019 @08:14PM (#21237296)
I like this :)

Programming is my poetry. Damn... that's a nice take

Re:Show HN: Bel by roryrjb on Saturday October 12, 2019 @07:27AM (#21232222)
I always thought that SBCL was considered high performance and for example Chicken Scheme compiles to C. Both might be slower than Rust but I always had the impression both of these were more performant than say Java, but I haven't used either in a meaningful way to really know how it would rate for your performance needs.
Re:Show HN: Bel by cylinder714 on Saturday October 12, 2019 @01:15PM (#21234641)
Chicken's author also created Bones, a Scheme that outputs x86-64 assembly language.

http://www.call-with-current-continuation.org/bones/

README: http://www.call-with-current-continuation.org/bones/bones.ht...

Re:Show HN: Bel by ska on Saturday October 12, 2019 @02:30PM (#21235172)
SBCL is quite fast for a lot of things. I used to use it frequently for research projects that required performant code, and it generally wasn't to difficult to get within a factor of 2 of c code, though getting much closer could be hard. I haven't really kept up with it recently, but it regularly impressed me at the time.
Re:Show HN: Bel by JohnStrangeII on Saturday October 12, 2019 @10:11AM (#21233241)
There is no conflict of goals, languages offer certain features, some of them offer only "zero-cost" abstractions (C++ and Rust) and others offer more abstractions. You get what you pay for in terms of runtime executable speed / features trade-offs. The other factor is the compiler toolchain - see below.

If Rust had the same features as most LISPs have, then using these features would make Rust programs as "slow" as LISP programs. That is generally true for most programming language comparisons. What also matters for final executable speed is the toolchain, of course. Any languages that compile directly using GCC or LLVM and allows for compile-time typing will be roughly in the same ballpark. If they use their own compiler, such as Chez or Racket, then they usually don't match the performance, because there is not enough manpower in their teams to implement all those nifty optimizations GCC and LLVM have. SBCL is probably the fastest LISP with its own compiler. (Or Allegro?)

To give an example, here are some CommonLisp features that Rust lacks: Full object system with inheritance and multiple dynamic dispatch, dynamic typing, hot runtime code reloading/recompilation, garbage collection.

Re:Show HN: Bel by chrismorgan on Saturday October 12, 2019 @10:47AM (#21233543)
You seem to be describing the effects of conflicting goals.
Re:Show HN: Bel by 13415 on Saturday October 12, 2019 @01:55PM (#21234935)
You mean trade-offs? The point is that every language and every implementation has them.
Re:Show HN: Bel by capableweb on Saturday October 12, 2019 @06:28AM (#21231970)
I don't think "Lisps are just generally slower and use more resources" is true.

According to "TechEmpower Web Framework Benchmarks" (which might not be perfect but at least give some indication), Clojure is one of the fastest language (in terms of handling responses per second) for building a JSON API with. Take a look at https://metosin.github.io/reitit/performance.html

Re:Show HN: Bel by chrismorgan on Saturday October 12, 2019 @06:50AM (#21232067)
I don’t think those results are actually particularly meaningful or that they scale up very well, but I’m going to skip that and address other relevant matters.

I mentioned resource usage, and that includes memory usage. The JVM can be surprisingly fast for some types of code, but it’s never a memory lightweight.

I suppose I might as well mention another feature I value: ease of deployment. In Rust, I can produce a single statically-linked binary which I can drop on a server, or on users’ machines, or whatever as appropriate, and run it. For anything on the JVM… yeah, without extremely good cause I will consider dependency on the JVM to be a blocker, especially for a consumer product.

Re:Show HN: Bel by capableweb on Saturday October 12, 2019 @07:38AM (#21232264)
True, but also Clojure is not the only Lisp, just one I remembered was mentioned in a actual benchmark as being fast at some things.

Nowadays you can either chose a Lisp that does compile to a single binary and doesn't require the JVM (like SBCL or something like that), or you could use Clojure but use GraalVM to get the single binary.

Anyways, I agree with your general point, Rust being in general faster. But I don't agree with the whole "Lisps are just generally slower and use more resources" thing, while it's certainly true in some conditions.

Re:Show HN: Bel by cies on Saturday October 12, 2019 @07:18AM (#21232181)
TechEmpower is (historically) a JVM shop. No surprise they do not bench the aspects JVM stinks at (startup/warmup, mem usage, total installed size).
Re:Show HN: Bel by chrismorgan on Saturday October 12, 2019 @07:54AM (#21232325)
It’s rather hard to meaningfully measure any of these figures.

Startup you can measure, but the optimal tuning for faster general operation may start up slower, so now you might want both figures. And then you’re getting perilously close to development considerations, so once you’re doing that surely you should benchmark any required compilation, and so on.

Warmup is even harder to handle well, because it introduces another dimension; even if you were presenting just a single-dimensional figure (which you’re not quite), you’re now wanting to consider how that varies over time while warming up, so now it’s at least two-dimensional. But unless warmup takes ages, you’ll find it hard to get statistically significant figures, because you have so many fewer samples in each time slice.

Total installed size? Problematic because the number isn’t meaningfully comparable, as this is a minimal test, and a number in that scope gives no indication of how much is due to the environment (e.g. JRE, CPython, &c.), and how much further growth there will be as you add more features. People will also start arguing about what should count; if for example you count the delta from a given base OS installation, then you’re providing an advantage to something that uses the system version of, say, Python, and penalising something that requires a different and extra version of Python.

Memory usage? Suppose you pick two figures: peak memory usage, and idle memory usage after the tests. Both are easy to measure, but neither is particularly useful. Idle memory usage, similar problem to disk usage, and so the numbers aren’t usefully comparable. Peak memory usage is perhaps surprisingly the more useless of the two, because the increase in memory usage is strongly correlated with how many requests are being served at once—and so a slower contestant might artificially use less memory than a faster one; and so if you wanted those numbers to be comparable, you’d need to throttle requests to the lowest common denominator, which could then be argued as penalising light memory usage patterns.

Re:Show HN: Bel by tigershark on Saturday October 12, 2019 @07:43AM (#21232290)
You can have a single binary with the JVM and .Net core, so it’s a non issue.
Re:Show HN: Bel by StreamBright on Saturday October 12, 2019 @06:47AM (#21232061)
The fastest for these sort of things are usually C++, Rust, C projects[1]. The fastest Java projects are Rapidoid, wizzardo-http, and proteus. The link you provided does not have a comprehensive comparison of different HTTP JSON frameworks.

1. https://www.techempower.com/benchmarks/#section=data-r18&hw=...

Re:Show HN: Bel by vindarel on Saturday October 12, 2019 @08:42PM (#21237412)
and here the author ports a Clojure program to Common Lisp with a x10 speed gain: http://johnj.com/from-elegance-to-speed.html. Sorry, x300.
Re:Show HN: Bel by sedachv on Saturday October 12, 2019 @03:31PM (#21235625)
The issue is memory management. Henry Baker helped popularize linear types in the early 1990s (http://home.pipeline.com/~hbaker1/) in his proposals for Lisp, from which work Rust's affine types derive, but no one wants to write in a dialect with those restrictions. Garbage collection seems like an algorithmically insurmountable problem. The other overheads are constant time, and Common Lisp already includes mechanisms to optimize them away (declarations and efficient arrays).
Re:Show HN: Bel by aasasd on Saturday October 12, 2019 @08:35AM (#21232544)
I'm currently using a CPU-slow machine, and I've discovered everything is slow among the popular scripting languages, except Lua. I've thought JS has good startup time, but some of my Lua scripts that are doing file i/o finish faster than node.js does a ‘hello world.’ Lua is also very lightweight on memory, to my knowledge. I think it can even do true multithreading, via libraries.

So, there's a Lisp on top of Lua―compiled, not interpreted: https://fennel-lang.org

It's deliberately feature-poor, just like Lua: you use libraries for everything aside simple functions and loops. And it suffers somewhat from double unpopularity of Lua and Lisp. But it works fine.

Re:Show HN: Bel by tonetheman on Saturday October 12, 2019 @10:14AM (#21233257)
I am using Fennel for this: https://itch.io/jam/autumn-lisp-game-jam-2019

I will not finish ... I suck at lisp. But it works.

Re:Show HN: Bel by DickieStarshine on Saturday October 12, 2019 @09:09AM (#21232779)
Have you looked at Julia?
Re:Show HN: Bel by MiroF on Saturday October 12, 2019 @09:15AM (#21232830)
Julia is compiled to machine code, not interpreted
Re:Show HN: Bel by fiddlerwoaroof on Saturday October 12, 2019 @10:59AM (#21233645)
Many lisps compile to machine code too. Compilation vs. interpretation is a feature of an implementation, not a language.
Re:Show HN: Bel by MiroF on Saturday October 12, 2019 @11:00AM (#21233660)
Scripting languages are by definition interpreted. The question was about fast scripting languages. I'm skeptical that Lisp compiled to Lua would count as in that category, but Julia unequivocally doesn't.
Re:Show HN: Bel by fiddlerwoaroof on Saturday October 12, 2019 @11:56AM (#21234102)
"Scripting languages are by definition interpreted" [[Citation Needed]].

There are Common Lisp implementations of both Python and Javascript (ES3) that compile to Common Lisp and then the Common Lisp compiles to machine code: as I said before, whether or not a language is interpreted or compiled is an implementation detail, not part of its spec.

Re:Show HN: Bel by MiroF on Saturday October 12, 2019 @01:59PM (#21234959)
https://www.webopedia.com/TERM/S/scripting_language.html

I chose this based off a random search on google of "scripting language." You can do the same and would get the same result.

It's not a rigorous term, because (you are right) its a property of the implementation not the language itself, despite the name.

But I don't think Julia has relevance to discussion of the speeds of interpreted Lisp.

Re:Show HN: Bel by lispm on Sunday October 13, 2019 @09:05AM (#21240162)
That term was a long time ago already seen as problematic in the Lisp community. At the time when Ousterhout used it for marketing TCL.

Basically a scripting language interpreter runs source code files, called scripts.

Lisp does that, too. But many Lisp implementations compile the code and often to machine code, since the runtime includes an incremental compiler. The incremental compiler can compile individual expressions to memory.

Thus when you use a Lisp system, running a script just looks like running an interpreter, even though the code gets compiled incrementally.

Lisp uses the function LOAD, which can load a textual source file and which can then read, compile, execute expressions from the file. Typically this is also available via command line arguments.

Like in SBCL one can do:

  sbcl --script foo.lisp
and it will read/compile/execute expression by expression from a textual source code file, actually incrementally compiling each expression to machine code.
Re:Show HN: Bel by ska on Saturday October 12, 2019 @02:36PM (#21235216)
> Scripting languages are by definition interpreted.

I don't think this is correct. Scripting aren't rigorously defined, of course, but it would be reasonable to say they are defined by practice (i.e. a scripting language is practical for scripting).

Most compiled languages knock themselves out of contention in this definition because the startup and/or compile times are too long to be practical. But I've used luaJit in scripting contexts before, so that at least muddies the waters. Also common lisp (a variant that was always compiled).

Re:Show HN: Bel by MiroF on Saturday October 12, 2019 @02:44PM (#21235278)
It's a term for a simpler era where these divides made sense.

I've always understood it to mean interpreted and from a quick google search there are at least a sizeable number of people who agree.

I think now that there are a lot of high level compiled languages, it makes less sense.

Re:Show HN: Bel by vanderZwan on Saturday October 12, 2019 @10:10AM (#21233224)
That has nothing to do with how "lispy" it might be. Part of the compiler is implemented in femtolispe no?
Re:Show HN: Bel by MiroF on Saturday October 12, 2019 @10:58AM (#21233641)
I suspect this does have to do with whether or not it is a fast scripting language, considering a language compiled into machine code is by definition not a scripting language.

Sure, flag me, but my comment was relevant to the discussion.

Re:Show HN: Bel by e12e on Sunday October 13, 2019 @07:33AM (#21239841)
Julia is currently (only) jit. AOT is stil work in progress AFAIK.

It's about as "compiled" as Luajit is.

Re:Show HN: Bel by alfiedotwtf on Saturday October 12, 2019 @08:02AM (#21232364)
Hey Chris :)

I totally get you with Lisps and performance, but I was more talking about the beauty and elegance of code written in them. Algorithms written in Lisps seem to be pieces of art.

And that's just Lisps... having a look at logic programming languages like Prolog and Mercury, it's amazing to see just how compact yet understandable an algorithm can be. They're beautiful!

But as for performance, take a look at Mercury - its a declarative logic programming language with built in constraint solving, which compiles down to C, and its performance is great. We've rewritten some Mercury in Rust, and yes our Rust is faster, but not by orders of magnitude as you'd think.

Re:Show HN: Bel by DickieStarshine on Saturday October 12, 2019 @09:09AM (#21232785)
How's the editor support with Mercury?
Re:Show HN: Bel by alfiedotwtf on Saturday October 12, 2019 @09:30AM (#21232959)
Not sure about other editors, but there's syntax highlighting for Vim in the repo, and mtags (ctags for Mercury).
Re:Show HN: Bel by mark_l_watson on Saturday October 12, 2019 @10:38AM (#21233477)
I use SBCL to build command line applications. Reasonable enough memory use and very fast startup times. I for a while used to use Gambit Scheme for this but decided I like Common Lisp better. We no longer need hardware Lisp machines for good performance. That said, for some applications Rust is clearly better.
Re:Show HN: Bel by e12e on Sunday October 13, 2019 @07:36AM (#21239853)
Do you have some examples you could share?
Re:Show HN: Bel by mark_l_watson on Sunday October 13, 2019 @10:55AM (#21240666)
There is one in the new edition of my Common Lisp book https://leanpub.com/lovinglisp

You can read it online for free, and clone the github examples repo.

Re:Show HN: Bel by neonate on Saturday October 12, 2019 @04:50PM (#21236144)
Why do you like Common Lisp better?
Re:Show HN: Bel by mark_l_watson on Saturday October 12, 2019 @05:34PM (#21236516)
I have so much experience with Common Lisp, starting around 1984 on my 1108 Lisp Machine. I have used various Scheme implementations a lot, but I just have more history and experience with Common Lisp. Both are great choices, and there are many high quality Schemes, plus Racket. Experiment, and then choose your own favorite Lisp.
Re:Show HN: Bel by antisemiotic on Saturday October 12, 2019 @07:20AM (#21232190)
Not exactly lisps, but Carp (https://github.com/carp-lang/Carp) and Scopes (https://bitbucket.org/duangle/scopes/wiki/Home) might be worth a look. I haven't tried the former, and couldn't get the latter to do anything useful, though. (it looks like the author stopped responding to issues, sadly).
Re:Show HN: Bel by bachmeier on Saturday October 12, 2019 @08:46AM (#21232617)
"they seem at least somewhat incompatible with such performance"

Lisp is for the other 99.5% of programming that doesn't require you to wring every last drop of performance out of your CPU.

Re:Show HN: Bel by tambourine_man on Saturday October 12, 2019 @11:16AM (#21233778)
After JavaScript’s success, I’m convinced any language can be made fast given enough time and money.

Some languages are easier to be made faster, but I think JS almost proves there’s no such thing as a language incompatible with high performance by design.

You’d be hard pressed to conceive a more dynamic language and here we are, with crazy fast performance through many JIT tiers, interpreters, compilers, each of which would take years for a bright engineer to understand.

Re:Show HN: Bel by chrisseaton on Saturday October 12, 2019 @11:49AM (#21234047)
JavaScript is an extremely small, well-defined language with relatively simple semantics and very limited metaprogramming. It’s not a challenge compared to something like Ruby.
Re:Show HN: Bel by iLemming on Saturday October 12, 2019 @01:44PM (#21234853)
When was the last time you looked at it? Javascript is not small anymore. ECMAScript specification is over 800 pages, only a few hundred pages smaller than Java's.
Re:Show HN: Bel by chrisseaton on Saturday October 12, 2019 @01:46PM (#21234867)
> When was the last time you looked at it?

I’ve read the latest version of the specs of all these languages in detail.

I’ve worked professionally on a team implementing Ruby, the latest version of JavaScript, and Java at the same time, using the same language implementation system, so I can directly compare.

JavaScript is simplest by far. There’s quite a lot of sugar now, but the core semantics are small and simple. The core semantics of a language like Ruby are an order of magnitude more complicated.

Re:Show HN: Bel by didibus on Saturday October 12, 2019 @06:11PM (#21236730)
You may be wrong in thinking all programs require maximum performance?

I just find your question a little confusing. My house is only two floors, yet meets all my needs. A bigger house would just waste my time in cleaning, cost me more in maintaining, in heating, etc.

It's the same for programs. Target performance at all cost, and for a lot of programs you get a hard to maintain, non scalable, bug ridden, featureless program that took you way too long to build.

That's why for example I use Clojure and Rust. Rust gets the least use, because the programs I tend to write can manage fine with Clojure's performance. In fact, I mostly toy with Rust, because I really never needed to write anything higher performance.

So I'm just not sure what you mean. The world is full of useful programs that meets the needs of their users which aren't high performance. For all these programs, Lisp is a superpower.

Re:Show HN: Bel by vindarel on Saturday October 12, 2019 @01:17PM (#21234652)
Some pointers:

- how to make lisp go faster than C: https://www.reddit.com/r/lisp/comments/1udu69/how_to_make_li...

- https://github.com/marcoheisig/Petalisp "Petalisp is an attempt to generate high performance code for parallel computers by JIT-compiling array definitions. It is not a full blown programming language, but rather a carefully crafted extension of Common Lisp that allows for extreme optimization and parallelization."

Re:Show HN: Bel by elamje on Saturday October 12, 2019 @07:07AM (#21232131)
I don’t know if you are wrong, but I would give fennel lang a look. It’s a lisp that compiles to Lua, so you can access LuaJIT performance while lisping away.
Re:Show HN: Bel by didibus on Saturday October 12, 2019 @06:33PM (#21236837)
I don't think OP considers LuaJIT high performance, considering lots of Lisps are just as performant as LuaJIT.
Re:Show HN: Bel by SigmundA on Saturday October 12, 2019 @08:40AM (#21232569)
What if there was hardware accelerated Lisp?: https://en.wikipedia.org/wiki/Lisp_machine
Re:Show HN: Bel by agumonkey on Saturday October 12, 2019 @08:42AM (#21232587)
a forth array cpu based lisp machine would be a fun toy
Re:Show HN: Bel by deepaksurti on Saturday October 12, 2019 @06:28AM (#21231972)
>> they seem ... incompatible with such performance

Might answer your question [0]

[0] https://news.ycombinator.com/item?id=2192629

Re:Show HN: Bel by chrismorgan on Saturday October 12, 2019 @07:06AM (#21232130)
I don’t think so. My simple reading of things there is that that was for one particular micro-benchmark (and the Benchmarks Game is acknowledged to be unrealistic and not actually suitable for comparing language performance), that the results were not actually conclusive, and that it had required telling SBCL to do some stupidly dangerous things that you should probably never turn on on real software, because they may well make it behave catastrophically badly rather than just crashing when you have a bug.

On https://benchmarksgame-team.pages.debian.net/benchmarksgame/... at present, the fastest SBCL implementation, which seems to include these optimisations, is at 2.0, with other SBCL implementations being slower, the first one (whatever that means) being 8.0; meanwhile, the Rust implementations range between 1.0 and 1.2. The SBCL implementations all use at least eight times as much memory as the Rust implementations, too.

I think this demonstrates my point pretty well, actually.

Re:Show HN: Bel by igouy on Tuesday October 22, 2019 @11:01AM (#21324370)
> … required telling SBCL to do some stupidly dangerous things …

No, that isn't required.

On the contrary SBCL is quite insistent that the arithmetic be made safe.

I'm not even a Lisp newbie, but with help from SO I've been able to tweak those spectral-norm programs to make the SBCL compiler happy without destroying the performance:

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re:Show HN: Bel by armitron on Saturday October 12, 2019 @11:33AM (#21233915)
The (micro)benchmarks game is a gimmick and should not be taken seriously. You forgot to mention that the SBCL #3 implementation also sits at 2.0 and is fully memory safe.

I fail to see the reason for you presenting the facts in this manner especially the "stupidly dangerous things part" which is of course totally inaccurate. (safety 0) has its uses (e.g. like Rust unsafe).

Your conclusions are not indicative of real world performance.

Re:Show HN: Bel by igouy on Saturday October 12, 2019 @12:19PM (#21234267)
> … benchmarks game is a gimmick …

What exactly is it designed to attract attention to?

> … should not be taken seriously.

Because?

> … fully memory safe.

Here's the problem, the programs are explicitly required to use function calls but:

;; * redefine eval-A as a macro

Re:Show HN: Bel by igouy on Saturday October 12, 2019 @12:37PM (#21234404)
> … acknowledged to be unrealistic and not actually suitable for comparing language performance …

By whom?

Maybe there are situations for which it is "realistic" — the point is that we don't know.

What would actually be suitable for comparing language performance?