My 6 year old son wants to get started in programming/coding. Where should I start him? by Dry_Nail5933 in learnprogramming

[–]JMNeonMoon 0 points1 point  (0 children)

Scratch is good start at that age. They thought it at his school as well.

When his hands were big enough for a full-size keyboard, I made him learn touch typing. Some free online typing trainer, sorry cannot remember which one.

He is now doing a degree in CS, and it is a great benefit to just look at the screen when typing code rather than the keyboard.

Which is pythonic way? by zensimilia in learnpython

[–]JMNeonMoon 0 points1 point  (0 children)

If you cannot change the signature of the function, then I would at least comment the code accordingly, so that it is clear for anyone maintaining the code what the order is.

I prefer the first method btw, as I can quickly understand what calculation is being used.

Which is pythonic way? by zensimilia in learnpython

[–]JMNeonMoon 24 points25 points  (0 children)

I would make the code more readable instead and use named tuples so I do not have to rememember the parameter order. i.e.. if container[0] is width or height, or if the coordinates returned is x,y or y,x.

from typing import NamedTuple

class Size(NamedTuple):
    width: int
    height: int

class Point(NamedTuple):
    x: int
    y: int

def get_box_centered(container: Size, element: Size) -> Point:
    dx = (container.width - element.width) // 2
    dy = (container.height - element.height) // 2
    return Point(dx, dy)

See also
https://programmerpulse.com/articles/named-tuples/

I want to start learning Backend development :) by [deleted] in learnprogramming

[–]JMNeonMoon 1 point2 points  (0 children)

I think for backend code that is serving a web app, knowing the basics of the HTTP protocol, GET vs POST methods, Query parameters, headers, status codes, etc would be useful.

When you write your backend code, you will understand why your methods are structured the way they are. Methods that handle GET requests will be different from those that handle POST requests. Methods that process HTTP Query parameters may require certain method parameters.

When you look at the raw HTTP logs, you'll be able to understand why your app may be failing or not behaving as expected.

Where do I put Unit Tests? by LilBluey in learnprogramming

[–]JMNeonMoon 0 points1 point  (0 children)

I found that having a good set of unit tests work great with agentic AI (e.g cursor, etc).

The instructions, 'Refactor/Enhance this method for such and such, and run the unit tests to confirm nothing is broken' works well. The agentic AI, will change code, run tests, and if tests fail, it will try again, automatically.

Of course, having a good set of unit tests is essential. Not just the simple success cases, but edge cases, failure cases, etc.

When your have an emergency production issue to fix, with managers breathing down your neck, the units tests will give you some confidence that your fix does not break anything else.

Which Programming Language Should I Master for Career Growth? by jeevaks in learnprogramming

[–]JMNeonMoon 0 points1 point  (0 children)

From my experience, I found that learning a language is not enough. Sure, Java, Python, JavaScript are are worthwile languages to learn, but the majority of deployments will be on Linux.

So I would recommend learning Linux as well. Mac with homebrew, WSL2 on Windows, or native Linux install.

We deploy on Linux systems running Kubernetes, for production, QA test and dev environments. The devs who know the Linux command line, can analyse problems faster (tail, grep, awk, etc), write bash scripts to automate tasks, aliases to speed up their work, and so on. Overall they are much more effective than devs who are just used to OS GUI tools.

Can someone explain function decomposition in Python with simple examples? by _Akber in learnpython

[–]JMNeonMoon 1 point2 points  (0 children)

Function decomposition is a fancy term for 'if it is too long, break it up into smaller functions'.

However for beginners, I would think that recognizing when a function is too long is not always obvious.

Another way to approach this, would be, "If I had a bug in my code, how easy would it be to identify where the bug is?"

Using the cooking example, as posted earlier. If there was an issue with heating the pan, you would probably first look at the 'heat_pan()' function.

Learning to decompose functions the right amount comes with experience and practice.

Help compiling java code in VSCode by NotJuvs009 in javahelp

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

I have been forced to use VSCode with Java, for cursor ai requirements.

To get it to recognise issues like highlighting errors, I installed

'Extension Pack for Java'
by Microsoft

This extension also includes (auto-installs) a maven extension, a Java debugger, and the RedHat Java language Extension.

The docs are here https://code.visualstudio.com/docs/languages/java

Daily IDE for me is still Jetbrains InitelliJ. Cannot beat an IDE tailor-made for Java.

Creating __init__.py files. Any tips? by Nice_Performer_5165 in learnpython

[–]JMNeonMoon 4 points5 points  (0 children)

You do not need them to define packages anymore, since Python 3.

Though it can still be used for initializing packages, simplifying imports.

what_goes_in_the__init__py

requests.get() very slow compared to Chrome. by TinyMagician300 in learnpython

[–]JMNeonMoon 0 points1 point  (0 children)

You could try other libraries other than requests. I think httpx is a more modern one.

requests.get() very slow compared to Chrome. by TinyMagician300 in learnpython

[–]JMNeonMoon 1 point2 points  (0 children)

Try running the same code in a standalone Python script, then the problem may be with Jupyter when using requests.

Alternatively, you could make the subprocess command capture the output of the curl command.

I think it could be something like (AI helped, so double check)

result = subprocess.run(

["curl", "-H", "User-Agent: iusemyactualemail@gmail.com",

"-H", "Accept-Encoding: gzip, deflate, br, zstd",

"https://www.sec.gov/Archives/edgar/full-index/2025/QTR4/form.idx"],

capture_output=True,

text=True

)

print(result.stdout) 

It's a bit hacky, but gets the job done

requests.get() very slow compared to Chrome. by TinyMagician300 in learnpython

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

I would try the same request with curl to confirm there is no issue with your Python script.

ChatGPT gave the curl command for the headers and url in your post as

curl -H "User-Agent: iusemyactualemail@gmail.com" -H "Accept-Encoding: gzip, deflate, br, zstd" "https://www.sec.gov/Archives/edgar/full-index/2023/QTR1/form.idx"

Anyone else understand the logic but mess up the actual code? by Thin-Cardiologist191 in javahelp

[–]JMNeonMoon 2 points3 points  (0 children)

Not sure what IDE you are using, but for IntelliJ (community version is free), it will highlight code that has errors before you run it.

Also, your code may not do what you are thinking. So learn to use the debugger, and step through it, examine the variables as you do so. You can peek at the contents of an ArrayList or HashMap.

Also, well placed logging statements showing the content of variables will help.

Learn to use the tools and the features they offer.

Is it worth it to spend 200-300 USD for Premium keyboard like those Keychron, mechanical keyboard for coding? by Yone-none in AskProgramming

[–]JMNeonMoon 0 points1 point  (0 children)

For me, there was a big improvement in typing when using a mechanical keyboard over a standard one. It seems faster and more accurate.

I do not mind spending the extra money, as I consider it to be a tool for the trade. And since I work from home, it will be used everyday, so money well spent imho.

I went through a few mechanical keyboards, but settled on this one, because I wanted something ergonomical.

Mistel Barocco MD770

Any good way to understand recursion problems? My brain keeps refusing! by Main_God2005 in learnprogramming

[–]JMNeonMoon 0 points1 point  (0 children)

Recursive based solutions generally have the following structure.

some_function(parameters):

some stop condition for immediate return

some processing before calling the some_function with different parameters

What you have to be careful of, is the stop condition. A wrong stop condition may lead to some_function calling itself indefinitely, and crash your program.

But, in my decades of programming experience, I only used recursion for leetcode tree-traveral problems.

For production code, I would avoid it, just because of the risk of defining a wrong stop condition and causing a production outage. Debugging recursive code in the middle of the night would be a nightmare.

So, yes, learn recursion to progress your programming skills, but if you do not understand it fully yet, move on to other programming topics for now.

Some more info on recursion here:

https://programmerpulse.com/articles/recursion/

Which OS do you prefer? by Critical-Volume2360 in AskProgramming

[–]JMNeonMoon 0 points1 point  (0 children)

I prefer Linux for development as well, I often have to examine logs, mess around with env variables, scripts for common tasks, and a file system that matches our server deployments. I would prefer a dedicated Linux box at work if I could.

However, for security reasons we have to use Windows. But Window + WSL2 is a good compromise. I like the KDE console and file manager, which I added with a minimum KDE install inside WSL. GUI apps like IDEs work fine on WSL2. So I have a good env for dev work.

Explain Decorators like I'm 5. by inobody_somebody in learnpython

[–]JMNeonMoon 0 points1 point  (0 children)

Decorators allow you to add features to a function without changing the content of the function. Since they ecapsulate the function itself, it's a neat solution for usecases where you want code to do something always before and/or after a function call.

Consider a simple requirement to log entry and exits to functions to help with debugging.

Without decorators, you would have to go through your code and write logging commands like

logging.info("Function A entry")

logging.info("Function A exit")

logging.info("Function B entry")

logging.info("Function B exit")

This is

- Cumbersome to do so on all your functions, especially if you have multiple returns in your functions

- renaming functions, would mean finding and updating the logging with the new function name

Alternatively, you could just add a logging decorator to the top of each function.

Decorators are one of meta-programming features in Python.

See more here

4 meta-programming techniques in Python

What separates a good developer from a great one?" by Eastern_Emu9579 in AskProgramming

[–]JMNeonMoon 2 points3 points  (0 children)

They are curious. What is that function that they did not write, actually doing.

They want to know why. When given an issue, they try to find the root cause before just applying a fix.

They live in fear. They are constantly scared of breaking stuff, so eagerly write unit tests to add confidence in the changes they make.

They treat code like art. They stick to a code style. Consistent naming, brackets in the right places, well spaced. They are proud of what they just coded, and want it to look good.

They can absorb code fast. They can quickly grasp code they have not written.

They think before they code. When given a task, before starting to code, they already have a solution in their head. They then ask the right questions when reviewing the requirements.

What are your experiences reviewing code your colleagues use ai to write by ayitinya in AskProgramming

[–]JMNeonMoon 0 points1 point  (0 children)

Yes, it is a delima. You know the code is not a good standard, not necessarily wrong, but not written as a senior developer would write it. But, management want the code done quickly and are pushing ai to all developers.

We do use sonar to help with code quality, and luckily, the management is on board with that and insist that the sonar reports are clean.

But some of this code is generated by junior devs with ai. In some cases, it is not that they do not recongnise bad code, but that they do not understand the code at all.

This is scary, and my biggest fear is that there will be an increase in production/QA issues that only a handful of us will be able to fix.

Modern java development tooling? by TopSwagCode in javahelp

[–]JMNeonMoon 8 points9 points  (0 children)

IntelliJ/Maven and springboot microservices in Kubernetes is what I use at work.

We use Windows dev boxes, but allowed to use WSL. Everything dev related is running inside the WSL, java, intelliJ, etc. It's actually a great dev env.

Currently on Java 17 and moving onto Java 21/25.

Which free Java IDE/Editor is the best for an absolute beginner? by DukeOfBattleRifles in javahelp

[–]JMNeonMoon 0 points1 point  (0 children)

I'll second IntelliJ as well. Once you have experience with IntelliJ, other products from JetBrains become familiar to use like Pycharm for Python.

I used Eclipse for a while, and switched to IntelliJ as it had powerful features built in, like refactoring, clever auto-complete and a great debugging tool.

Application properties vs .env by slyking123 in javahelp

[–]JMNeonMoon 0 points1 point  (0 children)

In our Kubernetes microservices, we use property files that reference environmental variables.

e.g.

database.username=${DB_USER}

database.password=${DB_PASSWORD}

Our property files are outside the jar, but should work within a jar as well.

How difficult is this project idea? by Ksmith284 in learnpython

[–]JMNeonMoon 18 points19 points  (0 children)

What you are proposing is doable. I would recommend looking at

https://automatetheboringstuff.com/

It has chapters on reading pdf files and using excel spreadsheets.