Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ is a great language in many ways, but some things in particular are cumberso

ID: 654949 • Letter: C

Question

C++ is a great language in many ways, but some things in particular are cumbersome to write without an IDE. As a VIM user, it would be very interesting if I had access to a higher level language which enabled me to write C++ with S-Expressions and possibly with Lisp-like macros, allowing for the generation of clean code while avoiding rewriting the same patters over and over again.

I've asked on freenode and tested several ideas, such as compiling Lisp->C with compilers such as ECL and Bigloo, but none of those generated particularly clean C code.

Are there any works on this issue?

Explanation / Answer

Compiling higher level languages to lower level ones is cake. There's countless examples of it being done. Without going off on much of a tangent, we can point to early C++ compilers that compiled down to C.

When you start throwing "clean" and "readable" into the mix, however, things get really tough. Clean, readable code expresses the meaning and intent of what you were writing. Computers are notoriously bad at interpreting & creating meaning. You're more likely to end up with variables named int_147 than input_buffer_length. Sure, if you really wanted to make this project work, you could engage in a massive AI project to handle converting your Lisp to some sort of decently readable C++ but, to be perfectly honest, Common Lisp compilers are pretty fucking good at what they do.

More important than the difficulty of generating C++ from a Lisp is the usefulness of this. What purpose would it serve for the generated C++ to be readable? If the Lisp is your source code, intermediate representations should be irrelevant. If you want to be able to hand the C++ over to programmers that don't understand your original Lisp, you've now got another problem. What happens when they want to modify your generated C++? What happens if they write things in C++ that don't cleanly translate to your Lisp?

Let's say we've solved that. It's a decade later and, after burning through hundreds of millions of dollars of DoD grant money, we've build this massive, complex (but flawless) language translation engine that can turn Lisp into idiomatic C++ and vice versa. What have we really gained that wouldn't be better accomplished by either teaching people a new programming language or just developing a new compiler that lets us link the two languages?

Oh, right. Your boss wants you to write C++ and you'd rather not. Update your resume & find a new job.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote