HackerTrans
TopNewTrendsCommentsPastAskShowJobs

amno

no profile record

Submissions

Greenspun's 10th rule and the sad state of software quality

gist.github.com
2 points·by amno·в прошлом году·1 comments

comments

amno
·5 месяцев назад·discuss
I have read through your pdf and I think you make a best case for Lisp I have read in last few years.

We could just imagine who programming languages would look like if we abandoned the specialized notations like Haskell or C++, of which C++ really starts to show up that such notations are probably a dead-end. Or if B. Eich was allowed to use Scheme as the built-in scripting language for Netscape. Perhaps we would not need XML and/or Json even Yaml as machine interchange and description formats?

Anyway, I am not familiar with Futamura and yaml spec, your texts in the repo, and your project is the first time I see this. I did a webserach and have read through the Wikipedia page on Partial evaluation which talks about Futamura projections. But can you please ELI5-me about your project: is this a yaml parser generator or is this a DSL/PL language parser generator? Can I specify few rules in a language of my choice, say C, and it will generate a yaml parser and test suite in C language? Or does it mean I can specify a parser for a programming language, say C or a DSL, as yaml production rules in language of my choice, say Common Lisp, and it will generate a parser for C or that DSL in Common Lisp? Or do I understand this completely wrongly? :)

How does this project compares to something like tree-sitter? This AST you build, I have just glanced over it thus far, or use under the hood, could that be exposed somehow, or is it already, to the application? For example, could we build a server in Common Lisp, that reads this various language specs, builds an AST and gives us answers on questions like: is this position in a code for a function definition, or in a comment, and similar? In other words, could we use it for a tool that gives information about meta-data from the source code so we could use it to build tools like LSP servers, indentation servers, syntax highlight and such? Just a curious question, forgive me if I misunderstand what this does.

Edit: was looking a bit around and found a nice intro into Futamura projections: https://www.youtube.com/watch?v=RZe8ojn7goo.

This is awesome :). Thanks.
amno
·в прошлом году·discuss
(= * x x ^ x 2)
amno
·в прошлом году·discuss
Not by me, but thought it was well written article with some good points. Hope you enjoy it!
amno
·2 года назад·discuss
Hi Drew!
amno
·2 года назад·discuss
> setf is like referring to a mutable reference in C++ or Java.

Setf is rather a computation of a reference, than a reference.

A reference in Java and C++ is a pure pointer, with some syntactic sugar in java (you skeep */-> to define and dereference it), and few corns of sugar spread on top of it in C++ (can't be null).
amno
·2 года назад·discuss
And lambda calculus isn't even a programming language. The argument was like saying "C still tries to preserve something from Touring machine".
amno
·2 года назад·discuss
We need nsetf! :-)
amno
·2 года назад·discuss
I am with you, I think setf is making code repetitive and more verbose in many cases, however in this particular case, if you see

    (var *some-object* value)
somewhere far away from the class definition, say in another file, can you tell immediately what that code does? Can you understand it directly by looking at the code? Do you define something? Do you set something or do you just read something like a property list (something like rassoc)?

    (setf (var *some-object*) value)
With setf it is immediately clear from the code what is going on. I don't know if that is the best example, just thinking of all the arguments for and against setf :). Personally, I find it makes code more verbose in many situations.
amno
·2 года назад·discuss
Yeah, that is great idea, and I agree it sounds great on paper. However, some time ago, I have come to a conclusion that it soon becomes quite verbose and tedious.

I think it worked better in the past when people used acronyms and very short names for function and variable names. Today, with self-documenting code style, names are longer for both functions and names. Constantly typing full paths gets annoying quite soon. Code is also more verbose to read and less code fits into 80 columns.

My personal conclusion is that I actually prefer to abstract those away with a proper name like aset, put, and so on, just to make my own code less verbose.

If they really wanted to simplify the language, they should have perhaps removed 'setq' and 'setf' and just kept 'set' in the language but with the powers of setf. Not to mention that users have to learn how to write own setf accessors, unless it is very simple stuff (the extra bit of magic you mention).

As a "simplification" of the language I think they have failed, if that was the goal. That does not mean that 'setf' is not useful. On the contrary, it is a very useful tool to be able to compute and set a "place", just shouldn't be sold as a simplification.
amno
·2 года назад·discuss
> The author of “Let Over Lambda” dislikes Emacs and does not use it.

I have no idea what Hoyte like to type in, but why does it matter what text editor he uses? Einstein didn't had any computer, not even a calculator. Do we have to use paper and pencil for all the calculations just because Einstein did? Our physics teacher in gymnasium, forced us for 4 years to do all calculations on tests by hand, at four decimal places, with that exact excuse: Einstein didn't have a mini calc. Non of us have become a Nobel prize taker in physics :).

> Also, a lot of the interactivity is required by the standard to be built in to your Lisp’s REPL, so you can do quite a bit if your REPL isn’t primitive.

Mnjah; not so much really. Using at least SBCL from plain command line really sucks. If you mistype something you have to retype everything, no history, etc.

> SBCL doesn’t even have readline

If you are on some *nix OS, you can get a long way by just using SBCL with built-in sb-aclrepl + linedit. Aclrepl gives you "command-like" stuff, similar to ":" in Vi (or M-x in Emacs), and linedit adds cursor motion, history and some basic completion. I would still not type entire programs in repl, but for running and testing the code it is a basic survival kit. For me personally it is enough.

There is also cl-repl package which gives you native bindings and some extras if you want to go all-in readline from within the lisp itself.
amno
·3 года назад·discuss
It have corrupted my drive several times.
amno
·3 года назад·discuss
> Clarity in your technical communications matters.

Indeed; it does.

I wish more people watched that Steels talk, where he speaks about importance to use accessible language. One-syllabus words all the way would be perhaps a bit tedious read, but he makes a very good point about clarity in connection to simplicity.

Thanks for all the links Raiyner.
amno
·3 года назад·discuss
Thank you for the paper, and for the work!

Can I ask a newbish question: will this new GC be available on all OS:s and CPU architectures, or only on some? I don't see anything in the paper about being limiting to some certain platform, so my hopes are high :).
amno
·3 года назад·discuss
> Perhaps the negativity stems from the all the illegal, immoral, and damaging acts in this era.

Perhaps, but hate against Microsoft was not the point of the discussion. You are free to see them in whichever light you want, I just don't understand why you have to down-vote me or bring that into completely different discussion.

The question here was about the technical issues and their work on making software tick despite people abusing the API and producing buggy software. That has nothing to do with hate against Microsoft. To me that sounds like a whataboutism.

By the way, I personally don't even use Windows, I have been 100% Linux user since many years and have contributed to a GNU project, I am not some Microsoft fanboy as you might see me. But I see no value in defending a wrong, and I see the same behavior repeated in other communities. People abuse the API or don't read the documentation or just are plain idiots, and than accuse the developers for being malicious or stupid or whatever when things break. That behavior is bad for anyone, regardless if it is against Microsoft or some GNU project.

> In short people hated them for being shitty people who do shitty things and present leadership were important folks when these shitty things were done everyone just moved up a few rings.

I am sure people have many reasons they hate something or someone for, Microsoft included. There are people who passionately hate GNU, Linux, FSF, you name it. If you justify such behavior, it is your choice, but I am not interested in that discussion. I was talking about people abusing API and than blaming Microsoft for incompetence or deliberate evil, while the company obviously went to quite long efforts to make things work, even for buggy software. Microsoft may as well be evil or good for other reasons, but wasn't really the point of discussion.

> They aren't better people they just have better aligned incentives where illegality and immorality aren't profitable.

This is outright dangerous behavior on your part. You are transferring a behavior you have projected on a company over the entire group of people, all the thousands of people who work for Microsoft. To start with, they are all individuals, and as in every group there are good and bad characters among them. Also, history is against you, Microsoft was, and still is very profitable company. In the time we speak about, they were probably too profitable for its own best. For the second there are law and law enforcement officials to decide if they did illegal business or not.

Not to mention, that probably most of those who worked there back in 90's are probably retired or have changed the job by now. Also, to note, with thinking and statements like that one, you are denying people chance to develop as individuals and become better persons.
amno
·3 года назад·discuss
Yes, people used undocumented functions, which were left undocumented as they were a subject to change, and accused Microsoft of not understanding software development or thought that those undocumented APIs were somehow better than the recommended documented ones. When stuff crushed after Microsoft changed an API people would be accusing them for deliberately breaking their applications and what not. I remember the hostility in those years 95-2005 towards Microsoft. There is still some cult in some Internet communities where trashing anything developed by Microsoft is seen as some kind of expertise or something by usually self-proclaimed experts.
amno
·3 года назад·discuss
Yes, Raymond Chen describes such fixes in [several blog posts](https://devblogs.microsoft.com/oldnewthing/) and in his book The Old New Thing. Check the old posts, back at the beginning. There are posts about to which lengths they went to ensure buggy applications still worked after an update or a fix.
amno
·3 года назад·discuss
Perhaps you wish to look at Common Lisp? I think it gets you covered in all those things you mention. There is distinct read, compile and evaluation phase, all exposed to the application code.

If you get a good compiler like sbcl, you can go a long way with just the language itself since the language itself offers a blend of scripting language qualities while being a compile language. Emacs Lisp can go long way too.
amno
·3 года назад·discuss
> I am experimenting with runtime generation of shared libs.

Sure, you can produce an executable or a shared library at runtime; after all, that is what compilers and linkers do, those are also just programs, aren't they :). But do you really need to do that? As others said, you can also dlopen and rename your symbols, put them in an array and what not, but your problem seems quite simple, unless you need to transport that library somewhere or keep it for later use, I don't see reason why would you bother with generating a file just to load it after into your program again?

> We have a database of rules in the form 'A OR (B AND C)' stored just like that in human readable form.

That sounds like you could construct a "bottom-up" parser, i.e. an operator precedence parser, and just evaluate that directly, or emit the assembly code directly to a page memory and mark that as an executable page? Unless you are doing some optimizations, do you really need an explicit AST?

Anyway, if your AST is slow, it may depend of course on the size, but also on how you create your AST in the memory and how you use it. If you are doing some linked structure with pointers pointing all over the memory and accessing it randomly you can be trashing your cache which should be slow. But if you put it in some vector and can access it sequentially, it might help performance. I don't know, just thinking loud, no idea what you are really doing.

I suggest look at a good Lisp compiler like SBCL or CCL. They generate code at runtime which is than mark as executable and call that code. They can also save themselves into an executable (or a shared library in the case of sbcl). Writing a read-macro that transforms your human readable strings into compiled Lisp functions would be trivial exercise in Common Lisp. Perhaps you should try to solve your problem with that tool instead of C++? If you are going to generate code dynamically every now and than as you describe, than pick a tool that already has infrastructure to do that in-place so you don't have to do everything from the scratch; albeit you could do something similar based on llwm or libgccjit too.
amno
·3 года назад·discuss
Certainly not in Lisp; I have never heard it before; I thought Op made it up :); but have looked it up on Wikipedia and indeed is a term. Seems just to alter the behavior at the runtime.
amno
·3 года назад·discuss
Honestly, I had no idea that "monkey-patching" was a term, I thought it was something Op just made up :-).

I have just looked it up, and it indeed is a term [meaning something](https://en.wikipedia.org/wiki/Monkey_patch). Even meta-magic seem to be a term, but less defined seems like.

I don't think we need AST for monkey-patching, but it can be argued that each program can be converted to an AST. Anyway, less important.

The "monkey-patching" seem to basically mean anything that changes the runtime somehow. The example in Python on Wikipedia article just changes the value of a global variable. In Lisp we have many, many tools which can change code at runtime, I would even argue that Lisp is all about flexibility and "monkey-patching" since we already write AST and have the entire symbol table and the compiler available to us at runtime. Functions are just objects like any others and we can install any object in the function slot of an symbol, we can wrap it in our own function and install that one, everything is a list and dynamic in some way, so we can add slots to classes and structs if we want etc.

For meta-magic I found [this one article](https://betterprogramming.pub/the-magic-of-metaprogramming-7...) and [this one](https://codeburst.io/laziness-i-meta-programming-34ef4abdafc...) that seems to use the term in a sense as what we normally do with macros in Lisp or with templates in C++. The other one is a bit lengthy and I really didn't have patience nor time to read it in full length, I have just skimmed through it.

As I conclude, the terms mean what I meant, but with code generation, I mean not just classical generate some code to a file from another file; I mean transform the code in some way, during either the runtime or compile time.