• Breaking News

    Wednesday, February 5, 2020

    How do modern CPUs run multiple programs at the same time? Ask Programming

    How do modern CPUs run multiple programs at the same time? Ask Programming


    How do modern CPUs run multiple programs at the same time?

    Posted: 05 Feb 2020 08:46 AM PST

    I'm currently taking a digital logic class and learning about code from the hardware side, specifically the ins and outs of how a processor receives bytes of machine code and performs calculations. This makes sense in the context of, say, old video game consoles; if I pick up a Super Mario Bros NES cartridge I know that it contains the exact CPU instructions, byte for byte, to play the entire game, plus sections of memory dedicated to storing non-code information like sprites. Unless I'm misunderstanding, when I plug in an NES the 6502 inside is just sitting there, waiting for instructions until I push in the cartridge and give it something to run.

    Likewise, if a Gameboy gets turned on without a cartridge, the only thing the CPU is doing is looping a "display logo" program. Once I put the cartridge in, that's the only thing the CPU will run, and if I yank it out, everything grinds to a halt because the processor has no more instructions. (Again, please correct me if I'm misunderstanding).

    Where I start to get confused is if I try to apply this to modern game consoles, which have an environment outside of the game itself. If I turn on an empty Wii, I get an entire menu, so clearly there's a lot of code already running on. When I push in a game disk, though, it's not like the default program just stopped running; I can hit pause at literally any moment and return to the home screen. What is the game console doing to allow itself to break into the game code at any moment, and how does it switch back and forth so easily?

    submitted by /u/int16wis8
    [link] [comments]

    Does it take longer for a program to draw a long line vs a short line?

    Posted: 05 Feb 2020 09:27 PM PST

    I'm pretty sure the answer is yes but I wanted to verify. Is it the same for thicker lines? multiple lines?

    submitted by /u/Lilac0996
    [link] [comments]

    "coding issue" with Iowa caucus app... Truth? Details? Bullshit?

    Posted: 05 Feb 2020 10:14 PM PST

    So I've seen a few pundits mention the phrase "coding issue." I know that means virtually nothing but I was curious to see if there's any details, from anyone who might know about it. TIA

    submitted by /u/9070932767
    [link] [comments]

    Why don't C compilers give warnings about converting to a smaller integer type?

    Posted: 05 Feb 2020 02:41 PM PST

    If I say, int num = x; where x is a long integer, why don't I get a compiler warning? I understand that the expected C behavior is to convert the long to an int, but I'm wondering why gcc doesn't give a warning about it, like it would for something like int num = INT_MAX + 1;

    Just curious, because I feel like a lot of mistakes could be avoided if there was some kind of compiler warning. Another example of this is the following code, it just feels like it should generate a warning but it doesn't:

    int subtract(long *a, long *b)

    {

    return *a - *b;

    }

    submitted by /u/greenpepperpasta
    [link] [comments]

    Question regarding Python List

    Posted: 05 Feb 2020 08:43 PM PST

    Hello,

    I have a problem i have stumped on, but will use a hypothetical for this situation.

    Lets say we have a 2d array:

    [['mexican_food', 'burrito], ['indian_food', 'samosa'], ['mexican_food', 'taco'], ['italian_food', 'pasta']]

    Is there anyway to traverse and reorganize the list to group it like so:

    [['mexican_food', 'burrito', 'taco'], ['indian_food', 'samosa'], ['italian_food', 'pasta']]

    Thanks!

    submitted by /u/idkwhattodoanymo
    [link] [comments]

    Information Interview Request Computer Sci

    Posted: 05 Feb 2020 04:54 PM PST

    Hi all,

    I am a college student who is preparing for a computer science career. May I conduct an informational interview with someone who has experience in computer science career?

    submitted by /u/Trying-to-Graduate
    [link] [comments]

    How could I check an array of characters if a character is present, and if it isn't, print something out?

    Posted: 05 Feb 2020 03:48 PM PST

    Hi, I've got a sort of logic question rather than a specific programming language. Im making a Hangman game, I've got the majority of it, but I've made it so that after each guess, the entire alphabet is printed. As each letter is used once, it is crossed off in the alphabet (I've managed to implement this bit). I'm struggling with implementing the bit where if the letters has already been used up, it should print a message saying this to the user. I've got something but my logic is kinda not working. This is my code for this:

    char arrAvailable[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; for (j = 0; j < 26; j++) { if (guessedLetter == arrAvailable[j]) { arrAvailable[j] = '-'; break; } else if (guessedLetter != arrAvailable[i]) { printf("Letter already used, use another one!"); break; } } 

    The first if branch works as it should, but it's the second one that is causing issues as for example if the user guesses the letter d which has already been guessed, my idea was for the loop to go through the entire of arrAvailable and then print the message if the d is not in the array (since it would've been changed to the - character after being used initially), but after stepping through it, the second if will evaluate to true in the first case already since 'd' != 'a' but i'm unsure on how to do it differently. Does anyone have any tips/suggestions/improvements?

    Appreciate any advice, thanks!

    submitted by /u/RedbullConoisseur
    [link] [comments]

    Do most professional Java developers use IntelliJ or Eclipse at work?

    Posted: 05 Feb 2020 06:31 PM PST

    I feel like this is kind of a stupid question to ask, but what IDE do most Java developer use at their work? IntelliJ or Eclipse?

    Will most jobs let you choose based on your own personal preference? Or is standard that everyone at a company uses the same IDE?

    For context, I'm a college student studying Computer Science and I prefer using IntelliJ while a majority of my class uses Eclipse (professor let us decide which one we preferred using). I've used Eclipse before and don't like it as much as IntelliJ, but If I had to use it I wouldn't mind that much.

    submitted by /u/beansoverrice
    [link] [comments]

    An efficient way of using human time. Ideas?

    Posted: 05 Feb 2020 03:55 PM PST

    Hi wonderful community of knowledge. Here is my state of situation, I'm 28 I have some knowledge about Django (webframework), Python and a bit of haskell. And I have some understanding about bootstrap, html, javascript, how http requests works. Also I have some maths understanding, as many of you surely, Discrete math, Calculus, Algebra, Logic. And here is the big question, What project can I do? Today I'm jobless, but that's OK, because I'm focused in studying. But as you can imagine I'm not 24hrs studying but here is the problem when I take a break from studying If I see tv or play video games I don't feel excited is just like: "Okay I'm tired from studying, but I don't want to see tv or play a video game". I'm with this vague idea in my head: "Ok, I'm with a computer, internet connection and now I have these new concepts from theory just open the code editor and start to....(just a blinking cursor on the screen)". Just to no make this too long, I have no idea in with personal project work. If I said, ok I will start a blog, but what content will I put in there? and a thousand of excuses to no start with something. Seems like everything is already invented, making a hover over github page is a bit discourage. But even with that I have set as goal to me in the next 8 months have at least 3 interestings projects wich ones I could say: "Ok here I applied this techniques..., or this aspect of this language..., this library it's useful for this..., I abstracted this classes in this way because...". I don't know if showing a website in the personal portfolio is still valuable or a videogame (I mention this kind of projects because it's what I found in many tutorials - courses - bootcamps online). What you think are good projects ideas?

    submitted by /u/venguiatser
    [link] [comments]

    i have a question about porting games from one engine to an other engine

    Posted: 05 Feb 2020 07:52 AM PST

    i saw a video about leaks for counter-strike source being ported from the source engine to source 2,and i heard once that valve is also thinking of doing the same with tf2,i want to know how does the whole porting thing happens?

    do they copy-paste things from one engine to the other?do they press a button and everything changes?do they redesign everything so it looks like it did in the old engine?

    i am just asking out of curiosity,i am not a programmer.

    submitted by /u/soiramio3000
    [link] [comments]

    do you know anyone that only programs using a mobile device?

    Posted: 05 Feb 2020 09:14 AM PST

    since phones have gotten so good and prevalent, i was wondering if anyone knows someone that works completely this way?

    submitted by /u/right-to-die
    [link] [comments]

    Looking for a rewarding system

    Posted: 05 Feb 2020 02:41 AM PST

    I'm working on an app where you earn points which you then can exchange for gift cards or discount vouchers. I found a website, flexawards.com, that provides an api to reward users with gift cards of numerous companies on your app/website, but it looks like those gift cards can be used only in US/Canada. Although this is exactly what i'm looking for, my app will only be available in Europe (Belgium only until it grows popularity). Does anyone know of some api's where I can reward users with vouchers or gift cards for European brands (Decathlon, krefel, leonidas...)? Or maybe have better ideas?

    submitted by /u/Tokke93
    [link] [comments]

    What is a good way to pull data from various brand smart home sensors and display it in one place?

    Posted: 05 Feb 2020 12:35 PM PST

    Looking to pull data from my power usage loggers from various appliances, temp loggers, solar panels, oil tank, and water meter and display it all in one place. How would you do this? Make a web page and aggregate data? Is there an easy solution?

    submitted by /u/Kevin11313
    [link] [comments]

    Resolve bad camera shooting

    Posted: 05 Feb 2020 10:38 AM PST

    We have a mobile app to report traffic accidents, but we have a quality issues in the taken photos because users do not shoot properly, either they use bad angle or zoom in/out incorrectly. How can we programatically guide the user while shooting cars or may be force the user to shoot properly ?

    submitted by /u/bmbsa
    [link] [comments]

    Things to consider when planning for offline/remote data sync?

    Posted: 05 Feb 2020 10:16 AM PST

    You can't handle the truth!

    That's the client talking to the remote. I don't know who to trust. Consider you have the same data client(A) and remote(B).

    Then A has less data than B so you think to delete stuff on B to match A.

    But if A is completely empty would it empty the remote side. I guess in this case you'd assume client is new/needs to pull all content down.

    These are the thoughts I'm looking for opinions on.

    Also do you actually delete or just mark as deleted.

    submitted by /u/ie11_is_my_fetish
    [link] [comments]

    Graphics in C

    Posted: 05 Feb 2020 09:56 AM PST

    Hello,

    Need help on how I can achieve to put more shapes in this code.

    When executed, I would like to have random shapes different colors. (C code)

    After it being executed I copy the html output and then open it on my browser to show the shapes.

    #include <stdio.h> #include <stdlib.h> #include <time.h> void circle ( int cx, int cy, int r, char* color ) { printf ( "\t<circle cx='%d' cy='%d' r='%d' fill='%s' />\n", cx, cy, r, color) ; } void line ( float x1, float y1, float x2, float y2, char* stroke ) { printf ( "<line x1='%f' y1='%f' x2='%f' y2='%f' style='%s' />\n", x1, y1, x2, y2, stroke ) ; } void rect ( int x, int y, int width, int height, char* color ) { printf ( "<rect x=%d y=%d width='%d' height='%d' style = 'fill:%s;stroke-width:3;stroke:rgb(0,0,0)'/>\n", x, y, width, height, color ) ; } void beginHtmlSVG ( int wide, int high, char* backColor) { printf ( "<!DOCTYPE html>\n" ) ; printf ( "<html>\n" ) ; printf ( "<body>\n" ) ; printf( "<svg height='%d' width='%d' style='stroke-width: 0px; background-color: %s;'>\n", high, wide, backColor ) ; } void endHtmlSVG ( ) { printf( "</svg>\n") ; printf ( "</body>\n" ) ; printf ( "</html>\n" ) ; } char* getRGBColor ( int red, int green, int blue ) { static char* svgFillString = "rgb(%d, %d, %d)" ; static char result[100] = { 0 } ; sprintf( result, svgFillString, red, green, blue ) ; return result ; } int main ( ) { srand( time ( NULL ) ) ; beginHtmlSVG ( 1000, 1000, getRGBColor( 100, 0, 100 ) ) ; int x = ( rand ( ) % 300 ) + 200 ; int y = ( rand ( ) % 300 ) + 100 ; int size = ( rand ( ) % 150 ) + 10 ; int red = rand( ) % 255 ; int blue = rand( ) % 255 ; int green = rand ( ) % 255 ; circle ( x, y, size, getRGBColor( red, green, blue ) ) ; endHtmlSVG ( ) ; return 0 ; } 
    submitted by /u/jorge407
    [link] [comments]

    Calculating population average BMI with R

    Posted: 05 Feb 2020 09:50 AM PST

    Simulate 100 observations of height, which follows the normal distribution with parameter values μ=170 and σ=8 and the same amount of weight observations with parameters μ=70 and σ=5 . Calculate the average of BMI. The average can be obtained with the function mean() and the formula for BMI is

    weight kg/ height2 m .

    Note that the observations of height are in centimetres but the formula for BMI uses metres.

    Can't figure it out. I came up with something like:

    height <- rnorm(100, mean = 170, sd = 8)

    weight <- rnorm(100, mean = 70, sd = 5)

    BMI <- sum(weight)/(sum(height)/100)2

    mean(BMI)

    but it's not quite right. Would appreciate if someone could help.

    submitted by /u/mathnoob12345
    [link] [comments]

    What are good "coding challenge" websites for getting interviews and finding the "right fit"?

    Posted: 05 Feb 2020 05:58 AM PST

    What sites are good for established engineers looking for a job transitions?

    I'm looking for a change of pace that works with my working schedule. I went through two on-site interviews and the time off, although limited, has created friction at my current job.

    submitted by /u/Neotelos
    [link] [comments]

    Why not visual programming languages?

    Posted: 05 Feb 2020 09:32 AM PST

    Everyone is familiar with Scratch, the "programming language" that is the butt of many jokes in r/ProgammerHumor. However, isn't there something to be said for fully featured graphical programming environments? Text editing in c++ is all fine in good, but I feel as though I'll get RSI from the amount of times I've typed out a for loop or if statement. I also get that macros and auto complete functions exist, but are those really better than something that is ready to go, and easily identified by sight, such as an element within a VPL? Take a look at how many people on r/unixporn have powerline for their terminal and tell me people don't like a bit of graphics. Maybe a compromise would be something in between, being text driven, but also having some visual flair that makes constructs easily distinguishable.

    submitted by /u/SirBrian_
    [link] [comments]

    How do I lock computer programme?

    Posted: 05 Feb 2020 03:23 PM PST

    I find myself unnecessarily addicted to a computer game. It's really eating up my life.

    Is there a programme where I can lock it up and only access it in a timed limit?

    E.g. 8 hours on weekends and only 2 hours on weekdays

    submitted by /u/yourfoodiate
    [link] [comments]

    What are some fun things to do with free REST APIs?

    Posted: 05 Feb 2020 09:09 AM PST

    Very broad question I know. I am keeping it open-ended to not steer it to any specific kind of API. Hobby/random neat portfolio item.

    submitted by /u/tyrannosauru
    [link] [comments]

    Best practice regarding repeat use of for() loops

    Posted: 05 Feb 2020 08:54 AM PST

    A friend of mine warned that my us of multiple for loops is inefficient and that I should refactor any loops I can down into a single loop, and I'm wondering how important this is. For example, I have some code that runs a basic (for i=0;i<n;++), and then runs 3 more for loops to manipulate the information generated by the first one. I can see how logically I can use variables to jam it all into one loop, but am I actually gaining anything by doing so? As a programmer, would you rather see several loops that are easy to read or one long loop that has to be deciphered to understand how it works?

    submitted by /u/micahld
    [link] [comments]

    I need advice on learning languages. I'm a little unsure of the direction I'm taking and I don't want to waste time learning stuff that's just not worth it.

    Posted: 05 Feb 2020 08:23 AM PST

    I guess what I'm asking depends a lot on what are my goals. I do know what I want and where I want to be.

    To begin, this isn't about money for the most part although I do have some money related goals for this, but I'm not heading towards that just for the money.

    Anyway, this is a short description of what I like and my goals:

    First, I want to open a business, pretty much everything I do has some relation to that. Learning languages is part of that, I want to use that to create my business.

    Second, I'm a huge fan of finance, and I'm learning more about it as I go. I love markets and investing in general.

    Third, I'm also into math, whatever I do with that business I mentioned, I want it to be related to math. I'm a fan of applied mathematics.

    Fourth, I like automation a lot, half of the programming projects I come up with are related to automating things. I've taken the initiative at my job to automate stuff, I created the company's chatbot, I'm automating their testing processes, their CI/CD and their package distribution. That said, I don't like DevOps, that bores me. I like creating apps that automate stuff.

    Finally, the languages I'm into the most are Python(do this at work), Rust, and Elixir. I'm still learning Rust, which for the most part takes a lot of effort, I've spent 1+ years learning about it. Elixir is simpler, surprisingly after having spent so much time beating my head against the wall with FP things have magically gone right and "getting" the language hasn't been all that tough.

    Now here's where it gets dicey. I've considered learning C#, there's a personal app I want to build to automate food choices throughout the week. I've considered doing it on C#. I'm worried that I'm trying to learn too much stuff, and I'm not sure whether I want to learn C#. I think the biggest motivation I have to use C# is because of jobs. I actually don't dislike the language, .NET core is pretty cool and I definitely like it more than Java. I think it also has a more stable ecosystem than Rust or Elixir do, otherwise I'd just do that app in those languages.

    What I'm trying to ask here is this: Should I just go with what I like or should I consider other enterprisey languages like C# and Java?

    Historically, things don't go very well for me in that world, I know that those languages are subject to whatever you'd like to do with them, but I often feel that they hold your hand too much and that you can't learn as much. That's just my biased opinion, however.

    Anyway, if someone could give me some advice. I'd appreciate it.

    submitted by /u/Braxis89
    [link] [comments]

    [HTML JS CSS] Less image assets, but displayed multiple times VS more assets, but displayed once? Effects of each scenario on hardware?

    Posted: 05 Feb 2020 08:01 AM PST

    Hello!

    I have a theoretical question. What would the effects be of:

    1. Generating 100 icons via 16 pictures (for each of the 4 layers of which an icon consists, we have 3 different versions. This gives probably about 81 possible permutations) VS

    2. Showing 100 icon assets - 81 different unique unlayered pictures, and 19 duplicates

    I suspect the first one would eat up 3x as much CPU, and the second one would eat up 6x as much RAM. But I have no idea, so I am asking you. I feel like the second option is more fool-proof, and RAM is free real-estate, compared to CPU, no?

    Please advise!

    PS: PNG vs SVG?

    submitted by /u/awwwes
    [link] [comments]

    decade after Node.js was first announced, JavaScript and the web platform have evolved, and TypeScript has changed the way JS applications are developed. Deno is a new JavaScript/TypeScript runtime that was designed with all those new capabilities in mind.

    Posted: 05 Feb 2020 07:48 AM PST

    No comments:

    Post a Comment