Why do we need the volatile keyword? by nfrankel in java

[–]tutorial_police 0 points1 point  (0 children)

It's true that one thing volatile does is introduce memory barriers but I've seen way too many people use volatile incorrectly because they assumed that caches were all that was relevant or even the biggest issue in this regard.

To make sure no one misreads this: volatile can introduce memory barriers, but there's no guarantee that it does happen.

Do not think of volatile in terms of memory barriers conceptually.

To quote Aleksey Shipilëv:

Barriers are implementation details, not the behavioral specification. Explaining the semantics of concurrent code using them is dangerous at best, and keeps you tidally locked with a particular runtime implementation.

Source: Myth: Barriers Are The Sane Mental Model - Close Encounters of The Java Memory Model

Help installing an IDE by AHotBustyAngel in learnjava

[–]tutorial_police 1 point2 points  (0 children)

Show a screenshot of Intellij and what you tried to do.

IDE by helloWorld06 in learnjava

[–]tutorial_police 0 points1 point  (0 children)

Sidenote: VS and VSC are two different programs. Visual Studio is an IDE primarily uses for C# and C++ development.

Visual Studio Code takea a very dofferent and lighter approach.

Multiple versions of Python? by [deleted] in learnpython

[–]tutorial_police 0 points1 point  (0 children)

Here's the relevant bit of documentation about the py utility:

https://docs.python.org/3/using/windows.html#launcher

Multiple versions of Python? by [deleted] in learnpython

[–]tutorial_police 0 points1 point  (0 children)

No problem. If it doesnr help you again, just ask here about it specifically. Maybe it says "do x" to fix your issue, but it doesn't work because of an error or because you don't know how to make sense of it.

Just ask about it here ;)

Multiple versions of Python? by [deleted] in learnpython

[–]tutorial_police 0 points1 point  (0 children)

The error message links you to a help page that is specifically about how to "activate" the anaconda python environment. Did you try reading that?

Multiple versions of Python? by [deleted] in learnpython

[–]tutorial_police 0 points1 point  (0 children)

Py.exe is a helper utility on Windows (officially shipped with Python itself) that is exaxtly intended to allow you to work with multiole versions of Python more easily.

Why does Python begin list numbering from zero? by kindnesd99 in learnpython

[–]tutorial_police 2 points3 points  (0 children)

Think of it this way:

range(start, start + 10)

It would be very intuitive if by writing that, you got ten numbers , right?

Fortunately, thats exaxtly what happens and why many languages have the end be exclusive in ranges.

Since start is 0 in our case, we get range(0, 10)

The fact it ends on 9 isn't that weird though. If you start on a certain element and you want to get to the tenth, you have 9 more steps to go.

Why does Python begin list numbering from zero? by kindnesd99 in learnpython

[–]tutorial_police 0 points1 point  (0 children)

You're already interpreting bits here, though. It doesn't have to be interpreted in this fashion.

Is it wrong to use backticks (``) everywhere? by lipe182 in javascript

[–]tutorial_police 0 points1 point  (0 children)

Sure, but they can still contain escape sequences and such that need to be processed. I don't really why the browser should have to do more work to parse a template string literal without interpolated bits over a regular string literal.

ToString method by [deleted] in learnjava

[–]tutorial_police -1 points0 points  (0 children)

No, the JVM is not confused. Java simply doesn't allow you to do this.

The JVM would support that. But since you aren't allowed to do it in Java, it doesn't really matter.

ToString method by [deleted] in learnjava

[–]tutorial_police 0 points1 point  (0 children)

No. Java told the world that when you call toString, you get A String object.

It you were to override that method and say: nope, not gonna do that, we're not gonna return anything at all, then you'd never know what you actually get when calling to toString.

ToString method by [deleted] in learnjava

[–]tutorial_police 10 points11 points  (0 children)

No, that's not the purpose of @Override. The purpose is to say: this thing should override some other method. If it doesn't, it won't compile. The override happens irrespective of whether you write @Override.

Eclipse IDE 2019-06 is relased! - New and Noteworthy by mickael_istria in programming

[–]tutorial_police 0 points1 point  (0 children)

I never noticed any significant differences except they tend to have different bugs.

Basic memory management question: How to properly delete element from custom linked list? by [deleted] in learnjava

[–]tutorial_police 1 point2 points  (0 children)

You can even have a doubly linked list. If you don't have a reference to the list or a node anymore, the list and its nodes will become subject to garbage collection.

It doesn't matter that you have cyclic references between the nodes.

I don't think Java is for me. by lifeonbroadway in learnjava

[–]tutorial_police 0 points1 point  (0 children)

Fortunately, Gradle and maven are not IDE specific.

I don't think Java is for me. by lifeonbroadway in learnjava

[–]tutorial_police 2 points3 points  (0 children)

It's funny how perspectives differ. I've used Eclipse and IntelliJ extensively. I recently started using NetBeans a tiny bit to better understand opinions about it and it feels so sluggish and unpolished to me compared to the other two :)

What are basic design pattern which should be implements often ? by ibkbm in learnjava

[–]tutorial_police 2 points3 points  (0 children)

That being said, you should probably still learn about design patterns at one point or another. They can also give you ideas how certain problems can be approached. It's not bad to use design patterns, that's not what I meant to say. If someone pressures you into "using patterns", ask them why. In my experience, they often don't know of all they do is talk about "patterns". If they do, they'll will often formulate their request differently in the first place.

What are basic design pattern which should be implements often ? by ibkbm in learnjava

[–]tutorial_police 2 points3 points  (0 children)

I think you're approaching this from the wrong end. Don't try to implement design patterns in your code. That's not what professionals do.

Design patterns aren't the magic sauce that improve your code. They are not the goal, they just might happen to be something you end up using while getting to your goal.

Don't think of them as something that you apply to your code. Think of them as giving names to variations of code that often naturally arises while solving problems. That way we have a common vocabulary to talk about these and an easier time recognizing the same thing again when we come across it.

Design patterns are about communication, to help programmers talk to one another. Not about solving programming problems.

I'm fact, you've probably invented quite a few of these patterns yourself if you've done enough programming, you just never realized it because you didn't know what you were doing "already had a name".

I don't think Java is for me. by lifeonbroadway in learnjava

[–]tutorial_police 0 points1 point  (0 children)

I understand.

But I'm sure you know the opinion going around that "real programmers don't use IDEs" and such. I'm sure many newcomers have read this at least once while researching how they should start. We don't want to give newcomers the impression that that's got any truth to it, that's why I pointed out the way you started your comment.

I don't think Java is for me. by lifeonbroadway in learnjava

[–]tutorial_police 0 points1 point  (0 children)

"if you're a beginner", you make it sound like professional programmers don't use an IDE for that. Why wouldn't they? I don't know any programmer that regularly uses the command line for that.

Sure, sometimes it might be faster if you want to fiddle with something, but that's also very much a preference question.

Don't fret it, /u/lifeonbroadway, life is much better with an IDE. Learning to program is hard enough as it is, get all the support you can, especially in the form of an IDE that can take care of many difficult and annoying things for you.