
How I stopped worrying and switched to C++ for my Bob Scheme VM - wglb
http://eli.thegreenplace.net/2011/11/30/how-i-stopped-worrying-and-switched-to-c-for-my-bob-scheme-vm/
======
marshray
Nice to read an article about someone successfully using C++ in an ordinary
way, even with a little OO to it. We know it happens all the time given the
volume of C++ in development.

But so many articles are like "C++ isn't OO", "C++ has awful syntax", "C/C++
is insecure", "ZOMG templates", etc.

~~~
barrkel
The problem with C++ isn't that it has any one of these problems; the problem
is that different people have different opinions on what the problems are.

~~~
malkia
I'm currenty on a project, where C++ is used as "C", and I'm quite fine with
this. In couple of the thread loops, there is setjmp handler waiting for
longjmp... It's also waiting for the unaware new programmer on the team to use
RAII, and not suspect it's failing. (We use longjmp/setjmp not only for error
situations, but to handle other exceptional situations and recover from them).
One of the platform we are targeting simply does not support C++ exceptions.

~~~
Meai
How do you guys deal with the long compilation times? For me, I wouldn't mind
C++...if it only compiled faster. Even just two or three C++ files take ~5
seconds to compile on my machine. Is this not an unacceptable amount of time
for you, or do you have tools to make this go below the 3 second threshold? In
my mind, this is a serious problem that is keeping me from using C++ more. I
try to do as much as possible in C for now.

~~~
roel_v
\- For simple 'syntax checking' compiles, compile only the module ('.cpp
file') you're working in. This requires a proper IDE or at least some editor
support - for VS it's ctrl-f7.

\- For 'whole-project' compiles, limit the amount of them to the absolute
minimum. Use unit tests to test fundamental functionality rather than running
the whole program.

\- Use a compiler that supports precompiled headers, understand how it works
and use it as it's designed.

\- Pay attention to your #include graph. Only include headers where they're
used (i.e., in the .cpp file and not in the header where it's possible), use
Cheshire cat where possible, and put as much into the precompiled header as
possible.

Doing all of these things make C++ compilation bearable, but still it's a nice
change when I write code in C# or 'scripting' languages and compilation times
disappears. It's one of the more annoying aspects of C++, but despite it and a
bunch of other nitpicks, it's still my favorite language.

------
jdpage
For one of my current projects, I found myself in a similar position. I
actually ended up picking Go instead of C++, since it's a language I've been
wanting to learn for a while, and the feature set intrigues me. I have yet to
see how this decision pans out though.

~~~
eliben
Well, I already had the VM implemented in Python, so I really wanted to do
that in C or C++. Go was not an option because (1) one of the goals was to
understand how other VMs are implemented, and most VMs today are C/C++, and
(2) I wanted a language without garbage collection (which Go has, AFAIK)

~~~
lucian1900
Perhaps Vala would also be a viable language for this sort of thing.

I've been pondering writing a GC in Vala to learn more about them, and see how
suitable Vala is to low-level work.

------
fredsanford
Bob language and VM already exists... :)

<http://drdobbs.com/open-source/184409401>

------
viandante
Is your code posted somewhere?

~~~
eliben
The 3rd and 4th words in the linked post point to Bob's Google Code page
(<http://code.google.com/p/bobscheme/>) where its code is stored.

The code is wholly in the public domain, by the way -
<http://code.google.com/p/bobscheme/source/browse/COPYING>

