Jump to content
On 4/23/2023 at 5:23 PM, Dat Guy said:

Which is a good way to understand basic memory management. 😛

Which is pretty pointless outside of intellectual curiosity for most purposes. Even C and C++ nowadays ships with many garbage collector libraries that will clean up your dangling pointers and garbage memory for you. If you want intellectual curiosity, you should try writing your own dynamic memory allocator. It isn't all that complicated. The only syscall you need is sbrk() and brk() to grow/shrink the heap. It will likely turn into a buggy mess but it will demystify what malloc and free functions actually do under the hood. 

Sudo make me a sandwich 

Link to post
Share on other sites

42 minutes ago, wasab said:

Which is pretty pointless

 

I'll quote this next time someone asks me why "modern" software eats half of your RAM while doing nothing.

 

43 minutes ago, wasab said:

Even C and C++ nowadays ships with many garbage collector library

 

Please enlighten me: Which implementation of C and C++ ships with many garbage collector libraries and which are those?

 

 

Write in C.

Link to post
Share on other sites

59 minutes ago, Dat Guy said:

Please enlighten me: Which implementation of C and C++ ships with many garbage collector libraries and which are those?

come on man, garbage collector for c and c++ have existed for like forever

https://www.geeksforgeeks.org/smart-pointers-cpp/

https://en.wikipedia.org/wiki/Boehm_garbage_collector

Sudo make me a sandwich 

Link to post
Share on other sites

@Dat Guy is correct. Boehm GC is not included in C/C++ by default, and I would not call smart pointers "garbage collection" by any means.

Computer engineering PhD student and RFML researcher

 

Daily Driver:

CPU: Ryzen 7 4800H | GPU: RTX 2060 | RAM: 32GB DDR4 3200MHz C16 | OS: Debian 13

 

Gaming PC:

CPU: Ryzen 5 5600X | GPU: EVGA RTX 2080Ti | RAM: 32GB DDR4 3200MHz C16 | OS: Windows 11

Link to post
Share on other sites

10 minutes ago, dcgreen2k said:

@Dat Guy is correct. Boehm GC does is not included in C/C++ by default, and I would not call smart pointers "garbage collection" by any means.

by "shipped", i dont mean it needs to be included with the libc and smart pointers solve many of the same underlying issues as full-blown garbage collections. technically yeah, you can argue on the semantics, but practically, they are "shipped garbage collectors" 

 

Sudo make me a sandwich 

Link to post
Share on other sites

12 minutes ago, wasab said:

by "shipped", i dont mean it needs to be included with the libc

 

So by "shipped" you mean "absolutely not shipped at all". I see.

 

12 minutes ago, wasab said:

smart pointers solve many of the same underlying issues as full-blown garbage collections.

 

Rust solves many of the same underlying issues as C++, so "practically", Rust is C++?

Anyway, you can leak memory with smart pointers, which is basically the opposite of what you want to do with a garbage collector.

Write in C.

Link to post
Share on other sites

13 minutes ago, Dat Guy said:

So by "shipped" you mean "absolutely not shipped at all". I see.

why would that disqualify the word "ship"? You can choose to add any library as part of a compiler package. 

13 minutes ago, Dat Guy said:

Rust solves many of the same underlying issues as C++, so "practically", Rust is C++?

Anyway, you can leak memory with smart pointers, which is basically the opposite of what you want to do with a garbage collector.

you can leak memory EVEN WITH a garbage collector too so? My point is it aint too difficult to achieve the same effect of automatic memory management in c and c++

Sudo make me a sandwich 

Link to post
Share on other sites

Just now, wasab said:

You can choose to add any library as part of a compiler package. 

 

"Shipped" = "it is already there".

 

1 minute ago, wasab said:

My point is it aint too difficult to achieve the same effect of automatic memory management in c and c++

 

C and C++ have non-standard libraries to achieve (semi-)automatic memory management. You will need to

  1. understand that allocated memory can leak, so you actually understand that they could help, for which you will need to
  2. find (and install) them,
  3. understand how to use them and
  4. hope that they don't have their own set of critical issues.

That's not quite the same thing as automatic memory management for which you don't even need to think about memory.

Write in C.

Link to post
Share on other sites

Just an idea but "shipped" can mean that a product is available, like say in production.

Any who, There are indeed libs that you can use for these unmanaged languages but I wouldn't go as far as saying learning how memory works is pointless. I think it is very much a necessity these days as more and more programmers take resources like memory and cpu for granted.

Link to post
Share on other sites

  • 1 month later...
On 3/20/2023 at 3:54 PM, Ripred said:

Are there any disadvantages to using IDE? Maybe it better to keep both a IDE and a good text editor, use one or the other depending on project, what would be the advantages/disadvantages between these, and what would be the best use case for each? I'm still very beginner, just managed to get Hello world! to output over the weekend through textpad

An IDE might be a bad thing for a beginner as it trivializes certain aspects of coding and has tons of features that aren't of any use at this stage. Many, including myself, find MSCode to be the best environment to code in, providing the majority of features from IDEs and more, with unrivaled customization features.

*using non-conversational, sketch-level language to gesture at structure and direction.
The GB8/12 Liberation Front

 

 

Link to post
Share on other sites

3 hours ago, Timme said:

An IDE might be a bad thing for a beginner as it trivializes certain aspects of coding and has tons of features that aren't of any use at this stage. Many, including myself, find MSCode to be the best environment to code in, providing the majority of features from IDEs and more, with unrivaled customization features.

There are many things that trivialize. Things like WordPress is just drag and drop and there are this new breed of low code/no code developers who pride themselves on never writting a single line of code to get a project done. 

Sudo make me a sandwich 

Link to post
Share on other sites

19 minutes ago, wasab said:

There are many things that trivialize. Things like WordPress is just drag and drop and there are this new breed of low code/no code developers who pride themselves on never writting a single line of code to get a project done.

Let's not be those guys. They are the first in line to be replaced with ChatGPT.

*using non-conversational, sketch-level language to gesture at structure and direction.
The GB8/12 Liberation Front

 

 

Link to post
Share on other sites

Senior Java developer and local dev academy "associate" here.

Java 8 is pretty old by now, but it still has "general Java stuff (like steams)" most people use till today, so you're fine 🙂 Sooo, you can pick Java 17 or even 20 (17 is curent LTS (Long Term Support)) and all Java 8 stuff will be there too (some stuff might be deprecated (like deleted or replaced because they're old and obsolete), but like 95% should be there, I think).

IMHO, Java is OK for personal projects, but it's mostly used in a corporate environments as a back-end language (generally back-end is where received data is getting processed, stored, etc.), so while creating a website with Java, is possible, but is quite painful and please no 🙂 GUI apps that run locally are fine (JavaFX/Swing), but it's kinda hard to make them look modern. Also shipping apps to other regular users is kinda pain, but that's another topic. Java today is mainly used for various integrations (API) and business logic (processing data, inputs, whatever), communicating with databases and other back-end stuff.

There are different Java "Editions". There's oracle, openJDK, RedHat, Amazon and many more. You don't care about that. It's just the same Java with extra libraries included. Just use OpenJDK or oracle. (Oracle owns Java. And OpenJDK is the source for Oracle Java).

Where to start? What to do? Well, first, learn the basics from the book or online tutorial (like syntax and just have some assumptions on what's possible at all) pick a mini-project fro yourself (anything, start simple, like sort students by grades). And learn everything you need to complete this project.

As an example, sort students by grade (console app, to simplify):

1) You need to input data. Let it be a student name and a grade. So you need to learn how to read user input in Java.

2) You'll have a bunch of students, so they will be stored in a List. So learn how to work with lists.

3)Then you'll need to sort them by grades. Just google any Java sorting algorithm (or modern Java has one built-in) and just copy-paste it and learn what it does and how it works.

4) And then output the result!

5)...

6) Profit!

Also, use IntelliJ - it is GOD IDE, community edition (free) is pretty good too. While you can use random notepad or VScode or anything else you want, normal people who actually work with Java to earn money use IntelliJ (in the past it was Eclipse or NetBeans). It's just a proper, good quality tool.

A good learning platform that has this "learn-by-doing-projects" is Hyperskill. It's from JetBrains (people, who created IntelliJ), so they know what they're doing. It's not three, though.. But it's amazing! Udemy and even YouTube are fine too, if you want a video. It's kinda hard to find a decent course though.

Next step after feeling comfortable with plain Java (it could be a few months, could be more) is to learn a framework. So, basically it's a Spring Boot. While it's not required, it makes things easier (like, working with API). But it will break your brain at first, because a lot of stuff is happening behind the scenes and looks like dark magic (Anotations?? What are they doing? Why is there "invisible" code??). I'm mentioning Spring Boot just because it's a #1 framework for Java and you'll find many mentions of it online together with Java.

 

Hope that helps and happy coding!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×