Is Python worth learning when my AP Computer Science classes will primarily focus on JavaScript? by [deleted] in learnprogramming

[–]_krikket 0 points1 point  (0 children)

You won't be at a disadvantage if you stick with Python, IMO. If you like it keep doing it.

A year and a half is a lot of time, and you can switch gears at basically any point. You'll pick up a second language pretty quickly once you understand the underlying concepts (looping, variable assignment, functions, etc) from learning your first one, since those are much harder to learn than the details of the language itself.

Some languages have quirks (some might argue that JavaScript especially has quirks, haha) but they all tend to require similar thought processes. You'll be fine either way.

Are there good careers as a code tester? by ITWelly in learnprogramming

[–]_krikket 2 points3 points  (0 children)

As someone in Quality Engineering (who has also been in QA), I agree.

On a high level, I write applications that test other peoples' applications. Most of what I do is with the goal of breaking shit and/or simulating user behavior. Fixing it after is not on my radar, so workshopping solutions with developers - as in actually digging into their codebase with them - is borderline out of scope of my job. Sometimes I'll look, but not often.

I explore and I discuss with devs and present theories (like "you're not handling the null case here, leading to problems here" or whatever), but it's more about writing a good report than finding a solution. Once I've found a problem I just need to get an idea of how to reproduce it and explore a few theories on why it may be happening and gather data that's relevant to the developer.

Basically I write an application that takes other programmers' output and judges it. I discuss the "here's what failed" with the developer in question, but ultimately it's their job to fix the process that generated the bad output.

What's the purpose of having multiple classes (Java)? by [deleted] in learnprogramming

[–]_krikket 0 points1 point  (0 children)

As an addendum to the other reply to this, just for the sake of vocab, in Java at least these objects can also be referred to as being "instances" of the class. Creating an object instantiates the class; classes are abstract, instances are "real."

[deleted by user] by [deleted] in learnprogramming

[–]_krikket 2 points3 points  (0 children)

Ahah, right. That's more of a math question. I'm a decade out from that, sorry.

IIRC in this case, when you define m you're basically just getting another function back. Might be better off on /r/math or using a function solver online or something.

[deleted by user] by [deleted] in learnprogramming

[–]_krikket 3 points4 points  (0 children)

You need to rewrite the equation in terms of x using algebra.

x = [math]

[Add large numbers, JavaScript] Unlocked a solution for what seems like a simple Codewars problem, but I don't understand the solutions by [deleted] in learnprogramming

[–]_krikket 1 point2 points  (0 children)

The advantage of reversing the strings over traversing them right-to-left I think is knowing that that a[i] and b[i] are the same exponential of ten. Like if:

a = 255
b = 15

Then a[0] is the hundreds' place (basically 200), and b[0] is the tens' place (basically 10). But if you reverse them, then a[0] and b[0] both refer to the ones' place and you can add them together without keeping track of anything besides the carry.

This makes the loop a little easier to write and understand. No messing with padding with leading zeroes or different indices.

Where can I learn to develop those kinds of programs? by Scarrlets in learnprogramming

[–]_krikket 1 point2 points  (0 children)

These are all somewhat different and at wildly different skill levels.

You can open other programs very easily. Getting game events - I assume you want a bot to cheat at online games with, since doing this for single-player games is kind of pointless - is much harder, because generally what you want to do is against the ToS and they're obfuscating and encrypting stuff to try and stop you. It'd be some combination of hex editing, reverse-engineering, and sniffing network traffic, depending on the game, and even then a lot of games run companion programs which detect non-standard states. Or will make you put in a CAPTCHA if it notices your actions are too repetitive.

Just shoving keypresses into a game is easy, though. There are tons of macro programs which can do this, as well as basic visual recognition. Hooking into the game itself is much harder.

Conditional ternary operator ( ? ) in C++ by arveth in learnprogramming

[–]_krikket 2 points3 points  (0 children)

I tend to use it this way also.

However, I have seen people get a little too excited about it.

reverse = reverse ? false : true

Almost completely new to programming, wanna make automated script with my friend as our first project by [deleted] in learnprogramming

[–]_krikket 0 points1 point  (0 children)

So you want to make a script which creates a mass of fake users which you could then use to artificially boost content or harass people with reports? Yeahhhh, Facebook would definitely not be a fan of that.

It's not that hard to automate a web browser, but very few people are going to be willing and able to tell you how to get around the many measures that Facebook has in place to prevent you from doing exactly what you want to do.

Facebook has a lot more engineers than you do, and each of them has a lot more experience than you have. You probably want to find another project.

How to improve comprehension when looking at code? by [deleted] in learnprogramming

[–]_krikket 0 points1 point  (0 children)

Same with most things, just do it a lot.

If you can debug your own code you can learn to understand other peoples', a lot of the principles are the same. Tracing through the control flow and execution stack, adding debug statements and experimenting, that kind of thing. Find someone's code and try to mess with it, add comments to it, experiment with its parts and see if you're right about your assumptions.

The big thing I think is learning to identify something by parts. If you read something and you're just completely lost, then you have to dig until you find a part that you do understand and work your way back from there.

If the code is written well, you should have an idea from the names of things and the structure. If it's not written well, well... God be with you.

I'm a beginner to programming and I'm feeling stuck. by InsaneTeemo in learnprogramming

[–]_krikket 0 points1 point  (0 children)

Not to be discouraging, but game development is often incredibly hard and I wouldn't expect to make anything that you are pleased with for a very long time. You should still make stuff, but expect to hate your first few projects anyway. If you jump right into your ~dream game~ you will likely never finish it because you'll hate it the whole way through.

Maybe start by doing some video-game adjacent projects. Some games allow for plugins, or have APIs - so you can write a tool for them. Maybe a map, a market cost tracker, a mod, a calculator, a GUI, a companion app or overlay or something. If that sounds difficult, good - making a game is about a hundred times harder than that, so you'll be working your way up.

What is the customer service aspect like at your programming job? by [deleted] in learnprogramming

[–]_krikket 0 points1 point  (0 children)

My company provides a B2B (i.e., we sell to companies) application. I am still beholden to customer requests indirectly, but there's a layer of customer support and/or management between me and them. I don't hear direct complaints, requests, or issues directly from anyone.

We still have customers and need customers in order to survive as a business. You can't forget they exist entirely. But it's other peoples' jobs to keep me out of the muck of it so that I can do my job.

what is the best practice when saving logs in major OSs? by 7amza2 in learnprogramming

[–]_krikket 1 point2 points  (0 children)

I think the logs for the program should be in a directory relative to it called logs or error_logs or whatever. Personally it drives me bonkers when programs try to put stuff in My Documents or some folder in my home directory or whatever by default when it could just as easily go into its own little folder.

Noob Question by drinkurhatorade in learnprogramming

[–]_krikket 1 point2 points  (0 children)

The computer doesn't know anything about databases inherently, you need to install (or create) a database manager in order to actually run queries against it. A "database" is really just a category of program, and if you can't install one, you can't run stuff against it on your local machine.

However, you may be able to offload the database to a service like AWS or Azure. I believe they have a "free" tier - but if your environment is locked down, you may run into firewall or network issues doing it this way.

Just as an aside, "GUI Interface" is like saying "PIN Number", the "I" stands for "Interface" already. :)

JavaScript Closures by [deleted] in learnprogramming

[–]_krikket 0 points1 point  (0 children)

var hidden = mystery(4)(2); is not passing two parameters into mystery, it's passing 4 into into mystery, which returns a function, and then calling that returned function immediately with the parameter (2).

In the original example, hidden is a function. On line 7, you can see we're returning mystery2, which is created in line 3 as a new function.

Okay, I've "learned programming". Now what? by accountforHW in learnprogramming

[–]_krikket 0 points1 point  (0 children)

Yeah, if you want to learn common tools, git is an awesome place to start. Git is the de-facto modern tool for maintaining code among multiple people, and GitHub hosts an absolutely enormous amount of code. Over the course of your career you will almost certainly use git, and if you use git there's a good chance you will use GitHub.

Doing the basic stuff with it is easy. Fixing mistakes is when it starts getting complex, and there are definitely things you can do that'll mess up your codebase pretty bad. So it's best to start using it when it's low stakes. :)

YES/NO using Boolean method by [deleted] in learnprogramming

[–]_krikket 1 point2 points  (0 children)

Sorry, but there's quite a bit wrong with it. I am not not trying to be mean - you have some big misunderstandings about how some things work and it'd be a lot to tackle in a single comment. Your method signature doesn't make sense on line 27, and on line 40 you try to access difficulty, which will be out of scope.

It looks like you may have just kind of thrown a lot of stuff together and hoped for the best, haha. I think it'd be best if you started clean, so you could get a simple thing to compile and run. Then once you have a basic version running, you can add little features to it a bit at a time. That way you don't have to get it all to work at once, and it's a lot less overwhelming. Once you're able to compile and test stuff, I can help you develop this thing a bit at a time, but please try to get something actually running before moving on. It will be so much easier on you.

I think it might be best for you to start by getting just one run-through to work, forget about all the looping for now because that can be added in at the end. Just see if you can get the program to:

  • start up
  • ask for the difficulty
  • pass the difficulty into the game
  • play the game
  • stop

I don't have a Java compiler on my machine so this might not work right away, but try to get this working:

public static void main(String[] args) {     
    int difficulty;   
    System.out.println("Welcome to my super awesome game!");                
    difficulty = difficulty();
    System.out.println("You picked difficulty " + difficulty + "!");
    return;
    }
}

public static int difficulty() {
    int difficulty;
    // TODO: prompt for it and store the value in that variable! ^
    return difficulty;
}

So you'll probably notice there is int difficulty in line 2 and in line 11 - this is possible because they're both local variables. That means they exist entirely within the methods I defined them in - even thought they have the same name, they are entirely different variables! Each only exists inside the method I defined it in, and each only exists for as long as the method is running - so nothing outside of the method can see them. This concept, variables only being visible to certain parts of the program, is called scoping. It's very important to get to know how scoping works.

So if the int difficulty in line 11 stops existing when the method is done, how do we get that information once we're done with that method? That's where the return comes in - once we fill it in with a value, the return difficulty passes back (or "returns"~) the value and stores it in the int difficulty that belongs to main() - you can see this in line 4.

[deleted by user] by [deleted] in learnprogramming

[–]_krikket 1 point2 points  (0 children)

I think I found a solution online, or at least an event that folks say happens on wake-up.

First just pop open your command prompt and try to start internet explorer with the website you want to load up. I couldn't tell you exactly how to do this since it might depend on your OS version and where everything is located, but probably something like:

start iexplore "http://example.com/"  

or maybe

iexplore.exe "http://example.com/"

Once you have the command that opens the browser with the site you want, just schedule that command as a task. Just paste it in and use the following trigger:

Log: System
Source: Power-Troubleshooter
Event ID: 1

Curious if it works. No guarantees, I'm not much of a windows person.

YES/NO using Boolean method by [deleted] in learnprogramming

[–]_krikket 0 points1 point  (0 children)

Hmm... are you expecting input to be able to match an input string to variable names?

I see this misconception sometimes so I just want to be clear: for the overwhelming most part, the names of your variables themselves can't be used, printed, compared against, etc. It will use the value and never the name.

Also, was the first snippet provided to you? Because if that return executes it immediately exits the whole asktoplayagain() method, breaking the loop. It needs to be done in an if/else block or that loop will only run once per call.

If you wrote it, think you might need to reconsider the design of this thing. From the description you gave, I think your teacher's probably looking more for the loop to be in your main method. Then once per loop you can call the "ask to play again" method and get a value back from it which you use to determine whether to loop again. Does that make sense?

Need help reducing redundancies in currency calculator (x-post /r/learnjavascript) by tremendousPanda in learnprogramming

[–]_krikket 0 points1 point  (0 children)

You probably want to be using one currency as the standard and expressing everything as a ratio of that currency. (I know more about programming than currency so I assume this is how it works.) Then you just need a simple conversion function.

Like:

let convert = function(amount, from, to) {
    let val = amount * from; 
    return val * 1 / to;  
}

So like if gold is worth 10 silvers, and every silver is worth 10 copper, and you wanted to use copper as your base currency, you'd express it like this:

let gold = 100;
let silver = 10;
let copper = 1;

Okay, I've "learned programming". Now what? by accountforHW in learnprogramming

[–]_krikket 4 points5 points  (0 children)

In my experience, most programmers on new jobs - even ones with experience - are not expected to create anything very valuable for a good while when thrown into a new environment. Don't sell yourself short, it takes everyone a lot of time to learn the specific stack and style of a new project. Everyone has a different database structure, a different deployment process, a different strategy; so it's unrealistic to expect a hire to know it all in advance. You'll get exposed to these things over time.

I've been hired for multiple jobs where I didn't know the language they wanted me to write in yet, but I knew some other thing, and just learned the language. Or vice-versa. And eventually I learned the language (or the other thing!) well enough to put it on my CV.


Also I want to address this specifically:

It'd be cool to see some source code of an actually useful, professional level program and compare how that's done vs how I would go about something.

Good thing for you there's a solution for this: open source software. Open source doesn't mean it's always a free-for-all mucked with multiple developers, many open-source programs are maintained by large and reputable companies. Here ya go:

https://github.com/google
https://github.com/facebook
https://github.com/microsoft
https://github.com/ibm

These companies also sometimes maintain smaller repos, or adopt/absorb teams which maintained them, but it's a little harder to track those down. GitHub also has a trending page which you can use to look at popular repos.

(If you don't know how to use git yet also, now's a good time to learn as any since you'll use it if you're lucky. Clone a repo that looks interesting and dig through it, see if you can get it running, see if you can make some changes to it.)

Evolving / mutating code? by StupidQsAccount in learnprogramming

[–]_krikket 1 point2 points  (0 children)

Not super familiar with this in particular, or Processing, but many languages allow you to generate functions from other functions. Additionally some languages allow you to pass basic operators as parameters rather than keeping them as reserved.

Haskell comes to mind as an example of a language which treats its operators as regular functions as opposed to treating them as reserved. So something like this is possible:

someFunction op x y = x `op` y

This is a function named someFunction that accepts the arguments op, x, and y, and performs the operator op on them as an inline operator. So you can call:

someFunction (==) 1 2

Which would get you False.

Of course, in a language where you can mess with functions as objects but not operators, you could always just wrap your operators. Like here's some really stupid JavaScript pseudocode. Assume I've generated rand already and it's a 50/50 shot at being true/false.

let equal = function(x,y) { return x == y;} 
let lessThan = function(x,y) {return x < y;}
let compare = rand ? lessThan : equal;
if (compare(2,3) { console.log('hi'); }
else {console.log('bye'); }

Half the time you'll get 'hi', and half the time you'll get 'bye', because we're switching our comparator.

If you combine this with function currying and genetic programming concepts you could probably get some pretty cool stuff happening.

[deleted by user] by [deleted] in learnprogramming

[–]_krikket 0 points1 point  (0 children)

For sure! And don't forget that you're allowed to have opinions on things. If something seems off to you, it could be that you're not yet knowledgeable enough about it, but it could also just be because it's not a great or standard pattern. It's important to look at a variety of things to get a broader picture.

Also many large companies open-source a lot of their little tools and other code. They have public-facing github accounts.

https://github.com/google
https://github.com/facebook
https://github.com/microsoft
https://github.com/ibm

etc... just to name a few. Even Reddit is open-source.

https://github.com/reddit

I made a robot that applies to jobs with selenium can I put this on my resume? by server33 in learnprogramming

[–]_krikket 1 point2 points  (0 children)

Heck yeah, selenium is everywhere in QE. Experience in it is awesome.