Live data from Hacker News

Aro – Zig's new C compiler

github.com

111–120 of 130 posts

Re: Aro – Zig's new C compiler

#111
post #102
post #86

Earlier quoted context omitted.

Given Zig has one, it might actually be possible to delegate to that then? It would be awesome to have a post explaining how to do that :)

The older “cross compiling Go with Zig” post might give a good start if you want to figure it out

I had a look at the post. It only shows how to tell the Go compiler how to use Zig as the C Compiler. In our case, what we need is to tell Zig to link the object files created by D.

I've had a look and saw that Zig is still implementing the `ld` command, but there's already a `ld.ldd` command which might work if you know what magical options to use. I've tried to link my D object file but it can't find a whole lot of generated symbols, and a quick search online does not tell me where do I get those symbols from. That's always what happens when I try to do stuff with D that's not well documented.

I tried this (used the dmd -v option to get the linker command):

    zig ld.lld -L/Users/me/dlang/dmd-2.109.1/osx/bin/../lib  app.o
Output:

```

ld.lld: error: undefined symbol: _d_assert_msg >>> referenced by myd/source/app.d >>> app.o:(_D4core8internal5newaa__T6makeAATAyaTiZQoFNaNeHQoiZSQByQBwQBq7AAShell) >>> referenced by myd/source/app.d >>> app.o:(_D3std6format5write__T14formattedWriteTSQBm5stdio4File17LockingTextWriterTaTS3app__T9StringMapTiZQnZQDaFNfKQCqMxAaQBmZk) >>> referenced by myd/source/app.d >>> app.o:(_D3std6format5write__T14formattedWriteTSQBm5stdio4File17LockingTextWriterTaTS3app__T9StringMapTiZQnZQDaFNfKQCqMxAaQBmZk) >>> referenced 27 more times

ld.lld: error: undefined symbol: _aaLen >>> referenced by myd/source/app.d >>> app.o:(_D4core8internal5newaa__T6makeAATAyaTiZQoFNaNeHQoiZSQByQBwQBq7AAShell) >>> referenced by myd/source/app.d >>> app.o:(_D3std6format8internal5write__T15formatValueImplTSQBw5stdio4File17LockingTextWriterTHiHAyaiTaZQClFNfKQCaQuMKxSQEeQEd4spec__T10FormatSpecTaZQpZv) >>> referenced by myd/source/app.d >>> app.o:(_D3std6format8internal5write__T15formatValueImplTSQBw5stdio4File17LockingTextWriterTHAyaiTaZQCjFNfKQByQsMKxSQEcQEb4spec__T10FormatSpecTaZQpZv)

ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)

```

Do you know how to get past that?

Re: Aro – Zig's new C compiler

#112
post #73

One of the features missing in bun:ffi is inferring types for symbols from header files. This would let you import C libraries in JavaScript/TypeScript directly, without having to configure bindings. We embed TinyCC for FFI, but TinyCC doesn't expose a way to read the types for exported symbols. Currently, it looks like this: import { dlopen, FFIType, suffix } from "bun:ffi"; // `suffix` is either "dylib", "so", or "…

Perhaps a middle-of-the-road approach would be to use inline C like LuaJIT's FFI does? For instance: new_clib("/system/lib64/liblog.so", "log") ffi.cdef[[int __android_log_print(int priority, const char *tag, const char *msg);]] ffi.log.__android_log_print(5, "TEST_TAG", "Hello from FFI") I can't say I'm familiar with Bun, but I've used a similar syntax to the example you provided of the current Bun syntax when worki…

LuaJIT spends about 2000 lines[1] on its C parser which even includes a limited expression evaluator, though not a preprocessor. My experience suggests explicit memory management could add half again that (LuaJIT’s piggybacks on its GC), and writing one is something like a month of work even if you know exactly what you’re doing (I didn’t), but in any case it’s not a monumental task.

[1] https://repo.or.cz/luajit-2.0.git/blob/HEAD:/src/lj_cparse.c

Re: Aro – Zig's new C compiler

#113
post #98

Earlier quoted context omitted.

Sure, I will let you say it :) Let me say that I think the same about this comment of yours upthread: >>D would deserve attention too, in a separate post, or here if it was explained how it relates to Aro. In case you cannot or don't want to google for some reason, here are the Wikipedia articles about D, Walter and Andrei, and important related topics (all on Wikipedia, which implies notability) that I suggested you…

Sorry, but what does this have to do with Aro?

Sigh.

See here for one way to get it, i.e. someone else's comment on the topic:

https://news.ycombinator.com/item?id=41026310

If that doesn't help, start reading from the start of this subthread that starts with Walter Bright's comment about D, and pay attention throughout, otherwise don't waste your time commenting.

If even that doesn't help, nothing will; sorry, I don't have the time to explain things more than that, for a trivial matter like this.

Re: Aro – Zig's new C compiler

#114
post #72

Earlier quoted context omitted.

Let me just say, your comments have not been the most constructive I’ve read.

He's right, what he's saying is just so obvious it's annoying it has to be said in reply to low effort posts like yours

thanks. you are one of the few people among the commenters who got what I was saying in this thread, I mean. I am sure tons of other sensible people here understood it but did not comment, because it was not worth their time to comment on something so obvious, as you said above, in reply to nequo above.

Re: Aro – Zig's new C compiler

#115
post #97

Earlier quoted context omitted.

You are essentially necromancing the ISO C99 discussion that happened already. Here is an answer that, after 25 years, is still wrong https://learn.microsoft.com/en-us/cpp/c-runtime-library/comp...

That doesn't tell me much about the usage scenario of complex numbers that would justify adding native support in programming languages. As a sibling comment said, builtin vector and matrix types (up to 4 dimensions) would probably be more useful.

I'll paste the same comment here as I did in the sibling; Why should complex numbers need justification? If you need to do serious computation, you need them. If you say Zig is not for number crunching which Java explicitly decided then fine otherwise searching for a reason for complex number tells me that you don't do any numerical programming which is fine but asking for justification makes no sense. Why is any other thing in the language justified?

Re: Aro – Zig's new C compiler

#116
post #91
post #84

I hope Zig adds complex numbers before it is too late. It's a pity that they did not steal array syntax and slices from Fortran/Numpy.

Why would complex numbers in particular deserve to be a native type? What about quaternions, or vectors and matrices of sizes 2-4 at least? Is there any real advantage over just using a struct? Would MultiArrayList help with performance for complex numbers and vectors?

Why should complex numbers need justification to be native type? If you need to do serious computation, you need them. If you say Zig is not for number crunching which, say, Java explicitly decided then fine otherwise searching for a reason for complex number tells me that you don't do any numerical programming which is fine but asking for justification makes no sense. Why is any other thing in the language justified? float64 is just two float32. Why stop at float64 why not float128 float256?

Re: Aro – Zig's new C compiler

#117
post #103

Earlier quoted context omitted.

Jeez! The post title is "Aro, Zig's new C compiler ", not just about Aro or Zig. In fact, just by virtue of being about Aro, it is also about C compilers - as the title clearly says , whether you (pedantically) like it or not. And D is a language that is used as a better C too, apart from other things. In fact, lang C -> lang D, says something significant to this discussion, right? >Could you draw a comparison for th…

And just by virtue of being about C compilers, it is also about C, thereby making all talk about programming languages on-topic? I see your point about other C compilers being related, but following this line of thought, most any topic could be generalised to whatever you want. Generally speaking, the more you stray from the most concrete topic at hand (in this case Aro and only Aro ), the more it becomes appropriate…

your logic in the first sentence of your first paragraph is quite faulty.

how did you jump from C to all programming languages, in the context of that statement? I did not say anything of the kind.

I can't waste my time explaining things multiple times to different people who don't get it, when others have got it.

maybe check my answers to the other people in this subthread, if you are that interested, for what is such a trivially obvious matter.

good luck.

Re: Aro – Zig's new C compiler

#118
post #111
post #102

Earlier quoted context omitted.

The older “cross compiling Go with Zig” post might give a good start if you want to figure it out

I had a look at the post. It only shows how to tell the Go compiler how to use Zig as the C Compiler. In our case, what we need is to tell Zig to link the object files created by D. I've had a look and saw that Zig is still implementing the `ld` command, but there's already a `ld.ldd` command which might work if you know what magical options to use. I've tried to link my D object file but it can't find a whole lot of…

Looks like the D runtime library isn't being linked in.

Re: Aro – Zig's new C compiler

#119
post #103

Earlier quoted context omitted.

And just by virtue of being about C compilers, it is also about C, thereby making all talk about programming languages on-topic? I see your point about other C compilers being related, but following this line of thought, most any topic could be generalised to whatever you want. Generally speaking, the more you stray from the most concrete topic at hand (in this case Aro and only Aro ), the more it becomes appropriate…

your logic in the first sentence of your first paragraph is quite faulty. how did you jump from C to all programming languages, in the context of that statement? I did not say anything of the kind. I can't waste my time explaining things multiple times to different people who don't get it, when others have got it. maybe check my answers to the other people in this subthread, if you are that interested, for what is su…

> how did you jump from C to all programming languages, in the context of that statement? I did not say anything of the kind.

Simply by taking further steps in the same direction. The submission is about Aro, and therefore comments about Aro are on-topic. By your own stated logic, Aro is a C compiler, and therefore comments about other C compilers are also on-topic. One could then go on to say that C compilers in turn pertain to C, and C in turn is a programming language, therefore rendering all comments about programming on-topic under a submission about Aro.

Granted, the example is a bit of a hyperbole, and I doubt anyone would really jump that far. But I find your assertion that a submission about a program (in this instance Aro) renders comments about all other programs of the same kind (in this instance C compilers for other languages) on-topic to be much in the same vein.

> I can't waste my time explaining things multiple times to different people who don't get it, when others have got it.

> maybe check my answers to the other people in this subthread, if you are that interested, for what is such a trivially obvious matter.

I have, of course, read your other comments, but haven’t found anything that would help me understand or accept your argument (assuming that is what I'm supposed to ‘get’). I suppose it's not so ‘trivially obvious’ to me. Don't feel obliged to elaborate any further if you feel that's a waste of your time, though. Good luck!

Re: Aro – Zig's new C compiler

#120
post #119

Earlier quoted context omitted.

your logic in the first sentence of your first paragraph is quite faulty. how did you jump from C to all programming languages, in the context of that statement? I did not say anything of the kind. I can't waste my time explaining things multiple times to different people who don't get it, when others have got it. maybe check my answers to the other people in this subthread, if you are that interested, for what is su…

> how did you jump from C to all programming languages, in the context of that statement? I did not say anything of the kind. Simply by taking further steps in the same direction. The submission is about Aro, and therefore comments about Aro are on-topic. By your own stated logic, Aro is a C compiler, and therefore comments about other C compilers are also on-topic. One could then go on to say that C compilers in tur…

Seems like multiple instances of either unintentionally poor logic, intentionally fake logic, or just weasel words, on your part, in your above comment that I am replying to.

Here is one, i will not go into others:

>>how did you jump from C to all programming languages, in the context of that statement? I did not say anything of the kind.

>Simply by taking further steps in the same direction.

but i did not ask you to take further steps in the same direction, so that you could twist my words.

i limited myself to C and closely related topics, like D, C++, Walter, and Andrei - related languages and people involved with them.

don't try to twist my words, as you appear to have done above.

yes, once i find people talking fake or not understanding, it is a waste of my time, so i will not engage further with you.

Post reply on HN