Quote:
Originally Posted by Slice
I'm not sure why you're bashing every language except C++. They all serve different purposes.
|
I'm not, personally. This is a post about being positive about a particular programming language (which I must note means that PAWN isn't even relevant lol) however, I don't have to be positive about every language.
Quote:
What's wrong with HTML? What do you think websites should be written with? Some C++ JIT compiler in the web browser that uses 20 frameworks to write "hello world"?
|
Actually, the entire state of web design is a bit laughable. We got languages coming out of our asses because the tools to write web pages have been terribly outdated for years. Half the useful stuff is deprecated, with no alternatives. Of course, we finally have had HTML5 recently come out which is a step up, but to me, HTML is no more impressive than BB code. It provides little functionality in web pages and can only be used to make static content. Like PAWN, it suffers from needing to be easy to use for it's purpose. It suffers in optimisation (heavily), design, reliability and complete-ness. I've been web designing for ages. I use my own template system in PHP nowadays, of course.
Quote:
Not sure what you mean with low-level PHP code - PHP is anything but low-level!
It's also a much better fit for serving web pages than C++. Think about continuous integration, ease of maintenance, cross-compatibility, and - yes - the learning curve. Anyone can learn to start modifying bits of PHP scripts to fit their needs very quickly, the same can't be said for C++.
|
Exactly. Ease of maintenance, ease of accessibility.. these are all things that benefit the person who probably wants to make money off the suckers who visit the page he took 10 minutes to write. The page that is vulnerable to MySQL injections (many times I've got past logins by a simple MySQL injection - naughty me - but why should I enter my password where it won't be encrypted?), XSS, doesn't work on multiple browsers (cause HTML isn't even cross-compatible, in fact) and 70% of what the user waits for to load is useless text data about elements, images not optimised for web use, countless lines of inflated CSS (I don't minify my scripts because I'm certain the regex will screw somthing up lol - instead I write it minified) and JavaScript, which has to be the most nasty thing that has been invented for use in websites.
Mostly, I'm just ranting. There are ways to do it right, but it's hard to find someone who knows them, because the so called ease of the language makes them believe they know more than they do and proceed with using bad methods to do everything.
[quote]The same goes for every other language out there. If you don't want a compiler, make your programs on circuit boards.
Quote:
Yes, and it all works silky smooth!
Then, in production, you have tons of memory leaks, way too high CPU usage, and other fun stuff. Why is that? Because you only learned C++ to script SA-MP servers, you didn't learn every aspect of C++. You just wanted to write some code!
What now? No clue! Where could the errors be? No clue! You didn't write the functions you used.
(I don't mean "you" being "Deji")
|
You couldn't have
, because C++ makes it easy to write code that is flawless, actually. If you plan your storage right (OOP is brilliant for SA-MP) you will never have a memory leak. Plus, the debuggers available makes it easy to fix any problem.. they basically tell you what to do. But I guess I find something easy now, that many others including myself in the past have found insanely difficult. But it's mind-blowing how little I have to do to make a feature as big as any filterscript posted in the forums that the author is
really proud of, by instead of letting SA-MP give me a easy platform to code with, making my own better platform to code with.
The same can be said for PAWN, though... as you said for C++ and I said for PHP. People see that it's easy and don't bother to learn every aspect. And really, the amount of random things I've seen from PAWN makes me believe that it's really got a lot going on which most people aren't aware of. They don't know how it works, they don't know how SA-MP works, they don't even know how GTA works, which is upsetting. But hey, at least they know how to write a class system.
Quote:
C++ is great for SA-MP servers if you're very familiar with it, yes, but Pawn is a much better choice for most people.
|
But then again... it's only a choice if you've considered the alternatives. It may not be a better choice, it might just be an easier choice in the short-term. Depending on what you want to get done... But I find it very hard to argue with using C++ for large projects.
Just for fun, I brought some Playin' Awesome code as a demonstration of how easy C++ is, especially under the SAMPGDK environment which makes it have everything AMX does:
Code:
// SAMP is a namespace which I used to define SAMP-specific stuff, such as the player base structure
// Here, if nBestMatch isn't -1, we set the 'type' to an eVehicleType, else we can set it to the invalid vehicle type ID
SAMP::eVehicleType type = nBestMatch != -1 ? (SAMP::eVehicleType)(nBestMatch + 400) : SAMP::MAX_VEHICLE_TYPE;
// 'type' should now contain the vehicle model found to match the search string
if(type >= SAMP::VT_FIRST_TYPE && type < SAMP::MAX_VEHICLE_TYPE)
{
int i = nBestMatch;
// Get the player coordinates
float x, y, z;
pPlayer->GetPos(x, y, z);
// Create the vehicle there and at the players current angle
auto pVehicle = new CVehicle(type, x, y, z, pPlayer->GetHeading());
// IMPORTANT: Always confirm vehicles exist after creating them by checking if they're not "wrecked" (dead)
if(pVehicle->IsAlive())
{
// Plop that player in the driverseat
pVehicle->AddDriver(pPlayer);
// E.G. "Spawned NRG-500"
std::string msg = "Spawned " + std::string(g_szVehicleNames[nBestMatch]);
pPlayer->SendMessage(msg.c_str(), GetColour(COLOUR_SUCCESS));
// Add to the debug vehicles list so we can save memory by deleting them when we're not debugging
g_DebugVehicles.push_back(pVehicle);
}
else
{
// Send the player a client message and delete the vehicle
pPlayer->SendMessage("Vehicle limit reached", GetColour(COLOUR_ERROR));
delete pVehicle;
}
}
I can have more code inline, more automatic things going on (for example, when I delete pVehicle, some other action can be happening in the destructor to ensure that all deleted vehicles go through a certain process) and besides from the STL, everything's childishly simple. Again, there's a case of there being an easier option (C-style strings) and it not necessarily being the best way to do things. Still, I wrote a system which spawns cars depending on text searches and it only took ~63 lines. Once I move the amazing search score analyser code to it's separate function, it will be only ~46 lines of code.
It's stuff that could probably be done in PAWN (using really hacky methods) but wouldn't be most of the time, because in order to do something that efficient even in PAWN, you'd have to know the C++ that it's based off.