News for hackers. Stuff that matters.
Re:Based C++ by stephenlf on Friday September 19, 2025 @09:25PM (#45308964)
I love sheaf’s work
Re:Based C++ by phamtrongthang on Friday September 19, 2025 @11:38PM (#45310107)
Me too. He is so creative. I came across this repo and realized he also made a video about it.
Re:Based C++ by luserz on Tuesday September 23, 2025 @12:17AM (#45342798)
great video and source but needs a try-catch block
Re:Based C++ by chris_wot on Tuesday September 23, 2025 @12:20AM (#45342813)
So confused what this is...
Re:Based C++ by ajkjk on Tuesday September 23, 2025 @03:17AM (#45343796)
Re:Based C++ by ptspts on Tuesday September 23, 2025 @04:42AM (#45344420)
This video doesn't explain what the project does and how it does it. Also it's deliberately misleading the viewer, for example it purposefully incorrectly states that C++ is an interpreted language.

Also the music is way is too loud and sudden.

Re:Based C++ by ajkjk on Tuesday September 23, 2025 @08:09AM (#45345844)
Well the video is almost entirely a joke and almost every sentence in it is ironically false; that's the point.
Re:Based C++ by octocop on Tuesday September 23, 2025 @07:14AM (#45345427)
The video is a compliment to the Github repository, the presenter even shows code and brings up the repo in the video. I guess you didn't watch that part and unfortunately you didn't get the joke either.
Re:Based C++ by olivia-banks on Tuesday September 23, 2025 @12:50AM (#45342959)
As far as I can tell, it looks like a wrapper for cc1plus (internal GCC tool) and ld that do a custom #define of some input data, compile, extract some data from the binary, and do... something with it. Makes it look like C++ is an interpreted language.
Re:Based C++ by pjmlp on Tuesday September 23, 2025 @02:29AM (#45343478)
Implementations are orthogonal to languages, there have been C and C++ interpreters since the languages exist, as you can see by looking at BYTE and Dr Dobbs archives looking for compiler developer tools ads.
Re:Based C++ by 1718627440 on Tuesday September 23, 2025 @03:15AM (#45343788)
But some are more suited then others. For example, I believe the C standard to not describe what is supposed to happen when the definition of a function changes.
Re:Based C++ by pjmlp on Tuesday September 23, 2025 @03:34AM (#45343919)
It doesn't have to, that is an implementation detail or OS specific feature.

Two scenarios where the definition of a function in C changes, are dynamic libraries on OSes that allow reloading the same library multiple times, or self-rewriting code.

Here you stay within the realms of a compiled language implementation, where what happens, is only expecified by compiler specific features, or OS capabilities handling executables and dynamic libraries.

Re:Based C++ by 1718627440 on Tuesday September 23, 2025 @05:04AM (#45344550)
Yes, but it suddenly matters if you execute code in an interpreter, where the user can change any symbol/function definition at anytime. What do you do with a a struct definition, that changes? Do all the functions return something different now? Or does the return type of all the functions change to an anon struct and the name now refers to something different. Stuff like that is what the distinction is between a compiled and an interpreted language.
Re:Based C++ by pjmlp on Tuesday September 23, 2025 @05:45AM (#45344831)
The same way you deal with them as they come from a dynamic library, and the code gets reloaded on the fly, like on game engines that use compiled C and C++ instead of whatever scripting language.

Compiled code with dynamic replacement during execution,

https://liveplusplus.tech/

https://learn.microsoft.com/en-us/visualstudio/debugger/hot-...

https://dev.epicgames.com/documentation/en-us/unreal-engine/...

Plain interpreters,

https://iel.ucdavis.edu/publication/2006/CUJ_proof.pdf

https://root.cern/

Just some examples.

Re:Based C++ by 1718627440 on Tuesday September 23, 2025 @12:32PM (#45349351)
That's really cool, but I think you still run in situation where its impossible to keep the program running, and/or you need to make decisions which are not described by the language standard.

>

    Warning message

    If you see the following dialog box, Hot Reload is unable to apply the current edits without restarting. You can choose either to rebuild the app and apply changes (restart) or to continue editing. If you rebuild, all application state is lost. If you continue editing, it's possible that additional changes or corrections might cause Hot Reload to work again.

    [Screenshot of the apply changes dialog box]

    If you select the Always rebuild when changes can't be applied option in the dialog box, you won't see the dialog box again in the current Visual Studio session, and Visual Studio will automatically rebuild and reload instead of showing the dialog box.
Re:Based C++ by olivia-banks on Tuesday September 23, 2025 @11:10AM (#45348191)
C++ is considered to be a typically compiled language by the majority of people. But you’re right, I should have said that it makes GCC look like a C++ interpreter.
Re:Based C++ by olivia-banks on Tuesday September 23, 2025 @12:35AM (#45342882)
I wish all projects like these had some sort of documentation as to how they worked. All I can see is that the `-B` flag tells GCC to look in the ased directory for internal binaries (cc1plus and ld), but anything other than that would require more than the few minutes I have to look into.

It's also really interesting to see the audience this is reaching. The issues on the GitHub repository are quite telling.

Re:Based C++ by OvbiousError on Tuesday September 23, 2025 @05:28AM (#45344715)
Open the cc1plus or ld "internal binaries" to be even more confused ;)
Re:Based C++ by haskellshill on Tuesday September 23, 2025 @08:46AM (#45346275)
Is it really that confusing though? He's just using a python script that runs the program instead of linking it. Sure the details may be interesting but the high-level concept is obvious
Re:Based C++ by olivia-banks on Tuesday September 23, 2025 @11:08AM (#45348154)
Yeah, I was referring to the details. It looks like it calls internally into both tools, but not after doing some messing with the binary sections.
Re:Based C++ by rurban on Tuesday September 23, 2025 @12:48AM (#45342945)
A bit silly, but ok.
Re:Based C++ by s20n on Tuesday September 23, 2025 @03:48AM (#45344011)
Man, that went way over my head.

But if you just want to run C++ in a REPL, you can use Clang-Repl <https://clang.llvm.org/docs/ClangRepl.html> which uses the LLVM JIT to "interpret" C++.

Re:Based C++ by jwrallie on Tuesday September 23, 2025 @05:13AM (#45344622)
I had good experience with Xeus cling for a notebook interface.
Re:Based C++ by serbuvlad on Tuesday September 23, 2025 @04:07AM (#45344164)
Based? Based on what?
Re:Based C++ by naruhodo on Tuesday September 23, 2025 @04:28AM (#45344312)
Usually means "based on facts".[1]

Here, probably used ironically.

[1] https://www.urbandictionary.com/define.php?term=based

Re:Based C++ by pjc50 on Tuesday September 23, 2025 @04:46AM (#45344439)
I don't think I've ever seen it used outside of a heavily irony-poisoned context.
Re:Based C++ by gpderetta on Tuesday September 23, 2025 @05:12AM (#45344615)
So it fits perfectly.
Re:Based C++ by KuSpa on Tuesday September 23, 2025 @09:54AM (#45347074)
Based.
Re:Based C++ by indigoabstract on Tuesday September 23, 2025 @04:32AM (#45344345)
Got roped into watching the whole video. He obviously loves C++. And since I actually enjoyed it, I suppose that also tells something about me.

Also read up on sheafification really quick. Neither Firefox nor Chrome seem aware of it (red underline), so there.

Edit: If anyone is actually interested in interpreted C++, I think AngelScript is the most practical way for this.

Re:Based C++ by olivia-banks on Tuesday September 23, 2025 @11:12AM (#45348224)
Seconding AngelScript, but there’s also Squirrel, and a myriad of other C/Lua-like languages. AngelScript’s interop story is really cool, though.
Re:Based C++ by Iwan-Zotow on Tuesday September 23, 2025 @02:27PM (#45350948)
Cling from root
Re:Based C++ by pjc50 on Tuesday September 23, 2025 @04:50AM (#45344465)
Would anyone like to explain in text form how this works? I've got as far as the use of <{ meaning to run at compile time, so the whole thing is going to be one of those template metaprogramming stunts.
Re:Based C++ by seiferteric on Tuesday September 23, 2025 @08:11AM (#45345881)
The whole thing is a joke but presented in a serious manner. The idea is that if you know your program input at compile time you can turn everything into a constexpr which gets evaluated at compile time so your program is "ran" by the compiler instead of at run time. So he built a "runtime" that is actually ran by the compiler around this idea for fun.
Re:Based C++ by delta_p_delta_x on Tuesday September 23, 2025 @08:23AM (#45346016)
> So he built a "runtime" that is actually ran by the compiler around this idea for fun.

Funnily enough, sufficiently enough of C++ is constexpr-able that it was the driving force for compile-time reflection in C++[1], which is not unlike what the author has done.

Although the new syntax is much more readable than what the author chose to do with expression templates, it's still annoying, as is much of C++. But I still like it, so I am decidedly Stockholmed.

[1]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p29...

Re:Based C++ by gpderetta on Tuesday September 23, 2025 @05:18AM (#45344651)
it is "simply" a DSL implementing a full custom language that is run at compile time. As far as I can tell the DSL is implemented with the tried-and-true technique of expression templates[1] combined with constant evaluation and unrestricted template value parameters (although these days there are multiple options to implement compile time DSLs, up to compile time parsing of strings).

As to why, I can't pretend to know the author mind, but I suspect they did it because they could, the project itself is the objective.

[1] https://en.wikipedia.org/wiki/Expression_templates

Re:Based C++ by gpderetta on Tuesday September 23, 2025 @05:12AM (#45344613)
10/10 no notes.
Re:Based C++ by oytis on Tuesday September 23, 2025 @07:22AM (#45345475)
Can't wait for this to be consumed by LLMs.