News for hackers. Stuff that matters.
Re:Dale – A Lisp-flavoured C by inputcoffee on Monday April 10, 2017 @06:49PM (#14083254)
A lot of the responses to hermitdev point out that a language can just be for fun, and need not "solve" anything.

This is true, but hermitdev's point still stands: why was this particular idea pleasurable? Why c and lisp? Is it because they want a fast compiling lisp? Did they like the syntax of c but find it easier to implement in lisp's tree-like structure?

What's the character motivation in this scene?

Re:Dale – A Lisp-flavoured C by kazinator on Monday April 10, 2017 @08:08PM (#14083695)
Further clouding the picture is that Dale is actually implemented in C++. The inner syntax under the S-exps is grotty C++ data structures and some brutally ugly code to deal with them that doesn't seem to even try to leverage the ability of C++ to simulate a dynamic language (like with suitable.

Like look at this fragment from https://github.com/tomhrr/dale/blob/master/src/dale/Function...

  bool
  isUnoverloadedMacro(Units *units, const char *name,
                      std::vector<Node*> *lst,
                      Function **macro_to_call)
  {
      std::map<std::string, std::vector<Function *> *>::iterator
          iter;
      Function *fn = NULL;
      for (std::vector<NSNode *>::reverse_iterator
              rb = units->top()->ctx->used_ns_nodes.rbegin(),
              re = units->top()->ctx->used_ns_nodes.rend();
              rb != re;
              ++rb) {
          iter = (*rb)->ns->functions.find(name);
          if (iter != (*rb)->ns->functions.end()) {
              fn = (*iter->second)[0];
              break;
          }
      }
This is not even up to good C++ coding practice, what with the raw exception-unsafe pointers and whatnot.

Name represented as char * ? I stopped using C strings in C++ code around 1998, other than in low level code interfacing with things that require them. Kids that were born then are now in college. If you're doing Lisp manipulation, you want anything that is a "name" of some kind to be an interned symbol, which quickly compares to another symbol variable as a pointer.

Why would you do all this to yourself, if (or so it seems) you know enough about Lisp to want a C-like language in S-exp syntax?!

Re:Dale – A Lisp-flavoured C by skrebbel on Tuesday April 11, 2017 @02:56AM (#14085464)
This is pretty standard "C-with-classes" style of coding. You see it a lot in embedded systems too. Ok in this case it's more like "C with the STL", but it's close enough. Those would exactly be the two things I'd want to add if I were a C programmer longing for a little more power.

All your critique would also apply if this were written in idiomatic C. C pointers are exception unsafe by definition because there are no exceptions. STL containers don't throw exceptions other than out-of-range exceptions, which isn't much better or worse than the access violation you'd get for the same bug in plain C.

One good reason why the code might be like this is the author doesn't know all 2568287 C++ features that are required to write modern idiomatic C++ - but the author does know C and std::map.

Re:Dale – A Lisp-flavoured C by andrewchambers on Monday April 10, 2017 @10:28PM (#14084391)
I've just been browsing the txr code and I must say, it's pretty poorly written.

Just take this random example http://www.kylheku.com/cgit/txr/tree/rand.c#n138 . The abuse of the preprocessor for checking pointer size is definitely poor practice.

Because of this I won't even bother thinking critically about the language itself. (Though it does make my eyes bleed to read.)

In summary, your comment is low effort, and I hope more people call you out for it.

Re:Dale – A Lisp-flavoured C by kazinator on Monday April 10, 2017 @11:16PM (#14084561)
> The abuse of the preprocessor for checking pointer size is definitely poor practice.

[Non-moving-target reference with commit hash: http://www.kylheku.com/cgit/txr/tree/rand.c?id=6ca6be767f8ac... ]

The problem with your statement is that it isn't true.

Selecting code alternatives using #ifdef is one of the benign uses of the C preprocessing feature, exemplifying "use it like this" in contrast with "bad" uses. In many a coding guide you can it recommended to use the preprocessor to do a little #ifdef here and there, while avoiding crazy macros. (Of course, code can turn into a hairball of nested #ifdefs, which everyone rightfully hates, but this sort of use is not characterized with the word abuse. It is just use.)

We could split the function into two copies for those alternatives, put them into separate files and then have something slick in the Makefile to pick the correct file (not the GNU Make ifeq syntax, of course; that would be ironic).

However, those two functions would then contain lots of repeated code also. If something has to change, two identical parts in similar functions have to be updated.

Okay so then we could refactor the function so that all the common things are in a generic part, and then the switched pieces are in a helper inline function (included from one of two different files, etc).

It's not clear that it would improve things in that particular case.

I really have no idea what, if anything, would be worth doing, and that could be due to my mental limitations. If someone sends me a plan about how to refactor that code in a good way (just an outline with bullet points in plain language, no code) I will seriously consider it, and possibly do the work.

Re:Dale – A Lisp-flavoured C by nickpsecurity on Monday April 10, 2017 @11:05PM (#14084525)
Your comment is amusing but otherwise doesn't contradict the claims of parent. Probably better off on a thread discussing parent's tech. This thread is about the Dale language and its implementation. Surely you of all people would appreciate that both should be done with some quality, esp in implementation language. You didn't pick shoddy C++. You went with a language that you thought was better among a number of them. I haven't heard gripes about your code so far so maybe the style was OK, too.

So, your parody is interesting but maybe counterproductive. It doesn't change the fact that the OP is already using language that isn't great for this in a way that doesn't inspire confidence. That's worth noting always as shitty implementations can lead to bugs for early adopters. Best to call out problems in parent's work in threads on that, a mailing list or repo if there is one, etc.

Re:Dale – A Lisp-flavoured C by andrewchambers on Tuesday April 11, 2017 @04:26AM (#14085825)
My code is certainly flawed, the question is if it behaves more or less as advertised.

I would be more open to such criticism from users of the software. In my opinion that type of comment is worse than backseat driving, at least in that case the passenger is a stakeholder.

Re:Dale – A Lisp-flavoured C by nickpsecurity on Tuesday April 11, 2017 @08:22AM (#14086990)
"In my opinion that type of comment is worse than backseat driving"

By that logic, I'd have to lease a mainframe for millions of dollars before critiquing aspects of their offering. Likewise, I'd have to pay Oracle $70,000 per processor. If flawed FOSS, I'd have to go through the pain of setting up and using it instead of submitting the flaw. Your analogy would apply better if you said "person in back seat shouting about an obstacle they're about to hit to driver that fell asleep."

Realistically, though, better to critique than use flawed products unless it gets the job done enough to be worth using anyway. No need to become a stakeholder.

Re:Dale – A Lisp-flavoured C by kazinator on Monday April 10, 2017 @11:42PM (#14084669)
The thing is, I really think that the sort of thing which Dale is is a very, very good idea. Any time I see a link to "C-like language done up in S-exps with macros", I'm very keenly interested, and have all these expectations. I should perhaps do a better job of hiding my disappointment.
Re:Dale – A Lisp-flavoured C by hermitdev on Monday April 10, 2017 @09:07PM (#14084047)
Yikes, yeah, this is bad. I only went through the readme, I didn't look at the source, and just...no. NULL? no. nullptr, please. And, as you've said, const char* as strings? again, no. I know GLS isn't terribly old, but something like string_view is in order. Arguments as undecorated pointers...no. Are they in or out? optional? C++ has semantics to indicate these things (even without GLS).
Re:Dale – A Lisp-flavoured C by andrewchambers on Monday April 10, 2017 @10:13PM (#14084331)
This thread of conversation is unproductive. Could you link me to both of your respective github accounts so I can nitpick without any stake or contribution in your projects?
Re:Dale – A Lisp-flavoured C by kazinator on Monday April 10, 2017 @11:49PM (#14084698)
You may criticize anything I've ever written that you can find. As a software developer, that's my daily assumption.

The increasing adoption of code review tools like Gerrit is one of the best things that has been happening in recent years.

No piece of code I've written in the past few years on the job has gone into the stream without the approval of several people.

Frequently, it had to be revised. More than once.

Re:Dale – A Lisp-flavoured C by hermitdev on Tuesday April 11, 2017 @08:52PM (#14093905)
No, because I'm bound by contract, cannot disclose my source, and I'm under NDA. That said, my comments are not unreasonabe or overly critical for C++11 or newer code. Quite honestly, if I desired to, there's more I could probably find issue with in even that small of a code sample.
Re:Dale – A Lisp-flavoured C by milesrout on Monday April 10, 2017 @11:11PM (#14084544)
It's not unproductive. The project was linked, and code quality is relevant.