u/RevanProdigalKnight - 116 Archived Voat Posts in v/programming
u/RevanProdigalKnight
  • home
  • search

u/RevanProdigalKnight

1 post · 115 comments · 116 total

Active in: v/programming (116)

  • ‹‹‹
  • ‹‹
  • ‹
  • 1
  • 2
  • ›
  • ››
  • ›››
Comment on: Dynamic Typing vs. Static Typing

I was trying to learn it for a class where we were forbidden from using an IDE. I ended up resorting to poor man's debugging instead.

0 23 Jul 2019 12:09 u/RevanProdigalKnight in v/programming
Comment on: Dynamic Typing vs. Static Typing

I tried to learn to use gdb. I failed.

Thankfully, there are other debuggers available for C and C++ that I have learned.

0 23 Jul 2019 04:18 u/RevanProdigalKnight in v/programming
Comment on: [Javascript] Project Euler #2 (and print answer) in as few characters as possible

I'm a few days weeks late to the party, but you can actually accomplish the same in fewer characters.

First, in your current solution, the c variable is completely unused, so it can be stripped.

Result:

for(s=0,i=0,j=1;;i=j,j=x){x=i+j;if(x<4000000){if(x%2===0){s+=x}}else{console.log(s);break;}}

That strips (4 + 9 + 4) = 17 characters from the solution without affecting the output. But we can still do better.

4000000 === 4e6, which strips a further 4 characters.

for(s=0,i=0,j=1;;i=j,j=x){x=i+j;if(x<4e6){if(x%2===0){s+=x}}else{console.log(s);break;}}

So far we're down 21 characters, but there's still more we can strip. In JS, we can replace if statements with truthy conditions using &&. Now, we can't replace the outer if/else block with this, and a ternary causes a syntax error, but the inner if statement can be replaced. Unfortunately, x%2===0&&s+=x also causes a ReferenceError to be thrown, because the left hand side of that statement is evaluated as x%2==0&&s. This means we must wrap s+=x in parentheses, and we have saved no characters. Fortunately, an if statements with a falsy condition can be replaced with ||, which allows the much shorter overall syntax of x%2||(s+=x). This saves us another 6 characters.

for(s=0,i=0,j=1;;i=j,j=x){x=i+j;if(x<4e6){x%2||(s+=x)}else{console.log(s);break;}}

With the new inner statement, we can also omit the curly braces and simply separate the if and the else with a semicolon, which saves us one more character, and we can also omit the semicolon after the break statement at the end for one last character. This brings us to a total savings of 29 characters, resulting in the final solution of:

for(s=0,i=0,j=1;;i=j,j=x){x=i+j;if(x<4e6)x%2||(s+=x);else{console.log(s);break}}
0 20 May 2019 03:46 u/RevanProdigalKnight in v/programming
Comment on: [Python] Project Euler #1 without looping over 1000 numbers

Equivalent JS code that I used to figure out the method beforehand (because my Python is a bit rusty):

function euler_1() {
  const multiples = new Set()
  let t;
  let i =0;
  while ((t = 3 * ++i) < 1000) {
    multiples.add(t)
    if ((t = 5 * i) < 1000) {
      multiples.add(t)
    }
  }
  console.log(`Found ${multiples.size} total multiples in ${i} iterations.`);
  console.log('Sum:', [...multiples].reduce((acc, n) => acc + n, 0));
}
0 04 May 2019 04:34 u/RevanProdigalKnight in v/programming
Comment on: [Python] Project Euler #1 without looping over 1000 numbers

Your euler function could still be made more deterministic and shorter than it is.

def euler_1():
    multiples = []
    counter = 1
    while True:
        t = 3 * counter
        if t < 1000:
            if t not in multiples:
                multiples.append(t)
            t = 5 * counter
            if t < 1000:
                multiples.append(t)
            counter += 1
        else:
            break
    print("Found {} total multiples.".format(len(multiples)))
    print("Sum: {}".format(sum(multiples)))

This finds the same answer in only 334 iterations

0 04 May 2019 04:31 u/RevanProdigalKnight in v/programming
Comment on: Learning JS a few questions.

Every version of JavaScript builds on the previous versions, so if you learn ES6 you'll still be able to read and understand the vast majority of ES5 code. There were a few tricks in ES5 to make "classes" that don't make a lot of sense if you start with ES6, but so long as you never have to work on a codebase solely developed in ES5, that shouldn't be a problem.

JavaScript is a prototypical language, meaning that it's duck-typed (if it looks like a duck and sounds like a duck, it is a duck). You can assign any object the prototype of another object and suddenly it is the same type as the other object. With ES6 classes, it looks more like an Object-Oriented language, but it is still a prototypical language under the covers. A big reason that JavaScript has become as popular as it is is because of its support for non-Object Oriented programming paradigms, such as passing functions as arguments to other functions. It has become a popular bed for a sort of "modern Renaissance" into Functional programming paradigms, such as data immutability and pure functions.

As far as learning JavaScript goes, one of the best places to start is on the web. Just search for JavaScript tutorials, there are thousands (millions?) of them.

Really, JavaScript is a good language to start with primarily because you can learn any programming paradigm (Object-Oriented, Functional, etc.) when using it. You're not coerced into any of them, because there is no compiler to enforce a pattern.

0 29 Aug 2018 12:42 u/RevanProdigalKnight in v/programming
Comment on: Your job as a developer is to make code that makes lives of the users easy. That is your primary goal.

You make a fair point. Maybe the optimum solution is somewhere in the middle, e.g.:

const pad = v => v < 10 ? `0${v}` : v;
const _formatDate = (
  year, 
  month, 
  date, 
  hour, 
  minute, 
  second
) => `${year}-${pad(month)}-${pad(date)} ${pad(hour)}:${pad(minute)}:${pad(second)}`;
const formatDate = date => _formatDate(
  date.getUTCFullYear(),
  // etc. 
) ;
0 15 Jun 2018 20:29 u/RevanProdigalKnight in v/programming
Comment on: Your job as a developer is to make code that makes lives of the users easy. That is your primary goal.

You replaced date.getUTCSeconds() at the end of the line with date.getUTCMilliSeconds(), which is not only the desired function, but is the wrong name, the real function being date.getUTCMilliseconds().

That wasn't difficult to spot. All I had to do was scroll along the line, which is the one unfortunate part about template strings in JavaScript - they can't be broken up into multiple lines without inserting multiple lines into the output. That said, unit tests would have failed long before it ever got to production.

0 15 Jun 2018 04:14 u/RevanProdigalKnight in v/programming
Comment on: Your job as a developer is to make code that makes lives of the users easy. That is your primary goal.

Just the a few days ago one of my coworkers asked me to consider refactoring the following JavaScript code:

const pad = n => n < 10 ? `0${n}` : n;
const formatDate = date => `${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())} ${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}:${pad(date.getUTCSeconds())}`

It takes a date and formats it into UTC YYYY-MM-DD HH:mm:ss using two single-line functions. Simple, right?

His rationale was (paraphrased):

This doesn't look like it would be easy to maintain moving forwards. You should consider using Moment.js to format this instead.

My first reaction was "How is this not easy to maintain?", followed shortly by "Why add all of Moment.js for one date formatting operation?" and finally "No, this is a stupid suggestion."

0 14 Jun 2018 05:52 u/RevanProdigalKnight in v/programming
Comment on: Your job as a developer is to make code that makes lives of the users easy. That is your primary goal.

Don't forget little Bobby Tables: ROBERT'); DROP TABLE Students;--

0 14 Jun 2018 05:43 u/RevanProdigalKnight in v/programming
Comment on: Stop using these giant single liners

Tell that to the Java developers who make function names that are entire sentences by themselves.

0 10 Jun 2018 02:28 u/RevanProdigalKnight in v/programming
Comment on: C/C++ inc/decrement operator style

Just in case you didn't already know, there is actually a difference between counter++ and ++counter, as the first increments after reading the value and the second before reading the value, e.g.:

```js int counter = 0;

printf("%d\n", counter++); // 0 printf("%d\n", ++counter); // 2 ```

Most people use counter++ because of this behavior being closer to the logical alternative of counter += 1.

0 10 Jun 2018 02:25 u/RevanProdigalKnight in v/programming
Comment on: Reasons why you should delete your GitHub account

roznak, you make good contributions usually, but I've got to call a spade a spade: this is nothing but blatant fear mongering. If Microsoft tried this the git commit history for any project would serve as the proof that Microsoft stole the code, because the patent would always come after the commit.

0 05 Jun 2018 21:28 u/RevanProdigalKnight in v/programming
Comment on: Forcing women into programming is a fucking mistake

PascalCase for class names, camelCase for method names.

0 18 May 2018 03:39 u/RevanProdigalKnight in v/programming
Comment on: Feeling like I'm lacking theory

From my experience, most of what you think you're lacking right now you'll learn over the next two years, then anything that misses will be covered by your first few years out of college. It's also important to remember that your college education is supposed to give you the building blocks to succeed in your professional life, and won't necessarily teach you everything there is to know about a given subject. A great college will teach you to always be curious and have a drive to always learn more.

Personally for me, a lot of the concepts I learned in my CS degree came together when I took a compilers course my last semester.

0 30 Apr 2018 01:24 u/RevanProdigalKnight in v/programming
Comment on: Linus Torvalds - "That is either genius, or a seriously diseased mind."

I think it also depends on which compiler you use. For example, I'm pretty sure GCC/G++ allows this unconditionally, whereas I think Clang/LLVM doesn't (depending on which revision of C/C++ you're using).

0 31 Mar 2018 07:05 u/RevanProdigalKnight in v/programming
Comment on: Linus Torvalds - "That is either genius, or a seriously diseased mind."

#define private public ftw

0 30 Mar 2018 04:52 u/RevanProdigalKnight in v/programming
Comment on: (((active users)))

For forcing integer conversions (as Math.floor does), I prefer using a bitwise OR, e.g. var onlineCount = (Math.random() * 2001 + 3000) | 0;, which drops everything after the decimal place. I think that would actually be one operation faster since you don't need to negate the operation.

0 05 Feb 2018 02:29 u/RevanProdigalKnight in v/programming
Comment on: Q. What's today's top language? A. Python... no, wait, Java... no, C

There are sometimes minutiae about the language (especially in Python, with all of its extra features) that make it so that you need to dig a bit deeper to be able to effectively use it, but generally knowledge of one of the C-based languages will allow you to pick up any other C-based language in short order.

3 22 Jul 2017 13:46 u/RevanProdigalKnight in v/programming
Comment on: CSE graduates of voat: How many internships have you had and what are you doing now?

1 internship, just over 3 years in the industry, and I'm currently looking for a new job.

With the skills I picked up in my first job I'm desirable to most companies. It's the first job that's hardest to get.

0 19 Jul 2017 21:14 u/RevanProdigalKnight in v/programming
Comment on: I feel dirty ... Lol ... Started using visual studio code and so far liking it better than sublime.

*insert vim vs nano vs vi argument here*

It's hard to beat the classics. Though I'll admit, having a way to interface with the file other than the keyboard can be nice at times. Like having multiple cursors.

1 12 Jul 2017 02:30 u/RevanProdigalKnight in v/programming
Comment on: I feel dirty ... Lol ... Started using visual studio code and so far liking it better than sublime.

Hey, no problem. Everybody should be happy with whatever text editor they choose, and if you choose to go back to Sublime then you should be as happy as you are with VS Code. That includes good syntax highlighting.

1 11 Jul 2017 23:39 u/RevanProdigalKnight in v/programming
Comment on: I feel dirty ... Lol ... Started using visual studio code and so far liking it better than sublime.

For JavaScript highlighting in Sublime I use the following plugins (through Package Control, of course):

  • Monokai Extended (has more defined syntax scopes for syntax highlighting)
  • JavaScriptNext - ES6 Syntax (for obvious reasons)
1 11 Jul 2017 20:22 u/RevanProdigalKnight in v/programming
Comment on: I feel dirty ... Lol ... Started using visual studio code and so far liking it better than sublime.

Since I was reading a blog post from somebody who just recently switched from Atom to VS Code, here's somebody who already did performance metrics on Sublime, Atom, VS Code, and TextEdit: https://blog.xinhong.me/post/sublime-text-vs-vscode-vs-atom-performance-dec-2016/

1 11 Jul 2017 18:24 u/RevanProdigalKnight in v/programming
Comment on: I feel dirty ... Lol ... Started using visual studio code and so far liking it better than sublime.

I can't get around the lack of Ctrl+Click for multiple cursors. It can do it via Alt+Click, but I've grown far too used to Ctrl+Click and don't want to re-train myself. Also, Sublime still performs much better with large files.

1 11 Jul 2017 16:55 u/RevanProdigalKnight in v/programming
Comment on: I feel dirty ... Lol ... Started using visual studio code and so far liking it better than sublime.

It has significantly better performance when handling large files than Atom does

1 11 Jul 2017 16:54 u/RevanProdigalKnight in v/programming
Comment on: Rust: I like the language, I fucking hate the community - thoughts?

I'd recommend sticking to StackOverflow, since the system there is almost completely meritocratic. It keeps the SJW bullshit to a minimum, at least.

1 11 Jul 2017 10:59 u/RevanProdigalKnight in v/programming
Comment on: Where should I ask for help with my naive ideas about cryptography?

absolutely unbreakable

No cipher is absolutely unbreakable. The cipher you describe would be as good as unbreakable for messages up to 4GB, but past that there is a chance of repetition. Your random data file would always have to be larger than the message you send in order to be truly secure.

1 25 Jun 2017 13:45 u/RevanProdigalKnight in v/programming
Comment on: COBOL Is Everywhere. Who Will Maintain It?

All it takes to learn any language is a bit of time and effort. Still, sounds like it may be a good idea to teach myself COBOL no matter how much I may hate it because that will allow me to dictate my salary :P

0 15 May 2017 00:22 u/RevanProdigalKnight in v/programming
Comment on: Working as a web developer is making me hate programming

Alternatively:

You spent so much learning to design only to design fuck all because your boss is a yes man to a moronic customer.

0 10 May 2017 03:05 u/RevanProdigalKnight in v/programming
Comment on: Found a good mechanical keyboard, here's what I bought..

The best thing about my ThinkPad was the keyboard. I'm a firm believer that the ThinkPad keyboard should be the industry standard for laptops.

That said, for you desktops I still use rubber-dome keyboards because I'm afraid I'll break a mechanical keyboard and be out the cost of a new one.

1 08 Apr 2017 20:46 u/RevanProdigalKnight in v/programming
Comment on: Learning Lisp Fast

I thank you for your apology, and I would also like to apologize for treating you in a less-than-respectful manner, since you have been attempting to teach me something with your comments. I have taken back the downvoats I gave some of your previous comments.

Also, it's been a few years since I last looked at Lisp, and I've had a lot of programming experience since then. I may find it less intimidating/confusing/difficult now. After all, it can't hurt to try.

0 25 Mar 2017 20:51 u/RevanProdigalKnight in v/programming
Comment on: Learning Lisp Fast

Look, I simply made a comment about how I tried Lisp but I wasn't good at it. In your response, you chose to insult my intelligence and question my schooling. Some people, despite being perfectly capable programmers, have trouble working through recursive problems and therefore have difficulty working in Lisp (and similar languages). I happen to be one of those people. I struggle with math sometimes. Does that make me a lesser person? Maybe. Does that mean you need to rub it in my face? Of course not. For fuck's sake, learn some common decency.

Now, to answer your question: No, it never occurred to me because I never had cause to think about it. Also, I don't care. Knowing that basic arithmetic is a set of recursive functions doesn't help me function in day-to-day life in any way, shape, or form.

0 25 Mar 2017 18:31 u/RevanProdigalKnight in v/programming
Comment on: Learning Lisp Fast

There's more to programming than just basic arithmetic, you know.

1 25 Mar 2017 16:28 u/RevanProdigalKnight in v/programming
Comment on: Learning Lisp Fast

I tried Lisp in college, but I'm not good with recursion.

2 25 Mar 2017 12:20 u/RevanProdigalKnight in v/programming
Comment on: Postgraduate Degree in Something Computerscience(ish)?

Based on my experience, yes. What most programmers look for in a new hire isn't necessarily their degree or even how well they did in school, but how passionate or knowledgeable they are about the subject of programming. I only graduated from college with a 2.9 GPA, but because I tinkered and worked on side projects, I was able to give answers to questions that weren't just memorized from books, but from my own experience.

0 25 Feb 2017 13:55 u/RevanProdigalKnight in v/programming
Comment on: Postgraduate Degree in Something Computerscience(ish)?

If you want to explore lambda calculus the best languages to pursue are probably purely functional ones such as lisp and Haskell, though Python has very good support for lambda functions (lambda x: x), and ES6 JavaScript makes it easier to use lambda functions with the new arrow function syntax (() => {}).

My personal recommendation if you choose to explore lambda calculus through code is to just pick a language and start a personal side project with the purpose of solving a random problem. Let's say you want to create a fractal generator. Just start writing code in your language of choice, get it to work, and then start tinkering to see what works better or worse.

When I tinker I like to mess around with the guts of the internals to see if I can eke out an extra 0.1% performance or make future modifications to the program as a whole easier by introducing utility classes, because those are the things that interest me most. This usually means that when I've finished tinkering with something I have to do a major refactoring of everything that influences, though.

1 25 Feb 2017 01:53 u/RevanProdigalKnight in v/programming
Comment on: AGILE/SCRUM is litteraly the homeopathy of the developers community

The problem is that Scrum (in most, if not all cases) has been turned into a process of micro-management by non-developers and then enforced upon the developers in the group, which goes against the Agile Manifesto. The non-developers have taken a great idea and turned it into shit in the process.

0 23 Feb 2017 04:11 u/RevanProdigalKnight in v/programming
Comment on: AGILE/SCRUM is litteraly the homeopathy of the developers community

Yeah, except that it predates Common Core by at least a decade (maybe more - not sure on when Common Core started), so really Common Core is Agile all over again.

2 23 Feb 2017 04:07 u/RevanProdigalKnight in v/programming
Comment on: Ask Programming: if you ever got burnt out in this job or hobby, how did you get back into it?

Thanks for the advice, I'll keep that in mind. Also, you pretty much perfectly described the scenario in my company right now, which is most of why I'm trying to get out.

2 06 Feb 2017 04:00 u/RevanProdigalKnight in v/programming
Comment on: Ask Programming: if you ever got burnt out in this job or hobby, how did you get back into it?

That sounds like what I'm going through right now. Hopefully one of my applications/interviews will get somewhere and I'll be able to know for sure if it's me or just my employer.

4 06 Feb 2017 03:31 u/RevanProdigalKnight in v/programming
Comment on: For $deity's sake, smile! It's Friday! Sad coders write bad code - official

If it's anything like where I work, I've been explicitly told by my manager(s) not to refactor existing code because we're constantly behind on tackling new issues. Also, we've been under a hiring freeze for about a year now because the company as a whole isn't meeting projected figures, so we can't bring in more people to alleviate the problem. The upper management doesn't realize/want to acknowledge that if this goes on much longer then all the good developers in my office are going to leave, and then their profits will sink further.

1 04 Feb 2017 02:26 u/RevanProdigalKnight in v/programming
Comment on: For $deity's sake, smile! It's Friday! Sad coders write bad code - official

Can confirm, I've been in zero-fucks-given mode where I work for a few months now and my code quality has gone down the tube.

2 04 Feb 2017 02:20 u/RevanProdigalKnight in v/programming
Comment on: Module-level variables

Since they're module level, they're essentially global variables inside that module. The "Best Practice" part of me would say to put them in a module_globals or config object so that you only have one "global variable" for the module. The pragmatic part of me says that unless it becomes a problem, they're fine where they are - less worry about needing to refactor all the code that depends on them that way.

1 26 Jan 2017 18:55 u/RevanProdigalKnight in v/programming
Comment on: C Continues to Weaken in TIOBE Rankings - Dice Insights

*takes one look at operating systems*

*stares at TIOBE for being idiots*

2 08 Jan 2017 15:33 u/RevanProdigalKnight in v/programming
Comment on: The little book about OS development

Thanks for the alternative suggestion.

0 28 Dec 2016 01:15 u/RevanProdigalKnight in v/programming
Comment on: Not to brag but I wrote some pretty sweet code three years ago, apparantly

I take issue with how you populate the default feeds in reader.js since you populate new feeds in the callback for populating a feed (I would have returned the Reader instance from the addFeed function), but otherwise this is some pretty good code.

1 25 Dec 2016 13:14 u/RevanProdigalKnight in v/programming
Comment on: Modern UI, flashy but ergonomically evil

As much as I do miss the context menus and nested drop-down menus of the old days, not all of Modern UI design is bad. It's making computing more accessible to people who didn't have the insight or intelligence necessary to figure out the (frankly) user-unfriendly design decisions of the past, which were mainly made because screen space was a premium back then.

At the same time, though, there is a distinction between normal mouse-and-keyboard computers and touchscreens, and I think that UI design needs to be considerate of both sides of the coin at least until one side no longer exists. That means that if a user doesn't have a touchscreen, they should remove some of the flashiness and make the buttons/menus a bit smaller. As I read somewhere (can't remember where), "With a mouse we can be precise, because we aren't jabbing at a screen with a fleshy appendage in the hopes of pressing the right button because there's no room on the screen to put space between them."

Personally, as far as websites are concerned (I don't have much experience with desktop UI design), I think that Twitter's Bootstrap CSS hits a nice comfort zone between large, touchscreen-friendly buttons on small screens and smaller, mouse-friendly buttons on large screens. Their margins and stuff are still way too big for keyboard-and-mouse users, but they do allow end users to tune the CSS instead of forcing them to use the library as published.

0 16 Oct 2016 18:35 u/RevanProdigalKnight in v/programming
Comment on: For the love of God, is there a modern VCS besides TFS, mercurial, and git (mainly git, fuck git)?

If you like using git branches you're in for a rude awakening with SVN. The shit you have to go through to create a branch...

1 14 Oct 2016 03:37 u/RevanProdigalKnight in v/programming
Comment on: What programming language SHOULDN'T you learn?

I think that may be where I was quoting from... Most of them look familiar to me.

1 13 Oct 2016 19:14 u/RevanProdigalKnight in v/programming
Comment on: What programming language SHOULDN'T you learn?

How to shoot yourself in the foot using PHP:

You shoot yourself in the foot using a gun made with parts from 300 other guns.

1 05 Oct 2016 02:27 u/RevanProdigalKnight in v/programming
Comment on: How to Shoot Yourself in the Foot (with various languages, operating systems, etc)

Did you mean to write: "This was funny until I got to ${language} after which it was totally stupid and wrong!"?

EDIT: I suppose this means there needs to be one for Markdown.

2 26 Sep 2016 20:13 u/RevanProdigalKnight in v/programming
How to Shoot Yourself in the Foot (with various languages, operating systems, etc)
3 4 comments 26 Sep 2016 19:40 u/RevanProdigalKnight (..) in v/programming
Comment on: Teach Yourself Programming in Ten Years

Fortran is one of the fastest compiled languages because there is no mucking about with dynamically sized objects - everything is static at runtime. Also, there is no recursion, but you can call two identical functions with different names to emulate recursion and it will (in most cases) run faster than real recursion and still use less RAM.

0 14 Sep 2016 17:18 u/RevanProdigalKnight in v/programming
Comment on: Teach Yourself Programming in Ten Years

I have an XKCD News Substitutes script running, so this title appeared a bit more... sensational than it actually is.

Good article, though.

4 13 Sep 2016 12:41 u/RevanProdigalKnight in v/programming
Comment on: C or C++: Which is the language you prefer?

But apps are the wave of the future! We need to teach everybody app development!

- Some idiot, probably.

I agree with you. Programming degrees should focus on the basics. Then students can branch out from a solid core instead of knowing parts of all the branches and none of the roots. I mean, you can't navigate a binary tree from a random node, you have to start at the root node. The same applies to learning how to program.

1 08 Sep 2016 15:12 u/RevanProdigalKnight in v/programming
Comment on: C or C++: Which is the language you prefer?

I also believe that all programming degrees should require a course on compilers. That was seriously the most helpful class I took at university, it really tied together a lot of the random bits and pieces of knowledge I'd accumulated up to that point, and it allows me to write better code because I understand how compilers work now.

3 08 Sep 2016 14:43 u/RevanProdigalKnight in v/programming
Comment on: C or C++: Which is the language you prefer?

The university I went to taught C, then C++, then Assembly. Then they went to Java for some reason...

0 08 Sep 2016 14:05 u/RevanProdigalKnight in v/programming
Comment on: [Poll] What's your favorite bit?

00110001

1 15 Aug 2016 19:40 u/RevanProdigalKnight in v/programming
Comment on: C++,Recursion,Three Number combination if their sum less than 10.

In the case of complicated command-line printing, I still prefer to use C's printf. It's less confusing and more readable, in my opinion.

printf('{%d,%d,%d}\n',i,j,k);
1 04 Aug 2016 19:57 u/RevanProdigalKnight in v/programming
Comment on: High Performance JavaScript Charts

About the only possible advantage it has over Chart.js is that it seems to have no issues with rendering tens of thousands of data points, but it looks like it achieves this by not anti-aliasing the chart lines or animating them in any way. If Chart.js doesn't have issues rendering this many data points is an unknown to me, because I've never had to try.

0 04 Aug 2016 18:23 u/RevanProdigalKnight in v/programming
Comment on: Stackoverflow needs to be circumvented. rant + ramble

I was invited to StackOverflow Careers in its beta (I only have 1.7k rep on the site, which I got by spamming regex answers over a 6-month period). If employers look at it, it gives an overview of an applicant's knowledge by linking to GitHub projects, articles the applicant has read, and 5 StackOverflow the applicant has made.

1 02 Aug 2016 11:18 u/RevanProdigalKnight in v/programming
Comment on: Top the Most Popular Programming Languages Of 2016

I'm actually a bit surprised that FORTRAN made it into the upper-right quadrant, even if just barely.

1 26 Jul 2016 11:50 u/RevanProdigalKnight in v/programming
Comment on: Destroy All Ifs A Perspective from Functional Programming

Well, it's no worse than hiding your branches in layers upon layers of abstraction like pure OOP advocates.

The thing I like about Functional programming is that it encourages smaller, more easily unit testable functions.

1 18 Jul 2016 02:45 u/RevanProdigalKnight in v/programming
Comment on: Looking for a dedicated programming team

I would definitely be interested in mentoring, though I may not be able to invest more than a few hours a week sometimes; my schedule doesn't vary much but my workload does.

As for networking, I've built up my (small) network by communicating with people and working with them. Some of my references are old classmates that I stay in touch with, some are professors, some are former coworkers. It's always a good practice to stay in touch with people, even if it's just the occasional message asking "Hey, just thought about you.", "How are you?", or "What have you been up to?", etc.

0 09 Jul 2016 04:14 u/RevanProdigalKnight in v/programming
Comment on: Looking for a dedicated programming team

No longer a student, and I have a job, but here's my two cents after a few years in the industry.

You need more than just a portfolio, you need to know people. If a portfolio of work was enough to get a job, anybody who teaches themselves to write some code and then participates in a whole bunch of projects could get a job in the field. Knowing people already in the field is key - as one of my professors put it when I started looking for jobs, "Who you know is worth more than what you know sometimes." If you know people, they can recommend you for things that you would never have found by yourself, or if their experiences with you are good enough, they'll recommend you for things that you don't consider yourself qualified for, and even sometimes for things that you aren't actually qualified for, because they know that you can adapt to situations well.

Now, some people at this point will just say "But the people we're working for are enough, right? They can recommend us!". Not necessarily. If the team is large enough, the people you're working for will only get to know the people that are in constant contact with them - the "Project Managers" or "Sales" people, per se (even if you don't actually have those positions). So when it comes down to the moment of recommendation, they'll only be able to say "Well, I only really interacted with <person or persons>. I can't really speak for the rest, but they seemed to do good work overall." If you're forming a team, you'll want to have volunteer(?) mentors for the team. Mentors can act as contacts for after the year is up, because they have the freedom to interact with anybody who comes to talk to them. Another nice thing about having mentors is that you have somebody (or some people) to bounce ideas off of, review code, and offer design suggestions. They don't have to be an integral part of the team, but it's a good idea to have some advisors for spreading awareness of your efforts.

Another, slightly more minor problem I have with (the wording of) your post:

The goal is to turn from student level programmers to top level programming students in 1 year.

"Top level" programmer is a lofty goal for one year. Like I said, I've been in the industry for a few years and neither I nor my coworkers are "top level" programmers, not even the ones that have been working with code their entire adult lives. I would like to believe that most of my coworkers and I are at least above average, maybe even towards the top end of the spectrum, but I wouldn't place any of us even in the top 10%. Even if I worked at a more prestigious company (e.g. Google, Microsoft, Amazon, etc.) not everybody is a "top level" programmer. Some people aren't built for it, some people never see their full potential, and some people simply don't care. At the end of one year, you still won't be a "top level" programmer. You'll be a highly desirable recruit, but nobody is "top level" within a year, no matter how good they are. "There will always be somebody who knows more about something than you do", as the saying goes.

1 08 Jul 2016 20:33 u/RevanProdigalKnight in v/programming
Comment on: Screeps: MMO RTS sandbox for programmers

I'm a full-stack developer whose primary project has been to rewrite rich desktop applications as webapps, and I seriously don't understand all the hate on JavaScript (Well, as of ES6, at least). It really isn't that bad if you put some effort into understanding how to write good JavaScript.

1 08 Jul 2016 11:39 u/RevanProdigalKnight in v/programming
Comment on: Agile, Unit tests and rapid release cycle is pure evil.

Sales: "We need you to write this super awesome bubbly application that will do absolutely everything the client wants it to do!"

Programmer: "Okay, what does the client want?"

Sales: "We don't know yet!"

Programmer: "...Okay. Can you get back to us when you know what they want?"

Sales: "Yeah, but we need something to show them first!"

Programmer: "Okay, I guess I'll start working on the UI then"

*6 months later*

Programmer: "Okay, I think I'm done with the UI."

Sales: "This UI looks fantastic! The customer loves it!"

Programmer: "Great! Do you know what they want yet?"

Sales: "Nope, still no clue! And the project is due tomorrow!"

Programmer: "..."

15 07 Jul 2016 23:47 u/RevanProdigalKnight in v/programming
Comment on: Between "async event based" and "multi-threading" programming models, which one gives better performance and why?

Not an expert, but here's my two cents:

Really, it all comes down to the question of what kind of tasks you're running and how interdependent they may or may not be. If you're running a whole bunch of really big, independent tasks, multi-threading is the way to go because then you can run them all in parallel. If you're running a whole bunch of really small interdependent tasks, then an asynchronous event-based model is probably a better choice. Then you have your typical muddy grey area in the middle where it's kind of up to what you feel like programming as to what's best.

To be honest though, Node.JS isn't the best choice for a server because it all runs in a single thread. You would need to make clusters of Node.JS servers just to get the equivalent of a single Apache server thanks to the fact that Apache is multi-threaded by nature. Regardless of multi-threaded or asynchronous programming model, you will get better performance out of a compiled language than you would with an interpreted language, and you'll get better performance across parallel sessions with a multi-threaded architecture.

Personally, I would love it if JavaScript interpreters added multithreading capabilities, because then there would be pretty much no question as to what the go-to language for a given task should be; you'd get the best of both worlds. At the same time, though, JavaScript still has a performance peak that it can't surpass since it is an interpreted language. The interpreters may get faster, or better at predicting how to run the code, but it still has to be interpreted at runtime, and that adds overhead that can't be ignored.

2 18 Jun 2016 03:02 u/RevanProdigalKnight in v/programming
Comment on: 0 experience, getting into C++, really just not understanding why you'd want/need to use void

The ability to reference a function using a void* variable is handy too, because then you can start doing things like this code snippet (Warning, my C++ is rusty so my syntax is probably off):

int incrementAndTransform(int i, void* (*transformer)(int i)) {
  return transformer(++i);
}
int add5Transformer(int i) {
  return i + 5;
}
int mod6Transformer(int i) {
  return i % 6;
}
int main() {
  int i = 0;
  int t = incrementAndTransform(i,add5Transformer);
  int result = incrementAndTransform(t,mod6Transformer);
  return 0;
}
1 10 Jun 2016 17:33 u/RevanProdigalKnight in v/programming
Comment on: List of 20+ free online programming/CS courses (MOOCs) with FREE certificates of accomplishments/transcripts/badges

You can also save the post instead of using a comment

3 07 Jun 2016 14:35 u/RevanProdigalKnight in v/programming
Comment on: Why can't programmers... Program?

We examined basic parsing using Flex in the "learn to learn" class. The professor had us use Flex to parse a valid Unix command (I took the course twice because I wasn't good at it - ls the first time and then tar the second time). We examined parse trees in our compilers class, since we'd need to implement one for our compiler anyways.

1 25 May 2016 15:06 u/RevanProdigalKnight in v/programming
Comment on: Why can't programmers... Program?

Javascript (ES6) version:

let fizzbuzz = function(n) {
  let mod_3 = n % 3 === 0, mod_5 = n % 5 === 0; // I just don't want to have to rewrite the modulus logic more than I have to
  if (mod_3 && mod_5) return "FizzBuzz";
  else if (mod_3) return "Fizz";
  else if (mod_5) return "Buzz";
  else return n;
}
for (let i = 1; i <= 100; i++) {
  console.log(fizzbuzz(i));
}
1 25 May 2016 11:28 u/RevanProdigalKnight in v/programming
Comment on: Why can't programmers... Program?

The CS program I was in was somewhere in the middle, but they also made a point to have us explore "emerging" technologies (about 10 years after they emerged, but better late than never). We also had one class that was designed specifically "to teach you how to learn" - as in, we explored 4 or 5 programming languages (plus Flex) over the course of one semester in order to learn how to learn (to use) a new concept/programming language/framework. That and the compilers class I took were probably the two things that have helped me the most in my career so far.

1 25 May 2016 11:18 u/RevanProdigalKnight in v/programming
Comment on: We need more programming challenges. We should start off small: First non-repeating character of a string. Any language you like.

Yeah, I was trying to match the ES6 precisely, though I noticed a few days after posting that I could have used arr = word.split('') instead of the manual loop.

0 28 Apr 2016 22:23 u/RevanProdigalKnight in v/programming
Comment on: What industry do you work in?

I work in the private Medicare/Medicaid processing industry. When your doctor prescribes you a medication that has certain limitations (Suboxone, for example), they have to submit a Prior Authorization request. This request is then reviewed by our own doctors and pharmacists for necessity and accuracy being algorithmically reviewed by our backend systems, running through validations specified by each state.

I help to develop the backend systems and am currently the sole developer of the Web-based for it.

1 27 Apr 2016 12:18 u/RevanProdigalKnight in v/programming
Comment on: Bored? Go over this text-based RPG I'm making. Tell me exactly how awful my coding is.

Yeah, the lambda makes the entry a function that you can invoke at any time. Sorry, I really should have included a link to some documentation in my original comment.

In short, lambdas are functions that are bound to variables, and can be called anywhere within the function that they're defined in, or they can be a return value from a function.

0 25 Apr 2016 22:36 u/RevanProdigalKnight in v/programming
Comment on: Bored? Go over this text-based RPG I'm making. Tell me exactly how awful my coding is.

Just thought of this - If you don't mind a more serious refactoring towards a more object-oriented solution, here's an example of how I would rewrite attributes.py (you are free to either follow this example or ignore it as you wish):

class Stat:
  def __init__(self, initValue=0, increaseAmount=0, statName="", max=initValue, min=0): # Yay default values
    self.value = initValue
    self.maxValue = max
    self.minValue = min
    self.increaseAmount = increaseAmount
    self.statName = statName
  def increase(self):
    self.maxValue += self.increaseAmount
    self.value += self.increaseAmount # Not sure if this should increase with the max or not, I'm not the one writing the game
    print("Your " + self.statName + " is now", self.value
  def mod(self,value=0):
    self.value += value
    if self.value > self.maxValue:
      self.value = self.maxValue
    elif self.value < self.minValue:
      self.value = self.minValue
class Stats:
  def __init__(self, max_hp, atk, acc, arm, moveset):
    self.stats = {
      'hp': new Stat(max_hp),
      'atk': new Stat(atk),
      'acc': new Stat(acc),
      'arm': new Stat(arm)
    }
    self.moveset = moveset
  def mod_stat(self, stat, value, mode):
    if mode == 0:
      value = -value
    if stat in self.stats:
      self.stats[stat].mod(value)
    else:
      print(stat, "is not a stat")
class PlayerStats(Stats): # mod_stat inherited from Stats, so we don't need to define it here
  def __init__(self):
    self.stats = {
      'hp': new Stat(100, 10, "HP"),
      'atk': new Stat(10, 3, "attack"),
      'acc': new Stat(85, 5, "accuracy"),
      'arm': new Stat(0, 5, "armor"),
      'mp': new Stat(100, 10, "mp"),
      'nut': new Stat(3, 0, "nut")
    }
    self.moveset = None
  def increase(self, stat):
    if stat in self.stats:
      self.stats[stat].increase()
    else:
      print("WHAT ARE YOU DOING")
1 25 Apr 2016 14:46 u/RevanProdigalKnight in v/programming
Comment on: Bored? Go over this text-based RPG I'm making. Tell me exactly how awful my coding is.

For a start, I would recommend swapping out any if/elif/else block with more than 3 clauses to a switch block, but that's more of a personal preference thing than an actual necessity. I find that maintaining large switch blocks tends to create fewer errors than maintaining a huge if/elif/else block. Ideally, if you're comfortable with it, I would recommend a more functionally oriented solution by creating a dict of lambda expressions to navigate, and reduce your giant if/elif/else blocks to something like this (example taken from attributes.py, Stats.mod_stat [line 25]):

def mod_stat(self, stat, value, mode):
  stats = {
    'max_hp': lambda value: self.max_hp += value,
    'hp': lambda value: self.hp += value,
    'atk': lambda value: self.atk += value,
    'acc': lambda value: self.acc += value,
    'arm': lambda value: self.arm += value
  }
  if mode == 0:
    value = -value
  if stat in stats:
    stats[stat](value)
  else:
    print(stat, "is not a stat")

Forgive me if my python syntax is a bit off, it's been a while since I was last able to use it

EDIT: Gaaah, I accidentally typed stat[stats] and didn't notice it. That most definitely would not work.

EDIT2: While typing up my reply to this, I noticed that I missed an if statement in this function

2 25 Apr 2016 13:51 u/RevanProdigalKnight in v/programming
Comment on: We need more programming challenges. We should start off small: First non-repeating character of a string. Any language you like.

Just out of curiosity, if you're using the ES6 for..of loop, why not use let for the loop variable?

0 15 Apr 2016 17:09 u/RevanProdigalKnight in v/programming
Comment on: We need more programming challenges. We should start off small: First non-repeating character of a string. Any language you like.

JavaScript (ES6):

word => [...word].filter(letter => word.lastIndexOf(letter) === word.indexOf(letter))[0];

Written in plainer JavaScript (ES5) with comments:

function(word) {
  var i, array = [];
  // Spread the letters of `word` into an array. This was done by `[...word]` in the ES6 version
  for (i = 0; i < word.length; i++) {
    array.push(word[i]);
  }
  // Filter the array, returning only the letters of the word whose first occurrence is also their last occurrence
  return array.filter(function(letter) {
    return word.lastIndexOf(letter) === word.indexOf(letter);
  })[0]; // Return the first element of the resulting array
}
3 15 Apr 2016 13:31 u/RevanProdigalKnight in v/programming
Comment on: Finding Entry Level Positions

Start applying for jobs that you know you aren't completely qualified for as well - sometimes that will get HR's attention as they move it over to the correct bin and they'll contact you merely for showing initiative. If you're lucky, they'll run it by the manager of the department that you'll (hopefully) end up working for and they'll contact you directly.

Another thing that you should do if you haven't already is start ignoring the minimum experience bit in the requirements, because even HR knows that that's an impractical requirement for an entry-level position. If it asks for 5 years experience and they bring it up in the interview, simply state that you naturally assumed your college experience would count towards that, because otherwise why would they want minimum experience?

1 07 Apr 2016 22:10 u/RevanProdigalKnight in v/programming
Comment on: What were your first projects, and what were some important things you learned from them?

My first major project has been translating a desktop client (rich app) to a webapp. I'm expanding/maintaining the second iteration now.

Some more important things in addition to what @multidan listed:

Given the opportunity, perform plenty of research on what frameworks/APIs you want to use ahead of time. Nothing sucks more than getting halfway (or more) through a project only to realize that you picked the wrong framework/API for some of the more advanced use cases and you have to either

  • finish with the current framework (and then maintain it); or
  • start from scratch with the other framework

I wasn't the one who made this mistake, but I was the lead (read: only) programmer on the project by that point, so I paid the price either way.

For small tasks, it may be preferable (in terms of time/effort) to simply find a few examples and then write a utility to do it yourself, provided you know that you will never need more functionality. If the task is larger, try to find a framework/API that already does most or all of what you need to do, and then just put a wrapping class around it if it doesn't do everything you need. ONLY write the entirety of a larger utility if the frameworks/APIs you can find are woefully inadequate.

UNIT TESTS, UNIT TESTS, UNIT TESTS. I cannot stress how much having good unit tests helps to write good, easy-to-maintain code. The more unit tests you can write ahead of time, the better, because that's all the more use cases or edge cases that you know will work as expected once you've finished writing the code. It's also great when the QA folks come back saying "it broke when I did this" and you have a unit test case that can explicitly prove they did something wrong.

2 22 Mar 2016 20:00 u/RevanProdigalKnight in v/programming
Comment on: Coding Bootcamps ?.

One StackExchange answer I read once (can't find it right now for some reason) said that the primary purpose of certifications is to make money for the certifying organization, and that these days with online resources abundant they don't have as much value as they did even just 10 years ago.

That said, there are a lot of people applying to programming jobs these days that have very little real-life experience in the languages they say they know, and some companies are starting to incorporate a small coding challenge into the interview process, so I'd say the most important aspect of learning a programming language is mastering the basics; conditions, loops, and functions. Once you've got that down in one or two languages, you can start to branch out into more complicated structures and more sophisticated solutions.

1 15 Mar 2016 20:22 u/RevanProdigalKnight in v/programming
Comment on: (Brian Will) Object-Oriented Programming is Embarrassing: 4 Short Examples

Well, (looking at the third example again) it's really functional programming wrapped in the guise of OOP - were I writing that solution in JavaScript, I would simply have a map of { string: function() } relationships and pull from the map as necessary, but the example in the video chose to wrap a single method within a class and call that particular method on each of the classes as necessary, which I suppose is the next best thing to pure function references.

0 05 Mar 2016 22:11 u/RevanProdigalKnight in v/programming
Comment on: (Brian Will) Object-Oriented Programming is Embarrassing: 4 Short Examples

I have to agree with you on the first two examples, they were both so simple that they could only be used as exercises in object-orient programming.

In the third case I can see an argument for keeping an object-oriented approach - the solution that he took and turned into a procedural approach was very minimal and easy to understand even as an object-oriented solution because the main class and all the subclasses used were right there in the encapsulating class, and all the subclasses were simply implementing a single method. Turning it into a procedural method with the switch statement really just reduced the amount of code, without increasing the readability or maintainability any.

I would actually argue that using functional programming would be a better solution for the third case, because that's very nearly what the original solution was doing already.

I think in the 4th example, Will was trying to demonstrate that you can create more procedural code inside of an object-oriented design instead of going to the extremes that the original example went to. The fact that he didn't make the entire thing procedural was because then it would actually be a mess of spaghetti code and very difficult to read. He did, however, reduce the number of classes and the number of methods and fields within each object by writing each of the objects in a more procedural way.

0 05 Mar 2016 21:32 u/RevanProdigalKnight in v/programming
Comment on: (Brian Will) Object-Oriented Programming is Embarrassing: 4 Short Examples

Object-oriented programming is only a disaster because people took it too far in languages like Java in forcing everything to be an object.

A nice blend of OO, Functional, and Procedural code is optimal, in my opinion.

6 05 Mar 2016 17:49 u/RevanProdigalKnight in v/programming
Comment on: Which Programming Language Should You Learn? The Infographic to Code It All

I didn't do so well in my computer architecture class, and I didn't understand object-oriented programming at first, but then I took a compilers class and everything started to click in place.

Best spent 3 credit hours of my degree.

3 04 Feb 2016 20:21 u/RevanProdigalKnight in v/programming
Comment on: An anonymous response to dangerous FOSS Codes of Conduct

The only CoC any open-source project needs is this:

Be nice.

If you have a problem with someone/something, discuss it with them privately first. If this doesn't work, then you are allowed to raise an issue to the higher-ups.

7 25 Jan 2016 13:31 u/RevanProdigalKnight in v/programming
Comment on: 4 Points to Consider When Becoming a Full Stack Web Developer or Web Designer

How to shoot yourself in the foot, using PHP:

You shoot yourself in the foot using a gun made with parts from 3,000 other guns.

0 19 Jan 2016 04:30 u/RevanProdigalKnight in v/programming
Comment on: 4 Points to Consider When Becoming a Full Stack Web Developer or Web Designer

PHP seems the most logical to me. It’s easy to understand

I had a little sick come up at that. PHP needs to curl up and die already.

0 18 Jan 2016 15:36 u/RevanProdigalKnight in v/programming
Comment on: Starting a tech startup with C++

It's undesirable, yes, but it builds in roughly the same amount of time as Unix GCC, and you can code for Unix on a Windows environment, then you can simply scp your code over to a Unix environment to build for production.

0 03 Jan 2016 03:01 u/RevanProdigalKnight in v/programming
Comment on: Starting a tech startup with C++

I didn't like Code::Blocks when I tried it, but back then it was only compatible with the MinGW compiler. These days I code in Sublime Text as much as possible, despite it not being a full IDE.

1 03 Jan 2016 00:40 u/RevanProdigalKnight in v/programming
Comment on: Starting a tech startup with C++

When I still worked with C++ on Windows I just kept a Cygwin install to run GCC for compilation.

0 03 Jan 2016 00:14 u/RevanProdigalKnight in v/programming
Comment on: Screenshots from developers: 2002 vs. 2015

I find it interesting, having 2 monitors at work and 3 in my apartment, how these developers can stand only having the one screen.

1 13 Dec 2015 00:47 u/RevanProdigalKnight in v/programming
Comment on: It Probably Works - Probabilistic Algorithms are All Around Us

When Google doesn't give me the results I want in the first page I just change up the search terms and it usually fixes the problem. Using the hyphen before search terms to filter out results is also helpful: e.g. "ducks -mallard" will return all results about ducks that aren't Mallard Ducks.

0 13 Dec 2015 00:30 u/RevanProdigalKnight in v/programming
Comment on: These Are the Highest-Paying Programming Languages (do you agree?)

Out where I am the cost of living is high, most of my coworkers are making 80k+ (granted, most of them have been working there for 10-15 years...), mostly Java programming.

I also work for a company that is required by U.S. law (and our contracts) to only hire U.S. citizens to work on our products/data. One good thing about HIPAA/PHI laws.

0 02 Nov 2015 02:34 u/RevanProdigalKnight in v/programming
Comment on: These Are the Highest-Paying Programming Languages (do you agree?)

It isn't a language, but an AWS certification for cloud computing platforms is highly valued these days.

0 02 Nov 2015 02:30 u/RevanProdigalKnight in v/programming
Comment on: xkcd comic: Git

It's actually sad how true this is. Everybody uses it, but nobody understands how it really works.

17 30 Oct 2015 12:30 u/RevanProdigalKnight in v/programming
Comment on: Any Bioinformatics software developers out there?

As someone who's graduated and entered the working world, Java is your best bet. It's got tons of third-party libraries and tools for easier development, there are millions of answers on StackOverflow for whatever questions you may have. Python is the best bet for simulations though, because of easier prototyping and less strict type relationships.

EDIT: What you said about GUI/web design is spot on, though. You really need to know Web Design Theory to make a decent website these days (though using Twitter's Bootstrap CSS is also really helpful in making it look nice).

1 30 Oct 2015 01:27 u/RevanProdigalKnight in v/programming
  • ‹‹‹
  • ‹‹
  • ‹
  • 1
  • 2
  • ›
  • ››
  • ›››

archive has 9,592 posts and 65,719 comments. source code.