News for hackers. Stuff that matters.
Re:Using C++ as a scripting language, part 8 by WanderPanda on Saturday July 29, 2023 @09:07AM (#36919935)
I recently plugged my extremely, abusively templated C++ library into Cling (the C++ interpreter mentioned) and everything worked like a charm. I can even use it in Jupyter notebooks. The speed feels more on the order of Python, though. But if the heavy lifting is done by precompiled libraries, I can see Cling having a pretty nice workflow for experimenting with and interfacing C++ code
Re:Using C++ as a scripting language, part 8 by binary132 on Saturday July 29, 2023 @09:11AM (#36919963)
If I’m not mistaken, Cling is an LLVM-based JIT compiler, so it really should be performing close to the same level as an ahead-of-time Clang-compiled binary executable. Perhaps what you are noticing is JIT latency (from compiling on the fly.)
Re:Using C++ as a scripting language, part 8 by WanderPanda on Saturday July 29, 2023 @11:23AM (#36921146)
Maybe it is because of Debug vs. Release mode (and the optimization level coming with it) but I see a speed difference on the order of 10-100x vs. Release mode GCC
Re:Using C++ as a scripting language, part 8 by gpderetta on Saturday July 29, 2023 @02:04PM (#36922849)
For heavily template code, a 10x-100x speed difference between -O0 and -O3 is not surprising in my experience.

The cost of compiling at -O3 is going to affect interactive use of course though.

Re:Using C++ as a scripting language, part 8 by AtlasBarfed on Saturday July 29, 2023 @11:21AM (#36921125)
"The speed feels more on the order of Python, though."

What part of "interpreted" did you not understand?

Re:Using C++ as a scripting language, part 8 by WanderPanda on Saturday July 29, 2023 @11:25AM (#36921161)
„Cling is an interactive C++ interpreter, built on the top of LLVM and Clang libraries.“

I don‘t understand your comment, do you care to enlighten me?

Re:Using C++ as a scripting language, part 8 by AtlasBarfed on Saturday July 29, 2023 @11:29AM (#36921203)
Interpreters are slower than compiled code.

Python is an interpreted language.

Yes, dynamic recompiling, JIT-ing, etc etc.

But you used a interpreter (for C++) with some expectation it would be faster than a language that is itself interpreted? I mean, I guess you could assume that the stronger typing of C++ would provide an advantage over Python...

But if you hear "interpreted", you should assume 10x slowdown at minimum, unless there has been human-centuries invested in performance improvement like the JVM.

Re:Using C++ as a scripting language, part 8 by pacha-- on Saturday July 29, 2023 @12:21PM (#36921748)
There’s nothing in the original message that suggests that the commenter was expecting a faster execution in an interpreted environment.
Re:Using C++ as a scripting language, part 8 by teleforce on Sunday July 30, 2023 @02:18AM (#36928398)
With D language you can have your cake and eat it too.

This is because D has one of the fastest compilers. You can use rdmd as the REPL and also invoking the compiler for scripting [1].

[1]Why I use the D programming language for scripting:

https://opensource.com/article/21/1/d-scripting