• Breaking News

    Wednesday, March 6, 2019

    Why do all the newer programming languages put the type specifier after a declaration? Ask Programming

    Why do all the newer programming languages put the type specifier after a declaration? Ask Programming


    Why do all the newer programming languages put the type specifier after a declaration?

    Posted: 06 Mar 2019 06:27 PM PST

    Newer Languages

    Kotlin:

    val number : Int = 1 fun getInt() : Int { return 1 } 

    Swift:

    let number : Int32 = 1 func getInt() -> Int32 { return 1 } 

    Rust:

    let number : i32 = 1; fn getInt() -> i32 { return 1; } 

    Older Languages

    C/C++/Java/C#:

    int number = 1; int getInt(){ return 1; } 

    Is there a reason why we switched the order in all the newer languages? I can't think of any advantages this offers. On top of this, I think this syntax is more confusing since we put the variable name in between information about the variable.

    If anything, the older syntax makes more sense. const int number = 1; in C++ gives us information about number before telling us its name, as opposed to let number : i32 = 1 in Rust where the name is sandwiched between information about the field.

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

    Newbie seeking the opinions of juniors/seniors

    Posted: 06 Mar 2019 04:02 PM PST

    Let me start this off by saying I'm not necessarily asking for advice, but rather your input/opinion. Recently, I got the itch to learn how to program and switch careers. There seems to be something in the air that this has started to kick up into the mainstream. I'm only about 6 weeks into my journey and I have noticed a few things right off the bat. These are some thoughts I have, just curious on your experience as well.

    The various languages and framworks seem to carry the same concepts? What I mean is that if I have a problem, and I need to solve that problem most concepts are similar in their approach to solving that problem but the syntax is different. I hope that made sense.

    And I feel about a week ago I started to get it, the idea of programming and thinking like a programmer. The first two weeks I was stuck in this mindset of what language should I learn, what courses are the best and all that junk. I narrowed down more specifically to the job I am interested in and that changed everything. And recently, I can look at code and seem to understand what I am trying to achieve. Does this continue to grow?

    Also - at what point do I need to start creating and move on from courses? I am fairly quick at learning, and sitting for long hours isn't an issue. But I am a believer of sink or swim, so is this question and bit more subjective towards what I am seeking to build?

    Anyways - wanted to start a dialogue for my own journey and others. Looking to create a database of knowledge.

    Thanks,

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

    How Did You Start Learning Programming?

    Posted: 06 Mar 2019 08:16 PM PST

    Hello everyone,

    I am a current philosophy major at ucla and I'm set to graduate this coming spring. I have tried learning programing about a year ago through code academy, but I found that it was hard to apply what I was learning or to really understand what it was that I was doing. I'm currently taking a course on the computational theory of the mind, and it rekindled my desire to learn programming. I have no intention on becoming a lawyer anymore and I would love to be able to learn C++ and work on software development. I wanted to know how you all got started in programming, as well as your thoughts on what my best course of action should be. I just hope you guys don't think it's too late of me, any advice is greatly apperciated!

    TL/DR: How did you get started in programming and what do you think is the best way for a noob to get started?

    submitted by /u/F-18Afterburner
    [link] [comments]

    Trying to make a bot- where do I start?

    Posted: 06 Mar 2019 05:34 PM PST

    Hi, I have a degree in computer science so I'm happy to learn to pick up new languages, just not sure where to start, so I'm looking for advice!

    What I want to accomplish: I run a browser-based meme generator app, I'm trying to make a bot that runs in the background on my computer, curling (specified) subreddits for images. The bot will take those images identified as meme templates, and generate the text HTML for a pending post to my Wordpress site, it will submit that post to my Wordpress site, and I can manually look through and approve different posts.

    Bonus: I would also like to submit new URL's to Fetch as Google for it to crawl.

    Any idea where I should start?

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

    When engineers talk about scale in web applications are they talking about the number of users or are they talking about the size/complexity of the app

    Posted: 06 Mar 2019 06:25 AM PST

    If a tiny app with 100lines of code is used by millions of people does that mean it was scaled big?

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

    Questions regarding graphics programming

    Posted: 06 Mar 2019 10:18 PM PST

    Heya!

    I'm a mechatronics student who has a little project on his hands. I'm planning to make a small game like system with an arduino, pc and a monitor in it. I have little experience when it comes to programming(c and c++ only)but I have an eagerness to learn more and I have some buddies who can help me out with that as well.

    The monitor should display a leaderboard when on standby mode and when used it swaps to another screen, where player's progress is compared to the best result + remaining time.

    How to pull off the display side of the project? What language should I use to get a neat, simple look on the display and at the same time communicates with the arduino.

    Can I pull this off with html, css and js? Perhaps it would be better to use rasperry bi instead? What are your recommendations?

    Thank you in advance! :)

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

    What do I do when I feel so incompetent and stupid?

    Posted: 06 Mar 2019 06:17 PM PST

    I graduated from my local coding bootcamp six days ago. Now, I'm just preparing for interviews. Throughout the bootcamp, we've been working mostly on our stack, rather than the computer science-heavy stuff, like Big O. I've just been at home for the past week studying up on algorithms and data structures, and boy do I feel SO stupid. I literally can't do most of these problems without relying on the solutions. I just feel so stupid. I don't know if I'm cut out for this thing anymore... I mean, Jesus Christ, some of these people come up with the most creative solutions, let alone having solutions at all. It's crazy. I could spend five hours on a problem and still be stuck. I Just don't know how to study all of this. If anybody has any tips on how I could study this stuff, I'd be extremely grateful.

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

    Is it common for developers to use their own OS while working for a company?

    Posted: 06 Mar 2019 09:28 PM PST

    I have never worked as a developer before, but am going to be entering the job market soon.

    I use Arch Linux as my main OS and I was wondering whether most companies would allow me to install it on the computer they provide for me (if they do)

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

    Fastest way I can make a chess application, online or mobile?

    Posted: 06 Mar 2019 09:27 PM PST

    I need to make a chess program for a school project. The way I do this does not matter. The software part is not even graded, but I need to build a fully functioning chess application like:

    https://www.chess.com/

    without AI and without online capability. This is so I can add an interface to a hardware part of my project (I'm building a smart chess board for a senior design project if any of you are interested). Currently, I believe that the fastest way is to use python chess: https://python-chess.readthedocs.io/en/v0.2.0/

    as the back end (for valid move detection, checkmate, etc) and use pygame:

    https://www.pygame.org/news

    to display everything visually. Any faster way you guys can think of for creating this?

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

    Python help: please help or refer to friend

    Posted: 06 Mar 2019 08:53 PM PST

    HTML/CSS How to make content load into the "body" when clicking a link in the header?

    Posted: 06 Mar 2019 08:03 PM PST

    I have a header finished, and now i want the buttons/links in the header to load content to the empty page below it, not link to a whole new page.

    I have a very simple html and css code written and i think there should be an easy way to do this, i just cant find a sollution.

    Its pretty much this https://www.w3schools.com/css/css_navbar.asp, just they dont show the next step.

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

    Is there a simple solution for making WAV files directly from table data? (Or any other standard sound format)

    Posted: 06 Mar 2019 03:51 PM PST

    Let's say I have 441,000 table entries. I want to write them into a 10 second long 44,100 Hz WAV file.

    Or whatever is the appropriate number of samples needed...I assume 44,100 Hz because that is in the file specs for many wavs. Might be more or less etc...

    So let's say I have the right number of data points to make a 10 second file. And I have the appropriate range of values...-x to x (whatever the actual specs are). Is there a way to compile them directly into a WAV or any other standard audio format????

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

    (C++)

    Posted: 06 Mar 2019 01:25 PM PST

    good afternoon,

    im having problems with the Extra Credit part

    question : Write a program that reads two times in military format (0900, 1730) and prints the number of hours and minutes between the two times. Here is a sample run.

    Please enter the first time: 0900

    Please enter the second time: 1730

    Output 8 hours 30 minutes

    Extra credit if you can deal with the case where the first time is later than the second:

    Please enter the first time: 1730

    Please enter the second time: 0900 15 hours 30 minutes

    here is what i have

    // ConsoleApplication5.cpp : Defines the entry point for the console application. // #include "pch.h" #include "string" #include <iostream> using namespace std; int main() { int time_1; int time_2; int differance; int differance_in_mn; int differance_in_hr; //int t1_in_hr; //int t1_in_mn; //int t2_in_hr; //int t2_in_mn; cout << "Enter the first time" << endl; cin >> time_1; cout << "Enter the second time" << endl; cin >> time_2; if (time_1 > time_2) differance = (2000 - time_1) - time_2; else differance = time_2 - time_1; differance_in_mn = differance % 100; differance_in_hr = differance / 100; cout << "The time differnce is " << differance_in_hr << " hr " << "and " << differance_in_mn << " minutes" << endl; cin; system("pause"); return 0; } 

    thanks for the help

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

    Bison: rule useless in parser due to conflicts

    Posted: 06 Mar 2019 12:33 PM PST

    I'm creating a parser for my programming language with Bison. I have kind of finished writing the parser.

    This is the Yacc/Bison file "parser.y": https://paste.ubuntu.com/p/ySCXJF4G5C/

    But some warnings, when I run bison parser.y -d, say: https://paste.ubuntu.com/p/vMCmFyKCp6/

    Why is that?

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

    "Reverse email verification" is this a good idea?

    Posted: 06 Mar 2019 12:22 PM PST

    So my app is almost done, but still working on it. Not long ago, I tested registration but with a fake e-mail. Apparently with my provider I tip off spam detection, and the account got disabled (for getting too many bounce backs). Seems that they may be OK with automated e-mails (as long as they aren't mass marketing), but I get the feeling this will keep happening (no workaround). Got me thinking: Change providers? Host my own email server?

    What about doing it in the opposite way:

    This mailbox would be monitored by the automated system. I'm not sure if this exists or what it would be called, but I've never seen it. Is this a good or bad idea? Perhaps it would be more vulnerable to spoofing?

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

    Help i have a python assignment but havent been taught python

    Posted: 06 Mar 2019 11:52 AM PST

    Edit: thanks for the help I've done a test run on my pc and it's working well

    Hi, I've recently picked up computer science and have immediately got a national 5 (GCSE level) assignment worth 40% of my over all grade

    The assignment is to make a username generator using the first three letters that the the user inputs and then adding on 1 of 5 endings randomly. If someone could help me I'd really appreciate it however I understand if no one does, Thank you

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

    A question about approaches to writing automated tests for my Master's thesis

    Posted: 06 Mar 2019 11:46 AM PST

    Hi!

    I'm a Master's degree student in Computer Science and I would like to ask you a question regarding my Master thesis.

    As you know, test automation is strictly connected to the costs of learning how to automate tests and the costs of maintaining them later. In case of companies (especially smaller ones) that are considering automating tests of their product, there is a dilemma: should they try the "quick and dirty" approach, or should they invest some time and resources and automate their test suite in the "recommended" way.

    In my thesis, I would like to compare such two approaches in the context of the ease of maintaining them. I would like to write some tests for a web application and track necessary changes in the tests that were needed while running them for a few releases of the application for those two approaches. I hope that the results will be a recommendation based on specific examples and measurements.

    Here is my question to you guys. From your own experience, if you had the following context: web application, rather based on page reloads (small amounts of JavaScript and AJAX), what would, in your opinion, be the two approaches to automating GUI tests run in a browser (e.g. Chrome or Firefox):

    A) "Quick and dirty" - if someone asked you how to cheap and quickly automate their test suite, what would you say?

    B) "Recommended" way - in your opinion, how should it be done "professionally" (but not to over-engineer it)?

    I would like the choice of the two approaches to be depicting a real dilemma that a company could face.

    By approach, I mean methods of creating tests (e.g. Capture & Replay, programming), the organization of the tests (linear scripting, keyword-driven, data-driven, etc.), usage the design patterns like Page Object or even specific tools.

    Thank you guys for the help, I will really appreciate any feedback given on the topic!

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

    Storing emails to be searchable in an Azure environment

    Posted: 06 Mar 2019 05:39 AM PST

    I work for a company who is all in on Azure, and I have a side project that I'm working on where we get emails from a vendor warning of fraudsters doing something unusual or the details of one that got caught by someone else.

    The emails come in with no attachments and an HTML body with a specific format.

    Where's a good place to stash them so they can be text searchable? I'm thinking of shoving them into CosmosDB or should I just shove them into a nvarchar(max) column in SQL Server or is there a better/more nifty solution for this?

    The email size is maybe a printed page, there's a few thousand of them, and we get maybe 10 a week.

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

    Algorithm for probability-tree of sorts

    Posted: 06 Mar 2019 02:26 AM PST

    I've designed a simple cardgame for two players, taking turns choosing cards for attacking and defending. Outcomes are based on card-type and role on the battle (attack or defending). SOm cards cannot attack, only defend. A tie leads to the attacker leaving the card open as a defend-only possibility onwards, and such.

    Anywho...

    I'm trying to programmatically determine if the game is balanced sensibly, both in card types and in winning conditions, or it should be adjusted. As in, would a certain first move determine the game totally? Is there a obvious winning strategy?

    Since it's only a small set of cards, six (one of which is a duplicate), I think it's realistic to simulate all the outcomes and calculate the probability of winning from each particular mid-set of hands. But I can't crack the code for implementing a good algorithm.

    Let's examplify/simplify: each hand is 1,2,3 as a start, higher always beats lower, except 1 can't attack, only defend, and it will kill a 3 attacking it. This would be like rock-paper-scissors. Except losing your 3 means loosing the game. A tie does nothing, it's just a failed attempt.

    Would I start with the full hands, recursively calculating a tree of alternating turns? Or is there a way to consider a base case of hands leading to a certain win for player 1, and recursively create a tree 'backwards' of possible hands leading to that moment?

    Or what?

    I'm trying to do it with Python, while learning Python, because I'm using Python for selenium automation and testing on the job, but these requires just a minimum of coding.

    Any pseudo-code will work for me, though.

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

    What do you do to keep engaged when things slow down at work?

    Posted: 06 Mar 2019 10:51 AM PST

    I work for a Fortune 500 company. I gravitate towards towards programming jobs for larger companies now since the pay is reliable and the level of stress tends to be much lower than people in small companies or startups.

    I love programming and couldn't see myself doing anything else long-term, as a career, but there are times at my job where there's not a whole lot of work and I have to find things to work on in my downtime. I work a desk job and am expected to be at the office 40 hours a week. Feel like I spend maybe 6 hours a week really programming and the rest biding my time or trying to find things to work on.

    At this point, I've kind of developed all my best ideas and side projects and have trouble staying engaged in continuing to work on side projects and find myself wandering on Reddit or other sites because I don't feel like I have anything that I REALLY want to learn on the side or build (having an idea I've been sitting on has always been a good motivation for me to learn a new technology).

    So my main question is: what do you do to stay engaged with programming when your job has either gotten boring or you're in a slow period where you're waiting for more work to come down the pipeline? Obviously, this is more directed at people that have been in the industry for awhile because those are the people that i'm sure have struggled with this same thing and have some good insight, but any feedback is appreciated.

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

    program outputs exit phrase instead of words stored in C.

    Posted: 06 Mar 2019 10:20 AM PST

    So I was working on an assignment for school, and had written up a variation of this code:

    #include <stdio.h> #include <ctype.h> #include <string.h> #define MAX 100 // This program takes an input of strings and prints them out with a new line separating each one. int main() { char *WordArray[MAX]; //initializing variables int i = 0; int count = 0; printf("enter up to 100 words, that are 20 characters maximum \n"); for (i = 0; i <100; i++){ //runs while there's less than 100 inputs char Array[1]; scanf("%s",Array); //stores string in the array if (strcmp(Array, "STOP") == 0) { //compares the string with stop, and if it is, it breaks out of the loop break; } WordArray[i]=Array; //stores the string in the pointer array } printf("The output is\n"); for (count = 0; count<i; count++){ //counts up to the amount of words stored printf("%s\n",WordArray[count]); //outputs each pointer string } } 

    and I noticed that the output was printing "STOP" instead of the values stored. Anyone have any answers to why and/or how to fix it? I know one of the methods is to switch to a 2D array instead of using pointers, but I'm still baffled as to why a program like this wouldn't work.

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

    Good (free) APIs to develop against?

    Posted: 06 Mar 2019 09:56 AM PST

    I want to learn some new front end tools (React mainly) and create some portfolio pieces along the way. But I don't want to spend time building the back end. Good APIs would also help with idea generation. What are some APIs out there you'd suggest for inspiration and fun that are free for hobby-level access?

    I know about PokéAPI and StarWars API and CoinMarketCap. What else could be good?

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

    is_even algorithm

    Posted: 06 Mar 2019 09:41 AM PST

    I learned in college and highschool that the correct way to assess evenness is to do % 2, but wouldn't it be cheaper to assess oddness using this & 1?

    For example

    bool is_even(int a) { return a % 2; }

    bool is_odd(int a) { return a & 1; }

    Because the way modules is implemented is pretty much a mod n = a - (n * Floor(a/n)) which seems to me like more work than a simple bitwise and.

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

    Help, i have a project due in Monday and i can’t make the button in this code turn the circuit off

    Posted: 06 Mar 2019 09:27 AM PST

    https://imgur.com/a/7zk7wD1 Here's the code, I will love you forever if you help

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

    Seeking your feedback for an idea I'm working on.

    Posted: 06 Mar 2019 09:23 AM PST

    As programmers, we all know the feeling of being "in the zone". Those moments when you feel unstoppable and nothing else matters. I've been a developer for 10 years now, and I found that in the last couple of years, getting in the right mind is becoming harder and harder

    I tried to pinpoint on what might be the reason and discovered that often time, my focus is shifted away from the code because I need to do many different little things like:

    • Copy/paste trivial code/snippets from Stack Overflow (like generate random number in JS, I can't seem to ever remember the syntax)

    • While waiting for long running tasks (like server provision or npm install), I find myself browsing Reddit/Hacker News for waaaaay too long.

    • Spell checking: I usually open chrome, type a word in the search bar and copy the suggested result.

    • Finding a color hex: I'm using the Mac Digital Color Meter which often is janky and only gives RGB

    • Calculating timezones

    • All sorts of data encoding/decoding/formatting using online tools

    • Debugging regex

    • ... and many more

    Now, these are all essential tasks for my work, but they feel rather inefficient, destructing, and time-consuming.

    I'm thinking of building a little tool that lives in the menu bar and helps automate all that stuff with a few keystrokes without losing focus and without the need to open the browser. Kinda like Alfred for Mac, but made for developers. I think this will save a bunch of time and memory with so many open browser tabs.

    So.. Am I a unique snowflake or does anyone else have similar productivity issues like these?

    Looking forward to hearing your thoughts. Thanks!

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

    No comments:

    Post a Comment