Just wondering why it says you need to know C…
The application page for GSoc ideas says:
Is that just because so much of the code is still in C?
Just wondering why it says you need to know C…
The application page for GSoc ideas says:
Is that just because so much of the code is still in C?
yep, for a long time only the game engine was c++
You could always start off with C. C++ doesn’t make what you learned with C obsolete (even if it changes some things and adds other stuff).
Most of Blender is written in C, and the general policy is that if some isolated modules (eg. booleans) must be written in C++, that there is a well defined C API that the rest of blender can talk to it through.
and there is pretty good reasons to stick with C, the main being the awfull portability of C++ code.
Not if you want into the industry. Knowing good OOP is almost required today, and it also makes it easier to branch into other languages easier.
Quite true. If you know how to program, the language are quite interchangeable. If one only knows how to solve specific tasks in a specific language he doesn’t have programming skills.
So learn at least one object-oriented, one procedural, one semantic, one logical and one functional language (but IMHO don’t plan to spend too much time in the last two). At least one, because otherwise you will think of language specific peculiarities as characteristic for the basic concept.
If you did this, you know some concepts. Languages are interchangable then and learned in days or hours.
Quite different with the used tools, libraries and frameworks. Knowing specifics of one (or more) will raise your market value enormously, but takes lot of time and experience.
And if you not only know how to program, but how to develop software, you will get the highly-paid job offers with long-term prospects. (If you just know a specific technology and how to apply it, you are very fast outdated.)
OOP is not only C++. and you can even do OOP with plain C.
And while C++ is an industry standard, it is good for some tasks but bad for others. That it was widely adopted dont really comes from its qualities (which exist, but at an immense complexity cost), but from external and historic reasons,
blender core is programmed in such a way that C++ main caracteristic (static strongly typed langage) would be a pain to handle in it. For external libs (like the fluid one), this is not a problem as they dont deal with the core.
More dynamic languages like Java or Obj-C would be better suited, but those have problems of their own, and fitting an OOP approach in the current design would be in any case problematic. So better use what we have and stick to C. the above mentioned portability problems dont exist in C too, which is a great advantage for a software like blender which runs on many platforms.
Where an OOP approach could shine is in the GUI part, if the language used is dynamic (so not C++). Reinforcing the role of python (which is both OOP and dynamic) could be a solution, similar to the role of MEL in maya.
First of all: I didn’t say C++ or OOP was better than C. They are in some cases, and worse in others. There is no such thing as a perfect language. I like both, in their own ways. I agree that he should use C for Blender coding, because it makes it easier for him, my recommendation was more generally speaking. In pursuit of a career in software engineering. “Sticking” with something is genreally a bad idea. Openminded and flexible programmers are more sought after on the market. You are bound to follow your employers choice of language, toolset, libraries etc anyway, and in that case it is better if you have at least tried some different languages.
C++ is a very good option if you know some C, better in fact than Java. Also, some “C pureists” also like to look down on C++ beacause it is possible to write code that is very hard to maintain and read. That is true, but it is also very much possible to avoid doing that. You don’t have to use every aspect of C++ just because you can. Design should control implementation, not the other way around. It is possible to write hidous code with C too, just as bad as C++. Just because you can write goto-statements doesn’t mean you should (unless you know exactly why), and the same goes for polymorphic classes and such. C++ isn’t a bad language, you just need to handle it appropriately (like with any OOP-language).
Wow, sounds like the core Blender code needs to be entirely rewritten then???![]()
![]()
Blender does not need a full rewrite. While some things need to be rewritten, other things simply need to be extended or better maintained.
Don’t be confused by all this talk about C++ and OOP. Blender’s core is written in C and will almost certainly always be, even if python starts to play a bigger role in the future. What the ‘rest of the world’ uses really dosn’t factor into the discussion of Blender internals…
Cheers
Xarf
Okay got a few question:
1.When did you start learning programming languages(age/grade)?
2.What would I need to do to get started to learn at least C or C++?
3.How do you stay awake while programming or trying to read code?
Burre : i was speaking only in the context of blender. knowing OOP and C++ is nowadays pretty required indeed.
HecticHermit : if you have never programmed, i would advise you to start with something simpler than C/C++, because both need quite general knowkledge.
Python or Ruby are good starting langages, and the former can be useful in blender.
With Python, you can learn all the important concepts that you will use later in C/C++, but avoiding as first step the complexities.
Switching later to other languages, including C/C++ is easy once the fundamentals are known.
Then read books (or web) about algoritms and design. For OOP programming, ''Design patterns" is the must have.
For python, the beginners guide available on python.org is quite good. Then after the one found at http://diveintopython.org/ is perfect to progress.
I did start programming at 9 on the apple IIc in Pascal, and Coffee/Tea are my fuel 
I started coding when starting with university, that’s about 4 years ago (am still student)…first C and then 2 years later C++…
I’m probably not the best coder out there, but it’s enough to continue on the level YafRay was written (i hope at least)…
Though i don’t quite get why C++ code would be harder to port than C code (unless you mean platforms where a C-compiler is the latest and greates you can get), or what makes Java more dynamic than C++ (i thought it’s the other way round, C++ at least features a “crutch” called dynamic cast, but i’m no Java expert)
Burre : i was speaking only in the context of blender. knowing OOP and C++ is nowadays pretty required indeed.
Ok, I thought you meant in a wider sense since you replied my “into the industry”-post. I totally agree that C is enough for Blender (although some Python wouldn’t hurt if he ever wanted to make his API available to those who makes scripts). Also I agree with Zarf, there’s no reason to rewite the core of blender just to switch language. But some parts need a good revision.
Lynx3d: It mostly has to do with the fact that the C++ standard isn’t followed as good as the C-standard. Many compilers have their own little quirks. However this has improved some over the years.
[Edit:] I forgot to answer the questions.
The first program I wrote was a color-memory game in BASIC when i was 12. My first C-program when I was 15. So I have been coding for about 12 years.
You need a good book, and a good tutor/mentor to guide you helps a lot. You need a development environment. If you use windows I would recommend that you download Visual Studio 2005 Express, it comes with IDE, compiler and debugger and some other stuff. If you are on linux, then gcc would be your natural choice. You also need patience, especially for bugtracking when (not if) they appear.
You don’t have to code late at night. But if you do, coffee and most importantly: motivation, will keep you up.
I really perfer C over C++. Maybe it’s just me, but for some reason C++ is way harder to read than C is. And don’t even get me started with Java. C is nice, but like assembly it is really easy to create bugs in.
There are some really good quotes that express my views of C++:
Within C++, there is a much smaller and cleaner language struggling to get out. (Bjarne Stroustrup)
If C++ has taught me one thing, it’s this: Just because the system is consistent doesn’t mean it’s not the work of Satan. (Andrew Plotkin)
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg. (Bjarne Stroustrup)
Arguing that Java is better than C++ is like arguing that grasshoppers taste better than tree bark. (Thant Tessman)
Anyway, Python is my language of choice, followed by C. And to answer the guy above: I started programming at the age of 10-11 in GWBASIC (horrors!). Moved to VB3 and then to DJGPP ©, and more recently to Python (in the last year). I use music to keep me going while I code. Mostly FFH, Casting Crowns and ZOEgirl.
I often say that C++ is better for solving big picture issues, and C for the opposite. I finished a 18 month projects this spring and it had between 600k to 800k lines of code. I’m glad we used C++ becase that made design much less of a hassle. Partitioning it into managable UML-blocks and implement one by one. It was a real success for us. The only troubles that took a long time to solve were either technical or algorithmic. Design never became a problem. When you get comfortable with design patterns it is hard to look back.
Okay Ive read a few tutorilas online from this site http://www.cprogramming.com/begin.html
In your opinion is this a good site to try and study programming?
I started programming in VB6 around 2000, moved to using mostly Python in the last two years, and picked up (just about, but there are still some things I have yet to learn) C in the last few months. Python is currently my language of choice.
Two languages I wouldn’t encourage anybody to learn/try are: Euphoria, and Scheme/Lisp. Both have pretty ugly looking syntax - Euphoria looks like a mutilated BASIC variant, and Scheme is obssessed with ( )'s.
Aligorith
Looks like a good site, at least better than my first C-book (wich is crap by todays standards). However having a mentor or tutor is a big plus, because you will run into problems sooner or later no matter how good book/tutorial you are following. If no mentor is available, try to find a friendly C/C++ community where you can get your questions answered. Also when you start to feel confident with the syntax I recommend you to complement your C/C+±tutorials with some articles on how to write properly and perhaps some on application design or coding standards. The reason for this being that most tutorials or book merely learn the language itself, not how to write it properly. Also, some tutorials are written with poor syntax (most of the time because they use very simplified examples) and might give you the wrong impression on how to structure your program properly.
For example C++ (oppisite to C) lets you define variables wherever you want to inside a code block. This is perfecly OK with an C++ compiler but not a C-compiler. However, I would strongly recommend sticking to the C-style of declaring variables here (only defining them at the beginning of a a code block), because this will keep you out of trouble later by making your code more readable. This is in my opinion a flaw of the C++ language (not being strict enough). Some coders see these type of things as a good thing that will cut new programmers some slack, but being too convenient will in my oppinion only make you lazy and that will come back and haunt you later. Because when you start to stretch the rules of the syntax you often also start to write poorly and that will sooner or later create hard to find bugs for you later. Do not rely on the compiler to find bugs for you, because the worst type of bugs slips through the complilers safetynet. The compiler can only catch errors that are related to wrong syntax, it cannot catch errors related to badly (or plain wrong) written code. Always rely on the possibility to come back and review your code a second time. Code should never be considered “final”, and therefore any effort to make it more readable and well commented will be payed back many times later. This is a common mistake amongst beginners. This is also the reason why I don’t recommend beginners to start of with languages that, for example, don’t require the programmer to define datatypes or similar type of freedom built into it. You are not doing yourself a favour if you start of with a language that is too easy to type, because proper syntax is easy to learn, proper coding is not. You might run into trouble later when blending or converting datatypes that aren’t really compatible. A consevative compiler might catch those for you at compile time, and a liberal one might not, leaving those for you to find. And if you are a beginner you might not be able to.
Personally I would start with C and accept (and be patient about) the fact that it will nag on you for writing poor syntax. Learning this the hard way will help you later. Once you start to understand how the error messages the compiler/linker gives you relates to your code, then it will really start to be your friend instead of foe.