/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

i.imgur.com/OjgCAVG.png
github.com/Capaverde/XBF
kotlinlang.org/docs/reference/sealed-classes.html
coinmarketcap.com/
clhs.lisp.se/
twitter.com/AnonBabble

Bumping my own post for halp

>tfw I've improved the accuracy of my pussy/dick detector enough for it to be finally useful
>tfw my screen fills with images of cropped pussy and dick like popups from a late 1990s porn site as my neural network classifies my dataset
here's what my screen looks like so far: i.imgur.com/OjgCAVG.png

Why are web-monkeys so damn retarded?
I'm working at one small company which develops web sites using C# and ASP.NET MVC

So they have some pattern called request-response pattern. Basically it means that they create special request class for each request and corresponding response class, then pass those objects to service from controller and vice-versa.

I had a legit question if that's a good solution when project gets big. Why the fuck would you allocate dynamic heap memory every time to pass a fucking string parameter or two?

The answer was something like "FUCK OFF RETARD, YOU ARE WEB DEVELOPER, COMPILER AND FRAMEWORK DO EVERYTHING FOR YOU!! STOP THINKING ABOUT LOW LEVEL STUFF"

I was like...but garbage collection is not perfect and dynamic memory allocation is still not cheap operation, what the fuck does it have to do with low level...


Thinking of changing job now.

That's hilarious. Borderless windows when?

also one guy was arguing with me that int in C# MUST be object because OOP is best paradigm and C# is OOP.

He couldn't explain why the fuck would C# bring overhead and turn int into object.

Who brainwashes those people with this crap? fuck him

not necessarily! my co-op is full-time but I'm still taking 3 credit hours anyways.

now make it generative so you can feed it an image and it'll make it so everything is made out of dick and pussy a la DeepDream

>DickDream

Any tips on remembering function names? I feel I have a good grasp on programming concepts but have to resort to looking at google or some form of documentation to remember how stuff works.

>He couldn't explain why the fuck would C# bring overhead and turn int into object
the .NET runtime generates distinct types for the "object" and "value" representations of value types. it doesn't actually incur overhead unless you're using it like an object, in which case it generates code to allow this. when using an int like a value (as you would in C or C++), it behaves like you'd hope/expect (that is to say "like a value"), with the size and semantics of an int

>Why the fuck would you allocate dynamic heap memory every time to pass a fucking string parameter or two?
In heavily managed languages like that they probably wouldn't be allocating memory through the system and would be a lot of faster than malloc or similar. As for allocating in the first place, when projects do get big memory isn't that big of a deal and because requests are usually handled quickly that memory becomes available fast.

this. your code doesn't request memory from the system; it's managed by the runtime

This makes sense. I don't know much about the .NET runtime, but VM languages with managed memory usually don't return all the memory to the OS after a GC cycle. They keep a pool of allocated but unused memory around, in which to allocate new objects. These allocations aren't free, but they're way cheaper than a malloc() call.

If the devs are smart, they might also keep a free list of a few response objects of each type, to avoid allocations entirely.

Off topic, google just blurred the signs in my captcha like they were faces. Clearly the botnet can't see yet.

Allocating from the heap in a GC lang is insanely cheap. It's essentially a stack that you never have to pop from - just (atomically) bump up the heap pointer by the size of the object you want to allocate and you're done.
A GC cycle will compact the heap and reset the pointer to a lower value. If the memory available to the runtime is large enough relative to the amount of garbage produced and the set of persistent objects, the overhead of a garbage collector is increasingly favorable compared to manual memory management and in extreme cases may even outperform it.

>the overhead of a garbage collector is increasingly favorable compared to manual memory management and in extreme cases may even outperform it.
Why do people equate manual memory management with going to the heap every time?

I'm sorry but you're the idiot here.

Typesafe bindings and transparent data modeling are more important than raw performance. Just load balance the fucker across a bunch of instances.

>tfw learnt Haskell just so I can finally act smug in /dpt/

should I bother studying design pattern books?
is programmers missing 'software engineer' skills usually?

you're supposed to learn that shit on your own, not have it fed to you through books

You will adapt as you keep dealing with the same stuff.

Creating a programming language

github.com/Capaverde/XBF

I don't think I would have thought of policy based design or anything just by thinking while staring at my editor

if a design pattern has a name, it's pretty much guaranteed to be shit

Hi there, ultra noob going through 'learn python the hard way'. The book tells me to use gedit, but is there any way to have Nano, the text editor you can use from the terminal itself, show the colors and such gedit shows? So as to do everything inside the terminal.

great minds of Sup Forums

>github.com/Capaverde/XBF

What are actually aiming for?

Is it supposed to be a lisp offshoot base on brainfuck ?

You can extend it with replace rules, which are similar to lisp macros.
It also allows you to specify evaluation precedence and will have streams tuples and sets as built-in types.
It did not start with general purpose in mind, but instead as a sort of glue language that is easy to make interpreters of, but general purpose is what I'm aiming for now.

>this is Kotlin's excuse for variant types and pattern matching
kotlinlang.org/docs/reference/sealed-classes.html

Why is this language being shilled so hard?

$$$

The guy or organization that created kotlin will be fucking rich once it takes foothold and they'll get to sell tons of books and consultancy services for kotlin until the end of time, just like stroustrup, oracle, microsoft and every other corporate backed programming language.
It's a literal racket.

Now it makes sense why this young language already appears to be bloated with features.

I want to write a window manager in linux. Whats the best way to test this program without exiting X and trying to run it all the time?

What do you mean? Kotlin is billed as java++, so obviously the syntax/ergonomics are going to suffer a bit but I don't see anything wrong with your example. Pretty similar to scala adt encoding, just with different (Imo worse) syntax.

what occupational injuries have you sustained from being a dev?
>hitting Ctrl-S after every small change out of paranoia
>counting from zero
>== instead of =

Just wrote a web crawler for $200 for a client.

Feels good man

As a first programming language is Python good to learn or is there something better ?

>>== instead of =
Dynamic typing and all numbers being floats is a really retarded combination.
C.

Python's easy to just get going and start writing things with immediate results. Honestly it doesn't matter what language you start with, just pick one rather than question which is the "best" one for weeks on end.

Yes it's a perfect first language.

python is good for beginners and supports learning multiple paradigms
just go for it, pic related

gay

Messing around with various atom themes for random rust experiments.

Common lisp

Always asking clarifying questions for edge cases to the point of insanity.
C
>rust

...

worth it tho

Nah, patterns are a meme

public class Email {
private String sender;
private String topic;
private String message;
private Boolean readornot;

public Email(String topic, String sender, String message){
this.sender = sender;
this.topic = topic;
this.message = message;
this.readornot = true;
}
public Boolean readorNot(){
return true;
}


How do I figure out if a message is read or not?

Zephyr I guess

Languages I can work with: X86 assembly, 6502 assembly, Arm Assembly, C, C++, Python, C#

Languages that I'm meh with: Java, Lua, JavaScript, Scheme

Languages I'm looking into trying out: Rust, Clojure, Scala,Elixir

Yes I'm trying to escape from 90% or more of my code being either C or C++ . Is there any particular problem?

>I had this great love and passion for C++ but after so many tries I figured I'm not a 'genius'. Going with Java and Python even though the horsepower behind C++ is just amazing. In our university, they gave us a piece of paper at the exam and asked us what the output of the next 10 expressions would be? So basically, we had to memorize the behavior of our own version of a compiler and how C++ generally produces error codes or handles precedence. That was just the easy part. I was like, well, even those of us who can memorize all of this (I can't) wouldn't program like this. We forget most of it the next day. We program by experimenting and opening a reference book and study online libraries. Horrible way of assessing a student's understanding.
>Being such a brainlet that you can't figure out what the output of an expression is without running the code
>Being such a brainlet that you think this ability is reserved for geniuses
Literally subhuman.

avoid oop

Why do floats have the ability to be subnormalized? Why can't the mantissa have a bias like the exponent?

It's good enough. Reddit does similarily and is written in Python and does just fine for being one of the biggest websites on the internet.

ArrayList numbers = new ArrayList();
for (int i = 0; i < 10; i++) {
numbers.add(i);
}
boolean b = true;

for (int i = 0; i < numbers.size(); i++) {
if(numbers.get(i) == numbers.get(i+1)){
b = false;
}
b = true;
}
System.out.println(b);


How do I change this so it wont say IndexOutOfBoundsException?

numbers.size - 1

public void processUserChoices(){

boolean userExit = false;
Scanner s1 = new Scanner(System.in);
String userInput;
displayMenu();

while (userExit == false) {

userInput = s1.nextLine();

switch (userInput) {

case "1":

System.out.println("Please tell us the grade of the student");
int gradePercent = s1.nextInt();

while (gradePercent < 0 || gradePercent > 100) {
System.out.print("\n\n ERR You have inputted " + gradePercent);
System.out.println(", Please Input a mark that is > 0 and < 100");
gradePercent = s1.nextInt();
}

char gradeLetter = Choice.markLetter(gradePercent);
System.out.print("The student got the a grade of " + gradePercent);
System.out.println("% which is a " + gradeLetter);
break;

case "2":

System.out.print("Please input two values that you");
System.out.println(" would like to square, cube and Square root");

int lower = s1.nextInt();
int upper = s1.nextInt();

if (lower == upper){
Choice.mathTable(lower, upper);
}
else if (lower > upper) { //switches the order in which the variables are passed
Choice.mathTable(upper, lower);
}
else {
Choice.mathTable(lower, upper);
}
break;

case "3":
Choice.summariseNumbers();
break;

case "0":
userExit = Choice.exit();
break;
}
}
s1.close();


why do I get
Exception in thread "main" java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Scanner.java:1540)
I am new to programmin' no bully pls

No line found, maybe you're supposed to check for that?

It scans from System.in which means it'll interrupt untill user enters something.

IIRC when you close the Scanner it also closes the input stream that the scanner is reading from. In this case it closes System.in, which can mean that you won't be able to read anything from it anymore.

s1.close is outside the while loop so doesn't close before s1 is next used

I only seem to geth this error when I call choice.summariseNumbers();

public static void summariseNumbers() {
int i, min, max, total, userInput;
float average;
Scanner s1 = new Scanner(System.in);

average = i = total = userInput = 0; //set all variables to 0 initially
min = -10000000; //initiate min value to a largely small number
max = 10000000; //initiate max value to a large number

System.out.println("Please enter the first number");
System.out.println("Please enter -1 to exit");

while (i != -1) {

userInput = s1.nextInt();

if (userInput == -1) {
i = -1;
continue;
}

i++;

total += userInput;
average = total/i;

if (userInput > min && userInput > -10000000) {
min = userInput;
}
else {
System.out.println("Value too small, smallest value allowed for min is -9999999");
System.out.println("/nExiting back to menu.../n");
break;
}
if (userInput < max && userInput < 10000000) {
max = userInput;
}
else {
System.out.println("Value too large, largest value allowed for max is 9999999");
System.out.println("/nExiting back to menu.../n");
break;
}

System.out.println("Current values are as follows:");
System.out.println("Average:" + average);
System.out.println("total: " + total);
System.out.println("Minimum: " + min);
System.out.println("Maximum: " + max);

System.out.println("Please enter the next number");
}
s1.close();
}

Am I an idiot? how obvious is my error?

python is the most explicit programming language

explicit is better than implicit

What the hell is that even supposed to mean?

I've been using notepad++ for years and it's been fine for development but I was thinking of at least trying alternatives. Atom is apparently an entire fucking web browser for some reason but I'll try it anyway. I don't want to pay money for a text editor, does anyone have any suggestions on what to try?

Also I kind of want to try making one so feel free to post things that piss you off with text editors or that you want in them.

explicit as in?

see

Try VSCode, it's like a better version of Atom.
Alternatively Sublime Text, you don't have to pay for it, the only thing is that you'll get a random "pls purchase" prompt when saving but you can just rebind the ^S key and it'll be gone (or just Google a license).

So you are just talking nonsense. I see.

>explicit is better than implicit
what does this explain?
are you shitposting on high right now user?

/dpt/ was a mistake.

Rookie alert (and sorry if this isn't really programming related), is it possible to use =IMPORTXML() to nab an image from a website? I'd like to be able to import a few sparklines from coinmarketcap.com/ into a spreadsheet but I get blank results trying to just do the usual Xpath copying into the aforementioned import function.

haha yes

How did you assemble your training set?
How many pictures of dicks and vagoos did you personally create?

I am trying to get a python script to work that sends data over pyserial, this script works on a different computer. but for some reason I always get something simular to AttributeError: module 'serial' has no attribute 'Serial'
I have been looking around forums and I AM 100% SURE THAT MY SCRIPT IS NOT CALLED SERIAL.PY, AND I HAVE ALSO TRIED USING from serial import serial AND THE OTHER WAY AROUND. please can somebody help me, this shit has been driving me crazy for abput half an hour.

Probably installed the wrong lib/a different version.

nvm reinstalling python3-serial fixed it

can somebody explain to me why ASCII is a signed number and not unsigned. why does it not go up to 255

Why not just google?

Because 7-bit integers.

I'm working with a junior programmer who can't implement anything. All he ever does is download tutorial samples, change a few variable names, and commit it as his own work. When he gets assigned tasks that he can't plagiarize, he struggles for a month or two until we have something that's slow and half-broken.

How do I make a good argument for firing him? My boss is a huge sucker for "company culture", and this guy fits in really well. We're also short on developers as it is.

The signedness of char is implementation-defined, ASCII is only 0-127 so it doesn't matter.

He's incompetent and is slowing work down.
If that's not enough for your normie boss to tell him to git gud or fuck off, then find a new job.

maybe focus on minimizing his damage.
all the thing you said is enough evident for firing him but if your boss think that is ok then welp.

I personally think DeepDream, while interesting, isn't worth replicating. Better to focus on something like generating hentai from text description.
I scraped tons of hentai.
I manually labeled bounding boxes of pussy/dick on thousands of images. Boring as fuck, but had to be done.

>I scraped tons of hentai.
This is what I hate about machine learning and the like.
Getting the training data is just too fucking tedious sometimes.
I wanted to program some NN-thing for my portfolio, but then I realized, that just getting enough data for the result to become acceptable would take forever.

umm how do i reference current row in SQL update statements?
what i want to do in pseudo sql:
UPDATE Template t SET t.Name = str(t.GROUP + t.ID)

Vim. Use it.

Block access to stackoverflow for him.
Volunteer to review his code before it is committed. For a month at most


Guys. What is the best, simple way to handle automatically distributing updates? I'm thinking about weekly/daily builds of one branch, with changelog being a file in a repo.

Is there a simplier way?

It should work. I did similar statements on firebird.(fuck firebird)
Update table t set t.somevalue = t.val2 || t.val3

Where can I find all the built-in functions and macros of Common Lisp?

clhs.lisp.se/

exactly like that

50% of machine learning in industry is data collection and cleaning. It's unavoidable but also extremely important because how you set up your data has massive effects on your model performance.

business idea: An ML bot that can collect and clean your data for you

Nobody uses ML languages, ocaml and sml suck.

fuck opengl, though

Wew, this is some nice Web 0.5.

still better than directx

you should just integrate search for it in your editor, there should exists such library for at least emacs.

They also did lispworks iirc