Live data from Hacker News

Ada: a C Developer's Perspective

methodsandtools.com

151–157 of 157 posts

Re: Ada: a C Developer's Perspective

#151
post #90
post #29

Earlier quoted context omitted.

> The subtyping feature I love the most. I only have very little experience with Ada, but being able to define a type whose values are integers in the range, say, 1 .. 7, to represent days of a week was an eye opener.

Though if you're dealing in days of the week, you probably want an enumeration to avoid the whole "does 1 mean Sunday" thing.

Which is why Ada has a Day type, an enumeration.

Re: Ada: a C Developer's Perspective

#152

Earlier quoted context omitted.

I don't really understand the "Rust is obsessed with memory safety" meme. When pitching Rust to others of course memory safety and thread safety get hyped a lot; because it's talking about something that most languages just can't do -- safety without compromise. But actually ... memory safety is a small part of the reasons why I like Rust, and there are plenty of other cool bits in the language. It stands out a bit b…

Safety without compromise doesn't exist. Rust does what it does well, but at significant cost in developer time. I'd rather use a garbage collector, it's much much simpler and fine for 99.9% of use cases.

"safety without runtime compromise", fine?

Re: Ada: a C Developer's Perspective

#153

Earlier quoted context omitted.

That's kind of his point, you can't write a GC language interpreter in a GC language forever, eventually you need a non-GC language to actually implement the GC in. So in this way writing a Javascript executor in a GC language wouldn't really make sense, you're just adding needless layers of abstraction (at a serious performance cost). So I think a browser is an excellent example of an application which can't really…

> you can't write a GC language interpreter in a GC language forever, eventually you need a non-GC language to actually implement the GC in Here's PyPy's GC, implemented in Python: https://github.com/tycho/pypy/tree/master/rpython/memory/gc (I haven't looked at it in detail.) Anyway, even if you absolutely had to use a non-GC language to implement a GC, that would not preclude writing 99% of the browser in a GC langu…

How do they compile/interpret PyPy's GC, is the compiler/interpreter written in a GC language? I said you can't do it forever, eventually you need to drop to a non-GC language (I feel very certain of this, so if I'm wrong I'd really like to know).

Also, why would implement GCs multiple times at different levels of abstraction in the stack, other than for something specific like PyPy which is specific like designing an interpreter to help test language features quickly?

Re: Ada: a C Developer's Perspective

#154

Earlier quoted context omitted.

> (not much call for it on the web) Server-side stuff is a big focus of the upcoming year, so maybe then? :) (I've been doing more of it lately and found it surprisingly pleasant)

The issue there isn't the language, Ada is lovely but that the surrounding infrastructure isn't there, it lacks widely used 'modern' libraries for a lot of stuff you take for granted in .Net/Java (even PHP) Land. I'd love to be able to use it at some point and writing a web framework on top of it has been one of those fun if I ever have lots of spare time projects that sits in my queue.

Yeah there's a ton of web frameworks so far, but with the new tokio stuff landing soon, I expect a lot of change!

Re: Ada: a C Developer's Perspective

#155

Earlier quoted context omitted.

> you can't write a GC language interpreter in a GC language forever, eventually you need a non-GC language to actually implement the GC in Here's PyPy's GC, implemented in Python: https://github.com/tycho/pypy/tree/master/rpython/memory/gc (I haven't looked at it in detail.) Anyway, even if you absolutely had to use a non-GC language to implement a GC, that would not preclude writing 99% of the browser in a GC langu…

How do they compile/interpret PyPy's GC, is the compiler/interpreter written in a GC language? I said you can't do it forever, eventually you need to drop to a non-GC language (I feel very certain of this, so if I'm wrong I'd really like to know). Also, why would implement GCs multiple times at different levels of abstraction in the stack, other than for something specific like PyPy which is specific like designing a…

Of course you need to drop to some sort of non GC language, or you would need a hardware GC. However look at Iota [0], that can compile LLVM to Common Lisp. So you can run GC and non GC languages within, kind of, Common Lisp. Or look at all the projects that compile a language to javascript, and there is no reason why the reverse could not be done.

[0] https://github.com/froggey/Iota

Re: Ada: a C Developer's Perspective

#156

Earlier quoted context omitted.

> you can't write a GC language interpreter in a GC language forever, eventually you need a non-GC language to actually implement the GC in Here's PyPy's GC, implemented in Python: https://github.com/tycho/pypy/tree/master/rpython/memory/gc (I haven't looked at it in detail.) Anyway, even if you absolutely had to use a non-GC language to implement a GC, that would not preclude writing 99% of the browser in a GC langu…

How do they compile/interpret PyPy's GC, is the compiler/interpreter written in a GC language? I said you can't do it forever, eventually you need to drop to a non-GC language (I feel very certain of this, so if I'm wrong I'd really like to know). Also, why would implement GCs multiple times at different levels of abstraction in the stack, other than for something specific like PyPy which is specific like designing a…

PyPy is originally bootstrapped on the C Python interpreter, but it can then interpret and compile itself without relying on CPythob anymore. If you insist, then once PyPy is bootstrapped, the "drop to a non-GC language" is its process of having compiled the garbage collector's Python code to machine code.

But you're still wrong on this drop being necessary, I think. You can do it just fine in a language with GC that also allows you to allocate a block of memory that is not considered by the GC.

Re: Ada: a C Developer's Perspective

#157

Earlier quoted context omitted.

How do they compile/interpret PyPy's GC, is the compiler/interpreter written in a GC language? I said you can't do it forever, eventually you need to drop to a non-GC language (I feel very certain of this, so if I'm wrong I'd really like to know). Also, why would implement GCs multiple times at different levels of abstraction in the stack, other than for something specific like PyPy which is specific like designing a…

PyPy is originally bootstrapped on the C Python interpreter, but it can then interpret and compile itself without relying on CPythob anymore. If you insist, then once PyPy is bootstrapped, the "drop to a non-GC language" is its process of having compiled the garbage collector's Python code to machine code. But you're still wrong on this drop being necessary, I think. You can do it just fine in a language with GC that…

> But you're still wrong on this drop being necessary, I think. You can do it just fine in a language with GC that also allows you to allocate a block of memory that is not considered by the GC.

I think it's a bit disingenuous to say a "GC language compiled a GC language" when the compiler used non-GC portions of the language to do it. You're right, I should have said "A language which can work without a GC" instead of "a non-GC language;" but I think the spirit of my comment was clear.

That said I think what you said above is right, and non-GC code is really only necessary in the hot parts of an application (and applications that can't use dynamic allocation for whatever reason, but that's another discussion). Rust is even working on adding GC support [1] (albeit very slowly, as they should). That said non-GC languages (or at least the ability to write code that doesn't use a GC) is still necessary in many industries for many reasons; that isn't going to change for a long time, if ever.

[1]: https://manishearth.github.io/blog/2016/08/18/gc-support-in-...

Post reply on HN