5 ms·
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
by kazinator 10y ago
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/FunctionProcessor/FunctionProcessor.cpp 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?!
- hermitdev 10y agoYikes, 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).
- andrewchambers 10y agoThis 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?
- milesrout 10y agoIt's not unproductive. The project was linked, and code quality is relevant.
- kazinator 10y agoYou 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.
- hermitdev 10y agoNo, 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.
- andrewchambers 10y agoI'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 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.
- nickpsecurity 10y agoYour 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.
- andrewchambers 10y agoMy 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.
- nickpsecurity 10y ago"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.
- skrebbel 10y agoThis 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.
- deleted 10y ago[deleted]