Top
Best
New

Posted by teleforce 2 days ago

“Stop Designing Languages. Write Libraries Instead” (2016)(lbstanza.org)
277 points | 275 commentspage 3
igt0 2 days ago||
Logic systems are a good place where the library first approach tends to work well: you keep a small, boring core (the inference engine), and let people extend it with predicates, rules/operators, and domain packages.

I’ve been experimenting with a small defeasible-logic core (argumentation semantics + priorities + conflict detection) that stays stable, while most of the real meaning lives in extension points. https://github.com/canto-lang/canto-lang

defactor 2 days ago||
Java has Grails web framework. We have designed apps with 75% less resources and time compared to Spring at a big enterprise. But most devs wanted springboot.
newsoftheday 2 days ago|
Grails requires Groovy, though you can integrate Java classes into a grails app.

Now that we can develop script style with Java 21, I'd like to see something like Grails that worked with Java only...that would be a fun way to develop web apps. I liked Grails, just not Groovy.

ninalanyon 2 days ago||
I'd say that the best thing ever would be an easy way to call a library written in xxx from a program written in yyyy.

There are lots of libraries already. Instead of rewriting them in every language why make them available to every language.

Yes, I know it would be difficult and in some cases impossible.

NoGravitas 2 days ago||
Of course, in Lisp, you can implement language features as libraries, which kind of undercuts the point of this article.
kazinator 2 days ago||
> In summary, the purpose of a general-purpose programming language is to enable the creation of powerful and easy-to-use libraries.

Close! The purpose of a general-purpose programming language is to enable the creation of powerful and easy-to-use languages, but often just libraries.

butterisgood 2 days ago||
I think this thinking makes sense if you've not used enough programming languages pragmatically.

But, if you squint, great API design is a bit like embedded domain specific language design as well.

I think there's room for both.

dominicrose 2 days ago||
Rails wouldn't exist without Ruby, Ruby wouldn't exist without C, Rails can't be rewritten in C, Rails isn't a library.

But aren't Rails, Laravel and Django a bit similar? At least for the people not directly involved in coding.

9rx 2 days ago||
> Rails can't be rewritten in C

It could if you added message passing to C.

Which we have, and DHH admits that Rails took directly from that. Rails is (loosely) a rewrite of what was originally written in C [with extensions].

kristianp 1 day ago||
> Rails is (loosely) a rewrite of what was originally written in C [with extensions].

Are you talking about WebObjects, which was written in Objective-C? (1) If so your comment is somewhat tangential to the truth.

(1 2104) https://news.ycombinator.com/item?id=8765009

vhantz 2 days ago|
> Stanza provides an optional type system, garbage collection, and a multimethod based object system. But if you don't like Stanza's object system, there is no way to write your own. This is one of the main directions of programming language research. Can we design a language so expressive that library writers can easily write the most appropriate object system, or most appropriate type system, to fit their application? Perhaps one day we'll have such a language.

We already have it. It's an obscure little language called C++. Tise interested in those kinds of extensions to a language should look into Herb Sutter's experiments with cppfront: https://hsutter.github.io/cppfront/welcome/overview/

lelanthran 2 days ago||
C++ is most definitely not it.

Lisp is what you are after if you want to include some object system as a library, or a new type of switch statement as a library or a new kind of if statement as a library.

C++ can do none of that.

AnimalMuppet 2 days ago|||
C++ can do some of that. Let's say I want an if statement that takes an integer and three blocks of code. It executes the first block if the integer is less than zero, the second if it is zero, and the third if it is positive.

OK, if you squint enough that by "block of code" you mean closure, or function object, then I can write that in C++. I can make the if statement a free-standing function (that is, not a member of a class), and add it to any library I wish.

Now, you can say that it's going to be tedious to use that, because you have to set up three closures every time you want to call this "super if". And you'd be right, but that's a different argument.

munificent 2 days ago|||
One problem is that closures don't actually behave like blocks. Consider that you might want to use this three-legged-if inside a loop. If it's a real statement, then those branches can have `break;` and `continue;` statements which affect the surrounding loop. If those branches are just closures being passed to a function, then they can't.
lelanthran 2 days ago||||
> OK, if you squint enough that by "block of code" you mean closure, or function object,

But we aren't squinting here; those closures can't perform a return where your `new-if` function is being used, they can't perform a `return` like a proper `if` can, you can't goto, or break or continue.

It's just a function taking functions, with all the restrictions that that entails.

philipallstar 2 days ago|||
How can you declare new syntax in C++? Wouldn't it just be a function call?
AnimalMuppet 2 days ago||
Yes, a function call. Not new syntax. But as a function, it would be trivial to add to a library.

My point was that you can often get the effect you want with no new syntax. (Cue 10,000 replies that state "but you can't get this effect without new syntax!" Perhaps not. Many of those tend to be rather contrived, though. I'm more sympathetic to the argument that new syntax would make something less clumsy. If it's something you need to do a lot, that matters.)

philipallstar 1 day ago|||
Yes - I see what you mean. There are degrees of ease of use at between - at the extremes - what writing assembly provides, which technically can do it too, and what something like, say, Haskell provides. C++ is of course closer to Haskell than Assembly, but there's still quite a headache in using your solution that is down to absent C++ language features.
DonHopkins 2 days ago|||
You can always use macros! Just look at how beautiful and elegant and easy to learn and transparent to debug the Microsoft C++ MFC COM/OLE/IDispatch/ActiveX object system macrology is. /s

https://learn.microsoft.com/en-us/cpp/mfc/tn038-mfc-ole-iunk...

pjmlp 1 day ago|||
C++26 reflection alongside compile time code execution, and template metaprogramming, can already do a lot.

It is the best way? Probably not, but we seldom get to chose what mainstream languages win out on the field.

More comments...