Getting back into programming

Chat about just about anything else
User avatar
0x2620
Level 3
Level 3
Posts: 117
Joined: Mon Jan 09, 2017 3:17 pm

Getting back into programming

Post by 0x2620 »

I was fooling around with inxi and I discovered that my new laptop has a maximum RAM capacity of 32 GB DDR4. This is enough to run Windows in VirtualBox, do cross-platform development, and play Windows games.

Unfortunately it's been about 2 years since I did any serious programming, and then it was in Java ( :oops: ). Can you recommend me a programing language to learn, the best modern books with which to learn it, and what options exist for IDE and editors? Please, anything but Java - I hate forced OOP.

Goal is to write cross-platform editors for old-school (SNES, PS1, GBA, PS2, PSP) video games. I heard C is a good language to learn, but I'm not sure what book I should read to learn modern C. I heard good things about Rust, but I'm not sure it's cross-platform. Python v3.x seems like a good choice. C++ seems too complex. C# is just Windows Java.
Last edited by 0x2620 on Sat Dec 14, 2019 9:34 pm, edited 2 times in total.
User avatar
ACE_
Level 2
Level 2
Posts: 59
Joined: Thu Sep 12, 2019 12:44 pm
Location: Earth (and slightly to the left)

Re: Getting back into programming

Post by ACE_ »

If you are familiar with JAVA then you will be familiar with the syntax used in both C and C++. However, C++ does have a much steeper learning curve. If your interest is in video game programming, then I would suggest that you lean more towards learning Python. Plus, if you do manage to become proficient, you will find more opportunities available to you, career wise (if you wish to pursue it that far), than you will for most of the other programming languages.

Here is a link to available Editors / IDEs for Python:

https://www.programiz.com/python-programming/ide

You will also see a link in the upper left corner of that page with an introduction to Python.
User avatar
0x2620
Level 3
Level 3
Posts: 117
Joined: Mon Jan 09, 2017 3:17 pm

Re: Getting back into programming

Post by 0x2620 »

Modding is more about reverse engineering and implementing obscure standards and algorithms. I attempted and apparently failed to implement disc image input/output using Java. Java does everything stupidly. Even getting GUI combo boxes and check boxes to behave correctly was impossible.

I don't really care about making games as much as I do about taking them apart.
User avatar
catweazel
Level 19
Level 19
Posts: 9884
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Getting back into programming

Post by catweazel »

0x2620 wrote:
Sat Dec 14, 2019 9:30 pm
I don't really care about making games as much as I do about taking them apart.
What you are asking for is an answer to your personal preferences, which we cannot give you. The suggestions by @ACE_ are not wrong, and while my responses as a long-time software developer would be quite different, they also would not be wrong. You need to make your own mind up. Asking this type of question on an internet forum will only get you opinions, much like asking two accountants for their opinions and getting three.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
User avatar
0x2620
Level 3
Level 3
Posts: 117
Joined: Mon Jan 09, 2017 3:17 pm

Re: Getting back into programming

Post by 0x2620 »

I meant that more as a clarification. Feel free to add opinions.
rene
Level 16
Level 16
Posts: 6693
Joined: Sun Mar 27, 2016 6:58 pm

Re: Getting back into programming

Post by rene »

C is not a bad language in the context of reverse engineering, something which certainly I associate with lower level bit-twiddling; I expect that the older the game the truer this is in that field as well, conversely, the newer the less true. But I also see you say things about "combo boxes", GUI programming, and for that plain C is not a great choice (even though GTK+ is C it is still about as object-oriented as a non-natively object-oriented framework can get).

C++ you could for the lower-level parts treat as a superset of C and for the higher-level GUI parts "natively interface to" Qt, an as far as I'm concerned nicer toolkit. Full-blown C++ is a fairly complex language but you can sort of limit its scope by yourself. Rust is not something I'd consider outside of the system-programming context or e.g. writing an emulator itself.

Python is a fine choice. It's less geared towards bit-twiddling, but certainly you can, and bindings for e.g. GTK+ and (newer) Qt are widely available, mature and generally less work to use from Python than natively from C resp. C++. It is as an interpreted language also a bit more natively cross-platform. Assuming you wouldn't be satisfied with the "native" Python GUI Toolkit Tcl/Tk, I'd also in that sense recommend Qt over GTK+; it's much more present on e.g. Windows.

There are many Python IDEs out there; PyCharm would be one I recommend; https://www.jetbrains.com/pycharm/. Start at https://www.qt.io/qt-for-python for Qt from Python, although when I last tried, Mint's distribution of Python did not yet have a useable version of said "official" Qt bindings OOTB. Books depend on your current level and the type you are. For a DIY-person I'd only recommend https://doughellmann.com/blog/the-pytho ... y-example/ and possibly something up to date for the GUI toolkit of your choosing, should any such exist.
User avatar
0x2620
Level 3
Level 3
Posts: 117
Joined: Mon Jan 09, 2017 3:17 pm

Re: Getting back into programming

Post by 0x2620 »

You're right; I need to do a lot of bit-twiddling and I need something which makes well behaved GUI applications. I was told that an understanding of C would improve my assembly language skills (most PS1 games were written with a very old version of GCC for which there exists an IDA pro plugin), but I took a class on Python five years ago and it was very easy.

A lot of the open source tools for the PS1 are written in C. Understanding C would help me write tools that interface with disc images. Is it possible to mix C and Python?

I tried to learn C a few years ago using K&R, but I was stopped dead by the inability to inspect fields and step through code at runtime. Python is easier to debug and therefore learn, unless you know of a good C IDE with a debugger. Learning from a book whose code no longer compiles probably wasn't the brightest idea either. Any recommendations on C books, IDEs, and debuggers?

Here are a few PS1 tools written in Python: https://github.com/abyssonym/randomtools
gm10
Level 20
Level 20
Posts: 10999
Joined: Thu Jun 21, 2018 5:11 pm

Re: Getting back into programming

Post by gm10 »

My personal choices would be C++ or C# and I've hooked games in both of them. It does not matter what language your game is written in.

But given you (rather silly) opinions on OOP, Java (which is not "forced" OOP), C#, and debugging, I guess C-style languages aren't realistically on the table. So by all means, do it in Python.
User avatar
0x2620
Level 3
Level 3
Posts: 117
Joined: Mon Jan 09, 2017 3:17 pm

Re: Getting back into programming

Post by 0x2620 »

gm10 wrote:
Sun Dec 15, 2019 3:24 pm
My personal choices would be C++ or C# and I've hooked games in both of them. It does not matter what language your game is written in.
Agreed, you can do anything with any language, but given that most PS1 games were written in C (Aside: Crash Bandicoot was written in Common Lisp) and I would be using a decompiler to generate C code, should I not learn C in order to understand the output of a decompiler?
gm10 wrote:
Sun Dec 15, 2019 3:24 pm
But given you (rather silly) opinions on OOP, Java (which is not "forced" OOP), C#, and debugging, I guess C-style languages aren't realistically on the table. So by all means, do it in Python.
1. How exactly is OOP useful? It just seems like needless complexity. Procedural programming feels more natural to me, I don't need to convolute my thinking to fit it like I do with OOP.

2. How is Java not forced OOP? The only way you can avoid instantiating objects is by using methods of static classes or putting everything in main(...). Given that Java has a limit on the length of methods, it's impossible to fit a sizable program in main(...) without using objects or static methods. Some of the languages built on the JVM aren't forced OOP, but "the JVM isn't forced OOP" != "Java is not forced OOP".

3. Having a good debugger (especially a good GUI debugger, so you don't need to manually type out a bunch of commands to see the values of all fields as you step through a program) seems like something that's language agnostic. Are there seriously no good C IDEs with GUI debuggers, even toy ones intended for learning? Or is this one of those masochistic things where you're not a real programmer if you use one, especially to learn a language?

4. Unrelated, but designing GUI applications in Java is a complete nightmare, especially doing it by hand. My best guess is that I was experiencing race conditions in a GUI program I wrote to edit a game, because switching between two items in a JList would scramble the GUI representations (combo boxes, check boxes, and the like) associated with the data for that entry in the JList. I could not find a single tutorial on debugging race conditions in a Java application with GUI objects, which clearly indicates that no sane person uses Java to create complex GUI applications. I see tons of complex C# GUI applications, so this criticism doesn't apply to C#.

No hard feelings, just asking questions.
Last edited by 0x2620 on Sun Dec 15, 2019 5:56 pm, edited 2 times in total.
rene
Level 16
Level 16
Posts: 6693
Joined: Sun Mar 27, 2016 6:58 pm

Re: Getting back into programming

Post by rene »

0x2620 wrote:
Sun Dec 15, 2019 11:30 am
A lot of the open source tools for the PS1 are written in C. Understanding C would help me write tools that interface with disc images. Is it possible to mix C and Python?
Sure, most easily through shared libraries. See the attached minimal example if interested. However; I personally in fact tend to at least enjoy C more than Python and if indeed most of your immediate surrounding use it I wouldn't really want to keep you from using it. The "C as portable assembler" meme I always considered a load of bull; while C may be one of the lower-level languages among high-level languages, a high-level language it is: like for other such languages program structure is primary, not processor-structure such as for all assembly languages. And you'd agree as soon as you'd also use it for GTK+ interface programming; quite far removed from assembly language programming...

Anyways, no, I have never found a C environment on Linux worth its salt. Nothing such as, betraying age, the Borland IDEs on DOS or Windows or even, shudder, Microsoft Visual Studio. With a slight exception for the Qt Creator IDE everything on Linux sucks the testicles off of a Siberian Yak. These days Visual Studio Code (the editor) is available on Linux and might be useful; I've personally been away from Windows too long now to consider using it, and especially since I do little application programming other than mostly interface-less command-line tools in the first place.

I above mentioned the JetBrains Python IDE which, while with its downsides, is the best I've found for Python. Haven't tried https://www.jetbrains.com/clion/ but expect it might be worth the investment for those who do extensive C and/or C++ application-development on Linux. Due to that same age thing I also can not recommend any current C or C++ books; I learned too long ago to know of current resources; an era when K&R was in fact a current resource.

But returning to Python.... it can certainly be used both for bit-twiddling and GUI programming; it is what I would in fact probably consider the best all-round language, period. I'd probably start there if I were you. Note that other than e.g. "interfacing" in the attached sense, Python is also fairly close to a scripting language; can call out to external binaries easily and is often used for that. I.e., you could just wrap existing binaries where that';s more to the point. That's in turn not something which I'd do in C or C++.

[NOTE: the stupid board software feels that .py files are evil; strip the .txt from hello.py.txt]
Attachments
hello.py.txt
(88 Bytes) Downloaded 14 times
hello.c
(135 Bytes) Downloaded 15 times
rene
Level 16
Level 16
Posts: 6693
Joined: Sun Mar 27, 2016 6:58 pm

Re: Getting back into programming

Post by rene »

0x2620 wrote:
Sun Dec 15, 2019 5:42 pm
How exactly is OOP useful?
For GUI programming. Most definitely. Being able to treat, say, any old widget "the same", an instance of some base class, allows for code that works on all. And that said, sure. OOP tends to invite over-generalisation, and the GUI-framework context is also the only context I consider convincing. Well. And operator-overloading...
gm10
Level 20
Level 20
Posts: 10999
Joined: Thu Jun 21, 2018 5:11 pm

Re: Getting back into programming

Post by gm10 »

0x2620 wrote:
Sun Dec 15, 2019 5:42 pm
No hard feelings, just asking questions.
Nor here, everybody writes the code they want to write, that's why we've got so many languages and ways to use them. There's more than one way to do it, as they say over at Perl.

Regarding OOP, your code doesn't become OOP as far as I am concerned just because you put it in a class. You can write perfectly procedural code within a Java class. Unless you're a purist in that you don't want any objects at all. Then Java become a problem indeed, it's hard (but not impossible) to avoid objects. But Python becomes impossible, everything is an object in Python. So back to C indeed, definitely no OOP there.

I'm not sure what you mean by GUI debuggers but every IDE I know supports debugging - obviously the debugger spits out text, i.e. the same thing as your code.

Race conditions are easily possible in any multi-threaded code, C# is no exception. GUI libraries and the programming language itself are not the same thing.
User avatar
0x2620
Level 3
Level 3
Posts: 117
Joined: Mon Jan 09, 2017 3:17 pm

Re: Getting back into programming

Post by 0x2620 »

Everything is indeed an object in Python (except maybe for some C primitives IIRC), but in Python I don't need to type a bunch of boilerplate to acknowledge this.

RE GUI debuggers vs purely text debuggers: in the former I can step once in a program and then watch a dozen or more fields as they change (or don't), while with the latter I need to manually poll each field whose value I want to see every time I step through a program. Some data are better represented visually rather than textually, although strictly speaking both are text.

In Java the standard library - which is massive - includes a ton of GUI classes. I haven't found a book that deals with the things I experienced, nor have I found any info on the internet.
User avatar
lsemmens
Level 11
Level 11
Posts: 3547
Joined: Wed Sep 10, 2014 9:07 pm
Location: Rural South Australia

Re: Getting back into programming

Post by lsemmens »

I started procedural languages back in the 80s. They were good, back then. When Windwoes and other windwoes type programs came along, the procedural languages, in many cases became redundant.

My experience was in database development and, in some ways, a set procedure ensures no data is missed, but it also makes it difficult to modify only one instance without having to trawl through thousands of lines of code to ensure data integrity is maintained.
Fully mint Household
Out of my mind - please leave a message
gm10
Level 20
Level 20
Posts: 10999
Joined: Thu Jun 21, 2018 5:11 pm

Re: Getting back into programming

Post by gm10 »

0x2620 wrote:
Sun Dec 15, 2019 7:19 pm
RE GUI debuggers vs purely text debuggers: in the former I can step once in a program and then watch a dozen or more fields as they change (or don't), while with the latter I need to manually poll each field whose value I want to see every time I step through a program. Some data are better represented visually rather than textually, although strictly speaking both are text.
Sure, but basically every IDE does that, for every language they know how to debug, and that includes C, which was my point. Personally I am using Visual Studio Code, which is a multi-language, cross platform code editor, not a full IDE, and it certainly can do that as well.
User avatar
0x2620
Level 3
Level 3
Posts: 117
Joined: Mon Jan 09, 2017 3:17 pm

Re: Getting back into programming

Post by 0x2620 »

Well that solves the IDE/editor problem, what about modern books on C?
gm10
Level 20
Level 20
Posts: 10999
Joined: Thu Jun 21, 2018 5:11 pm

Re: Getting back into programming

Post by gm10 »

That was just an example for something not even being a full IDE and yet still supporting that. IDEs certainly support it as well.

Regarding books, I wouldn't know, I've never read any book on programming.

PS: That said, here's a reading list:

Image

:mrgreen:
User avatar
murray
Level 5
Level 5
Posts: 759
Joined: Tue Nov 27, 2018 4:22 pm
Location: Auckland, New Zealand

Re: Getting back into programming

Post by murray »

Visual Studio Code has a great debugger. If you want to see it in action with a C program then have a look at this video: https://www.youtube.com/watch?v=X2tM21nmzfk Also lots of info can be found at https://code.visualstudio.com/Docs/editor/debugging
Running Mint 19.3 Cinnamon on an Intel NUC8i5BEH with 16GB RAM and 500GB SSD
User avatar
Hexeratops
Level 1
Level 1
Posts: 12
Joined: Fri Jul 05, 2019 9:11 pm

Re: Getting back into programming

Post by Hexeratops »

0x2620 wrote:
Sun Dec 15, 2019 8:41 pm
Well that solves the IDE/editor problem, what about modern books on C?
I found "A Book on C" to be useful when I was going through college, although it feels a little overkill after having learned C and C++. It's over 700 pages explaining syntax, but if you need the support, it offers some really good tips and lots of examples.

"Code Complete" by Steve McConnell is also a very good read for learning more general programming techniques and for learning how to write more maintainable code. Although it has some C, C++ and Java examples, it's much more theory based and is relevant regardless of your language of choice. I'd say it's definitely worth a read once you've started getting the hang of things in C or whichever language you want to learn.
User avatar
0x2620
Level 3
Level 3
Posts: 117
Joined: Mon Jan 09, 2017 3:17 pm

Re: Getting back into programming

Post by 0x2620 »

Thoughts on these two? Already acquired pdfs.

https://www.amazon.com/gp/aw/d/0534491324/

https://www.amazon.com/Data-Structures- ... 534390803/

Reviews say the first one is very in-depth (good) but the code has occasional syntax errors. Good to know that in advance so I can google it and figure out which snippets are broke.
Post Reply

Return to “Open chat”