
Dale – A Lisp-flavoured C - macco
https://github.com/tomhrr/dale
======
hermitdev
I would love to see announcements of new languages include a rationale. Why
was this created? What problem was the author trying to solve that they
thought the solution was a new language? What short comings did existing
languages have that this new language overcomes?

This is not a critique; I'm just curious.

~~~
inputcoffee
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?

~~~
kazinator
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...](https://github.com/tomhrr/dale/blob/master/src/dale/FunctionProcessor/FunctionProcessor.cpp)

    
    
      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?!_

~~~
andrewchambers
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](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
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.

~~~
andrewchambers
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.

~~~
nickpsecurity
"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.

------
nonsince
Oh hey, I posted this on /r/lisp just earlier today. I discovered it because
of a Google rabbit hole triggered by a rediscovery of this article[0] on
Naughty Dog's GOAL (Game-Oriented Assembly Lisp). It looks really interesting,
although I can't imagine doing serious programming in it (as much as I'd love
to).

[0]: [http://www.codersnotes.com/notes/disassembling-
jak/](http://www.codersnotes.com/notes/disassembling-jak/)

------
eatonphil
Very neat! Looks like this is an even older language than the one I'm familiar
with: bone-lisp. Bone-lisp is interpreted but ops for "explicit regions
instead of garbage collection". There is also an awesome list of similar
projects on the bone-lisp README (on which I now see Dale included) which I'll
quote from:

> Somewhat related Free Software projects:

> * Pre-Scheme is a GC-free (LIFO) subset of Scheme

> * Carp is "a statically typed lisp, without a GC"

> * newLISP uses "One Reference Only" memory management

> * MLKit uses region inference (and a GC)

> * Linear Lisp produces no garbage

> * Dale is basically C in S-Exprs (but with macros)

> * ThinLisp is a subset of Common Lisp that can be used without GC

[1] [https://github.com/wolfgangj/bone-
lisp](https://github.com/wolfgangj/bone-lisp)

------
pcwalton
At a glance, the compiler looks solid, with full LLVM integration instead of
compiling to C. That'll pay dividends down the road. Really great job :)

------
piokuc
This looks really nice. A low level Lisp as a system programming language - a
C replacement - is an interesting idea. First thought after going through the
readme: does it try to provide stable ABI? This is an important feature for a
C replacement; for example, C++ has not managed to get it right, although the
idea was to provide a better, object oriented C... What worries me in
particular is that Dale has overloaded functions, that makes things harder as
far as stable API is concerned, but maybe I'm wrong. Nice stuff, anyway. I can
see a little PLT trend of new high level languages that want to be good in
doing low level stuff and don't use GC. I like that!

------
eschaton
A systems programming language need not eschew GC. Zetalisp and Common Lisp
are perfectly fine for Lisp Machine operating system implementation, without
falling back to a language other than assembly for isolated bits of the very
lowest-level code. Mezzano reaffirms this on x86-64 too.

------
jaccarmac
Previous discussion:
[https://news.ycombinator.com/item?id=9226260](https://news.ycombinator.com/item?id=9226260)

~~~
taeric
It saddens me that one of the main comment threads there is complaining about
parentheses. :(

Some of the shouts out to thinlisp and other systems that did similar to this
before are interesting. Very interesting.

------
lisper
Another Lisp implemented in C++, but with a GC:

[https://github.com/rongarret/Ciel/](https://github.com/rongarret/Ciel/)

------
monkpit
Programmed by Mr Worldwide himself?!

------
appleflaxen
isn't this a C-flavored lisp?

I mean, it's _not_ C. And it _is_ a lisp.

So doesn't it make sense to call it "lisp with a flavor of C" rather than the
other way around?

Cool project!

~~~
yellowapple
It might've been named in the same vein as Lisp-Flavoured Erlang, which is
indeed (last I checked) a Lisp and very much not Erlang (at least language-
wise; it still uses the Erlang VM and OTP).

On another note, the lack of garbage collection at the very least would make
Dale very abnormal in terms of being a Lisp v. some other language that
happens to embrace s-expressions for its syntax.

------
coldtea
Can we have a C-flavored C with the extra features of Dale?

~~~
nickpsecurity
I used one that almost did what you ask. I refused to work with C++ codebases.
Better to start with a language actually designed for metaprogramming, etc
that thrn synthesizes C. If it has IDE & ecosystem, you get its language-level
benefits then C's on tooling side. Win, win.

------
lngnmn
Any high-order functions, TCO? Is there an implementation of _Everything Is An
Expression_ and _Everything Is A First-class Value_ principles? Type-tagging,
which implements _Values Has A Type, Not Variables_ principle, which gives
_The Numerical Tower_ and other nice things for free? Proper lexical scoping
based on Environments which makes every lambda a closure? I am not asking
about homogeneity and the possibility of the _First-class Macros_ it provides.

No? So what then makes it Lisp-flavored? CONS CAR CDR and parentheses?

------
catnaroek
C's syntax is horrible, but we can live with it. Where are the attempts to fix
C's semantics, dammit? This project is as if a mechanic were given a broken
car, and the first thing he did were repainting it.

------
iLemming
How does this compare with Chicken Scheme?

------
muyuu
How do you pronounce it? Like Pitbull in "dale!"?

------
tromp
Wonder how hard it is to write a quine in Dale...

------
spraak
I want this for Go!

------
lispm
Why isn't it written in Lisp? It would be so much easier...

See for example C-MERA:

[https://github.com/kiselgra/c-mera](https://github.com/kiselgra/c-mera)

~~~
brandonbloom
C-MERA's default code generator is textual C. This project uses LLVM's API,
which is sadly difficult to utilize outside of C++.

~~~
lispm
[https://github.com/drmeister/clasp](https://github.com/drmeister/clasp)

From the CLASP page:

> Clasp is a new Common Lisp implementation that seamlessly interoperates with
> C++ libraries and programs using LLVM for compilation to native code. This
> allows Clasp to take advantage of a vast array of preexisting libraries and
> programs, such as out of the scientific computing ecosystem. Embedding them
> in a Common Lisp environment allows you to make use of rapid prototyping,
> incremental development, and other capabilities that make it a powerful
> language.

you wrote:

> This project uses LLVM's API, which is sadly difficult to utilize outside of
> C++.

I would guess that you could use LLVM's API via CLASP. The author initially
wrote ( [https://drmeister.wordpress.com/2014/09/18/announcing-
clasp/](https://drmeister.wordpress.com/2014/09/18/announcing-clasp/)) :

> Clasp exposes the LLVM C++ library within Common Lisp providing a rich,
> dynamic, programming environment for exploring the LLVM library and for
> writing new compilers that generate LLVM-IR.

Then you could write the parser/compiler in Lisp, which supports manipulating
s-expressions on a simpler level than C++ does.

~~~
brandonbloom
1) That's an interesting project. Worthy of discussion on its own.

2) "Why isn't it written in Lisp?" It's 42% C++ according to GitHub.

3) Based on a hunch and past experiences, I'm going to ignore any follow ups
on this thread.

EDIT: And now I look like a jerk because lispm replaced his terse comment with
a fuller comment. My apologies for even engaging in the first place. Should
have known better.

~~~
lispm
I'm just wondering if there isn't already some large infrastructure in the
Lisp world, which could have been reused. Something like CLASP was especially
written to seamlessly interoperate with LLVM. Sometimes working with an
existing system is difficult, but sometimes it can help both projects.

Anyway, Dale looks like a cool project.

