Read the NerveBreak sourcecode. I use 8 space tabs and 80cols limit and it works (no scrolling). Except in 2-3 cases... :-).
I break long functions to smaller (which will be probably inlined by the GCC optimizer).
It keeps the code clean and readable.
Nice scripting language
quote:
Tab based blocking might seem nice, but if you have code with loads of fors and ifs, you might have to horisontally scroll 3 pages, which is not nice..
You use the same amount of tabs in python programs and C++ programs, but you don''t have those ugly braces in the python code. I can get up to 25 tabs without scrolling in Scite, and it only takes up about 500 pixels of horizontal space. Also, if you factor your code properly, you shouldn''t have that many fors and ifs inside of each other.
The generally accepted Python style guide is to use spaces, not tabs.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Quote: Original post by RaduprvSo in other languages, you just don't indent if the lines get too long? That sounds like a bad solution. I'd break the complex function into smaller functions to add comprehensibility. I've been using Python for year and a half now and I can keep the line length in less than 80 most of the time, using the standard 4 space indentation. When coding C++, I use 2 space indentation and my lines usually end up being a lot longer due to added type notations and other complexity of the language.
Tab based blocking might seem nice, but if you have code with loads of fors and ifs, you might have to horisontally scroll 3 pages, which is not nice..
Quote: Original post by RaduprvDepends on how familiar you mean. Learning the syntax, which GnuVince was talking about, takes maybe 10 minutes really. If Python had a C-like syntax I doubt I could've gained more time than that. Nearly all of the time was spent learning the standard library and the new language features.
Learning how towrite a Hello Word program is ! than knowing the syntax/grammar. It takes at least a few weeks to get familiar with a totally new language.
Well, in C you don't HAVE to indent your code, so you can put 3 ifs one after another (same line). It saves space, and it is not harder to understand.
As for learning the syntax in 10 minutes, I simply disagree with that. It takes longer than that to just read the entire language description (I don't mean the libraries/built in functions).
Small has very few grammar/syntax differences than C, and it still took me a few hours to read all it's documentation. Plus that you also have to remember the new syntax, and be fluent in it. Not to mention that almost every language has some subtleties
it takes time to learn.
Of course, Python is a very good language for many people, but most of the C (not C++) programmers I know don't like it. This is a subjective thing, so, of course, I decided to use a language I actually like.
As for learning the syntax in 10 minutes, I simply disagree with that. It takes longer than that to just read the entire language description (I don't mean the libraries/built in functions).
Small has very few grammar/syntax differences than C, and it still took me a few hours to read all it's documentation. Plus that you also have to remember the new syntax, and be fluent in it. Not to mention that almost every language has some subtleties
it takes time to learn.
Of course, Python is a very good language for many people, but most of the C (not C++) programmers I know don't like it. This is a subjective thing, so, of course, I decided to use a language I actually like.
Quote: Original post by Raduprv
Yes, sorry for the typo :)
Well, the problem is, a lot of people, including me, don''t like the fact that you have to obey some strict allignment rules, or else your code gets messed up in various unfunny ways.
Second, it is slow, I seen a Phyton script exporting an MD2 out of Blender, and it took like 6 seconds to do that, on a XP 1.7 GHZ
I need all the speed I can get, because the scripting language is embedded in an MMORPG server (which is not threaded).
I also heard that it''s kind of complicated to embed it in your host, and that phyton is meant more as a programming language which you expand with external modules than as a glue language (which is what most of the games need)
I felt a bit iffy about the alignment rules, but after coding with it for 15 minutes I fell in love with it. How can you not!?
You CAN embed python into your program, it's just not very pretty. Generally people have gone down the extension path -- where you write your game in python and glue your fast parts on with modules.
Quote: Original post by blueEbola...
I felt a bit iffy about the alignment rules, but after coding with it for 15 minutes I fell in love with it. How can you not!?
July 02, 2004 05:18 AM
Quote: Original post by Raduprv
quote:
This looks very good. Can you do any type of OOP with it?
No, it''s a procedural language. If you want OOP, then use LUA. But I don''t think it''s a good idea to have an OOP scripting language for a game, because OOP is harder to learn than procedural programming, so you''ll have less users to make mods for you.
quote:
I hope you get along well with SMALL, but there''s no single scripting language for all tasks. Even if it works well for you in your current project, there might be a better choice for your next project.
I know that. But for what I need, Small is the perfect language. I think I will use it for my future projects as well, since it doesn''t lack anything I need ;)
Have you considered TCL as an embedded scripting language. It's not OOP, but it's very simple. There's a tutorial in the the book Programming Linux Games (online somewhere-google for it) and Game Scripting Mastery. I've used it for some simple stuff and found it is a bit faster than python, but not nearly as easy to program in.
cheers,
Bob
cheers,
Bob
[size="3"]Halfway down the trail to Hell...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement