5 ms·
How I stopped worrying and switched to C++ for my Bob Scheme VM
- jdpage 15y agoFor 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 15y agoWell, 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 15y agoPerhaps 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.
- marshray 15y agoNice 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 15y agoThe 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 15y agoI'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 15y agoHow 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.
- octopus 15y agoIt really depends on what compiler you use, in my experience g++ coupled with make is as fast as gcc for compilation. clang++ is even faster. Visual Studio 2010 has a decent compilation speed if you use a Dos prompt.
- roel_v 15y ago- 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.
- fredsanford 15y agoBob language and VM already exists... :) http://drdobbs.com/open-source/184409401 http://drdobbs.com/open-source/184409401
- viandante 15y agoIs your code posted somewhere?
- Marwy 15y agohttp://code.google.com/p/bobscheme/source/browse/#hg%2Fbarevm%2Fsrc http://code.google.com/p/bobscheme/source/browse/#hg%2Fbarev...
- eliben 15y agoThe 3rd and 4th words in the linked post point to Bob's Google Code page (http://code.google.com/p/bobscheme/ 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 http://code.google.com/p/bobscheme/source/browse/COPYING