Jump to content

Random Programming Questions


Recommended Posts

The problem with game developers (having been one myself) is that they use MS Visual Studio. Often not by choice, because you pretty much have to for XBox development, and supporting multiple dialects at once is problematic. Unfortunately, C++ features are added to MSVS sluggishly. It's better than it used to be, but MSVS 2015 still doesn't support about half of the C++14 features. Although, to their credit, they have dropped support for trigraphs as far back as 2013, and that's a C++17 feature. (This was sarcasm, by the way.)

 

Worse yet, because games take a while to develop, and Microsoft is very bad at backwards compatibility, game developers very frequently aren't using the latest version of Visual Studio. Last studio I've worked at only switched to MSVS 2012 last year, and they were basically forced into that version by XBOne development. Up to that point, studio was using 2010, which has actual compiler bugs that aren't being fixed by MS because the version is no longer supported. So they had to switch from one outdated version to another, encountering new unsupported compiler bugs along the way, some of which I had to fix personally.

 

So the problem really isn't with the language so much as with the tools available to game developers for that language. That's not to say that C++ is perfect. But right now, I work at a company that's all C++14 under clang. Between new language features, clang's helpful error messages, and tools like clang-format, it's a completely different work process. I hope, game developers working exclusively on PS4 titles are making the best of this as well.

  • 1 year later...

I have a question about a PHP:

 

In a combo box connected with MYSQL, I use a while to pick the data from a column, but I wonder how much data can pick the "while"? If I have a table with +100 data, the while will pick all the data and print on the combo box or pick less?

 

Sorry for my english...

Depending on exact implementation of the SQL DB, there can be a limit to how many rows you can fetch with a single SELECT statement. As far as I know, MySQL will let you iterate through as many as the DB will provide, memory limitations notwithstanding.

 

With big data sets, it is sometimes desirable to set a limit to how many rows you fetch.

 

SELECT * FROM table_name LIMIT 1000;
will return the first 1000 rows. You can combine it with WHERE and some index to break up data into pages. This is often done to reduce memory requirements and to otherwise improve performance.

 

However, 100+ rows are usually no problem to get in one query. You only really start having to think about it at 1000+ mark.

  • 2 months later...

Are you trying to parse something from xml or json and fire off a notification? Or is Parse some android package that has passed me by since it's been years since I've written for android.

  • 2 years later...
10 minutes ago, NileshKumar said:

Which is better: Codeblocks or Borland?

 

For C++

Borland%20CPP%205.02.png

Just because you want to code in an old language doesn't mean you need to use an old IDE.

Admittedly, I don't work with C++, but you won't go wrong with VS Code or maybe CLion (<3 JetBrains). I've used Codeblocks in uni (it's what a teacher suggested), was not a great experienced, very quickly switched to Visual Studio.

Actually I am gonna learn (and master) C,Java,Python and C++ all in the next 4 years in my college.

 

They only teach C and Java, for the others I am on my own, I recently started C++.

Edited by NileshKumar
spelling

Visual Studio would be my go-to for C++. I'd also drop Java entirely if you can, it's objectively awful.

  • Like 2
On 11/29/2020 at 8:50 PM, NileshKumar said:

I am only interested in Python and C++, which the colleges here don't teach. They are stuck on primitive languages like C and Java.

If you think you're going to learn C++ without learning C, you'll be better off learning JavaScript. You aren't going to get a C++ job if you don't know C.

 

f*ck Java with a rusty pipe, though. That's not worth anything anymore, unless you have a deep masochistic desire to work on Android Java code.

 

Oh, and to get you started, you don't even need a compiler.

https://wandbox.org/ - for actually running your code.

https://godbolt.org/ - for code analysis and disassembly.

 

But to get a job, companies will expect you to know how to use VisualStudio C++ from both the GUI and command line as well as GCC or CLang from command line. All three are free and available for your choice of operating system in one form or another. Companies/projects that don't rely on VisualStudio will also usually use something like make or cmake for managing large projects, and you'll be expected to know at least the basics of these as well. Also take a look at Bazel if you'll be working on anything Google-related, but you can get to that later.

 

The reason I recommend to get a bit of a feel for writing code with online compiler is because the way you structure input to the compiler has a bit to do with how you write code in C/C++, so it's easier to understand how to build a project and compile code once you understand a little bit about how to write it.

  • Like 1

While Java 8 is not too fun an experience, if you want to do Android stuff, you'll choose Kotlin. But Java knowledge is useful for Kotlin, too, so you know how some of the Kotlin black magic (syntactic sugar) works.

 

I wouldn't call it a primitive language, though.

7 hours ago, Edmachine said:

I wouldn't call it a primitive language, though.

Antiquated is a better term for Java. By the time Google bought Android, it was already an outdated piece of tech solving problems that didn't exist in modern world. The fact that Google stuck with it instead of burning it all down is the most evident proof that the company was already run by "effective managers", rather than engineers, at that point, long before Alphabet happened.

 

If you actually want to embrace all the things Java is claiming as its objectives, you ought to be compiling Rust code to LLVM. That solves the same problems much more efficiently, at compile time, and giving you full native performance on output. Moreover, none of the lifetime errors will show up in the runtime, because they will be resolved at compile time. As a result, garbage collection and memory leaks just aren't a thing.

 

But even that's overkill, which is why pretty much everything except Android has abandoned Java and is sticking to C-derivatives. A compiler handles all platform variations far, far better than JVM ever could with no penalty to performance, and while garbage collector is an excellent safeguard in most cases, in practice, it leads to overwhelming majority of Java developers not understanding the difference between strong and weak references, and end up writing code that leaks memory. You're better off with "unsafe" memory model of C/C++ and good development practices than a garbage collector you don't understand. And this is particularly true of modern C++, where simply slapping hands of your junior developers, metaphorically speaking, any time they use a raw pointer, is generally adequate for preventing leaks and dangling references.

 

Which reminds me, @NileshKumar. If you are going to be learning C++ on your own, make sure you find books/tutorials that focus specifically on modern C++. That is C++11/14/17/20. These should focus on proper use of STL, in particular, smart pointers. That will save you a lot of headache and make you a better candidate when you're looking for jobs. On the flip side, you do need to understand how raw pointers work, but that's what your schoolwork in C is going to get you. So if you learn C++ from perspective of a modern, memory-safe(ish) language and C from perspective of old-school low-level slightly-better-than-Assembly point of view, you'll eventually meet somewhere in the middle and have a full picture of all that is C++.

  • Like 1
  • 2 months later...

Alright I am trying to learn C++ by myself with practically no programming knowledge and it seems I cant compile a basic Hello World code without getting a host of errors. Can someone please tell this fool what is going wrong that he cant run even a simple program like this successfully?

 

Code (just an elementary Hello world code)

Spoiler
#include <iostream>
 
int main()
{
    std ::cout << "Hello World";
}

 

Errors

Spoiler
g++: error: Hello: No such file or directory
g++: error: World: No such file or directory
g++: error: programming\Hello: No such file or directory
g++: error: World: No such file or directory
g++: fatal error: no input files
compilation terminated.

 

I think the answer will most likely be simple and whoever reads this will laugh and I'll embarrass myself posting this but I just want to figure out what is wrong and get educated on this stuff, I'm stumped right at the beginning of my programming journey lol.

 

Edit: I'm using Visual Studio Code v 1.53.0 and the code runner extension for my compiler.

Edited by Wayne Kerr
23 minutes ago, Wayne Kerr said:

Alright I am trying to learn C++ by myself without practically no programming knowledge and it seems I cant compile a basic Hello World code without getting a host of errors. Can someone please tell this fool what is going wrong that he cant run even a simple program like this successfully?

 

Code (just an elementary Hello world code)

  Reveal hidden contents
#include <iostream>
 
int main()
{
    std ::cout << "Hello World";
}

 

Errors

  Reveal hidden contents
g++: error: Hello: No such file or directory
g++: error: World: No such file or directory
g++: error: programming\Hello: No such file or directory
g++: error: World: No such file or directory
g++: fatal error: no input files
compilation terminated.

 

I think the answer will most likely be simple and whoever reads this will laugh and I'll embarrass myself posting this but I just want to figure out what is wrong and get educated on this stuff, I'm stumped right at the beginning of my programming journey lol.

 

Edit: I'm using Visual Studio Code v 1.53.0

RIP

 

I copy pasted the exact same code in CodeBlocks and it is working, try reinstalling the complier

image.png

It seems I cant input any values in Visual Studio Code's terminal for C++. I ticked 'Run in terminal' in coderunner's settings but I get some '&& is not a valid statement separator' error. I'm new to this and dumb so I'd like some assistance on what has gone wrong here

 

the code

Spoiler
#include <iostream>
 
int main()
{
    int x,y,temp;
    std:: cout << "Values of x and y are-";
    std:: cin >> x >> y;
    temp=x;
    x=y;
    y=temp;
    std:: cout << "Exchanged values-" << x <<  y;
 
}

 

and the error

Spoiler

PS C:\Users\pc\C++> cd "c:\Users\pc\C++\" && g++ WAP2.cpp -o WAP2 && "c:\Users\pc\C++\"WAP2
The token '&&' is not a valid statement separator in this version.
At line:1 char:25
+ cd "c:\Users\pc\C++\" && <<<<  g++ WAP2.cpp -o WAP2 && "c:\Users\pc\C++\"WAP2
    + CategoryInfo          : ParserError: (&&:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : InvalidEndOfLine

 

The weird thing is this exact same error happens to my Hello word program on C++ too when 'Run in terminal' is ticked, but when its unticked the Hello World program runs properly. With this program I need to input the values in the compiler so I cant untick 'Run in terminal'. 

 

Can someone help on how to correct this?

  • 2 years later...

no posts since 2021? lol, good luck to me..

 

Is there a way I could rename a bulk load of files so that all of them are edited in the same way? I have about 1000 files in a folder and each has a unique name and are numbered beginning with " 001" and so on. For example, the first three files could be 001 fruit.jpg, 002 cloud.jpg, and 003 shoe.jpg. I want to remove those numbers and the following space so that they are in alphabetical order like this: cloud.jpg, fruit.jpg, and shoe.jpg

 

I was thinking a script could achieve this result, but I've no idea how to write that, and the resources I've found online don't apply to this kind of example. Any tips or help would be greatly appreciated!

  • 5 months later...
On 5/27/2023 at 8:35 PM, cactus. said:

I was thinking a script could achieve this result

I'm sure it's no longer relevant, but for future reference, yeah you can do this with a simple script using a few console commands. You'd be looking at a batch script (.bat files) if you're on Windows, or shell/bash scripts (.sh files) if you're on Linux or Mac. E.g., see accepted answer (green checkmark) here for Windows. You'll need to change the delimiter and then modify the ren rule to drop the prefix to make it work for the case you described, but pretty much any name-substitution batch rename will look something like that.

  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.