/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

gnu.org/software/emacs/manual/html_node/emacs/Lisp-Eval.html#Lisp-Eval
boards.straightdope.com/sdmb/showpost.php?p=10436780
freecode.com/projects/fortran-games
youtube.com/watch?v=3J-m3hMW2Fo
youtube.com/watch?v=QM1iUe6IofM
merriam-webster.com/dictionary/tumorous
youtu.be/6yU9FjrR2Ig?t=20
twitter.com/NSFWRedditVideo

First for comfy programming

Looking for p2p libraries for C/C++. libp2p for C/C++ in other words, but I guess that doesn't exist. Is using a boost-based solution the only way?

[public void]

you would make a fine pair programming partner

You cannot dispute this.

>MS Java is somehow different from Sun Java

Where ma boi ALGOL 68

PROGRAMMING CHALLENGE

Make a £sd calculator. It must be able to add, subtract in £sd, multiply and divide by decimal fractions. Lowest coin is farthing.
4 farthings make 1 penny, 12 pence make 1 shilling, 20 shillings make 1 pound.

So far, we have a solution in APL, J and C!
What other languages will present Sup Forums later?

If you actually knew your Java 8, you would understand just how much better it can be when structured well.

Have any of you written a program to solve General Lambert's Problem yet?

I'm not smart enough to "get" programming

what dont you get lad?

Trying to learn lisp...

How do I use emacs to run a lisp file?

Currently, I'm trying to do C-x C-e, as it says here: gnu.org/software/emacs/manual/html_node/emacs/Lisp-Eval.html#Lisp-Eval

But I'm getting the error in pic related.
When I run the same code in DrRacket, the code works, so I'm not really sure what to do

I've been browsing some other boards. I have to say /dpt/, you're not dumb. We have disagreements and arguments but in other places people don't even speak at you, nevermind attempt to address arguments.
I had a guy describe an argument me and another user was having over at /3/ and it's way inaccurate, and the guy I was discussing with somehow agreed with that description. Its like they're brain damaged.

Thanks for being good people /dpt/.

Do I need to learn vanilla JS in order to learn how to use ext JS? I've done pretty much no frontend stuff my whole career (C/C++/python/ruby/Java) but my new project wants me to work on some frontend tickets. How hard is it to learn open source JS frameworks from a backend perspective?

When's your homework deadline, user?

the first chapter of sicp, 1.1.7

try running racket as a child process (C-u M-x run-scheme racket)
my guess is it's assuming you're trying to evaluate it in emacsLisp, rather than racket

java was expressly made for being easier to learn than C though

no it was made as a portable language for niche systems
and its popularity on common, established platforms was as a result of being easier to learn than C++, not C

anyone know a good resource for modern C, one that covers the GObject library

that may be one of the reasons, but it made a lot of decisions to make itself easy to learn. english-like expressions instead of cryptic C abbreviation. method syntax and OOP makes it so code completion can remove any requirement of you to memorize libraries. it's a language for the lowest common denominator of being as easy to program in as possible

hey /dpt/ can you recommened a linux IDE for developing in c#?

Monodevelop

atom i guess? if you're trying to be as hipster as possible you shouldn't be using an IDE though

...

thank you

I want to get work done not be ironic

Reminder.

>do i need to learn vanilla JS
yes

why does no one realize the ancient prophecy of the golem is upon us?

statues formed from the stuff of the earth, given very literal orders by cryptic inscriptions derived from grimoires and written inside their bodies, and given life to carry out the orders by a raw force of divine might harnessed by learned men

it's all true

stuff of the earth -- copper and silicon

statues made from these materials -- computers and robots

literal orders -- programming

cryptic inscriptions -- source code in text files

derived from grimoires -- standards documents, tutorials

written inside their bodies -- typed in, to be precise, as source code files

raw force of divine might -- lightning

harnessed -- electricity

learned men -- programmers and electrical engineers

given life to carry out the orders -- AC adapters

we did it, we made the biblical golems

now we're all fucked

i see now that the precautionary tale of man's hubris refers to the impending technological singularity

how do we combat the robot takeover

pls

lol

How many of you are capable of manually writing your own machine code?

Do you miss Dennis Ritchie?

I miss John Lennon more.

I made a break from improving my programming skills to learn about cryptography. I have a feeling it can be a source of inspiration for many interesting programming exercises.

I too can compare multiple languages to a single one (or maybe not: "byte"). Also "Resizable arrays" is listed twice.

Old news bro.
Old as in at least 9 years old.
boards.straightdope.com/sdmb/showpost.php?p=10436780

You forgot static, const, volatile, restrict, case, break, continue, auto, struct, union, short, long, float, double, and the fact that C can do literally any of the things listed on the left with enough work, "enough work" being an amount of work that C programmers actually do regularly to realize these concepts in C from scratch.

only the ELITE few can write boilerplate for every project

Posting solution in two parts because I'm one verbose bitch

Wasn't really sure if I implemented multiplication/division as you intended, but hopefully I did decently enough.
Code in C++

#include

#define FARTHING_TO_PENCE 4
#define PENCE_TO_SHILLING 12
#define SHILLINGS_TO_POUND 20

struct Money
{
int farthings;
int pence;
int shilling;
int pounds;

double equiv_value; /* Equivalent of all the above converted to decimals and added */

/* Helper function that makes constructor a bit prettier */
void
reduce(int& farth, int& pen, int& sh, int& pou)
{
if(abs(farth) > FARTHING_TO_PENCE)
pen += (farth / FARTHING_TO_PENCE), farth %= FARTHING_TO_PENCE;
if(abs(pen) > PENCE_TO_SHILLING)
sh += (pen / PENCE_TO_SHILLING), pen %= PENCE_TO_SHILLING;
if(abs(sh) > SHILLINGS_TO_POUND)
pou += (sh / SHILLINGS_TO_POUND), sh %= SHILLINGS_TO_POUND;
}

double
convert_to_decimal(int farth, int pence, int sh, int pound)
{
return (pound +
(double) (sh) / (SHILLINGS_TO_POUND) +
(double) (pence) / (SHILLINGS_TO_POUND * PENCE_TO_SHILLING) +
(double) (farth) / (FARTHING_TO_PENCE * SHILLINGS_TO_POUND * PENCE_TO_SHILLING));
}

/* Constructor... Takes in four values and, after reducing,
intializes the class variables (in terms of coins) of the "Money" structure*/
Money(int f = 0, int pe = 0, int sh = 0, int pou= 0)
{
/* Create four additional variables to be able to reduce (passing by reference) */
int temp_f = f, temp_pe = pe, temp_sh= sh, temp_pou = pou;
reduce(temp_f, temp_pe, temp_sh, temp_pou);

farthings = temp_f;
pence = temp_pe;
shilling = temp_sh;
pounds = temp_pou;

equiv_value = convert_to_decimal(farthings, pence, shilling, pounds);
}
/* To be continued */

This is worth checking out for anyone interested in ancient programming:

freecode.com/projects/fortran-games

>auto
Literally useless, since it is default behavior.

Part II

/* Define operations */
struct Money
operator+ (struct Money rhs)
{
return Money
((this->farthings+ rhs.farthings ),
(this->pence + rhs.pence ),
(this->shilling + rhs.shilling ),
(this->pounds + rhs.pounds)) ;
}

struct Money
operator-(struct Money rhs)
{
return Money
((this->farthings- rhs.farthings ),
(this->pence - rhs.pence ),
(this->shilling - rhs.shilling ),
(this->pounds - rhs.pounds ));
}

double
operator*(struct Money rhs)
{ return rhs.equiv_value * this->equiv_value; }


double /* Doesn't make much sense to return a "Money" structure if we're dealing
with nonexact coinage... But feel free to crucify me if you disagree with me */
operator/(struct Money rhs)
{ return this->equiv_value / rhs.equiv_value; }

friend std::ostream& operator

>and the fact that C can do literally any of the things listed on the left with enough work, "enough work" being an amount of work that C programmers actually do regularly to realize these concepts in C from scratch.
also it's actually not useless, just redundant
you could declare ints as autos instead if you wanted
this would actually be more idiomatic to C because int is supposed to be the "default" type and everything is supposed to be an int unless indicated otherwise and unless there's a good reason to use a different type

youtube.com/watch?v=3J-m3hMW2Fo

What about 1.1.7 Don't you get?

...

good idea, poor execution

Is there a license I can put my library under that lets companies use it however they please but encourages contributions well?

Or is that generally not needed?

BSD or MIT

Why are OOP defenders so obnoxious? Watch this already:

youtube.com/watch?v=QM1iUe6IofM

Why is being the left guy supposed to be bad?
Also why is being the guy on the right supposed to be good? He looks like a douchebag.

It makes more sense when done properly.

you don't understand the meme

>eternal triphomo
>retarded and wrong with every post, just as always
Yawn.

>Not correcting someone when they're wrong
Ooh boy

Not an argument.

>Not miscorrecting yourself when you're right so that you can correct the correction

Not an argument.

t. Haskell shill

Why do trashkell girlmales think it auspicious and reasonable to publish "moan ads" in which they use kode komments to embed videos of themselves moaning in their trashkell source files, so that prospective l33t masc programmer BFs will be l33t enough to uncover them and get hard?

Surely there must be a more efficient way to accomplish the same thing?

It is almost as bad and stupid as their "lamb duhs" in which they use Kode Komments[TM](C)(R) to draw pictures of mentally retarded sheep so that there will be something for their counting algorithms to count before bed.

public class timer {
private int hour;
private int minute;
private int second;

public tuna(){
this(0,0,0);
}
public tuna(int h){
this(h,0,0);
}
public tuna(int h, int m){
this(h,m,0);
}
public tuna(int h, int m, int s){
setTime(h,m,s);
}
public void setTime(int h, int m, int s){
setHour(h);
setMinute(m);
setSecond(s);
}
public void setHour(int h){
hour = ((h>=0 && h=0 && m=0 && s

>there is some alternate universe in which this post is considered humoorous

>Define a function that when passed three boolean values, returns true if exactly one of them is true, and false otherwise.
>My solution:
static boolean one(boolean a, boolean b, boolean c) {
if acc = 0;

if (a) acc++;
if (b) acc++;
if (c) acc++;

return acc == 1;
}

>Got marked down for it.

What the fuck was wrong with this code? It compiles, works, and is simple. Why is my marker such a fucking retard?

Woops, replace the if in the second line with int.

>humoorous

JetBrains Rider.

If using .NET Core *and* you already know C# *and* don't wanna pay for Rider, you can use VSCode.

After failing my Google interview 3 months ago, I am finally starting CTCI.

C++ seems to be used for way cooler projects than Java, but I have to learn Java first because it's easier and there are more jobs. Oh well.

Because returning 1/0 for true/false is bad practice.

Fucking idiot, try actually reading the code before embarrassing yourself.

equating true/false to a number is not good practice, what don't you understand?

You were supposed to do it with boolean logic. The question didn't say that but if you'd been paying attention in class you'd know that's what was expected. If you gave a technically correct answer that's not in line with that expectation, that's reason enough to believe you either weren't paying attention or are a smartass know-it-all, both of which are adequate reasons to mark you down.

Stop posting forever. You're obviously too dumb to know how to read.

yes that sure is a true thing you're saying
however it's irrelevant to the code the other guy actually posted which does not do that at any point

Are you genuinely retarded?

whoops

tumorous

Oh hey I got those same socks in nylon today.

>if you'd been paying attention in class you'd know that's what was expected
t. retarded TA

Highly inefficient use of memory. How dare you allocate memory for a totally needless int!

No where in the course did they hint that they wanted me to use Boolean logic, and yes, I was paying attention.
They asked for a solution, and I gave them one that I think is nice and simple (it was the first I thought of too). They have no fucking right to mark me down when they never even hinted they wanted it to be done with Boolean logic.
This is why I'm mad. There is nothing wrong my my solution whatsoever.

>tumorous

Oh and right after the test, my prac/lecture went over the solutions to the questions, and my exact fucking method was used to solve the same question.

Cleaning up, organizing, and adding a few enhancements to a reporting tcl script at work.

Should I be mad if my grader marks me down on a test everywhere I put T const instead of const T for any type T?

merriam-webster.com/dictionary/tumorous

Yes.

How do you guys deal with anger and frustration when you are have a problem programming. I'm still new to programming, but not that new. I am so tired of ripping my hair out when I can't solve a simple exercise program designed for beginners.

What's the problem? I want to laugh at u.

>it an meme the dip

>There is nothing wrong my my solution whatsoever.
I already told u what the problem was, bro. You just assumed u had infinite memory lol and carelessly allocated it. Rookie mistake.

What font is that?

youtu.be/6yU9FjrR2Ig?t=20
/dpt/ approriate

Do someone remember a gif of a japanese who modified his window's bar to put an anime girl sitting on top? actually i would also know how to add graphics to the gui

is it c++ or brainfuck?
i would stop and try it later. its just werks idk why.

Why don't this work?
int doSomething(int arr[][]
{
...
}

I was kinda looking for a presentation of systems that make them contribute.
But I guess I'll just not be lazy and read.

That's called a shimeji. They're actually usually implemented as windowed applications in their own right, but with transparent window backgrounds and borders. No modification to the target window is actually done; the shimeji just knows where to sit by querying the window system for the window's position and positioning the shimeji's window relative to there.
If you want to know more about how to actually make a shimeji, look it up, there are tons of tutorials and such. I'd link you some starter code I wrote for shimejis in Java, but I can't seem to find it.

because you forgot a ')' :^)

Why don't this work?
int doSomething(int arr[][])
{
...
}