/dpt/ - Daily Programming Thread

Previous Thread: What are you working on, Sup Forums?

Other urls found in this thread:

youtu.be/4TCnYYpZxEc?list=PL9F74AFA03AA06A11&t=2793
plv.mpi-sws.org/backpack/backpack-paper.pdf
twitter.com/NSFWRedditImage

First for MODERN SEE PLUS PLUS

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line;
procedure Cale is
type Days is (Sunday, Monday, Tuesday, Wednesday, THursday, Friday, Saturday);
type Months is (January, February, March, April, May, June, July, August, September, October, November, December);
type Date_Range is range 1..31;
package I_IO is new Ada.Text_IO.Integer_IO(Date_Range);

function Is_Leap_Year (Year : Natural) return Boolean is
begin
return (Year rem 4 = 0 and Year rem 100 /= 0) or Year rem 400 /= 0;
end Is_Leap_Year;

Day_Array : array (Months) of Date_Range := (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

Year_Input : Natural := Natural'Value(Ada.Command_Line.Argument(1));
First_Day : Days := Days'Value(Ada.Command_Line.Argument(2));

begin

if Is_Leap_Year(Year_Input) then
Day_Array(February) := Day_Array(February) + 1;
end if;

for I in Months loop
Put_Line(Months'Image(I));

for Enmpty in Monday..First_Day loop
Put(" ");
end loop;

for J in 1..Day_Array(I) loop
I_IO.Put(J, Width=>3);

if First_Day = Days'Last then
First_Day := Days'First;
else
First_Day := Days'Succ(First_Day);
end if;

if First_Day = Sunday then
New_Line(1);
end if;

end loop;

New_Line(1);
end loop;

end Cale;

>C++ Without Classes

NaN for JAVASCRYPT

5th for python

>Y
Appropriate.

Is there high level dynamically typed language with easy interface to C?
Something where you can just use C libraries without having to define every used C type and function?

Lua

ASM

Isn't python capable of doing that?

Use MODERN SEE PLUS PLUS. Just template everything and use autos everywhere. It's dynamically typed, at compile time.

Just use std::any everywhere and pretend it's dynamic typing.

reminder the pajeet peoples fun levels are beyond the particle horizon
youtu.be/4TCnYYpZxEc?list=PL9F74AFA03AA06A11&t=2793

Angular 2 or React for a front end javascript framework?

why can't u just use html css and javascript to make a webshite

Those are officially dead since, like, two weeks.
Everyone's using Vue.js now, where have you been?

You gotta keep up, man. Rewrite everything every month, that wheel's not gonna reinvent itself.

Because all of these fucking job postings are asking for Angular or React skills

>why can't u just use html to make a webshite
FTFY

Both will give you cancer, so pick at random.

Can vue.js be written using TypeScript?

Can I write a vue.js front end to gulp and npm and grunt so I can more quickly set up my vue.js dev environment?

>vue
>gulp
>npm
>grunt
wew tech jargon retardation is getting out of hand.

Is prototyping necessary in c++?

remember that anime is illegal

>Can I write a vue.js front end to gulp and npm and grunt so I can more quickly set up my vue.js dev environment?
Darling, that won't do. You need to use Webpack 2 and YARN or you can't call yourself a techie, understand?

...

brb deleting my files

I know this is a joke, but, really, what's the best javascript stack to start with?

jQuery.

t. SO contributor

>hn discusses race and/or feminism

Why do you even need a javascript stack. Just pick a good server-side language and use a minimal amount of client-side javascript for fuck's sake.

Again, because jobs.

Also using TypeScript with vue.js was a serious question but the other one wasn't :(

which should i read first, design patterns or cracking the coding interview?

Is there a way to edit the queue order in JS, instead of waiting for callbacks which by then it would already be too late?

Hey Sup Forums I bet you can't find an algorithm to generate all permutations of 8 bits by only changing one bit at a time

I've learned I hate my coworkers. People barely have more experience than I do yet they're the most stubborn assholes I've met, thinking their way is the only way to do something and that their seniority matters.

Cracking the Coding Interview will make you think, DP is overrated.

Not without terrible hacks.

That's called reflected binary code.

> tfw you can't get a binary number on a ti84

life is suffering

ti basic is a prison

You sound just like them.

...

Employed Haskell programmer reporting in

Just use C# and the "dynamic" type.

I realize that. It's a bit of my frustration coming through.

I've been pushing for more design discussions and attempts to nail down our actual spec (because we've had to rewrite classes multiple times due to missing large edge cases causing bad behavior) but it's hard when your coworkers can't explain why they're doing something a certain way and are not willing to budge an inch.

We have a couple of perfectionists who believe that their way is the only way to salvation, so we end up rewriting code according to one person and then having to rewrite it entirely later because either they changed their mind or someone else didn't like it.

how often do you use comonads

what do you do, generally? interested in learning it and want to see what people who work in it do.

Good one.

>Computer scientists = 1 point
>Pajeets = 0.0001

Nice, they figured out how to add interfaces to Haskell. Should be simple enough.

plv.mpi-sws.org/backpack/backpack-paper.pdf

>reads paper
wtf?

programming is boring, try to configure exim if you want a challenge
${sg{${lc:${domain:$h_from:}}}{^www\.}{}}

Pajeet is very easily distracted?

What's the most red pilled programming language?

I'm quite mentally challenged as it is, thank you.

assembly

>what are type classes

According to the comic it's easy to find a problem hard to solve for a Pajeet.

But you're right, unintelligent lifeforms won't try to compute a solution.

Oh, that kind of interface. Never mind.

What is the runtimeof printSorteString?

int numChars = 26;
void printSortedStrings(int remaining) {
printSortedStrings(remaining, "");
}
void printSortedStrings(int remaining, String prefix) {
if (remaining == e) {
if (islnOrder(prefix) {
system.out.println(prefix);
}
} else {
for (int i = e; i < numChars ; i++) {
char c = ithLetter(i);
printSortedStrings(remaining - 1, prefix + c);
}
}

boolean islnOrder(String s) {
for (int i = 1; i < s . length(); i++) {
int prev
ithLetter(s.charAt(i - 1));
int curr = ithLetter(s.charAt(i));
if (prev > curr) {
return false;
}
}
return true;
}

char ithLetter(int i) {
return (char) ((int)'a') + i);
}


No cheating, you should be able to solve this.

z80 or 6502?

God damn vim is shit. The more I use it the more I think about switching to emacs.

Sounds like a PEBKAC issue, it's the world's more powerful editor and everyone else uses it just fine.

I love vim! why don't you like it?

well can't you straight out write binary through an electric circuit?

that

>Sounds like a PEBKAC issue
You don't even know what my issue is.
>the world's more powerful editor and everyone else uses it just fine.
It's not. Emacs is more extensible. Kakoune has bette vimgolf scores.

I'm currently fighting with the way the autocompletion popup menu behaves. I don't want to use YCM and AutoComplPop is kinda shit.

What's wrong with a minimal GUI text editor?

Mousepad is pretty straightforward desu.

So use emacs for a bit and see how you do. My only experience with emacs was harrowing, I had no idea what the fuck I was doing. I'm sure I could soldier through and become useful in it.

>You don't even know what my issue is.
I don't need to, because vim is not "shit", it's actually a pretty damn good editor.
Chances are you're using it wrong.

>What's wrong with a minimal GUI text editor?
It's inefficient. Switching back to a non-modal editor would make me want to kill myself.

>My only experience with emacs was harrowing, I had no idea what the fuck I was doing. I'm sure I could soldier through and become useful in it.
Same here. But I'm so used to vim that switching will be painful for months.

>I don't need to, because vim is not "shit", it's actually a pretty damn good editor.
Vim uses a good editing paradigm but is terrible otherwise. Vimscript is terrible. Its C code is terrible too. Its maintainer is a lazy fuck. Vim is shit and I say that as someone who's been using it daily for more than 6 years.

>Vim uses a good editing paradigm but is terrible otherwise. Vimscript is terrible.
I completely disagree, I'll take vimscript over elisp)))) any day.

>Its C code is terrible too. Its maintainer is a lazy fuck
I'll give you that, though it looks like Neovim is lighting a bit of a fire under his ass.

>It's inefficient
I disagree. I'll never understand codemonkeys... I basically spend more time thinking with a sheet of paper than programming.

I'm converting a hex input given by the user and it outputs the value in decimal. It doesn't work and I don't know why.

unsigned long int hex2dec(const char *hex)
{
int sum = 0;
int v= 0;
int n=strlen(hex);
for (int i = 0; i= '0' && hex[i]

You just don't think fast enough.

>I'll take vimscript over elisp))))
Do you have anything against elisp besides the parentheses?


>I basically spend more time thinking with a sheet of paper than programming.
The faster you'll edit your files the more time you'll be able to spend with a sheet of paper. That's exactly why I need to be able to code as fast as I can.

If you don't need to think while programming then you're not doing anything useful.

You're returning the value before finishing parsing it for starters

I'm learning java at the moment.

How do I store a bunch of user inputted numbers in an array?
Currently I'm doing this:
public static double CalcAverage() //create new method named CalcAverage
{
double dGradeCounter = 0; //initialize local variable GradeCounter
double dTotal = 0.0; //initialize local variable dTotal
double dGrade; //delcare local variable dGrade
double dAverage = 0; //initialize local variable dAverage
//dGrade = 100.0; Test
dGrade = Double.parseDouble(JOptionPane.showInputDialog("Please enter your grade or -1 to quit:")); //enter 1st numerical grade and parse as double

while (dGrade != -1) //-1 is the sentinel
{
dTotal = dTotal + dGrade; //total grade
dGradeCounter = dGradeCounter +1; //counter

dGrade = Double.parseDouble(JOptionPane.showInputDialog("Please enter your grade or -1 to quit:")); // continue entering grades
//dGrade= -1; Test
} //end of loop

//calculating average Grade
if (dGradeCounter != 0)
{
dAverage = dTotal / dGradeCounter; //calculate average grade
}
return dAverage; //return double dAverage.

>Do you have anything against elisp besides the parentheses?
I have limited experience with it, but the API seemed really clumsy to me, and it looks like nobody anywhere gave a fuck about properly encapsulating things.

I set the if statement to i==n, still doesn't work. :S

Because you're looping for i

>but the API seemed really clumsy to me
More clumsy than Vim's? Man, it's like we live in two different universes.
Emacs's API seemed to make quite a lot of sense to me, but I don't a whole lot of experience with it either.
>and it looks like nobody anywhere gave a fuck about properly encapsulating
Yeah I kinda agree with you here.

#include
#include

unsigned long int hex2dec(const char *hex)
{
int sum = 0;
int v, i= 0;
int n=strlen(hex);
for (i = 0; i= '0' && hex[i]

Who said anything about not needing to think?
Intelligent people just think faster than you can type.

Also, here's the cleanest way I can think of to to the enumeration equivalent things.
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line;
procedure Cale is
type Days is (Sun, Mon, Tue, Wed, Thur, Fri, Sat, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday);
subtype Noramal_Day is Days range Sun..Sat;

type Months is (January, February, March, April, May, June, July, August, September, October, November, December);
type Date_Range is range 1..31;
package I_IO is new Ada.Text_IO.Integer_IO(Date_Range);
package Enum_IO is new Ada.Text_IO.Enumeration_IO(Noramal_Day);

function Is_Leap_Year (Year : Natural) return Boolean is
begin
return (Year rem 4 = 0 and Year rem 100 /= 0) or Year rem 400 /= 0;
end Is_Leap_Year;

Day_Array : array (Months) of Date_Range := (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

Year_Input : Natural := Natural'Value(Ada.Command_Line.Argument(1));
First_Day : Days := Days'Value(Ada.Command_Line.Argument(2));
Iterative_Day : Noramal_Day;
begin

Iterative_Day := Noramal_Day'Val(Days'Pos(First_Day) rem 7);

if Is_Leap_Year(Year_Input) then
Day_Array(February) := Day_Array(February) + 1;
end if;

for I in Months loop
Put_Line(Months'Image(I));
Put(" ");
for Day_Title in Noramal_Day loop
Enum_IO.Put(Day_Title, Width=>6);
end loop;
New_Line(1);

for Enmpty in Mon..Iterative_Day loop
Put(" ");
end loop;

for J in 1..Day_Array(I) loop
I_IO.Put(J, Width=>6);

Iterative_Day := (if Iterative_Day = Noramal_Day'Last then Noramal_Day'First else Noramal_Day'Succ(Iterative_Day));

if Iterative_Day = Noramal_Day'First then
New_Line(1);
end if;

end loop;
New_Line(1);

end loop;

end Cale;

Now that I learned about complexity analysis I can't stop trying to find more efficient way to do my programs. It's driving me nuts.

don't forget those hidden constants user

What language should i try out to start with basic programming and please no python because i hate that language.

That doesn't seem "clean", seems like a hack, especially if all you want is for the user to be able to input "Sun" and Get returning Sunday. Sounds more like you should just implement a Get function.

C. If you give up when you reach pointers try Javascript.

Just wait until you learn about cache.

Start with c

Just simulate MVVM with reactive streams.

whats uint8_t

visual basic

Well for a beginner it's mroe about learning how to abstract logic unto the computer. THe language is just a means to an end.

why do you hate it?

Ultimately you will learn that a language is a tool; you use the best tool for whatever you have to do. Python is the best one if you want to learn programming concepts.

Every OOP is shit anyways so try Haskell if you want to be a smartie.

THIS

Try to stay away from an OO language because any learning resource related to that language will mostly focus on masturbating to classes and design patterns without actually getting anything done.

It's not that bad. The proper way would be more complicated, taking in a string and comparing them the two different enumerations and then returning the main enumeration you want to use.

D deprecates C++ for the majority of use cases.

why?

Please help. What am I doing wrong here?
I'm trying to get the average of the values in the array.
double dTotal = 0;
double dAverage = 0;
double[] dGrades = new double[10];
for (int i = 0; i < dGrades.length; i++)
{
dGrades[i] = Double.parseDouble(JOptionPane.showInputDialog("Enter your grades"));
dTotal = dTotal + dGrades[i];
dAverage = dTotal /dGrades.length;
}
return dAverage;

I'm making my own programming language.

I have the parser taking my language fine, and I am using LLVM for the backend, which I already have set up.

The problem that I have, is I have no idea how exactly am I going to do semantic analysis.

The more I read into it, the more abstract it becomes with no simple implementations in sight. I saw one on github that was supposed to be a "simple" typechecker. Contained more LOC than the rest of my entire project.