Programming and Scripting :: C programming question



I've found the use of QT and fltk UI builders very easy.
With them I can easily create professional-looking gui apps, that execute very fast, compared to Lua for example.

:) Yes, I am lazy, and since I already know Java, I think learning C will be easier than learning Lua.

Anyway, both those builders output C++ files.

Can I just mix C and C++ code in the same file? If the C code is in it's own function and C++ in it's own?

Or, would it be a better way to create the "main" function in C in it's own file, calling that gui C++ file as needed?

Or a third option, should I learn C++ instead of C?


In C I can already do a Hello World - program!

Quote

I've found the use of QT and fltk UI builders very easy.
With them I can easily create professional-looking gui apps, that execute very fast, compared to Lua for example.

I believe the best for DSL would be nice to have murgalua compiled with fltk as a SHARED lib, so that this lib would be accessible to other light fltk c/c++ programs.

Quote

Yes, I am lazy, and since I already know Java, I think learning C will be easier than learning Lua.

Not necessarily! C/C++ has a similar overall syntax than Java. Yet, memory allocation, pointers, and c++ references might can be very tricky when coming from Java (which has garbage collection and has an implicit use of references)

Quote

Can I just mix C and C++ code in the same file?

In your case, as long as you can compile using g++, you probably can quite hapilly use a mix of c and c++ in your own code. Most of the trouble of mixing c and c++ is when using a pure c lib from c++ (then you should make sure you include everything with extern "C") or when exposing your c++ lib to c.

A very good resource if you have to deal with c++ is the the C++ FAQ Lite. Look at item 32; this is specifically about mixing C and C++

Thanks. For having fltk as a shared lib, it doesn't add many kb's even when static..
c++ is a superset of c... so technically if you learn c++, you'll also cover c (albeit different invocations)... but what may be missed is the approach you would take.  I'd advise just sticking with one, as it will avoid confusion.  Since you already have a Java background - which is OO, it may be easier to try c++.  However, I have not covered much of all the languages mentioned (Java, c++, c), so this is just my opinion.

As for the performance, I think lua is an interpreted language, so usually it will be slower.

florian wrote ....
Quote
I believe the best for DSL would be nice to have murgalua compiled with fltk as a SHARED lib, so that this lib would be accessible to other light fltk c/c++ programs.


I completely agree with this statement. Other have sugguested such on the murgaLua fourms. But it will not be so according to John Murga. That was my rant of late about LuaAIO (All in One), which apparently is a similiar goal of murgaLua. But we can't always get exactly what we want, and I for one am very glad to see an updated and current Lua / Fltk binding.  

I promote Lua/Fltk for nice looking guis and to easily share the knowledge with the community. If C or C++ were used then the community would not have such easy access to the code. Which btw I am awful at keeping source and object together. GUIs don't need speed.

Use C/C++ for window managers, icon managers and other large applications. For gui front ends C/C++ are IMHO overkill.

Next Page...
original here.